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

Side by Side Diff: test/elemHide.js

Issue 29342830: Issue 4057 - Further speedup ElemHide.getSelectorsforDomain (Closed)
Patch Set: Rebased, unconditionalSelectors Created May 24, 2016, 2:39 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 import: function() 22 import: function()
23 { 23 {
24 } 24 }
25 }; 25 };
26 26
27 let {ElemHide} = require("elemHide"); 27 let {ElemHide} = require("elemHide");
28 let {Filter} = require("filterClasses"); 28 let {Filter} = require("filterClasses");
29 29
30 exports.testGetSelectorsForDomain = function(test) 30 exports.testGetSelectorsForDomain = function(test)
31 { 31 {
32 function fromText(f) 32 let addFilter = filterText => ElemHide.add(Filter.fromText(filterText));
kzar 2016/05/24 14:45:22 `this` was being clobbered for the ElemHide method
33 { 33 let removeFilter = filterText => ElemHide.remove(Filter.fromText(filterText));
34 return (filterText) => f(Filter.fromText(filterText));
35 }
36 let addFilter = fromText(ElemHide.add);
37 let removeFilter = fromText(ElemHide.remove);
38 34
39 function normalizeSelectors(selectors) 35 function normalizeSelectors(selectors)
40 { 36 {
41 // getSelectorsForDomain is currently allowed to return duplicate selectors 37 // getSelectorsForDomain is currently allowed to return duplicate selectors
42 // for performance reasons, so we need to remove duplicates here. 38 // for performance reasons, so we need to remove duplicates here.
43 return selectors.sort().filter((selector, index, selectors) => 39 return selectors.sort().filter((selector, index, selectors) =>
44 { 40 {
45 return index == 0 || selector != selectors[index - 1]; 41 return index == 0 || selector != selectors[index - 1];
46 }); 42 });
47 } 43 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 156
161 addFilter("~example.com##foo"); 157 addFilter("~example.com##foo");
162 selectorsEqual("foo.example.com", []); 158 selectorsEqual("foo.example.com", []);
163 selectorsEqual("example.com", ["foo"]); 159 selectorsEqual("example.com", ["foo"]);
164 selectorsEqual("com", ["foo"]); 160 selectorsEqual("com", ["foo"]);
165 selectorsEqual("", ["foo"]); 161 selectorsEqual("", ["foo"]);
166 removeFilter("example.org##foo"); 162 removeFilter("example.org##foo");
167 163
168 test.done(); 164 test.done();
169 }; 165 };
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