| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> | 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 var worker1; | 6 var worker1; |
| 7 var worker2; | 7 var worker2; |
| 8 | 8 |
| 9 function startWorkers() | 9 function startWorkers() |
| 10 { | 10 { |
| 11 worker1 = new Worker("resources/worker-with-throw.js"); | 11 worker1 = new Worker("resources/worker-with-throw.js"); |
| 12 worker1.onerror = function(e) { | 12 worker1.onerror = function(e) { |
| 13 e.preventDefault(); | 13 e.preventDefault(); |
| 14 worker1.terminate(); | 14 worker1.terminate(); |
| 15 } | 15 } |
| 16 worker2 = new Worker("resources/worker-with-throw.js"); | 16 worker2 = new Worker("resources/worker-with-throw.js"); |
| 17 } | 17 } |
| 18 | 18 |
| 19 function test() | 19 function test() |
| 20 { | 20 { |
| 21 InspectorTest.sendCommandOrDie("Worker.enable", {}, didEnableWorkerDebugging
); | 21 InspectorTest.sendCommandOrDie("Target.setAutoAttach", {autoAttach: true, wa
itForDebuggerOnStart: false}, didEnableWorkerDebugging); |
| 22 | 22 |
| 23 function didEnableWorkerDebugging(event) | 23 function didEnableWorkerDebugging(event) |
| 24 { | 24 { |
| 25 InspectorTest.sendCommandOrDie("Runtime.evaluate", { expression: "startW
orkers()" }); | 25 InspectorTest.sendCommandOrDie("Runtime.evaluate", { expression: "startW
orkers()" }); |
| 26 } | 26 } |
| 27 | 27 |
| 28 var workerRequestId = 1; | 28 var workerRequestId = 1; |
| 29 function sendCommandToWorker(method, params, workerId) | 29 function sendCommandToWorker(method, params, workerId) |
| 30 { | 30 { |
| 31 InspectorTest.sendCommand("Worker.sendMessageToWorker", | 31 InspectorTest.sendCommand("Target.sendMessageToTarget", |
| 32 { | 32 { |
| 33 "workerId": workerId, | 33 "targetId": workerId, |
| 34 "message": JSON.stringify({ "method": method, | 34 "message": JSON.stringify({ "method": method, |
| 35 "params": params, | 35 "params": params, |
| 36 "id": workerRequestId++ }) | 36 "id": workerRequestId++ }) |
| 37 }); | 37 }); |
| 38 } | 38 } |
| 39 | 39 |
| 40 var waitForWorkers = 2; | 40 var waitForWorkers = 2; |
| 41 InspectorTest.eventHandler["Worker.workerCreated"] = function(messageObject) | 41 InspectorTest.eventHandler["Target.attachedToTarget"] = function(messageObje
ct) |
| 42 { | 42 { |
| 43 var workerId = messageObject["params"]["workerId"]; | 43 var workerId = messageObject["params"]["targetInfo"]["targetId"]; |
| 44 InspectorTest.log("Worker created"); | 44 InspectorTest.log("Worker created"); |
| 45 sendCommandToWorker("Runtime.enable", {}, workerId); | 45 sendCommandToWorker("Runtime.enable", {}, workerId); |
| 46 if (!--waitForWorkers) | 46 if (!--waitForWorkers) |
| 47 InspectorTest.sendCommandOrDie("Runtime.evaluate", { expression: "wo
rker1.postMessage(239);worker2.postMessage(42);" }); | 47 InspectorTest.sendCommandOrDie("Runtime.evaluate", { expression: "wo
rker1.postMessage(239);worker2.postMessage(42);" }); |
| 48 } | 48 } |
| 49 | 49 |
| 50 var workerTerminated = false; | 50 var workerTerminated = false; |
| 51 var messageReceived = false; | 51 var messageReceived = false; |
| 52 InspectorTest.eventHandler["Worker.dispatchMessageFromWorker"] = function(me
ssageObject) | 52 InspectorTest.eventHandler["Target.receivedMessageFromTarget"] = function(me
ssageObject) |
| 53 { | 53 { |
| 54 var message = JSON.parse(messageObject["params"]["message"]); | 54 var message = JSON.parse(messageObject["params"]["message"]); |
| 55 if (message["method"] === "Runtime.exceptionThrown") { | 55 if (message["method"] === "Runtime.exceptionThrown") { |
| 56 var callFrames = message.params.exceptionDetails.stackTrace ? messag
e.params.exceptionDetails.stackTrace.callFrames : []; | 56 var callFrames = message.params.exceptionDetails.stackTrace ? messag
e.params.exceptionDetails.stackTrace.callFrames : []; |
| 57 InspectorTest.log(callFrames.length > 0 ? "Message with stack trace
received." : "[FAIL] Message contains empty stack trace"); | 57 InspectorTest.log(callFrames.length > 0 ? "Message with stack trace
received." : "[FAIL] Message contains empty stack trace"); |
| 58 messageReceived = true; | 58 messageReceived = true; |
| 59 if (messageReceived && workerTerminated) | 59 if (messageReceived && workerTerminated) |
| 60 InspectorTest.completeTest(); | 60 InspectorTest.completeTest(); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 InspectorTest.eventHandler["Worker.workerTerminated"] = function(messageObje
ct) | 64 InspectorTest.eventHandler["Target.detachedFromTarget"] = function(messageOb
ject) |
| 65 { | 65 { |
| 66 InspectorTest.eventHandler["Worker.workerTerminated"] = undefined; | 66 InspectorTest.eventHandler["Target.detachedFromTarget"] = undefined; |
| 67 workerTerminated = true; | 67 workerTerminated = true; |
| 68 if (messageReceived && workerTerminated) | 68 if (messageReceived && workerTerminated) |
| 69 InspectorTest.completeTest(); | 69 InspectorTest.completeTest(); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 </script> | 72 </script> |
| 73 </head> | 73 </head> |
| 74 <body onload="runTest()">Tests that console message from worker contains stack t
race.</body> | 74 <body onload="runTest()">Tests that console message from worker contains stack t
race.</body> |
| 75 </html> | 75 </html> |
| OLD | NEW |