Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / debugger / postMessage-on-pause.html
blob6435377f6f6220a55e4812069606d3278bdada0c
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script>
6 var messageDispatched = false;
7 window.addEventListener("message", function(event)
9 messageDispatched = true;
10 debugger;
11 }, true);
13 function testFunction()
15 window.postMessage("test", "*");
16 debugger;
19 function 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.");
36 else
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.");
46 else
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();
68 </script>
69 </head>
70 <body onLoad="runTest();">
71 </body>
72 </html>