OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 4 <script type="text/javascript" src="css-protocol-test.js"></script> |
| 5 <link rel="stylesheet" type="text/css" href="resources/stylesheet.css"></link> |
| 6 <script type="text/javascript"> |
| 7 function test() |
| 8 { |
| 9 var frameId; |
| 10 var styleSheetHeader; |
| 11 |
| 12 setTimeout(InspectorTest.completeTest.bind(InspectorTest), 2000); |
| 13 |
| 14 InspectorTest.requestMainFrameId(step2); |
| 15 |
| 16 function step2(mainFrameId) |
| 17 { |
| 18 frameId = mainFrameId; |
| 19 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; |
| 20 InspectorTest.sendCommandOrDie("CSS.enable", {}, function() {}) |
| 21 } |
| 22 |
| 23 function styleSheetAdded(response) |
| 24 { |
| 25 var header = response.params.header; |
| 26 var urlString = header.sourceURL ? " (" + InspectorTest.displayName(head
er.sourceURL) + ")" : ""; |
| 27 InspectorTest.log("Style sheet added: " + header.origin + urlString); |
| 28 if (styleSheetHeader) |
| 29 return; |
| 30 |
| 31 styleSheetHeader = header; |
| 32 InspectorTest.loadAndDumpMatchingRules("#inspected", step3); |
| 33 } |
| 34 |
| 35 function step3() |
| 36 { |
| 37 InspectorTest.log("Adding a rule to the existing stylesheet."); |
| 38 InspectorTest.sendCommandOrDie("CSS.addRule", { styleSheetId: styleSheet
Header.styleSheetId, selector: "#inspected" }, step4); |
| 39 } |
| 40 |
| 41 function step4() |
| 42 { |
| 43 InspectorTest.loadAndDumpMatchingRules("#inspected", step5); |
| 44 } |
| 45 |
| 46 function step5() |
| 47 { |
| 48 InspectorTest.log("Creating inspector stylesheet."); |
| 49 InspectorTest.sendCommandOrDie("CSS.createStyleSheet", { frameId: frameI
d }, step6); |
| 50 } |
| 51 |
| 52 function step6(result) |
| 53 { |
| 54 InspectorTest.log("Adding a rule to the inspector stylesheet."); |
| 55 InspectorTest.sendCommandOrDie("CSS.addRule", { styleSheetId: result.sty
leSheetId, selector: "#inspected" }, step7); |
| 56 } |
| 57 |
| 58 function step7() |
| 59 { |
| 60 InspectorTest.loadAndDumpMatchingRules("#inspected", step8); |
| 61 } |
| 62 |
| 63 function step8() |
| 64 { |
| 65 InspectorTest.completeTest(); |
| 66 } |
| 67 }; |
| 68 |
| 69 window.addEventListener("DOMContentLoaded", function () { |
| 70 runTest(); |
| 71 }, false); |
| 72 |
| 73 </script> |
| 74 </head> |
| 75 <body> |
| 76 <div id="inspected">Inspected contents</div> |
| 77 </body> |
| 78 </html> |
OLD | NEW |