Bug 1415940 Part 8: Add a browser test to confirm DOM added rules work with leading newlines.
MozReview-Commit-ID: Alj2VimZNxQ
--- a/devtools/client/inspector/rules/test/browser_rules_cssom.js
+++ b/devtools/client/inspector/rules/test/browser_rules_cssom.js
@@ -10,13 +10,20 @@
const TEST_URI = URL_ROOT + "doc_cssom.html";
add_task(function* () {
yield addTab(TEST_URI);
let {inspector, view} = yield openRuleView();
yield selectNode("#target", inspector);
let elementStyle = view._elementStyle;
- let rule = elementStyle.rules[1];
+ let rule;
- is(rule.textProps.length, 1, "rule should have one property");
+ rule = elementStyle.rules[1];
+ is(rule.textProps.length, 1, "rule 1 should have one property");
is(rule.textProps[0].name, "color", "the property should be 'color'");
+ is(rule.ruleLine, -1, "the property has no source line");
+
+ rule = elementStyle.rules[2];
+ is(rule.textProps.length, 1, "rule 2 should have one property");
+ is(rule.textProps[0].name, "font-weight", "the property should be 'font-weight'");
+ is(rule.ruleLine, -1, "the property has no source line");
});
--- a/devtools/client/inspector/rules/test/doc_cssom.html
+++ b/devtools/client/inspector/rules/test/doc_cssom.html
@@ -6,17 +6,17 @@
<script>
"use strict";
window.onload = function () {
let x = document.styleSheets[0];
x.insertRule("div { color: seagreen; }", 1);
// Add a rule with a leading newline, to test that inspector can handle it.
- x.insertRule("\n\ndiv { font-weight: bold; }", 1);
+ x.insertRule("\ndiv { font-weight: bold; }", 1);
};
</script>
<style>
span { }
</style>
</head>
<body>