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

Side by Side Diff: qunit/tests/cssEscaping.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Addressed Wladimir's feedback Created March 15, 2017, 4:51 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « qunit/common.js ('k') | qunit/tests/filterValidation.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 "use strict"; 1 "use strict";
2 2
3 (function()
3 { 4 {
4 const {Filter, ElemHideFilter} = require("filterClasses"); 5 const {Filter, ElemHideFilter} = require("filterClasses");
5 const {escapeCSS, quoteCSS} = require("filterComposer"); 6 const {escapeCSS, quoteCSS} = require("filterComposer");
6 7
7 module("CSS escaping"); 8 module("CSS escaping");
8 9
9 test("CSS escaping", () => 10 test("CSS escaping", () =>
10 { 11 {
11 function testSelector(opts) 12 function testSelector(opts)
12 { 13 {
(...skipping 23 matching lines...) Expand all
36 for (let attr in opts.attributes) 37 for (let attr in opts.attributes)
37 element.setAttribute(attr, opts.attributes[attr]); 38 element.setAttribute(attr, opts.attributes[attr]);
38 39
39 doc.documentElement.appendChild(element); 40 doc.documentElement.appendChild(element);
40 } 41 }
41 42
42 let foundElement = doc.querySelector(opts.selector); 43 let foundElement = doc.querySelector(opts.selector);
43 let filter = Filter.fromText("##" + opts.selector); 44 let filter = Filter.fromText("##" + opts.selector);
44 45
45 if (!(filter instanceof ElemHideFilter)) 46 if (!(filter instanceof ElemHideFilter))
46 {
47 ok(false, opts.selector + " (not allowed in elemhide filters)"); 47 ok(false, opts.selector + " (not allowed in elemhide filters)");
48 } 48 else if (mustMatch)
49 equal(foundElement, element, opts.selector);
49 else 50 else
50 { 51 ok(true, opts.selector);
51 if (mustMatch)
52 equal(foundElement, element, opts.selector);
53 else
54 ok(true, opts.selector);
55 }
56 } 52 }
57 53
58 function testEscape(s) 54 function testEscape(s)
59 { 55 {
60 testSelector({ 56 testSelector({
61 selector: escapeCSS(s), 57 selector: escapeCSS(s),
62 tagName: s 58 tagName: s
63 }); 59 });
64 60
65 testSelector({ 61 testSelector({
(...skipping 26 matching lines...) Expand all
92 88
93 // Some characters are only escaped when in the first positon, 89 // Some characters are only escaped when in the first positon,
94 // so we still have to make sure that everything is correctly escaped 90 // so we still have to make sure that everything is correctly escaped
95 // in subsequent positions. 91 // in subsequent positions.
96 testEscape("x" + chr); 92 testEscape("x" + chr);
97 93
98 // Leading dashes must be escaped, when followed by certain characters. 94 // Leading dashes must be escaped, when followed by certain characters.
99 testEscape("-" + chr); 95 testEscape("-" + chr);
100 } 96 }
101 97
102 // Test some non-ASCII characters. However, those shouldn't require escaping . 98 // Test some non-ASCII characters. However, those shouldn't
99 // require escaping.
103 testEscape("\uD83D\uDE3B\u2665\u00E4"); 100 testEscape("\uD83D\uDE3B\u2665\u00E4");
104 }); 101 });
105 } 102 }());
OLDNEW
« no previous file with comments | « qunit/common.js ('k') | qunit/tests/filterValidation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld