Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / debugger / debugger-setTimeout-sourceUrl-dedicated-worker-loop.html
blob97055e39fc39a19f8352ac63d0f988b783b9a4d9
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script>
6 var worker;
7 function startWorkerAndRunTest()
9 worker = new Worker("resources/dedicated-worker-string-setTimeout.js");
10 log("Started worker");
11 runTest();
14 function test()
16 var workerId;
17 var workerRequestId = 1;
18 function sendCommandToWorker(method, params)
20 InspectorTest.sendCommand("Worker.sendMessageToWorker",
22 "workerId": workerId,
23 "message": JSON.stringify({ "method": method,
24 "params": params,
25 "id": workerRequestId })
26 });
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");
60 // Start setTimeout.
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"];
71 if (!sourceUrl)
72 InspectorTest.log("SUCCESS: script created from string parameter of setTimeout has no url");
73 else
74 InspectorTest.log("FAIL: script created from string parameter of setTimeout has url " + sourceUrl);
75 InspectorTest.completeTest();
79 </script>
80 </head>
81 <body onLoad="startWorkerAndRunTest();">
82 </body>
83 </html>