3 <script type=
"text/javascript" src=
"../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
6 var messageDispatched
= false;
7 window
.addEventListener("message", function(event
)
9 messageDispatched
= true;
13 function testFunction()
15 window
.postMessage("test", "*");
21 InspectorTest
.sendCommand("Debugger.enable", {});
22 InspectorTest
.eventHandler
["Debugger.paused"] = handleDebuggerPausedInTestFunction
;
23 InspectorTest
.sendCommand("Runtime.evaluate", { "expression": "testFunction()" });
25 function handleDebuggerPausedInTestFunction(messageObject
)
27 InspectorTest
.log("Paused on 'debugger;'");
28 InspectorTest
.sendCommand("Runtime.evaluate", { "expression": "messageDispatched" }, didEvaluateOnPause1
);
31 function didEvaluateOnPause1(messageObject
)
33 var r
= messageObject
.result
.result
;
34 if (r
.type
=== "boolean" && r
.value
=== false)
35 InspectorTest
.log("PASS: message has not been dispatched yet.");
37 InspectorTest
.log("FAIL: unexpected response " + JSON
.stringify(messageObject
, null, 2));
38 InspectorTest
.sendCommand("Runtime.evaluate", { "expression": "messageDispatched" }, didEvaluateOnPause2
);
41 function didEvaluateOnPause2(messageObject
)
43 var r
= messageObject
.result
.result
;
44 if (r
.type
=== "boolean" && r
.value
=== false)
45 InspectorTest
.log("PASS: message has not been dispatched yet.");
47 InspectorTest
.log("FAIL: unexpected response " + JSON
.stringify(messageObject
, null, 2));
48 InspectorTest
.sendCommand("Debugger.resume", { }, didResume
);
51 function didResume(messageObject
)
53 InspectorTest
.log("Resumed, now waiting for pause in the event listener...");
54 InspectorTest
.eventHandler
["Debugger.paused"] = handleDebuggerPausedInEventListener
;
57 function handleDebuggerPausedInEventListener(messageObject
)
59 InspectorTest
.log("PASS: pasued in the event listener.");
60 InspectorTest
.sendCommand("Debugger.resume", { }, didResume2
);
63 function didResume2(messageObject
)
65 InspectorTest
.completeTest();
70 <body onLoad=
"runTest();">