Bug 1237885 - Make browser_rules_add-rule_01.js faster by doing less; r=jdescottes

MozReview-Commit-ID: FlFVrnBrvDi

--HG--
extra : rebase_source : 34a29ca2a02bcbaff69031b1109b8b9dccf6243f
This commit is contained in:
Patrick Brosset 2016-05-27 21:17:53 +02:00
parent 743296ac11
commit 0f01caf64c
3 changed files with 42 additions and 26 deletions

View File

@ -53,6 +53,7 @@ support-files =
[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]

View File

@ -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");
});

View File

@ -4,8 +4,7 @@
"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">
@ -38,39 +37,24 @@ const TEST_DATA = [
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);
}