Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / debugger / debugger-evaluate-in-worker-while-pause-in-page.html
blob2a5a36e6a24ab44cf62185fffa3133fa787ba4f5
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script>
6 var worker;
8 function testFunction()
10 debugger;
13 function startWorkerAndRunTest()
15 worker = new Worker("resources/dedicated-worker.js");
16 worker.onmessage = function(event) { };
17 worker.postMessage(1);
18 log("Started worker");
19 runTest();
22 function test()
24 var workerId;
25 var workerRequestId = 1;
27 function sendCommandToWorker(method, params)
29 InspectorTest.sendCommand("Worker.sendMessageToWorker",
31 "workerId": workerId,
32 "message": JSON.stringify({ "method": method,
33 "params": params,
34 "id": workerRequestId })
35 });
36 return workerRequestId++;
39 InspectorTest.sendCommand("Debugger.enable", {});
40 InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedInTestFunction;
41 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" });
43 function handleDebuggerPausedInTestFunction(messageObject)
45 InspectorTest.log("Paused on 'debugger;'");
46 InspectorTest.sendCommand("Worker.enable", {}, didEnableWorkerDebugging);
50 function didEnableWorkerDebugging(messageObject)
52 if ("error" in messageObject) {
53 InspectorTest.log("FAIL: Couldn't enable worker debugger: " + messageObject.error.message);
54 InspectorTest.completeTest();
58 var savedWorkerRequestId = -1;
59 InspectorTest.eventHandler["Worker.workerCreated"] = function(messageObject)
61 workerId = messageObject["params"]["workerId"];
62 InspectorTest.log("Worker created");
63 InspectorTest.sendCommand("Worker.connectToWorker", { "workerId": workerId }, didConnectToWorker);
65 function didConnectToWorker(messageObject)
67 InspectorTest.log("didConnectToWorker");
68 savedWorkerRequestId = sendCommandToWorker("Runtime.evaluate", { "expression": "1+1"});
72 InspectorTest.eventHandler["Worker.dispatchMessageFromWorker"] = function(messageObject)
74 var message = JSON.parse(messageObject["params"]["message"]);
75 if (message["id"] === savedWorkerRequestId) {
76 var value = message["result"]["result"]["value"];
77 InspectorTest.log("Successfully evaluated, result: " + value);
78 InspectorTest.completeTest();
82 </script>
83 </head>
84 <body onLoad="startWorkerAndRunTest();">
85 </body>
86 </html>