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

Delta Between Two Patch Sets: test/elemHide.js

Issue 29342830: Issue 4057 - Further speedup ElemHide.getSelectorsforDomain (Closed)
Left Patch Set: Further improvements Created May 21, 2016, 4:41 a.m.
Right Patch Set: Addressed nits Created May 25, 2016, 10:50 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « lib/elemHide.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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));
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 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld