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

Side by Side Diff: test/elemHide.js

Issue 29354864: Issue 4223 - Migrate some more of adblockplustests (Closed)
Patch Set: Addressed feedback Created Oct. 4, 2016, 12:04 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
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 GLOBAL.Ci = {}; 20 let {createSandbox} = require("./_common");
21 GLOBAL.Cu = { 21
22 import: function() 22 let ElemHide = null;
23 { 23 let Filter = null;
24 } 24
25 exports.setUp = function(callback)
26 {
27 let sandboxedRequire = createSandbox();
28 (
29 {ElemHide} = sandboxedRequire("../lib/elemHide"),
30 {Filter} = sandboxedRequire("../lib/filterClasses")
31 );
32
33 callback();
25 }; 34 };
26 35
27 let {ElemHide} = require("elemHide");
28 let {Filter} = require("filterClasses");
29
30 exports.testGetSelectorsForDomain = function(test) 36 exports.testGetSelectorsForDomain = function(test)
31 { 37 {
32 let addFilter = filterText => ElemHide.add(Filter.fromText(filterText)); 38 let addFilter = filterText => ElemHide.add(Filter.fromText(filterText));
33 let removeFilter = filterText => ElemHide.remove(Filter.fromText(filterText)); 39 let removeFilter = filterText => ElemHide.remove(Filter.fromText(filterText));
34 40
35 function normalizeSelectors(selectors) 41 function normalizeSelectors(selectors)
36 { 42 {
37 // getSelectorsForDomain is currently allowed to return duplicate selectors 43 // getSelectorsForDomain is currently allowed to return duplicate selectors
38 // for performance reasons, so we need to remove duplicates here. 44 // for performance reasons, so we need to remove duplicates here.
39 return selectors.sort().filter((selector, index, selectors) => 45 return selectors.sort().filter((selector, index, selectors) =>
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 testResult("", ["dupe"]); 252 testResult("", ["dupe"]);
247 removeFilter("foo.com##dupe"); 253 removeFilter("foo.com##dupe");
248 testResult("", ["dupe"]); 254 testResult("", ["dupe"]);
249 removeFilter(",,##dupe"); 255 removeFilter(",,##dupe");
250 testResult("", ["dupe"]); 256 testResult("", ["dupe"]);
251 removeFilter("##dupe"); 257 removeFilter("##dupe");
252 testResult("", []); 258 testResult("", []);
253 259
254 test.done(); 260 test.done();
255 }; 261 };
OLDNEW
« no previous file with comments | « test/domainRestrictions.js ('k') | test/filterClasses.js » ('j') | test_runner.js » ('J')

Powered by Google App Engine
This is Rietveld