Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/filterListener.js

Issue 29757591: Issue 6562 - Remove filter keys from the element hiding code (Closed)
Patch Set: Created April 20, 2018, 6:41 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/elemHide.js ('K') | « lib/elemHide.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 12 matching lines...) Expand all
23 let FilterStorage = null; 23 let FilterStorage = null;
24 let Subscription = null; 24 let Subscription = null;
25 let Filter = null; 25 let Filter = null;
26 let defaultMatcher = null; 26 let defaultMatcher = null;
27 let SpecialSubscription = null; 27 let SpecialSubscription = null;
28 28
29 exports.setUp = function(callback) 29 exports.setUp = function(callback)
30 { 30 {
31 sandboxedRequire = createSandbox({ 31 sandboxedRequire = createSandbox({
32 extraExports: { 32 extraExports: {
33 elemHide: ["filterByKey", "exceptions"], 33 elemHide: ["filtersByDomain", "filterBySelector", "exceptions"],
34 elemHideEmulation: ["filters"] 34 elemHideEmulation: ["filters"]
35 } 35 }
36 }); 36 });
37 37
38 // We need to require the filterListener module so that filter changes will be 38 // We need to require the filterListener module so that filter changes will be
39 // noticed, even though we don't directly use the module here. 39 // noticed, even though we don't directly use the module here.
40 sandboxedRequire("../lib/filterListener"); 40 sandboxedRequire("../lib/filterListener");
41 41
42 ( 42 (
43 {FilterStorage} = sandboxedRequire("../lib/filterStorage"), 43 {FilterStorage} = sandboxedRequire("../lib/filterStorage"),
(...skipping 28 matching lines...) Expand all
72 test.equal(matcher.getKeywordForFilter(filter), keyword, 72 test.equal(matcher.getKeywordForFilter(filter), keyword,
73 "Keyword of filter " + filter.text); 73 "Keyword of filter " + filter.text);
74 filters.push(filter.text); 74 filters.push(filter.text);
75 } 75 }
76 } 76 }
77 result[type] = filters; 77 result[type] = filters;
78 } 78 }
79 79
80 let elemHide = sandboxedRequire("../lib/elemHide"); 80 let elemHide = sandboxedRequire("../lib/elemHide");
81 result.elemhide = []; 81 result.elemhide = [];
82 for (let key in elemHide.filterByKey) 82 for (let filters of elemHide.filtersByDomain.values())
83 result.elemhide.push(elemHide.filterByKey[key].text); 83 {
84 for (let filter of filters.keys())
85 result.elemhide.push(filter.text);
86 }
87 for (let filter of elemHide.filterBySelector.values())
88 result.elemhide.push(filter.text);
84 89
85 result.elemhideexception = []; 90 result.elemhideexception = [];
86 for (let [, list] of elemHide.exceptions) 91 for (let [, list] of elemHide.exceptions)
87 { 92 {
88 for (let exception of list) 93 for (let exception of list)
89 result.elemhideexception.push(exception.text); 94 result.elemhideexception.push(exception.text);
90 } 95 }
91 96
92 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation"); 97 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation");
93 result.elemhideemulation = []; 98 result.elemhideemulation = [];
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]}); 323 checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]});
319 324
320 FilterStorage.removeSubscription(subscription4); 325 FilterStorage.removeSubscription(subscription4);
321 checkKnownFilters(test, "remove subscription from the list", {blacklist: [filt er1.text]}); 326 checkKnownFilters(test, "remove subscription from the list", {blacklist: [filt er1.text]});
322 327
323 subscription3.disabled = false; 328 subscription3.disabled = false;
324 checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]}); 329 checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]});
325 330
326 test.done(); 331 test.done();
327 }; 332 };
OLDNEW
« lib/elemHide.js ('K') | « lib/elemHide.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld