blob: ea0195e32d97285d4cb199a56e0aac18e392f5f4 [file] [log] [blame]
<!doctype html>
<html>
<head>
<script type="text/javascript" src="../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script>
function appendIframe()
{
var frame = document.createElement("iframe");
frame.src = "resources/test-page-with-debugger-statement.html";
document.body.appendChild(frame);
}
function test()
{
/*
Testing that the Node ID can be retrieved before the onload event is triggered:
1. Create an iframe and point it to a page with a debugger statement.
2. Wait until the debugger statement is hit and pause using the inspector protocol.
3. Use the JS context to identify the "window.document" object inside the iframe.
4. Use the JS object to retrieve the DOM agent nodeId for the document node.
*/
InspectorTest.eventHandler["Page.loadEventFired"] = onLoadEventFired;
InspectorTest.eventHandler["Debugger.paused"] = onDebuggerPaused;
function step1_bootstrap()
{
InspectorTest.log("step1_bootstrap");
// Enable Page agent for the Page.loadEventFired event.
InspectorTest.sendCommand("Page.enable", {});
// Make sure the debugger ready to break on the "debugger" statement.
InspectorTest.sendCommand("Debugger.enable", {});
InspectorTest.sendCommand("DOM.getDocument", {}, callback);
function callback() {
InspectorTest.log("Adding iframe");
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "appendIframe()" });
}
}
function onDebuggerPaused(response)
{
InspectorTest.log("Paused on the debugger statement");
InspectorTest.sendCommand("Runtime.callFunctionOn", {
objectId: response.params.callFrames[0].this.objectId,
functionDeclaration: "function() { return this.document; }"
}, callback);
function callback(response)
{
step2_requestNode(response.result.result.objectId);
}
}
function step2_requestNode(objectId)
{
InspectorTest.log("step2_requestNode: Requesting DOM node for iframe's document node");
InspectorTest.sendCommand("DOM.requestNode", { objectId: objectId }, callback);
function callback(response)
{
InspectorTest.log(response.result.nodeId ? "PASS: Received node for iframe's document node" : "FAIL: Iframe's document node is not available");
InspectorTest.sendCommand("Debugger.resume", {}, completeTest);
}
}
function completeTest()
{
InspectorTest.log("Test finished");
InspectorTest.completeTest();
}
function onLoadEventFired()
{
// We should finish the test before this event is triggered.
// If you see this in the output, then the slow-image is not loaded correctly in the iframe.
InspectorTest.log("FAIL: Iframe load event fired before the test finished.");
}
step1_bootstrap()
}
</script>
</head>
<body onload="runTest()">
</body>
</html>