| OLD | NEW |
| (Empty) |
| 1 <!doctype html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script type="text/javascript" src="../http/tests/inspector-protocol/inspector-p
rotocol-test.js"></script> | |
| 5 <script> | |
| 6 function appendIframe() | |
| 7 { | |
| 8 var frame = document.createElement("iframe"); | |
| 9 frame.src = "resources/test-page-with-debugger-statement.html"; | |
| 10 document.body.appendChild(frame); | |
| 11 } | |
| 12 | |
| 13 function test() | |
| 14 { | |
| 15 /* | |
| 16 Testing that the Node ID can be retrieved before the onload event is trigger
ed: | |
| 17 1. Create an iframe and point it to a page with a debugger statement. | |
| 18 2. Wait until the debugger statement is hit and pause using the inspector pr
otocol. | |
| 19 3. Use the JS context to identify the "window.document" object inside the if
rame. | |
| 20 4. Use the JS object to retrieve the DOM agent nodeId for the document node. | |
| 21 */ | |
| 22 | |
| 23 InspectorTest.eventHandler["Page.loadEventFired"] = onLoadEventFired; | |
| 24 InspectorTest.eventHandler["Debugger.paused"] = onDebuggerPaused; | |
| 25 | |
| 26 function step1_bootstrap() | |
| 27 { | |
| 28 InspectorTest.log("step1_bootstrap"); | |
| 29 | |
| 30 // Enable Page agent for the Page.loadEventFired event. | |
| 31 InspectorTest.sendCommand("Page.enable", {}); | |
| 32 | |
| 33 // Make sure the debugger ready to break on the "debugger" statement. | |
| 34 InspectorTest.sendCommand("Debugger.enable", {}); | |
| 35 | |
| 36 InspectorTest.sendCommand("DOM.getDocument", {}, callback); | |
| 37 | |
| 38 function callback() { | |
| 39 InspectorTest.log("Adding iframe"); | |
| 40 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "appen
dIframe()" }); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 function onDebuggerPaused(response) | |
| 45 { | |
| 46 InspectorTest.log("Paused on the debugger statement"); | |
| 47 InspectorTest.sendCommand("Runtime.callFunctionOn", { | |
| 48 objectId: response.params.callFrames[0].this.objectId, | |
| 49 functionDeclaration: "function() { return this.document; }" | |
| 50 }, callback); | |
| 51 | |
| 52 function callback(response) | |
| 53 { | |
| 54 step2_requestNode(response.result.result.objectId); | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 function step2_requestNode(objectId) | |
| 59 { | |
| 60 InspectorTest.log("step2_requestNode: Requesting DOM node for iframe's d
ocument node"); | |
| 61 InspectorTest.sendCommand("DOM.requestNode", { objectId: objectId }, cal
lback); | |
| 62 | |
| 63 function callback(response) | |
| 64 { | |
| 65 InspectorTest.log(response.result.nodeId ? "PASS: Received node for
iframe's document node" : "FAIL: Iframe's document node is not available"); | |
| 66 InspectorTest.sendCommand("Debugger.resume", {}, completeTest); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 function completeTest() | |
| 71 { | |
| 72 InspectorTest.log("Test finished"); | |
| 73 InspectorTest.completeTest(); | |
| 74 } | |
| 75 | |
| 76 function onLoadEventFired() | |
| 77 { | |
| 78 // We should finish the test before this event is triggered. | |
| 79 // If you see this in the output, then the slow-image is not loaded corr
ectly in the iframe. | |
| 80 InspectorTest.log("FAIL: Iframe load event fired before the test finishe
d."); | |
| 81 } | |
| 82 | |
| 83 step1_bootstrap() | |
| 84 } | |
| 85 </script> | |
| 86 </head> | |
| 87 <body onload="runTest()"> | |
| 88 </body> | |
| 89 </html> | |
| OLD | NEW |