3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/elements-test.js"></script>
9 InspectorTest.selectNodeAndWaitForStyles("inspected", addAndIncrementFirstProperty);
14 function addAndIncrementFirstProperty()
16 InspectorTest.addResult("Before append:");
17 InspectorTest.dumpSelectedElementStyles(true);
18 section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1];
21 // Create and increment.
22 treeElement = section.addNewBlankProperty(0);
23 treeElement.startEditing();
24 treeElement.nameElement.textContent = "margin-left";
25 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
27 treeElement.valueElement.textContent = "1px";
28 treeElement.valueElement.firstChild.select();
29 treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Up"));
30 InspectorTest.waitForStyleApplied(incrementProperty);
33 function incrementProperty()
36 treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Up"));
37 InspectorTest.waitForStyleApplied(commitProperty);
40 function commitProperty()
43 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
44 reloadStyles(addAndChangeLastCompoundProperty);
47 function addAndChangeLastCompoundProperty()
49 InspectorTest.addResult("After insertion at index 0:");
50 InspectorTest.dumpSelectedElementStyles(true);
52 treeElement = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1].addNewBlankProperty(2);
53 treeElement.startEditing();
54 treeElement.nameElement.textContent = "color";
55 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
57 treeElement.valueElement.textContent = "green; font-weight: bold";
58 treeElement.kickFreeFlowStyleEditForTest();
60 treeElement.valueElement.textContent = "red; font-weight: bold";
61 treeElement.kickFreeFlowStyleEditForTest();
63 treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
64 InspectorTest.waitForStyleApplied(reloadStyles.bind(this, addAndCommitMiddleProperty));
67 function addAndCommitMiddleProperty()
69 InspectorTest.addResult("After appending and changing a 'compound' property:");
70 InspectorTest.dumpSelectedElementStyles(true);
72 treeElement = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1].addNewBlankProperty(2);
73 treeElement.startEditing();
74 treeElement.nameElement.textContent = "third-property";
75 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
76 treeElement.valueElement.textContent = "third-value";
78 treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
79 InspectorTest.waitForStyleApplied(reloadStyles.bind(this, dumpAndComplete));
82 function dumpAndComplete()
84 InspectorTest.addResult("After insertion at index 2:");
85 InspectorTest.dumpSelectedElementStyles(true);
87 InspectorTest.completeTest();
90 function reloadStyles(callback) {
91 InspectorTest.selectNodeAndWaitForStyles("other", otherCallback);
93 function otherCallback()
95 InspectorTest.selectNodeAndWaitForStyles("inspected", callback);
103 <body onload="runTest()">
105 Tests that adding a new blank property works.
108 <div id="inspected" style="font-size: 12px">Text</div>
109 <div id="other"></div>