3 <script type=
"text/javascript" src=
"../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
9 function startWorkerAndRunTest()
11 worker
= new Worker("resources/dedicated-worker.js");
12 worker
.onmessage = function(event
) { };
13 worker
.postMessage(1);
14 log("Started worker");
23 var workerRequestId
= 1;
24 function sendCommandToWorker(method
, params
)
26 InspectorTest
.sendCommand("Worker.sendMessageToWorker",
29 "message": JSON
.stringify({ "method": method
,
31 "id": workerRequestId
++ })
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();
72 <body onLoad=
"startWorkerAndRunTest();">