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 InspectorTest.selectNodeAndWaitForStyles("inspected", step1);
16 InspectorTest.addSniffer(WebInspector.UISourceCode.prototype, "addRevision", revisionAdded);
19 var hasResourceChanged;
23 // Click "Add new rule".
24 InspectorTest.addNewRule("foo, div#inspected, bar", step2);
29 var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
30 var newProperty = section.addNewBlankProperty();
31 newProperty.startEditing();
32 textInputController.insertText("color");
33 newProperty.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
34 textInputController.insertText("maroon");
35 newProperty.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
36 InspectorTest.selectNodeAndWaitForStyles("other", step3);
41 // Click "Add new rule".
42 InspectorTest.addNewRule(null, onRuleAdded);
44 function onRuleAdded()
46 InspectorTest.selectNodeAndWaitForStyles("inspected", step4);
52 InspectorTest.addResult("After adding new rule (inspected):");
53 InspectorTest.dumpSelectedElementStyles(true, false, true, true);
54 InspectorTest.selectNodeAndWaitForStyles("other", step5);
59 InspectorTest.addResult("After adding new rule (other):");
60 InspectorTest.dumpSelectedElementStyles(true, false, true);
62 InspectorTest.waitForStylesForClass("my-class", onStylesReceived);
63 InspectorTest.nodeWithClass("my-class", onNodeFound);
64 function onNodeFound(node)
66 WebInspector.Revealer.reveal(node);
69 function onStylesReceived()
71 InspectorTest.addNewRule(null, step6);
77 InspectorTest.dumpSelectedElementStyles(true, false, true);
79 InspectorTest.waitForStylesForClass("class-1", onStylesReceived);
80 InspectorTest.nodeWithClass("class-1", onNodeFound);
81 function onNodeFound(node)
83 WebInspector.Revealer.reveal(node);
86 function onStylesReceived()
88 InspectorTest.addNewRule(null, function() {
89 InspectorTest.dumpSelectedElementStyles(true, false, true);
90 InspectorTest.completeTest();
94 function revisionAdded(revision)
96 InspectorTest.addResult("Revision added: " + this.displayName());
103 <body onload="runTest()">
105 Tests that adding a new rule works after switching nodes.
108 <div id="inspected" style="font-size: 12px">Text</div>
109 <div id="other" style="color:red"></div>
111 <div class="my-class"></div>
112 <div class="my-class"></div>
113 <div class="my-class"></div>
116 <div class=" class-1 class-2 class-3 "></div>