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..354d1347262689be6ba90efa7be8afb306e8f314 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 |
@@ -4,17 +4,10 @@ |
<script> |
var worker; |
- |
-function testFunction() |
-{ |
- debugger; |
-} |
- |
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(); |
} |
@@ -23,7 +16,6 @@ function test() |
{ |
var workerId; |
var workerRequestId = 1; |
- |
function sendCommandToWorker(method, params) |
{ |
InspectorTest.sendCommand("Worker.sendMessageToWorker", |
@@ -36,17 +28,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 +35,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 +48,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(); |
} |
} |