3 <script type=
"text/javascript" src=
"../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
7 function startWorkerAndRunTest()
9 worker
= new Worker("resources/dedicated-worker-string-setTimeout.js");
10 log("Started worker");
17 var workerRequestId
= 1;
18 function sendCommandToWorker(method
, params
)
20 InspectorTest
.sendCommand("Worker.sendMessageToWorker",
23 "message": JSON
.stringify({ "method": method
,
25 "id": workerRequestId
})
27 return workerRequestId
++;
30 function didEnableWorkerDebugging(messageObject
)
32 if ("error" in messageObject
) {
33 InspectorTest
.log("FAIL: Couldn't enable worker debugger: " + messageObject
.error
.message
);
34 InspectorTest
.completeTest();
37 InspectorTest
.sendCommand("Worker.enable", {}, didEnableWorkerDebugging
);
39 var debuggerEnableRequestId
= -1;
40 InspectorTest
.eventHandler
["Worker.workerCreated"] = function(messageObject
)
42 workerId
= messageObject
["params"]["workerId"];
43 InspectorTest
.log("Worker created");
44 InspectorTest
.sendCommand("Worker.connectToWorker", { "workerId": workerId
}, didConnectToWorker
);
46 function didConnectToWorker(messageObject
)
48 InspectorTest
.log("didConnectToWorker");
49 debuggerEnableRequestId
= sendCommandToWorker("Debugger.enable", {});
53 var postMessageToWorker
= false;
55 InspectorTest
.eventHandler
["Worker.dispatchMessageFromWorker"] = function(messageObject
)
57 var message
= JSON
.parse(messageObject
["params"]["message"]);
58 if (message
["id"] === debuggerEnableRequestId
) {
59 InspectorTest
.log("Did enable debugger");
61 InspectorTest
.sendCommand("Runtime.evaluate", { "expression": "worker.postMessage(1)" }, didPostMessageToWorker
);
62 function didPostMessageToWorker()
64 postMessageToWorker
= true;
65 InspectorTest
.log("Did post message to worker");
69 if (postMessageToWorker
&& message
["method"] === "Debugger.scriptParsed") {
70 var sourceUrl
= message
["params"]["url"];
72 InspectorTest
.log("SUCCESS: script created from string parameter of setTimeout has no url");
74 InspectorTest
.log("FAIL: script created from string parameter of setTimeout has url " + sourceUrl
);
75 InspectorTest
.completeTest();
81 <body onLoad=
"startWorkerAndRunTest();">