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);
16 addNewRuleAndSelectNode("other", step2);
21 addNewRuleAndSelectNode("inspected", step3);
26 InspectorTest.addResult("After adding new rule:");
27 InspectorTest.dumpSelectedElementStyles(true, false, true);
28 printStyleSheetAndCall(step4);
33 WebInspector.domAgent.undo();
34 InspectorTest.selectNodeAndWaitForStyles("other", step5);
39 InspectorTest.addResult("After undo:");
40 InspectorTest.dumpSelectedElementStyles(true, false, true);
41 printStyleSheetAndCall(step6);
46 WebInspector.domAgent.redo();
47 InspectorTest.selectNodeAndWaitForStyles("inspected", step7);
52 InspectorTest.addResult("After redo:");
53 InspectorTest.dumpSelectedElementStyles(true, false, true);
54 printStyleSheetAndCall(step8);
59 InspectorTest.completeTest();
62 function addNewRuleAndSelectNode(nodeId, next)
64 // Click "Add new rule".
65 document.getElementById("add-style-button-test-id").click();
66 var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
67 section._selectorElement.textContent = "div.foo";
68 section._selectorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
69 InspectorTest.selectNodeAndWaitForStyles(nodeId, next);
72 function printStyleSheetAndCall(next)
74 var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
75 var id = section.styleRule.style.id.styleSheetId;
76 CSSAgent.getStyleSheetText(id, callback);
77 function callback(result, styleSheetText)
79 InspectorTest.addResult("===== Style sheet text: =====");
80 InspectorTest.addResult(styleSheetText);
81 InspectorTest.addResult("=============================");
90 <body onload="runTest()">
92 Tests that adding a new rule can be undone.
95 <div class="foo" id="inspected" style="font-size: 12px">Text</div>
96 <div class="foo" id="other" style="color:red"></div>