LEFT | RIGHT |
(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 Loading... |
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 Loading... |
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 }; |
LEFT | RIGHT |