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

Delta Between Two Patch Sets: test/snippets.js

Issue 29849575: Issue 6797 - Require active domains in snippet filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Add tests Created Aug. 7, 2018, 2:49 p.m.
Right Patch Set: Use different snippets names Created Aug. 8, 2018, 1:55 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
« no previous file with change/comment | « lib/filterClasses.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
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 let matches = Snippets.getScriptsForDomain(domain); 51 let matches = Snippets.getScriptsForDomain(domain);
52 test.deepEqual(matches.sort(), expectedMatches.sort(), description); 52 test.deepEqual(matches.sort(), expectedMatches.sort(), description);
53 53
54 Snippets.clear(); 54 Snippets.clear();
55 } 55 }
56 56
57 testScriptMatches( 57 testScriptMatches(
58 "Ignore generic filters", 58 "Ignore generic filters",
59 [ 59 [
60 "#$#foo", "example.com#$#foo", 60 "#$#foo-1", "example.com#$#foo-2",
kzar 2018/08/08 11:31:50 Shouldn't we use different snippet names for these
Manish Jethani 2018/08/08 13:56:42 Thanks, this makes sense. Done.
61 "~example.com#$#foo" 61 "~example.com#$#foo-3"
62 ], 62 ],
63 "example.com", 63 "example.com",
64 ["foo"] 64 ["foo-2"]
65 ); 65 );
66 testScriptMatches( 66 testScriptMatches(
67 "Ignore filters that include parent domain but exclude subdomain", 67 "Ignore filters that include parent domain but exclude subdomain",
68 [ 68 [
69 "~www.example.com,example.com#$#foo" 69 "~www.example.com,example.com#$#foo"
70 ], 70 ],
71 "www.example.com", 71 "www.example.com",
72 [] 72 []
73 ); 73 );
74 testScriptMatches( 74 testScriptMatches(
75 "Ignore filters for other subdomain", 75 "Ignore filters for other subdomain",
76 [ 76 [
77 "www.example.com#$#foo", 77 "www.example.com#$#foo-1",
78 "other.example.com#$#foo" 78 "other.example.com#$#foo-2"
79 ], 79 ],
80 "other.example.com", 80 "other.example.com",
81 ["foo"] 81 ["foo-2"]
82 ); 82 );
83 83
84 test.done(); 84 test.done();
85 }; 85 };
86 86
87 exports.testSnippetFiltersContainer = function(test) 87 exports.testSnippetFiltersContainer = function(test)
88 { 88 {
89 function compareRules(description, domain, expectedMatches) 89 function compareRules(description, domain, expectedMatches)
90 { 90 {
91 let result = Snippets.getScriptsForDomain(domain); 91 let result = Snippets.getScriptsForDomain(domain);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // between executions. In the example below, assertFoo does not find 456 but 247 // between executions. In the example below, assertFoo does not find 456 but
248 // it doesn't find 123 either. It's the initial value 0. 248 // it doesn't find 123 either. It's the initial value 0.
249 new Function( 249 new Function(
250 compileScript("setFoo 456; assertFoo 0", [ 250 compileScript("setFoo 456; assertFoo 0", [
251 ...libraries, "let foo = 1; exports.setFoo = value => { foo = value; };" 251 ...libraries, "let foo = 1; exports.setFoo = value => { foo = value; };"
252 ]) 252 ])
253 )(); 253 )();
254 254
255 test.done(); 255 test.done();
256 }; 256 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld