3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/elements-test.js"></script>
9 WebInspector.showPanel("elements");
10 InspectorTest.selectNodeAndWaitForStyles("inspected", addAndIncrementFirstProperty);
15 function addAndIncrementFirstProperty()
17 InspectorTest.addResult("Before append:");
18 InspectorTest.dumpSelectedElementStyles(true);
19 section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1];
22 // Create and increment.
23 treeElement = section.addNewBlankProperty(0);
24 treeElement.startEditing();
25 treeElement.nameElement.textContent = "margin-left";
26 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
28 treeElement.valueElement.textContent = "1px";
29 treeElement.valueElement.firstChild.select();
30 treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Up"));
31 InspectorTest.runAfterPendingDispatches(incrementProperty);
34 function incrementProperty()
37 treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Up"));
38 InspectorTest.runAfterPendingDispatches(commitProperty);
41 function commitProperty()
44 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
45 reloadStyles(addAndChangeLastCompoundProperty);
48 function addAndChangeLastCompoundProperty()
50 InspectorTest.addResult("After insertion at index 0:");
51 InspectorTest.dumpSelectedElementStyles(true);
53 treeElement = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1].addNewBlankProperty(2);
54 treeElement.startEditing();
55 treeElement.nameElement.textContent = "color";
56 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
58 treeElement.valueElement.textContent = "green; font-weight: bold";
59 treeElement.kickFreeFlowStyleEditForTest();
61 treeElement.valueElement.textContent = "red; font-weight: bold";
62 treeElement.kickFreeFlowStyleEditForTest();
64 treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
65 InspectorTest.runAfterPendingDispatches(reloadStyles.bind(this, addAndCommitMiddleProperty));
68 function addAndCommitMiddleProperty()
70 InspectorTest.addResult("After appending and changing a 'compound' property:");
71 InspectorTest.dumpSelectedElementStyles(true);
73 treeElement = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1].addNewBlankProperty(2);
74 treeElement.startEditing();
75 treeElement.nameElement.textContent = "third-property";
76 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
77 treeElement.valueElement.textContent = "third-value";
79 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
80 InspectorTest.runAfterPendingDispatches(reloadStyles.bind(this, dumpAndComplete));
83 function dumpAndComplete()
85 InspectorTest.addResult("After insertion at index 2:");
86 InspectorTest.dumpSelectedElementStyles(true);
88 InspectorTest.completeTest();
91 function reloadStyles(callback) {
92 InspectorTest.selectNodeWithId("other");
93 InspectorTest.runAfterPendingDispatches(otherCallback);
95 function otherCallback()
97 InspectorTest.selectNodeAndWaitForStyles("inspected", callback);
105 <body onload="runTest()">
107 Tests that adding a new blank property works.
110 <div id="inspected" style="font-size: 12px">Text</div>
111 <div id="other"></div>