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

Delta Between Two Patch Sets: test/elemHide.js

Issue 29893628: Issue 6957 - Skip selector lookup for unknown domains (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Sept. 27, 2018, 10:01 p.m.
Right Patch Set: Rebase Created Sept. 28, 2018, 6 p.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-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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 { 51 {
52 return index == 0 || selector != sortedSelectors[index - 1]; 52 return index == 0 || selector != sortedSelectors[index - 1];
53 }); 53 });
54 } 54 }
55 55
56 function testResult(test, domain, expectedSelectors, specificOnly) 56 function testResult(test, domain, expectedSelectors, specificOnly)
57 { 57 {
58 let normalizedExpectedSelectors = normalizeSelectors(expectedSelectors); 58 let normalizedExpectedSelectors = normalizeSelectors(expectedSelectors);
59 59
60 let {code, selectors} = 60 let {code, selectors} =
61 ElemHide.generateStyleSheetForDomain(domain, specificOnly); 61 ElemHide.generateStyleSheetForDomain(domain, specificOnly, true);
62 62
63 test.deepEqual(normalizeSelectors(selectors), normalizedExpectedSelectors); 63 test.deepEqual(normalizeSelectors(selectors), normalizedExpectedSelectors);
64 64
65 // Make sure each expected selector is in the actual CSS code. 65 // Make sure each expected selector is in the actual CSS code.
66 for (let selector of normalizedExpectedSelectors) 66 for (let selector of normalizedExpectedSelectors)
67 { 67 {
68 test.ok(code.includes(selector + ", ") || 68 test.ok(code.includes(selector + ", ") ||
69 code.includes(selector + " {display: none !important;}\n")); 69 code.includes(selector + " {display: none !important;}\n"));
70 } 70 }
71 } 71 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 let selectors = new Array(50000).map((element, index) => ".s" + index); 299 let selectors = new Array(50000).map((element, index) => ".s" + index);
300 300
301 test.equal((createStyleSheet(selectors).match(/\n/g) || []).length, 301 test.equal((createStyleSheet(selectors).match(/\n/g) || []).length,
302 Math.ceil(50000 / selectorGroupSize), 302 Math.ceil(50000 / selectorGroupSize),
303 "Style sheet should be split up into rules with at most " + 303 "Style sheet should be split up into rules with at most " +
304 selectorGroupSize + " selectors each"); 304 selectorGroupSize + " selectors each");
305 305
306 test.done(); 306 test.done();
307 }; 307 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld