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