michael@0: /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
michael@0: /* Any copyright is dedicated to the Public Domain.
michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0:
michael@0: "use strict";
michael@0:
michael@0: // Test that the rule-view behaves correctly when entering mutliple and/or
michael@0: // unfinished properties/values in inplace-editors
michael@0:
michael@0: let test = asyncTest(function*() {
michael@0: yield addTab("data:text/html,test rule view user changes");
michael@0: content.document.body.innerHTML = "
Testing Multiple Properties
";
michael@0: let {toolbox, inspector, view} = yield openRuleView();
michael@0:
michael@0: info("Creating the test element");
michael@0: let newElement = content.document.createElement("div");
michael@0: newElement.textContent = "Test Element";
michael@0: content.document.body.appendChild(newElement);
michael@0: yield selectNode(newElement, inspector);
michael@0: let ruleEditor = view.element.children[0]._ruleEditor;
michael@0:
michael@0: yield testCreateNewMultiPartialUnfinished(inspector, ruleEditor, view);
michael@0: });
michael@0:
michael@0: function* testCreateNewMultiPartialUnfinished(inspector, ruleEditor, view) {
michael@0: yield createNewRuleViewProperty(ruleEditor, "width: 100px; heig");
michael@0:
michael@0: is(ruleEditor.rule.textProps.length, 2, "Should have created a new text property.");
michael@0: is(ruleEditor.propertyList.children.length, 2, "Should have created a property editor.");
michael@0:
michael@0: // Value is focused, lets add multiple rules here and make sure they get added
michael@0: let valueEditor = ruleEditor.propertyList.children[1].querySelector("input");
michael@0: valueEditor.value = "10px;background:orangered;color: black;";
michael@0: EventUtils.synthesizeKey("VK_RETURN", {}, view.doc.defaultView);
michael@0:
michael@0: is(ruleEditor.rule.textProps.length, 4, "Should have added the changed value.");
michael@0: is(ruleEditor.propertyList.children.length, 5, "Should have added the changed value editor.");
michael@0:
michael@0: is(ruleEditor.rule.textProps[0].name, "width", "Should have correct property name");
michael@0: is(ruleEditor.rule.textProps[0].value, "100px", "Should have correct property value");
michael@0:
michael@0: is(ruleEditor.rule.textProps[1].name, "heig", "Should have correct property name");
michael@0: is(ruleEditor.rule.textProps[1].value, "10px", "Should have correct property value");
michael@0:
michael@0: is(ruleEditor.rule.textProps[2].name, "background", "Should have correct property name");
michael@0: is(ruleEditor.rule.textProps[2].value, "orangered", "Should have correct property value");
michael@0:
michael@0: is(ruleEditor.rule.textProps[3].name, "color", "Should have correct property name");
michael@0: is(ruleEditor.rule.textProps[3].value, "black", "Should have correct property value");
michael@0:
michael@0: yield inspector.once("inspector-updated");
michael@0: }