| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="../../http/tests/inspector/elements-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| WebInspector.showPanel("elements"); |
| InspectorTest.selectNodeAndWaitForStyles("inspected", addAndIncrementFirstProperty); |
| |
| var treeElement; |
| var section; |
| |
| function addAndIncrementFirstProperty() |
| { |
| InspectorTest.addResult("Before append:"); |
| InspectorTest.dumpSelectedElementStyles(true); |
| section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1]; |
| section.expand(); |
| |
| // Create and increment. |
| treeElement = section.addNewBlankProperty(0); |
| treeElement.startEditing(); |
| treeElement.nameElement.textContent = "margin-left"; |
| treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); |
| |
| treeElement.valueElement.textContent = "1px"; |
| treeElement.valueElement.firstChild.select(); |
| treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Up")); |
| InspectorTest.runAfterPendingDispatches(incrementProperty); |
| } |
| |
| function incrementProperty() |
| { |
| // Increment again. |
| treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Up")); |
| InspectorTest.runAfterPendingDispatches(commitProperty); |
| } |
| |
| function commitProperty() |
| { |
| // Commit. |
| treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); |
| reloadStyles(addAndChangeLastCompoundProperty); |
| } |
| |
| function addAndChangeLastCompoundProperty() |
| { |
| InspectorTest.addResult("After insertion at index 0:"); |
| InspectorTest.dumpSelectedElementStyles(true); |
| |
| treeElement = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1].addNewBlankProperty(2); |
| treeElement.startEditing(); |
| treeElement.nameElement.textContent = "color"; |
| treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); |
| |
| treeElement.valueElement.textContent = "green; font-weight: bold"; |
| treeElement.kickFreeFlowStyleEditForTest(); |
| |
| treeElement.valueElement.textContent = "red; font-weight: bold"; |
| treeElement.kickFreeFlowStyleEditForTest(); |
| |
| treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); |
| InspectorTest.runAfterPendingDispatches(reloadStyles.bind(this, addAndCommitMiddleProperty)); |
| } |
| |
| function addAndCommitMiddleProperty() |
| { |
| InspectorTest.addResult("After appending and changing a 'compound' property:"); |
| InspectorTest.dumpSelectedElementStyles(true); |
| |
| treeElement = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1].addNewBlankProperty(2); |
| treeElement.startEditing(); |
| treeElement.nameElement.textContent = "third-property"; |
| treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); |
| treeElement.valueElement.textContent = "third-value"; |
| |
| treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); |
| InspectorTest.runAfterPendingDispatches(reloadStyles.bind(this, dumpAndComplete)); |
| } |
| |
| function dumpAndComplete() |
| { |
| InspectorTest.addResult("After insertion at index 2:"); |
| InspectorTest.dumpSelectedElementStyles(true); |
| |
| InspectorTest.completeTest(); |
| } |
| |
| function reloadStyles(callback) { |
| InspectorTest.selectNodeWithId("other"); |
| InspectorTest.runAfterPendingDispatches(otherCallback); |
| |
| function otherCallback() |
| { |
| InspectorTest.selectNodeAndWaitForStyles("inspected", callback); |
| } |
| } |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| Tests that adding a new blank property works. |
| </p> |
| |
| <div id="inspected" style="font-size: 12px">Text</div> |
| <div id="other"></div> |
| |
| </body> |
| </html> |