Bug 1237885 - Make browser_rules_add-rule_01.js faster by doing less; r=jdescottes
MozReview-Commit-ID: FlFVrnBrvDi
--- a/devtools/client/inspector/rules/test/browser.ini
+++ b/devtools/client/inspector/rules/test/browser.ini
@@ -48,16 +48,17 @@ support-files =
[browser_rules_add-property_02.js]
[browser_rules_add-property-svg.js]
[browser_rules_add-rule_01.js]
[browser_rules_add-rule_02.js]
[browser_rules_add-rule_03.js]
[browser_rules_add-rule_04.js]
[browser_rules_add-rule_05.js]
[browser_rules_add-rule_06.js]
+[browser_rules_add-rule-and-property.js]
[browser_rules_add-rule_pseudo_class.js]
[browser_rules_add-rule_iframes.js]
[browser_rules_add-rule-with-menu.js]
[browser_rules_authored.js]
[browser_rules_authored_color.js]
[browser_rules_authored_override.js]
[browser_rules_blob_stylesheet.js]
[browser_rules_colorpicker-and-image-tooltip_01.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/rules/test/browser_rules_add-rule-and-property.js
@@ -0,0 +1,31 @@
+/* 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";
+
+// Tests adding a new rule and a new property in this rule.
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8,<div id='testid'>Styled Node</div>");
+ let {inspector, view} = yield openRuleView();
+
+ info("Selecting the test node");
+ yield selectNode("#testid", inspector);
+
+ info("Adding a new rule for this node and blurring the new selector field");
+ yield addNewRule(inspector, view);
+ EventUtils.synthesizeKey("VK_ESCAPE", {});
+
+ info("Adding a new property for this rule");
+ let ruleEditor = getRuleViewRuleEditor(view, 1);
+
+ let onRuleViewChanged = view.once("ruleview-changed");
+ ruleEditor.addProperty("font-weight", "bold", "");
+ yield onRuleViewChanged;
+
+ let textProps = ruleEditor.rule.textProps;
+ let prop = textProps[textProps.length - 1];
+ is(prop.name, "font-weight", "The last property name is font-weight");
+ is(prop.value, "bold", "The last property value is bold");
+});
--- a/devtools/client/inspector/rules/test/browser_rules_add-rule_01.js
+++ b/devtools/client/inspector/rules/test/browser_rules_add-rule_01.js
@@ -1,16 +1,15 @@
/* 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";
-// Tests the behaviour of adding a new rule using the add rule button and the
-// various inplace-editor behaviours in the new rule editor.
+// Tests adding a new rule using the add rule button.
const TEST_URI = `
<style type="text/css">
.testclass {
text-align: center;
}
</style>
<div id="testid" class="testclass">Styled Node</div>
@@ -33,44 +32,29 @@ const TEST_DATA = [
{ node: "p", expected: "p" },
{ node: "h1", expected: ".asd\\@\\@\\@\\@a\\!\\!\\!\\!\\:\\:\\:\\@asd" },
{ node: "h2", expected: "#asd\\@\\@\\@a\\!\\!2a" },
{ node: "circle", expected: "circle" }
];
add_task(function* () {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
- let {inspector, view, testActor} = yield openRuleView();
+ let {inspector, view} = yield openRuleView();
for (let data of TEST_DATA) {
let {node, expected} = data;
yield selectNode(node, inspector);
yield addNewRule(inspector, view);
- yield testNewRule(view, expected, 1);
-
- info("Resetting page content");
- yield testActor.eval(
- "content.document.body.innerHTML = `" + TEST_URI + "`;");
+ yield testNewRule(view, expected);
}
});
-function* testNewRule(view, expected, index) {
- let idRuleEditor = getRuleViewRuleEditor(view, index);
- let editor = idRuleEditor.selectorText.ownerDocument.activeElement;
- is(editor.value, expected,
- "Selector editor value is as expected: " + expected);
+function* testNewRule(view, expected) {
+ let ruleEditor = getRuleViewRuleEditor(view, 1);
+ let editor = ruleEditor.selectorText.ownerDocument.activeElement;
+ is(editor.value, expected, "Selector editor value is as expected: " + expected);
- info("Entering the escape key");
+ info("Escaping from the selector inplace editor");
EventUtils.synthesizeKey("VK_ESCAPE", {});
- is(idRuleEditor.selectorText.textContent, expected,
- "Selector text value is as expected: " + expected);
-
- info("Adding new properties to new rule: " + expected);
- let onRuleViewChanged = view.once("ruleview-changed");
- idRuleEditor.addProperty("font-weight", "bold", "");
- yield onRuleViewChanged;
-
- let textProps = idRuleEditor.rule.textProps;
- let lastRule = textProps[textProps.length - 1];
- is(lastRule.name, "font-weight", "Last rule name is font-weight");
- is(lastRule.value, "bold", "Last rule value is bold");
+ is(ruleEditor.selectorText.textContent, expected,
+ "Selector text value is as expected: " + expected);
}