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

Delta Between Two Patch Sets: test/filterClasses.js

Issue 29737558: Issue 6538, 6781 - Implement support for snippet filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Rebase Created June 19, 2018, 12:59 p.m.
Right Patch Set: Improve comment formatting Created July 11, 2018, 1:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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
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 const {createSandbox} = require("./_common"); 20 const {createSandbox} = require("./_common");
21 21
22 let Filter = null; 22 let Filter = null;
23 let InvalidFilter = null; 23 let InvalidFilter = null;
24 let CommentFilter = null; 24 let CommentFilter = null;
25 let ActiveFilter = null; 25 let ActiveFilter = null;
26 let RegExpFilter = null; 26 let RegExpFilter = null;
27 let BlockingFilter = null; 27 let BlockingFilter = null;
28 let ScriptFilter = null; 28 let ContentFilter = null;
29 let WhitelistFilter = null; 29 let WhitelistFilter = null;
30 let ElemHideBase = null; 30 let ElemHideBase = null;
31 let ElemHideFilter = null; 31 let ElemHideFilter = null;
32 let ElemHideException = null; 32 let ElemHideException = null;
33 let ElemHideEmulationFilter = null; 33 let ElemHideEmulationFilter = null;
34 let SnippetFilter = null; 34 let SnippetFilter = null;
35 35
36 let t = null; 36 let t = null;
37 let defaultTypes = null; 37 let defaultTypes = null;
38 38
39 exports.setUp = function(callback) 39 exports.setUp = function(callback)
40 { 40 {
41 let sandboxedRequire = createSandbox(); 41 let sandboxedRequire = createSandbox();
42 ( 42 (
43 {Filter, InvalidFilter, CommentFilter, ActiveFilter, RegExpFilter, 43 {Filter, InvalidFilter, CommentFilter, ActiveFilter, RegExpFilter,
44 BlockingFilter, WhitelistFilter, ScriptFilter, ElemHideBase, 44 BlockingFilter, WhitelistFilter, ContentFilter, ElemHideBase,
45 ElemHideFilter, ElemHideException, ElemHideEmulationFilter, 45 ElemHideFilter, ElemHideException, ElemHideEmulationFilter,
46 SnippetFilter} = sandboxedRequire("../lib/filterClasses") 46 SnippetFilter} = sandboxedRequire("../lib/filterClasses")
47 ); 47 );
48 t = RegExpFilter.typeMap; 48 t = RegExpFilter.typeMap;
49 defaultTypes = 0x7FFFFFFF & ~(t.CSP | t.ELEMHIDE | t.DOCUMENT | t.POPUP | 49 defaultTypes = 0x7FFFFFFF & ~(t.CSP | t.ELEMHIDE | t.DOCUMENT | t.POPUP |
50 t.GENERICHIDE | t.GENERICBLOCK); 50 t.GENERICHIDE | t.GENERICBLOCK);
51 51
52 callback(); 52 callback();
53 }; 53 };
54 54
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 216
217 exports.testFilterClassDefinitions = function(test) 217 exports.testFilterClassDefinitions = function(test)
218 { 218 {
219 test.equal(typeof Filter, "function", "typeof Filter"); 219 test.equal(typeof Filter, "function", "typeof Filter");
220 test.equal(typeof InvalidFilter, "function", "typeof InvalidFilter"); 220 test.equal(typeof InvalidFilter, "function", "typeof InvalidFilter");
221 test.equal(typeof CommentFilter, "function", "typeof CommentFilter"); 221 test.equal(typeof CommentFilter, "function", "typeof CommentFilter");
222 test.equal(typeof ActiveFilter, "function", "typeof ActiveFilter"); 222 test.equal(typeof ActiveFilter, "function", "typeof ActiveFilter");
223 test.equal(typeof RegExpFilter, "function", "typeof RegExpFilter"); 223 test.equal(typeof RegExpFilter, "function", "typeof RegExpFilter");
224 test.equal(typeof BlockingFilter, "function", "typeof BlockingFilter"); 224 test.equal(typeof BlockingFilter, "function", "typeof BlockingFilter");
225 test.equal(typeof ScriptFilter, "function", "typeof ScriptFilter"); 225 test.equal(typeof ContentFilter, "function", "typeof ContentFilter");
226 test.equal(typeof WhitelistFilter, "function", "typeof WhitelistFilter"); 226 test.equal(typeof WhitelistFilter, "function", "typeof WhitelistFilter");
227 test.equal(typeof ElemHideBase, "function", "typeof ElemHideBase"); 227 test.equal(typeof ElemHideBase, "function", "typeof ElemHideBase");
228 test.equal(typeof ElemHideFilter, "function", "typeof ElemHideFilter"); 228 test.equal(typeof ElemHideFilter, "function", "typeof ElemHideFilter");
229 test.equal(typeof ElemHideException, "function", "typeof ElemHideException"); 229 test.equal(typeof ElemHideException, "function", "typeof ElemHideException");
230 test.equal(typeof ElemHideEmulationFilter, "function", 230 test.equal(typeof ElemHideEmulationFilter, "function",
231 "typeof ElemHideEmulationFilter"); 231 "typeof ElemHideEmulationFilter");
232 test.equal(typeof SnippetFilter, "function", "typeof SnippetFilter"); 232 test.equal(typeof SnippetFilter, "function", "typeof SnippetFilter");
233 233
234 test.done(); 234 test.done();
235 }; 235 };
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 let rewriteEvil = "/(^https?:\\/\\/[^/])/$script,rewrite=$1.evil.com"; 584 let rewriteEvil = "/(^https?:\\/\\/[^/])/$script,rewrite=$1.evil.com";
585 let filterEvil = Filter.fromText(rewriteEvil); 585 let filterEvil = Filter.fromText(rewriteEvil);
586 586
587 test.equal( 587 test.equal(
588 filterEvil.rewriteUrl("https://www.adblockplus.org/script.js"), 588 filterEvil.rewriteUrl("https://www.adblockplus.org/script.js"),
589 "https://www.adblockplus.org/script.js" 589 "https://www.adblockplus.org/script.js"
590 ); 590 );
591 591
592 test.done(); 592 test.done();
593 }; 593 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld