summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/xpcshell/test_getRuleText.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/server/tests/xpcshell/test_getRuleText.js')
-rw-r--r--devtools/server/tests/xpcshell/test_getRuleText.js81
1 files changed, 68 insertions, 13 deletions
diff --git a/devtools/server/tests/xpcshell/test_getRuleText.js b/devtools/server/tests/xpcshell/test_getRuleText.js
index fe53dca158..bc89da974c 100644
--- a/devtools/server/tests/xpcshell/test_getRuleText.js
+++ b/devtools/server/tests/xpcshell/test_getRuleText.js
@@ -16,6 +16,25 @@ const TEST_DATA = [
throws: true,
},
{
+ desc: "Null input",
+ input: null,
+ line: 1,
+ column: 1,
+ throws: true,
+ },
+ {
+ desc: "Missing loc",
+ input: "#id{color:red;background:yellow;}",
+ throws: true,
+ },
+ {
+ desc: "No opening bracket",
+ input: "/* hey */",
+ line: 1,
+ column: 1,
+ throws: true,
+ },
+ {
desc: "Simplest test case",
input: "#id{color:red;background:yellow;}",
line: 1,
@@ -39,18 +58,6 @@ const TEST_DATA = [
expected: { offset: 4, text: "color:red;background:yellow;" },
},
{
- desc: "Null input",
- input: null,
- line: 1,
- column: 1,
- throws: true,
- },
- {
- desc: "Missing loc",
- input: "#id{color:red;background:yellow;}",
- throws: true,
- },
- {
desc: "Multi-lines CSS",
input: [
"/* this is a multi line css */",
@@ -61,7 +68,7 @@ const TEST_DATA = [
" /*something else here */",
"* {",
" color: purple;",
- "}",
+ "} ",
].join("\n"),
line: 7,
column: 1,
@@ -107,12 +114,60 @@ const TEST_DATA = [
},
},
{
+ desc: "Attribute selector containing a { character",
+ input: `div[data-x="{"]{color: gold}`,
+ line: 1,
+ column: 1,
+ expected: {
+ offset: 16,
+ text: "color: gold",
+ },
+ },
+ {
desc: "Rule contains no tokens",
input: "div{}",
line: 1,
column: 1,
expected: { offset: 4, text: "" },
},
+ {
+ desc: "Rule contains invalid declaration",
+ input: `#id{color;}`,
+ line: 1,
+ column: 1,
+ expected: { offset: 4, text: "color;" },
+ },
+ {
+ desc: "Rule contains invalid declaration",
+ input: `#id{-}`,
+ line: 1,
+ column: 1,
+ expected: { offset: 4, text: "-" },
+ },
+ {
+ desc: "Rule contains nested rule",
+ input: `#id{background: gold; .nested{color:blue;} color: tomato; }`,
+ line: 1,
+ column: 1,
+ expected: {
+ offset: 4,
+ text: "background: gold; .nested{color:blue;} color: tomato; ",
+ },
+ },
+ {
+ desc: "Rule contains nested rule with invalid declaration",
+ input: `#id{.nested{color;}}`,
+ line: 1,
+ column: 1,
+ expected: { offset: 4, text: ".nested{color;}" },
+ },
+ {
+ desc: "Rule contains unicode chars",
+ input: `#id /*🙃*/ {content: "☃️";}`,
+ line: 1,
+ column: 1,
+ expected: { offset: 12, text: `content: "☃️";` },
+ },
];
function run_test() {