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", step1);
11 InspectorTest.addSniffer(WebInspector.UISourceCode.prototype, "addRevision", revisionAdded);
14 var hasResourceChanged;
18 // Click "Add new rule".
19 document.getElementById("add-style-button-test-id").click();
20 var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
21 section._selectorElement.textContent = "foo, " + section._selectorElement.textContent + ", bar";
22 section._selectorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
23 InspectorTest.runAfterPendingDispatches(step2);
28 var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
29 var newProperty = section.addNewBlankProperty();
30 newProperty.startEditing();
31 newProperty.nameElement.textContent = "color";
32 newProperty.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
33 newProperty.valueElement.textContent = "maroon";
34 newProperty.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
35 InspectorTest.selectNodeAndWaitForStyles("other", step3);
40 // Click "Add new rule".
41 document.getElementById("add-style-button-test-id").click();
42 InspectorTest.selectNodeAndWaitForStyles("inspected", step4);
47 InspectorTest.addResult("After adding new rule (inspected):");
48 InspectorTest.dumpSelectedElementStyles(true, false, true, true);
49 InspectorTest.selectNodeAndWaitForStyles("other", step5);
54 InspectorTest.addResult("After adding new rule (other):");
55 InspectorTest.dumpSelectedElementStyles(true, false, true);
56 InspectorTest.completeTest();
59 function revisionAdded(revision)
61 InspectorTest.addResult("Revision added: " + this.displayName());
68 <body onload="runTest()">
70 Tests that adding a new rule works after switching nodes.
73 <div id="inspected" style="font-size: 12px">Text</div>
74 <div id="other" style="color:red"></div>