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: Move base class into lib/contentFilterModule.js Created Aug. 15, 2018, 8:56 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/contentFilterModule.js ('K') | « lib/elemHideEmulation.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: ["knownFilters"],
34 elemHideEmulation: ["filters"],
35 elemHideExceptions: ["knownExceptions"], 33 elemHideExceptions: ["knownExceptions"],
36 snippets: ["filters"] 34 snippets: ["filters"]
37 } 35 }
38 }); 36 });
39 37
40 // 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
41 // noticed, even though we don't directly use the module here. 39 // noticed, even though we don't directly use the module here.
42 sandboxedRequire("../lib/filterListener"); 40 sandboxedRequire("../lib/filterListener");
43 41
44 ( 42 (
(...skipping 29 matching lines...) Expand all
74 test.equal(matcher.getKeywordForFilter(filter), keyword, 72 test.equal(matcher.getKeywordForFilter(filter), keyword,
75 "Keyword of filter " + filter.text); 73 "Keyword of filter " + filter.text);
76 filters.push(filter.text); 74 filters.push(filter.text);
77 } 75 }
78 } 76 }
79 result[type] = filters; 77 result[type] = filters;
80 } 78 }
81 79
82 let elemHide = sandboxedRequire("../lib/elemHide"); 80 let elemHide = sandboxedRequire("../lib/elemHide");
83 result.elemhide = []; 81 result.elemhide = [];
84 for (let filter of elemHide.knownFilters) 82 for (let filter of elemHide.ElemHide._knownFilters)
85 result.elemhide.push(filter.text); 83 result.elemhide.push(filter.text);
86 84
87 let elemHideExceptions = sandboxedRequire("../lib/elemHideExceptions"); 85 let elemHideExceptions = sandboxedRequire("../lib/elemHideExceptions");
88 result.elemhideexception = []; 86 result.elemhideexception = [];
89 for (let exception of elemHideExceptions.knownExceptions) 87 for (let exception of elemHideExceptions.knownExceptions)
90 result.elemhideexception.push(exception.text); 88 result.elemhideexception.push(exception.text);
91 89
92 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation"); 90 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation");
93 result.elemhideemulation = []; 91 result.elemhideemulation = [];
94 for (let filterText of elemHideEmulation.filters) 92 for (let filter of elemHideEmulation.ElemHideEmulation._knownFilters)
95 result.elemhideemulation.push(filterText); 93 result.elemhideemulation.push(filter.text);
96 94
97 let snippets = sandboxedRequire("../lib/snippets"); 95 let snippets = sandboxedRequire("../lib/snippets");
98 result.snippets = []; 96 result.snippets = [];
99 for (let filterText of snippets.filters) 97 for (let filterText of snippets.filters)
100 result.snippets.push(filterText); 98 result.snippets.push(filterText);
101 99
102 let types = ["blacklist", "whitelist", "elemhide", "elemhideexception", 100 let types = ["blacklist", "whitelist", "elemhide", "elemhideexception",
103 "elemhideemulation", "snippets"]; 101 "elemhideemulation", "snippets"];
104 for (let type of types) 102 for (let type of types)
105 { 103 {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 checkKnownFilters(test, "add subscription of type circumvention with filter1", {snippets: [filter1.text]}); 348 checkKnownFilters(test, "add subscription of type circumvention with filter1", {snippets: [filter1.text]});
351 349
352 let subscription3 = Subscription.fromURL("~foo"); 350 let subscription3 = Subscription.fromURL("~foo");
353 subscription3.filters = [filter2]; 351 subscription3.filters = [filter2];
354 352
355 FilterStorage.addSubscription(subscription3); 353 FilterStorage.addSubscription(subscription3);
356 checkKnownFilters(test, "add special subscription with filter2", {snippets: [f ilter1.text, filter2.text]}); 354 checkKnownFilters(test, "add special subscription with filter2", {snippets: [f ilter1.text, filter2.text]});
357 355
358 test.done(); 356 test.done();
359 }; 357 };
OLDNEW
« lib/contentFilterModule.js ('K') | « lib/elemHideEmulation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld