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