Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / css / cssom-matching-rules.html
blobce3a07a9a3731720dc985c721a2c0d81b682d22d
1 <html>
2 <head>
4 <style>
5 #modifyRule {
6 box-sizing: border-box;
9 #modifyRule {
10 height: 100%;
13 #modifyRule {
14 width: 100%;
16 </style>
18 <style>
19 #insertRule {
20 box-sizing: border-box;
23 #insertRule {
24 width: 100%;
26 </style>
28 <style>
29 #removeRule {
30 box-sizing: border-box;
33 #removeRule {
34 width: 100%;
36 </style>
38 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
39 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-protocol-test.js"></script>
40 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-protocol-test.js"></script>
41 <script type="text/javascript">
43 function test()
45 var documentNodeId;
47 InspectorTest.requestDocumentNodeId(onDocumentNodeId);
49 function onDocumentNodeId(nodeId)
51 documentNodeId = nodeId;
52 InspectorTest.sendCommandOrDie("CSS.enable", {}, function() {
53 InspectorTest.runTestSuite(testSuite);
54 });
57 var testSuite = [
58 function testModifyRule(next)
60 InspectorTest.log("--------------");
61 InspectorTest.log("Original rule:");
62 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#modifyRule", step1, true);
64 function step1()
66 InspectorTest.evaluateInPage("document.styleSheets[0].rules[0].style.setProperty('color', 'red')");
67 InspectorTest.log("--------------");
68 InspectorTest.log("Modified rule 1:");
69 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#modifyRule", step2, true);
72 function step2()
74 InspectorTest.evaluateInPage("document.styleSheets[0].rules[2].style.setProperty('color', 'blue')");
75 InspectorTest.log("---------------");
76 InspectorTest.log("Modified rule 3:");
77 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#modifyRule", step3, true);
80 function step3()
82 InspectorTest.evaluateInPage("document.styleSheets[0].rules[1].style.setProperty('color', 'green')");
83 InspectorTest.log("---------------");
84 InspectorTest.log("Modified rule 2:");
85 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#modifyRule", step4, true);
88 function step4()
90 InspectorTest.evaluateInPage("document.styleSheets[0].rules[1].style.removeProperty('color')");
91 InspectorTest.log("---------------");
92 InspectorTest.log("Restored rule 2:");
93 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#modifyRule", step5, true);
96 function step5()
98 InspectorTest.evaluateInPage("document.styleSheets[0].rules[0].style.removeProperty('color')");
99 InspectorTest.evaluateInPage("document.styleSheets[0].rules[2].style.removeProperty('color')");
100 InspectorTest.log("-----------------");
101 InspectorTest.log("Restored rule 1,3:");
102 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#modifyRule", next, true);
106 function testInsertFirstRule(next)
108 testInsertRule(0, next)
111 function testInsertMiddleRule(next)
113 testInsertRule(1, next)
116 function testInsertLastRule(next)
118 testInsertRule(2, next)
121 function testRemoveRule(next)
123 InspectorTest.log("Original rule:");
124 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#removeRule", step1, true);
126 function step1()
128 InspectorTest.evaluateInPage("document.styleSheets[2].removeRule(0)");
129 InspectorTest.log("-------------------");
130 InspectorTest.log("After remove rule 1:");
131 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#removeRule", step2, true);
134 function step2()
136 InspectorTest.evaluateInPage("document.styleSheets[2].removeRule(0)");
137 InspectorTest.log("-------------------");
138 InspectorTest.log("After remove rule 2:");
139 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#removeRule", next, true);
145 function testInsertRule(index, next)
147 InspectorTest.log("Original rule:");
148 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#insertRule", step1, true);
150 function step1()
152 InspectorTest.evaluateInPage("document.styleSheets[1].insertRule('#insertRule { color: red }', " + index + ")");
153 InspectorTest.log("--------------");
154 InspectorTest.log("After inserted rule:");
155 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#insertRule", step2, true);
158 function step2()
160 InspectorTest.evaluateInPage("document.styleSheets[1].removeRule(" + index + ")");
161 InspectorTest.log("--------------");
162 InspectorTest.log("Restored rule:");
163 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#insertRule", next, true);
168 </script>
169 </head>
170 <body onload="runTest();">
171 <p>The test verifies CSS.getMatchedStylesForNode when used concurrently with the CSSOM modifications.</p>
172 <article id="modifyRule"></article>
173 <article id="insertRule"></article>
174 <article id="removeRule"></article>
175 </body>
176 </html>