Bug 1235603 - handle invalid authored CSS in rule view; r?pbro
MozReview-Commit-ID: 5j8dqND8DeR
--- a/devtools/client/inspector/rules/models/rule.js
+++ b/devtools/client/inspector/rules/models/rule.js
@@ -431,16 +431,22 @@ Rule.prototype = {
* to parse the style's authoredText.
*/
_getTextProperties: function() {
let textProps = [];
let store = this.elementStyle.store;
let props = parseDeclarations(this.style.authoredText, true);
for (let prop of props) {
let name = prop.name;
+ // If the authored text has an invalid property, it will show up
+ // as nameless. Skip these as we don't currently have a good
+ // way to display them.
+ if (!name) {
+ continue;
+ }
// In an inherited rule, we only show inherited properties.
// However, we must keep all properties in order for rule
// rewriting to work properly. So, compute the "invisible"
// property here.
let invisible = this.inherited && !domUtils.isInheritedProperty(name);
let value = store.userProperties.getProperty(this.style, name,
prop.value);
let textProp = new TextProperty(this, name, value, prop.priority,
--- a/devtools/client/inspector/rules/test/browser.ini
+++ b/devtools/client/inspector/rules/test/browser.ini
@@ -126,16 +126,17 @@ skip-if = os == "mac" # Bug 1245996 : cl
[browser_rules_filtereditor-commit-on-ENTER.js]
[browser_rules_filtereditor-revert-on-ESC.js]
skip-if = (os == "win" && debug) # bug 963492: win.
[browser_rules_guessIndentation.js]
[browser_rules_inherited-properties_01.js]
[browser_rules_inherited-properties_02.js]
[browser_rules_inherited-properties_03.js]
[browser_rules_inline-source-map.js]
+[browser_rules_invalid.js]
[browser_rules_invalid-source-map.js]
[browser_rules_keybindings.js]
[browser_rules_keyframes-rule_01.js]
[browser_rules_keyframes-rule_02.js]
[browser_rules_keyframeLineNumbers.js]
[browser_rules_lineNumbers.js]
[browser_rules_livepreview.js]
[browser_rules_mark_overridden_01.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/rules/test/browser_rules_invalid.js
@@ -0,0 +1,33 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test that an invalid property still lets us display the rule view
+// Bug 1235603.
+
+const TEST_URI = `
+ <style>
+ div {
+ background: #fff;
+ font-family: sans-serif;
+ url(display-table.min.htc);
+ }
+ </style>
+ <body>
+ <div id="testid" class="testclass">Styled Node</div>
+ </body>
+`;
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+
+ let {inspector, view} = yield openRuleView();
+ yield selectNode("#testid", inspector);
+
+ is(view._elementStyle.rules.length, 2, "Should have 2 rules.");
+ // Have to actually get the rule in order to ensure that the
+ // elements were created.
+ ok(getRuleViewRule(view, "div"), "Rule with div selector exists");
+});