|
1 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 // Test that the rule-view behaves correctly when entering mutliple and/or |
|
8 // unfinished properties/values in inplace-editors |
|
9 |
|
10 let test = asyncTest(function*() { |
|
11 yield addTab("data:text/html,test rule view user changes"); |
|
12 content.document.body.innerHTML = "<h1>Testing Multiple Properties</h1>"; |
|
13 let {toolbox, inspector, view} = yield openRuleView(); |
|
14 |
|
15 info("Creating the test element"); |
|
16 let newElement = content.document.createElement("div"); |
|
17 newElement.textContent = "Test Element"; |
|
18 content.document.body.appendChild(newElement); |
|
19 yield selectNode(newElement, inspector); |
|
20 let ruleEditor = view.element.children[0]._ruleEditor; |
|
21 |
|
22 yield testCreateNewMultiPartialUnfinished(inspector, ruleEditor, view); |
|
23 }); |
|
24 |
|
25 function* testCreateNewMultiPartialUnfinished(inspector, ruleEditor, view) { |
|
26 yield createNewRuleViewProperty(ruleEditor, "width: 100px; heig"); |
|
27 |
|
28 is(ruleEditor.rule.textProps.length, 2, "Should have created a new text property."); |
|
29 is(ruleEditor.propertyList.children.length, 2, "Should have created a property editor."); |
|
30 |
|
31 // Value is focused, lets add multiple rules here and make sure they get added |
|
32 let valueEditor = ruleEditor.propertyList.children[1].querySelector("input"); |
|
33 valueEditor.value = "10px;background:orangered;color: black;"; |
|
34 EventUtils.synthesizeKey("VK_RETURN", {}, view.doc.defaultView); |
|
35 |
|
36 is(ruleEditor.rule.textProps.length, 4, "Should have added the changed value."); |
|
37 is(ruleEditor.propertyList.children.length, 5, "Should have added the changed value editor."); |
|
38 |
|
39 is(ruleEditor.rule.textProps[0].name, "width", "Should have correct property name"); |
|
40 is(ruleEditor.rule.textProps[0].value, "100px", "Should have correct property value"); |
|
41 |
|
42 is(ruleEditor.rule.textProps[1].name, "heig", "Should have correct property name"); |
|
43 is(ruleEditor.rule.textProps[1].value, "10px", "Should have correct property value"); |
|
44 |
|
45 is(ruleEditor.rule.textProps[2].name, "background", "Should have correct property name"); |
|
46 is(ruleEditor.rule.textProps[2].value, "orangered", "Should have correct property value"); |
|
47 |
|
48 is(ruleEditor.rule.textProps[3].name, "color", "Should have correct property name"); |
|
49 is(ruleEditor.rule.textProps[3].value, "black", "Should have correct property value"); |
|
50 |
|
51 yield inspector.once("inspector-updated"); |
|
52 } |