Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / elements / styles / styles-add-new-rule.html
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/elements-test.js"></script>
5 <script>
6
7 function test()
8 {
9     WebInspector.showPanel("elements");
10     InspectorTest.selectNodeAndWaitForStyles("inspected", step1);
11     InspectorTest.addSniffer(WebInspector.UISourceCode.prototype, "addRevision", revisionAdded);
12
13     var treeElement;
14     var hasResourceChanged;
15
16     function step1()
17     {
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);
24     }
25
26     function step2()
27     {
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);
36     }
37
38     function step3()
39     {
40         // Click "Add new rule".
41         document.getElementById("add-style-button-test-id").click();
42         InspectorTest.selectNodeAndWaitForStyles("inspected", step4);
43     }
44
45     function step4()
46     {
47         InspectorTest.addResult("After adding new rule (inspected):");
48         InspectorTest.dumpSelectedElementStyles(true, false, true, true);
49         InspectorTest.selectNodeAndWaitForStyles("other", step5);
50     }
51
52     function step5()
53     {
54         InspectorTest.addResult("After adding new rule (other):");
55         InspectorTest.dumpSelectedElementStyles(true, false, true);
56         InspectorTest.completeTest();
57     }
58
59     function revisionAdded(revision)
60     {
61         InspectorTest.addResult("Revision added: " + this.displayName());
62     }
63 }
64
65 </script>
66 </head>
67
68 <body onload="runTest()">
69 <p>
70 Tests that adding a new rule works after switching nodes.
71 </p>
72
73 <div id="inspected" style="font-size: 12px">Text</div>
74 <div id="other" style="color:red"></div>
75
76 </body>
77 </html>