Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / css / css-create-stylesheet-and-add-rule.html
blobca49584e0acc43a2f915b05f739b9e1633e61874
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-protocol-test.js"></script>
5 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-protocol-test.js"></script>
6 <link rel="stylesheet" type="text/css" href="resources/stylesheet.css"></link>
7 <script type="text/javascript">
8 function test()
10 var frameId;
11 var styleSheetHeader;
12 var documentNodeId;
14 InspectorTest.requestDocumentNodeId(onDocumentNodeId);
16 function onDocumentNodeId(nodeId)
18 documentNodeId = nodeId;
19 InspectorTest.requestMainFrameId(step2);
22 function step2(mainFrameId)
24 frameId = mainFrameId;
25 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
26 InspectorTest.sendCommandOrDie("CSS.enable", {}, function() {})
29 function styleSheetAdded(response)
31 var header = response.params.header;
32 var urlString = header.sourceURL ? " (" + InspectorTest.displayName(header.sourceURL) + ")" : "";
33 InspectorTest.log("Style sheet added: " + header.origin + urlString);
34 if (styleSheetHeader)
35 return;
37 styleSheetHeader = header;
38 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#inspected", step3);
41 function step3()
43 InspectorTest.log("Adding a rule to the existing stylesheet.");
44 InspectorTest.addRule(styleSheetHeader.styleSheetId, false, {
45 location: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 0 },
46 ruleText: "#inspected {}",
47 }, step4);
50 function step4()
52 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#inspected", step5);
55 function step5()
57 InspectorTest.log("Creating inspector stylesheet.");
58 InspectorTest.sendCommandOrDie("CSS.createStyleSheet", { frameId: frameId }, step6);
61 function step6(result)
63 InspectorTest.log("Adding a rule to the inspector stylesheet.");
64 InspectorTest.addRule(result.styleSheetId, false, {
65 location: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 0 },
66 ruleText: "#inspected {}",
67 }, step7);
70 function step7()
72 InspectorTest.loadAndDumpMatchingRules(documentNodeId, "#inspected", step8);
75 function step8()
77 InspectorTest.completeTest();
81 window.addEventListener("DOMContentLoaded", function () {
82 runTest();
83 }, false);
85 </script>
86 </head>
87 <body>
88 <div id="inspected">Inspected contents</div>
89 </body>
90 </html>