3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/elements-test.js"></script>
7 var initialize_AdditionalPreload = function() {
8 InspectorTest
.preloadModule("source_frame");
13 InspectorTest
.selectNodeAndWaitForStyles("inspected", step1
);
16 var hasResourceChanged
;
18 var revisionAdded
= false;
19 var testFinished
= false;
20 var displayName
= null;
22 InspectorTest
.addSniffer(WebInspector
.UISourceCode
.prototype, "addRevision", onRevisionAdded
);
26 // Click "Add new rule".
27 InspectorTest
.addNewRule("foo, div#inspected, bar", step2
);
32 var section
= InspectorTest
.firstMatchedStyleSection();
33 var newProperty
= section
.addNewBlankProperty();
34 newProperty
.startEditing();
35 textInputController
.insertText("color");
36 newProperty
.nameElement
.dispatchEvent(InspectorTest
.createKeyEvent("Enter"));
37 textInputController
.insertText("maroon");
38 newProperty
.valueElement
.dispatchEvent(InspectorTest
.createKeyEvent("Enter"));
39 InspectorTest
.selectNodeAndWaitForStyles("other", step3
);
44 // Click "Add new rule".
45 InspectorTest
.addNewRule(null, onRuleAdded
);
47 function onRuleAdded()
49 InspectorTest
.selectNodeAndWaitForStyles("inspected", step4
);
55 InspectorTest
.addResult("After adding new rule (inspected):");
56 InspectorTest
.dumpSelectedElementStyles(true, false, true, true);
57 InspectorTest
.selectNodeAndWaitForStyles("other", step5
);
62 InspectorTest
.addResult("After adding new rule (other):");
63 InspectorTest
.dumpSelectedElementStyles(true, false, true);
65 InspectorTest
.waitForStylesForClass("my-class", onStylesReceived
);
66 InspectorTest
.nodeWithClass("my-class", onNodeFound
);
67 function onNodeFound(node
)
69 WebInspector
.Revealer
.reveal(node
);
72 function onStylesReceived()
74 InspectorTest
.addNewRule(null, step6
);
80 InspectorTest
.dumpSelectedElementStyles(true, false, true);
82 InspectorTest
.waitForStylesForClass("class-1", onStylesReceived
);
83 InspectorTest
.nodeWithClass("class-1", onNodeFound
);
84 function onNodeFound(node
)
86 WebInspector
.Revealer
.reveal(node
);
89 function onStylesReceived()
91 InspectorTest
.addNewRule(null, function() {
92 InspectorTest
.dumpSelectedElementStyles(true, false, true);
99 function maybeCompleteTest()
101 if (!revisionAdded
|| !testFinished
)
103 InspectorTest
.addResult("Revision added: " + displayName
);
104 InspectorTest
.completeTest();
107 function onRevisionAdded(revision
)
109 revisionAdded
= true;
110 displayName
= this.displayName();
118 <body onload=
"runTest()">
120 Tests that adding a new rule works after switching nodes.
123 <div id=
"inspected" style=
"font-size: 12px">Text
</div>
124 <div id=
"other" style=
"color:red"></div>
126 <div class=
"my-class"></div>
127 <div class=
"my-class"></div>
128 <div class=
"my-class"></div>
131 <div class=
" class-1 class-2 class-3 "></div>