1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 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 testCreateNewMultiPartialUnfinished(inspector, ruleEditor, view); 1.26 +}); 1.27 + 1.28 +function* testCreateNewMultiPartialUnfinished(inspector, ruleEditor, view) { 1.29 + yield createNewRuleViewProperty(ruleEditor, "width: 100px; heig"); 1.30 + 1.31 + is(ruleEditor.rule.textProps.length, 2, "Should have created a new text property."); 1.32 + is(ruleEditor.propertyList.children.length, 2, "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[1].querySelector("input"); 1.36 + valueEditor.value = "10px;background:orangered;color: black;"; 1.37 + EventUtils.synthesizeKey("VK_RETURN", {}, view.doc.defaultView); 1.38 + 1.39 + is(ruleEditor.rule.textProps.length, 4, "Should have added the changed value."); 1.40 + is(ruleEditor.propertyList.children.length, 5, "Should have added the changed value editor."); 1.41 + 1.42 + is(ruleEditor.rule.textProps[0].name, "width", "Should have correct property name"); 1.43 + is(ruleEditor.rule.textProps[0].value, "100px", "Should have correct property value"); 1.44 + 1.45 + is(ruleEditor.rule.textProps[1].name, "heig", "Should have correct property name"); 1.46 + is(ruleEditor.rule.textProps[1].value, "10px", "Should have correct property value"); 1.47 + 1.48 + is(ruleEditor.rule.textProps[2].name, "background", "Should have correct property name"); 1.49 + is(ruleEditor.rule.textProps[2].value, "orangered", "Should have correct property value"); 1.50 + 1.51 + is(ruleEditor.rule.textProps[3].name, "color", "Should have correct property name"); 1.52 + is(ruleEditor.rule.textProps[3].value, "black", "Should have correct property value"); 1.53 + 1.54 + yield inspector.once("inspector-updated"); 1.55 +}