Chromium Code Reviews| Index: LayoutTests/inspector-protocol/debugger/debugger-pause-dedicated-worker-loop.html |
| diff --git a/LayoutTests/inspector-protocol/debugger/debugger-evaluate-in-worker-while-pause-in-page.html b/LayoutTests/inspector-protocol/debugger/debugger-pause-dedicated-worker-loop.html |
| similarity index 59% |
| copy from LayoutTests/inspector-protocol/debugger/debugger-evaluate-in-worker-while-pause-in-page.html |
| copy to LayoutTests/inspector-protocol/debugger/debugger-pause-dedicated-worker-loop.html |
| index a0ff638e372b6a1fea045a9c37b0734b484b2660..a88eace4785e02a2cce8b2547a9f7a708c2c6a4a 100644 |
| --- a/LayoutTests/inspector-protocol/debugger/debugger-evaluate-in-worker-while-pause-in-page.html |
| +++ b/LayoutTests/inspector-protocol/debugger/debugger-pause-dedicated-worker-loop.html |
| @@ -3,27 +3,23 @@ |
| <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script> |
| <script> |
| -var worker; |
| -function testFunction() |
| -{ |
| - debugger; |
| -} |
| +var worker; |
| function startWorkerAndRunTest() |
| { |
| - worker = new Worker("resources/dedicated-worker.js"); |
| + worker = new Worker("resources/dedicated-worker-loop.js"); |
| worker.onmessage = function(event) { }; |
| - worker.postMessage(1); |
| log("Started worker"); |
| runTest(); |
| } |
| + |
|
loislo
2014/06/25 07:55:04
nuke this line
yurys
2014/06/25 07:56:08
Done.
|
| function test() |
| { |
| + |
|
loislo
2014/06/25 07:55:04
ditto
yurys
2014/06/25 07:56:08
Done.
|
| var workerId; |
| var workerRequestId = 1; |
| - |
| function sendCommandToWorker(method, params) |
| { |
| InspectorTest.sendCommand("Worker.sendMessageToWorker", |
| @@ -36,17 +32,6 @@ function test() |
| return workerRequestId++; |
| } |
| - InspectorTest.sendCommand("Debugger.enable", {}); |
| - InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedInTestFunction; |
| - InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" }); |
| - |
| - function handleDebuggerPausedInTestFunction(messageObject) |
| - { |
| - InspectorTest.log("Paused on 'debugger;'"); |
| - InspectorTest.sendCommand("Worker.enable", {}, didEnableWorkerDebugging); |
| - |
| - } |
| - |
| function didEnableWorkerDebugging(messageObject) |
| { |
| if ("error" in messageObject) { |
| @@ -54,8 +39,10 @@ function test() |
| InspectorTest.completeTest(); |
| } |
| } |
| + InspectorTest.sendCommand("Worker.enable", {}, didEnableWorkerDebugging); |
| - var savedWorkerRequestId = -1; |
| + var evaluateRequestId = -1; |
| + var debuggerEnableRequestId = -1; |
| InspectorTest.eventHandler["Worker.workerCreated"] = function(messageObject) |
| { |
| workerId = messageObject["params"]["workerId"]; |
| @@ -65,16 +52,30 @@ function test() |
| function didConnectToWorker(messageObject) |
| { |
| InspectorTest.log("didConnectToWorker"); |
| - savedWorkerRequestId = sendCommandToWorker("Runtime.evaluate", { "expression": "1+1"}); |
| + // Enable debugger so that V8 can interrupt and handle inspector commands while there is a script running in a tight loop. |
| + debuggerEnableRequestId = sendCommandToWorker("Debugger.enable", {}); |
| } |
| } |
| InspectorTest.eventHandler["Worker.dispatchMessageFromWorker"] = function(messageObject) |
| { |
| var message = messageObject["params"]["message"]; |
| - if (message["id"] === savedWorkerRequestId) { |
| + if (message["id"] === debuggerEnableRequestId) { |
| + InspectorTest.log("Did enable debugger"); |
| + // Start tight loop in the worker. |
| + InspectorTest.sendCommand("Runtime.evaluate", { "expression": "worker.postMessage(1)" }, didPostMessageToWorker); |
| + function didPostMessageToWorker() |
| + { |
| + InspectorTest.log("Did post message to worker"); |
| + evaluateRequestId = sendCommandToWorker("Runtime.evaluate", { "expression": "message_id > 1"}); |
| + } |
| + } |
| + if (message["id"] === evaluateRequestId) { |
| var value = message["result"]["result"]["value"]; |
| - InspectorTest.log("Successfully evaluated, result: " + value); |
| + if (value === true) |
| + InspectorTest.log("SUCCESS: evaluated, result: " + value); |
| + else |
| + InspectorTest.log("FAIL: evaluated, result: " + value); |
| InspectorTest.completeTest(); |
| } |
| } |