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

Delta Between Two Patch Sets: test/elemHide.js

Issue 29882562: Issue 6956 - Move extension's style sheet generation into core (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Make createStyleSheet top-level Created Sept. 18, 2018, 2:57 p.m.
Right Patch Set: Avoid temporary array and join Created Sept. 18, 2018, 3:11 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
« lib/elemHide.js ('K') | « 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
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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 }; 278 };
279 279
280 exports.testCreateStyleSheet = function(test) 280 exports.testCreateStyleSheet = function(test)
281 { 281 {
282 test.equal( 282 test.equal(
283 createStyleSheet([ 283 createStyleSheet([
284 "html", "#foo", ".bar", "#foo .bar", "#foo > .bar", 284 "html", "#foo", ".bar", "#foo .bar", "#foo > .bar",
285 "#foo[data-bar='bar']" 285 "#foo[data-bar='bar']"
286 ]), 286 ]),
287 "html, #foo, .bar, #foo .bar, #foo > .bar, #foo[data-bar='bar'] " + 287 "html, #foo, .bar, #foo .bar, #foo > .bar, #foo[data-bar='bar'] " +
288 "{display: none !important;}", 288 "{display: none !important;}\n",
289 "Style sheet creation should work" 289 "Style sheet creation should work"
290 ); 290 );
291 291
292 let selectors = new Array(50000).map((element, index) => ".s" + index); 292 let selectors = new Array(50000).map((element, index) => ".s" + index);
293 293
294 test.equal(createStyleSheet(selectors).split("\n").length, 294 test.equal((createStyleSheet(selectors).match(/\n/g) || []).length,
295 Math.ceil(50000 / selectorGroupSize), 295 Math.ceil(50000 / selectorGroupSize),
296 "Style sheet should be split up into rules with at most " + 296 "Style sheet should be split up into rules with at most " +
297 selectorGroupSize + " selectors each"); 297 selectorGroupSize + " selectors each");
298 298
299 test.done(); 299 test.done();
300 }; 300 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld