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

Side by Side Diff: test/filterListener.js

Issue 29784555: Issue 6665 - Abstract element hiding container logic into its own module Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created May 17, 2018, 5:15 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/elemHideExceptions.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 11 matching lines...) Expand all
22 22
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 let ElemHideException = null; 28 let ElemHideException = null;
29 29
30 exports.setUp = function(callback) 30 exports.setUp = function(callback)
31 { 31 {
32 sandboxedRequire = createSandbox({ 32 sandboxedRequire = createSandbox();
33 extraExports: {
34 elemHide: ["knownFilters"],
35 elemHideEmulation: ["filters"]
36 }
37 });
38 33
39 // We need to require the filterListener module so that filter changes will be 34 // We need to require the filterListener module so that filter changes will be
40 // noticed, even though we don't directly use the module here. 35 // noticed, even though we don't directly use the module here.
41 sandboxedRequire("../lib/filterListener"); 36 sandboxedRequire("../lib/filterListener");
42 37
43 ( 38 (
44 {FilterStorage} = sandboxedRequire("../lib/filterStorage"), 39 {FilterStorage} = sandboxedRequire("../lib/filterStorage"),
45 {Subscription, SpecialSubscription} = sandboxedRequire("../lib/subscriptionC lasses"), 40 {Subscription, SpecialSubscription} = sandboxedRequire("../lib/subscriptionC lasses"),
46 {Filter, ElemHideException} = sandboxedRequire("../lib/filterClasses"), 41 {Filter, ElemHideException} = sandboxedRequire("../lib/filterClasses"),
47 {defaultMatcher} = sandboxedRequire("../lib/matcher") 42 {defaultMatcher} = sandboxedRequire("../lib/matcher")
(...skipping 26 matching lines...) Expand all
74 "Keyword of filter " + filter.text); 69 "Keyword of filter " + filter.text);
75 filters.push(filter.text); 70 filters.push(filter.text);
76 } 71 }
77 } 72 }
78 result[type] = filters; 73 result[type] = filters;
79 } 74 }
80 75
81 let elemHide = sandboxedRequire("../lib/elemHide"); 76 let elemHide = sandboxedRequire("../lib/elemHide");
82 result.elemhide = []; 77 result.elemhide = [];
83 result.elemhideexception = []; 78 result.elemhideexception = [];
84 for (let filter of elemHide.knownFilters) 79 for (let filter of elemHide.ElemHide._knownFilters)
85 { 80 {
86 if (filter instanceof ElemHideException) 81 if (filter instanceof ElemHideException)
87 result.elemhideexception.push(filter.text); 82 result.elemhideexception.push(filter.text);
88 else 83 else
89 result.elemhide.push(filter.text); 84 result.elemhide.push(filter.text);
90 } 85 }
91 86
92 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation"); 87 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation");
93 result.elemhideemulation = []; 88 result.elemhideemulation = [];
94 for (let filterText of elemHideEmulation.filters) 89 for (let filter of elemHideEmulation.ElemHideEmulation._knownFilters)
95 result.elemhideemulation.push(filterText); 90 result.elemhideemulation.push(filter.text);
96 91
97 let types = ["blacklist", "whitelist", "elemhide", "elemhideexception", 92 let types = ["blacklist", "whitelist", "elemhide", "elemhideexception",
98 "elemhideemulation"]; 93 "elemhideemulation"];
99 for (let type of types) 94 for (let type of types)
100 { 95 {
101 if (!(type in expected)) 96 if (!(type in expected))
102 expected[type] = []; 97 expected[type] = [];
103 else 98 else
104 expected[type].sort(); 99 expected[type].sort();
105 result[type].sort(); 100 result[type].sort();
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]}); 313 checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]});
319 314
320 FilterStorage.removeSubscription(subscription4); 315 FilterStorage.removeSubscription(subscription4);
321 checkKnownFilters(test, "remove subscription from the list", {blacklist: [filt er1.text]}); 316 checkKnownFilters(test, "remove subscription from the list", {blacklist: [filt er1.text]});
322 317
323 subscription3.disabled = false; 318 subscription3.disabled = false;
324 checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]}); 319 checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]});
325 320
326 test.done(); 321 test.done();
327 }; 322 };
OLDNEW
« no previous file with comments | « lib/elemHideExceptions.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld