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

Delta Between Two Patch Sets: test/elemHide.js

Issue 29783618: Issue 6665 - Split out element hiding exceptions into their own module (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Emit own elemhideupdate event Created May 17, 2018, 5:19 a.m.
Right Patch Set: Add lib/elemHideExceptions.js Created Aug. 7, 2018, 2:18 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/filterListener.js ('k') | test/elemHideEmulation.js » ('j') | 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 test.deepEqual( 52 test.deepEqual(
53 normalizeSelectors(ElemHide.getSelectorsForDomain(domain, specificOnly)), 53 normalizeSelectors(ElemHide.getSelectorsForDomain(domain, specificOnly)),
54 normalizedExpectedSelectors 54 normalizedExpectedSelectors
55 ); 55 );
56 } 56 }
57 57
58 exports.testGetSelectorsForDomain = function(test) 58 exports.testGetSelectorsForDomain = function(test)
59 { 59 {
60 let addFilter = filterText => ElemHide.add(Filter.fromText(filterText)); 60 let addFilter = filterText => ElemHide.add(Filter.fromText(filterText));
61 let removeFilter = filterText => ElemHide.remove(Filter.fromText(filterText)); 61 let removeFilter = filterText => ElemHide.remove(Filter.fromText(filterText));
62 let addException = 62 let addException =
Manish Jethani 2018/05/17 05:42:48 We could just add type checks to addFilter and rem
63 filterText => ElemHideExceptions.add(Filter.fromText(filterText)); 63 filterText => ElemHideExceptions.add(Filter.fromText(filterText));
64 let removeException = 64 let removeException =
65 filterText => ElemHideExceptions.remove(Filter.fromText(filterText)); 65 filterText => ElemHideExceptions.remove(Filter.fromText(filterText));
66 66
67 testResult(test, "", []); 67 testResult(test, "", []);
68 68
69 addFilter("~foo.example.com,example.com##foo"); 69 addFilter("~foo.example.com,example.com##foo");
70 testResult(test, "barfoo.example.com", ["foo"]); 70 testResult(test, "barfoo.example.com", ["foo"]);
71 testResult(test, "bar.foo.example.com", []); 71 testResult(test, "bar.foo.example.com", []);
72 testResult(test, "foo.example.com", []); 72 testResult(test, "foo.example.com", []);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 removeFilter("~foo.example.com,example.com##foo"); 179 removeFilter("~foo.example.com,example.com##foo");
180 180
181 // Test criteria 181 // Test criteria
182 addFilter("##hello"); 182 addFilter("##hello");
183 addFilter("~example.com##world"); 183 addFilter("~example.com##world");
184 addFilter("foo.com##specific"); 184 addFilter("foo.com##specific");
185 testResult(test, "foo.com", ["specific"], true); 185 testResult(test, "foo.com", ["specific"], true);
186 testResult(test, "foo.com", ["hello", "specific", "world"], false); 186 testResult(test, "foo.com", ["hello", "specific", "world"], false);
187 testResult(test, "foo.com", ["hello", "specific", "world"]); 187 testResult(test, "foo.com", ["hello", "specific", "world"]);
188 testResult(test, "foo.com.", ["hello", "specific", "world"]);
189 testResult(test, "example.com", [], true);
188 removeFilter("foo.com##specific"); 190 removeFilter("foo.com##specific");
189 removeFilter("~example.com##world"); 191 removeFilter("~example.com##world");
190 removeFilter("##hello"); 192 removeFilter("##hello");
191 testResult(test, "foo.com", []); 193 testResult(test, "foo.com", []);
192 194
193 addFilter("##hello"); 195 addFilter("##hello");
194 testResult(test, "foo.com", [], true); 196 testResult(test, "foo.com", [], true);
195 testResult(test, "foo.com", ["hello"], false); 197 testResult(test, "foo.com", ["hello"], false);
196 testResult(test, "foo.com", ["hello"]); 198 testResult(test, "foo.com", ["hello"]);
197 testResult(test, "bar.com", [], true); 199 testResult(test, "bar.com", [], true);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 }; 239 };
238 240
239 exports.testZeroFilterKey = function(test) 241 exports.testZeroFilterKey = function(test)
240 { 242 {
241 ElemHide.add(Filter.fromText("##test")); 243 ElemHide.add(Filter.fromText("##test"));
242 ElemHideExceptions.add(Filter.fromText("foo.com#@#test")); 244 ElemHideExceptions.add(Filter.fromText("foo.com#@#test"));
243 testResult(test, "foo.com", []); 245 testResult(test, "foo.com", []);
244 testResult(test, "bar.com", ["test"]); 246 testResult(test, "bar.com", ["test"]);
245 test.done(); 247 test.done();
246 }; 248 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld