Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / debugger / debugger-pause-dedicated-worker.html
bloba4648f7cd9b0bb370dac9acee91b80cd0a60588a
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script>
7 var worker;
9 function startWorkerAndRunTest()
11 worker = new Worker("resources/dedicated-worker.js");
12 worker.onmessage = function(event) { };
13 worker.postMessage(1);
14 log("Started worker");
15 runTest();
19 function test()
22 var workerId;
23 var workerRequestId = 1;
24 function sendCommandToWorker(method, params)
26 InspectorTest.sendCommand("Worker.sendMessageToWorker",
28 "workerId": workerId,
29 "message": JSON.stringify({ "method": method,
30 "params": params,
31 "id": workerRequestId++ })
32 });
35 function didEnableWorkerDebugging(messageObject)
37 if ("error" in messageObject) {
38 InspectorTest.log("FAIL: Couldn't enable worker debugger: " + messageObject.error.message);
39 InspectorTest.completeTest();
42 InspectorTest.sendCommand("Worker.enable", {}, didEnableWorkerDebugging);
45 InspectorTest.eventHandler["Worker.workerCreated"] = function(messageObject)
47 workerId = messageObject["params"]["workerId"];
48 InspectorTest.log("Worker created");
49 InspectorTest.sendCommand("Worker.connectToWorker", { "workerId": workerId }, didConnectToWorker);
51 function didConnectToWorker(messageObject)
53 InspectorTest.log("didConnectToWorker");
54 sendCommandToWorker("Debugger.enable", {});
55 sendCommandToWorker("Debugger.pause", {});
59 InspectorTest.eventHandler["Worker.dispatchMessageFromWorker"] = function(messageObject)
61 var message = JSON.parse(messageObject["params"]["message"]);
62 if (message["method"] === "Debugger.paused") {
63 InspectorTest.log("SUCCESS: Worker paused");
64 sendCommandToWorker("Debugger.disable", {});
65 InspectorTest.completeTest();
70 </script>
71 </head>
72 <body onLoad="startWorkerAndRunTest();">
73 </body>
74 </html>