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">
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
);
37 styleSheetHeader
= header
;
38 InspectorTest
.loadAndDumpMatchingRules(documentNodeId
, "#inspected", 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 {}",
52 InspectorTest
.loadAndDumpMatchingRules(documentNodeId
, "#inspected", 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 {}",
72 InspectorTest
.loadAndDumpMatchingRules(documentNodeId
, "#inspected", step8
);
77 InspectorTest
.completeTest();
81 window
.addEventListener("DOMContentLoaded", function () {
88 <div id=
"inspected">Inspected contents
</div>