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