blob: 6435377f6f6220a55e4812069606d3278bdada0c [file] [log] [blame]
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script>
var messageDispatched = false;
window.addEventListener("message", function(event)
{
messageDispatched = true;
debugger;
}, true);
function testFunction()
{
window.postMessage("test", "*");
debugger;
}
function test()
{
InspectorTest.sendCommand("Debugger.enable", {});
InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedInTestFunction;
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" });
function handleDebuggerPausedInTestFunction(messageObject)
{
InspectorTest.log("Paused on 'debugger;'");
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "messageDispatched" }, didEvaluateOnPause1);
}
function didEvaluateOnPause1(messageObject)
{
var r = messageObject.result.result;
if (r.type === "boolean" && r.value === false)
InspectorTest.log("PASS: message has not been dispatched yet.");
else
InspectorTest.log("FAIL: unexpected response " + JSON.stringify(messageObject, null, 2));
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "messageDispatched" }, didEvaluateOnPause2);
}
function didEvaluateOnPause2(messageObject)
{
var r = messageObject.result.result;
if (r.type === "boolean" && r.value === false)
InspectorTest.log("PASS: message has not been dispatched yet.");
else
InspectorTest.log("FAIL: unexpected response " + JSON.stringify(messageObject, null, 2));
InspectorTest.sendCommand("Debugger.resume", { }, didResume);
}
function didResume(messageObject)
{
InspectorTest.log("Resumed, now waiting for pause in the event listener...");
InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedInEventListener;
}
function handleDebuggerPausedInEventListener(messageObject)
{
InspectorTest.log("PASS: pasued in the event listener.");
InspectorTest.sendCommand("Debugger.resume", { }, didResume2);
}
function didResume2(messageObject)
{
InspectorTest.completeTest();
}
}
</script>
</head>
<body onLoad="runTest();">
</body>
</html>