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

Side by Side Diff: test/filterListener.js

Issue 29780560: Issue 6665 - Optimize element hiding emulation filter lookups (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Use String.indexOf for subdomains Created May 14, 2018, 2:22 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/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 14 matching lines...) Expand all
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: { 33 extraExports: {
34 elemHide: ["knownFilters"], 34 elemHide: ["knownFilters"],
35 elemHideEmulation: ["filters"] 35 elemHideEmulation: ["knownFilters"]
36 } 36 }
37 }); 37 });
38 38
39 // We need to require the filterListener module so that filter changes will be 39 // 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. 40 // noticed, even though we don't directly use the module here.
41 sandboxedRequire("../lib/filterListener"); 41 sandboxedRequire("../lib/filterListener");
42 42
43 ( 43 (
44 {FilterStorage} = sandboxedRequire("../lib/filterStorage"), 44 {FilterStorage} = sandboxedRequire("../lib/filterStorage"),
45 {Subscription, SpecialSubscription} = sandboxedRequire("../lib/subscriptionC lasses"), 45 {Subscription, SpecialSubscription} = sandboxedRequire("../lib/subscriptionC lasses"),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 for (let filter of elemHide.knownFilters) 84 for (let filter of elemHide.knownFilters)
85 { 85 {
86 if (filter instanceof ElemHideException) 86 if (filter instanceof ElemHideException)
87 result.elemhideexception.push(filter.text); 87 result.elemhideexception.push(filter.text);
88 else 88 else
89 result.elemhide.push(filter.text); 89 result.elemhide.push(filter.text);
90 } 90 }
91 91
92 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation"); 92 let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation");
93 result.elemhideemulation = []; 93 result.elemhideemulation = [];
94 for (let filterText of elemHideEmulation.filters) 94 for (let {text: filterText} of elemHideEmulation.knownFilters)
95 result.elemhideemulation.push(filterText); 95 result.elemhideemulation.push(filterText);
96 96
97 let types = ["blacklist", "whitelist", "elemhide", "elemhideexception", 97 let types = ["blacklist", "whitelist", "elemhide", "elemhideexception",
98 "elemhideemulation"]; 98 "elemhideemulation"];
99 for (let type of types) 99 for (let type of types)
100 { 100 {
101 if (!(type in expected)) 101 if (!(type in expected))
102 expected[type] = []; 102 expected[type] = [];
103 else 103 else
104 expected[type].sort(); 104 expected[type].sort();
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]}); 318 checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]});
319 319
320 FilterStorage.removeSubscription(subscription4); 320 FilterStorage.removeSubscription(subscription4);
321 checkKnownFilters(test, "remove subscription from the list", {blacklist: [filt er1.text]}); 321 checkKnownFilters(test, "remove subscription from the list", {blacklist: [filt er1.text]});
322 322
323 subscription3.disabled = false; 323 subscription3.disabled = false;
324 checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]}); 324 checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]});
325 325
326 test.done(); 326 test.done();
327 }; 327 };
OLDNEW
« no previous file with comments | « lib/elemHideEmulation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld