3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/elements-test.js"></script>
9 if (!window.eventSender || !window.textInputController) {
10 document.write("This test does not work in manual mode.");
11 InspectorTest.completeTest();
15 WebInspector.inspectorView.showPanel("elements");
16 InspectorTest.selectNodeAndWaitForStyles("inspected", step1);
17 InspectorTest.addSniffer(WebInspector.UISourceCode.prototype, "addRevision", revisionAdded);
20 var hasResourceChanged;
24 // Click "Add new rule".
25 InspectorTest.addNewRule("foo, div#inspected, bar", step2);
30 var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
31 var newProperty = section.addNewBlankProperty();
32 newProperty.startEditing();
33 textInputController.insertText("color");
34 newProperty.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
35 textInputController.insertText("maroon");
36 newProperty.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
37 InspectorTest.selectNodeAndWaitForStyles("other", step3);
42 // Click "Add new rule".
43 InspectorTest.addNewRule(null, onRuleAdded);
45 function onRuleAdded()
47 InspectorTest.selectNodeAndWaitForStyles("inspected", step4);
53 InspectorTest.addResult("After adding new rule (inspected):");
54 InspectorTest.dumpSelectedElementStyles(true, false, true, true);
55 InspectorTest.selectNodeAndWaitForStyles("other", step5);
60 InspectorTest.addResult("After adding new rule (other):");
61 InspectorTest.dumpSelectedElementStyles(true, false, true);
63 InspectorTest.waitForStylesForClass("my-class", onStylesReceived);
64 InspectorTest.nodeWithClass("my-class", onNodeFound);
65 function onNodeFound(node)
67 WebInspector.Revealer.reveal(node);
70 function onStylesReceived()
72 InspectorTest.addNewRule(null, step6);
78 InspectorTest.dumpSelectedElementStyles(true, false, true);
80 InspectorTest.waitForStylesForClass("class-1", onStylesReceived);
81 InspectorTest.nodeWithClass("class-1", onNodeFound);
82 function onNodeFound(node)
84 WebInspector.Revealer.reveal(node);
87 function onStylesReceived()
89 InspectorTest.addNewRule(null, function() {
90 InspectorTest.dumpSelectedElementStyles(true, false, true);
91 InspectorTest.completeTest();
95 function revisionAdded(revision)
97 InspectorTest.addResult("Revision added: " + this.displayName());
104 <body onload="runTest()">
106 Tests that adding a new rule works after switching nodes.
109 <div id="inspected" style="font-size: 12px">Text</div>
110 <div id="other" style="color:red"></div>
112 <div class="my-class"></div>
113 <div class="my-class"></div>
114 <div class="my-class"></div>
117 <div class=" class-1 class-2 class-3 "></div>