browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +// Test that the rule-view behaves correctly when entering mutliple and/or
    1.11 +// unfinished properties/values in inplace-editors
    1.12 +
    1.13 +let test = asyncTest(function*() {
    1.14 +  yield addTab("data:text/html,test rule view user changes");
    1.15 +  content.document.body.innerHTML = "<h1>Testing Multiple Properties</h1>";
    1.16 +  let {toolbox, inspector, view} = yield openRuleView();
    1.17 +
    1.18 +  info("Creating the test element");
    1.19 +  let newElement = content.document.createElement("div");
    1.20 +  newElement.textContent = "Test Element";
    1.21 +  content.document.body.appendChild(newElement);
    1.22 +  yield selectNode(newElement, inspector);
    1.23 +  let ruleEditor = view.element.children[0]._ruleEditor;
    1.24 +
    1.25 +  yield testMultiValues(inspector, ruleEditor, view);
    1.26 +});
    1.27 +
    1.28 +function* testMultiValues(inspector, ruleEditor, view) {
    1.29 +  yield createNewRuleViewProperty(ruleEditor, "width:");
    1.30 +
    1.31 +  is(ruleEditor.rule.textProps.length, 1, "Should have created a new text property.");
    1.32 +  is(ruleEditor.propertyList.children.length, 1, "Should have created a property editor.");
    1.33 +
    1.34 +  // Value is focused, lets add multiple rules here and make sure they get added
    1.35 +  let valueEditor = ruleEditor.propertyList.children[0].querySelector("input");
    1.36 +  valueEditor.value = "height: 10px;color:blue"
    1.37 +  EventUtils.synthesizeKey("VK_RETURN", {}, view.doc.defaultView);
    1.38 +
    1.39 +  is(ruleEditor.rule.textProps.length, 2, "Should have added the changed value.");
    1.40 +  is(ruleEditor.propertyList.children.length, 3, "Should have added the changed value editor.");
    1.41 +
    1.42 +  EventUtils.synthesizeKey("VK_ESCAPE", {}, view.doc.defaultView);
    1.43 +  is(ruleEditor.propertyList.children.length, 2, "Should have removed the value editor.");
    1.44 +
    1.45 +  is(ruleEditor.rule.textProps[0].name, "width", "Should have correct property name");
    1.46 +  is(ruleEditor.rule.textProps[0].value, "height: 10px", "Should have correct property value");
    1.47 +
    1.48 +  is(ruleEditor.rule.textProps[1].name, "color", "Should have correct property name");
    1.49 +  is(ruleEditor.rule.textProps[1].value, "blue", "Should have correct property value");
    1.50 +
    1.51 +  yield inspector.once("inspector-updated");
    1.52 +}

mercurial