4 <script type=
"text/javascript" src=
"../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
6 function appendIframe()
8 var frame
= document
.createElement("iframe");
9 frame
.src
= "resources/test-page-with-debugger-statement.html";
10 document
.body
.appendChild(frame
);
16 Testing that the Node ID can be retrieved before the onload event is triggered:
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 protocol.
19 3. Use the JS context to identify the "window.document" object inside the iframe.
20 4. Use the JS object to retrieve the DOM agent nodeId for the document node.
23 InspectorTest
.eventHandler
["Page.loadEventFired"] = onLoadEventFired
;
24 InspectorTest
.eventHandler
["Debugger.paused"] = onDebuggerPaused
;
26 function step1_bootstrap()
28 InspectorTest
.log("step1_bootstrap");
30 // Enable Page agent for the Page.loadEventFired event.
31 InspectorTest
.sendCommand("Page.enable", {});
33 // Make sure the debugger ready to break on the "debugger" statement.
34 InspectorTest
.sendCommand("Debugger.enable", {});
36 InspectorTest
.sendCommand("DOM.getDocument", {}, callback
);
39 InspectorTest
.log("Adding iframe");
40 InspectorTest
.sendCommand("Runtime.evaluate", { "expression": "appendIframe()" });
44 function onDebuggerPaused(response
)
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; }"
52 function callback(response
)
54 step2_requestNode(response
.result
.result
.objectId
);
58 function step2_requestNode(objectId
)
60 InspectorTest
.log("step2_requestNode: Requesting DOM node for iframe's document node");
61 InspectorTest
.sendCommand("DOM.requestNode", { objectId
: objectId
}, callback
);
63 function callback(response
)
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
);
70 function completeTest()
72 InspectorTest
.log("Test finished");
73 InspectorTest
.completeTest();
76 function onLoadEventFired()
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 correctly in the iframe.
80 InspectorTest
.log("FAIL: Iframe load event fired before the test finished.");
87 <body onload=
"runTest()">