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

Unified Diff: test/elemHide.js

Issue 30002601: Issue 7284 - Move CSS escaping to createStyleSheet (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Added test Created Feb. 15, 2019, 2:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/browser/elemHideEmulation.js ('k') | test/filterClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/elemHide.js
===================================================================
--- a/test/elemHide.js
+++ b/test/elemHide.js
@@ -292,23 +292,32 @@
"html", "#foo", ".bar", "#foo .bar", "#foo > .bar",
"#foo[data-bar='bar']"
]),
"html, #foo, .bar, #foo .bar, #foo > .bar, #foo[data-bar='bar'] " +
"{display: none !important;}\n",
"Style sheet creation should work"
);
- let selectors = new Array(50000).map((element, index) => ".s" + index);
+ let selectors = new Array(50000).fill().map((element, index) => ".s" + index);
test.equal((createStyleSheet(selectors).match(/\n/g) || []).length,
Math.ceil(50000 / selectorGroupSize),
"Style sheet should be split up into rules with at most " +
selectorGroupSize + " selectors each");
+ test.equal(
+ createStyleSheet([
+ "html", "#foo", ".bar", "#foo .bar", "#foo > .bar",
+ "#foo[data-bar='{foo: 1}']"
+ ]),
+ "html, #foo, .bar, #foo .bar, #foo > .bar, #foo[data-bar='\\7B foo: 1\\7D '] " +
Manish Jethani 2019/02/16 04:34:04 Nit: This is the only line in the file that exceed
hub 2019/02/18 12:56:20 Done.
Manish Jethani 2019/02/18 13:07:21 Nit: When wrapping an expression `a + b` the break
hub 2019/02/18 13:51:08 Done.
+ "{display: none !important;}\n",
+ "Style sheet creation should work"
Manish Jethani 2019/02/16 04:34:04 "Braces should be escaped"
hub 2019/02/18 12:56:20 Done.
+ );
test.done();
Manish Jethani 2019/02/16 04:34:04 Nit: Can we leave a blank line above test.done?
hub 2019/02/18 12:56:21 Done.
};
exports.testRulesFromStyleSheet = function(test)
{
// Note: The rulesFromStyleSheet function assumes that each rule will be
// terminated with a newline character, including the last rule. If this is
// not the case, the function goes into an infinite loop. It should only be
« no previous file with comments | « test/browser/elemHideEmulation.js ('k') | test/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld