OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/inspector-protocol-test.js"></script> | 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/inspector-protocol-test.js"></script> |
4 <script> | 4 <script> |
5 | 5 |
6 | 6 |
7 var worker; | 7 var worker; |
8 | 8 |
9 function startWorkerAndRunTest() | 9 function startWorkerAndRunTest() |
10 { | 10 { |
11 worker = new Worker("resources/dedicated-worker.js"); | 11 worker = new Worker("resources/dedicated-worker.js"); |
12 worker.onmessage = function(event) { }; | 12 worker.onmessage = function(event) { }; |
13 worker.postMessage(1); | 13 worker.postMessage(1); |
14 log("Started worker"); | 14 log("Started worker"); |
15 runTest(); | 15 runTest(); |
16 } | 16 } |
17 | 17 |
18 | 18 |
19 function test() | 19 function test() |
20 { | 20 { |
21 | 21 |
22 var workerId; | 22 var workerSessionId; |
23 var workerRequestId = 1; | 23 var workerRequestId = 1; |
24 function sendCommandToWorker(method, params) | 24 function sendCommandToWorker(method, params) |
25 { | 25 { |
26 InspectorTest.sendCommand("Target.sendMessageToTarget", | 26 InspectorTest.sendCommand("Target.sendMessageToTarget", |
27 { | 27 { |
28 "targetId": workerId, | 28 "sessionId": workerSessionId, |
29 "message": JSON.stringify({ "method": method, | 29 "message": JSON.stringify({ "method": method, |
30 "params": params, | 30 "params": params, |
31 "id": workerRequestId++ }) | 31 "id": workerRequestId++ }) |
32 }); | 32 }); |
33 } | 33 } |
34 | 34 |
35 function didEnableWorkerDebugging(messageObject) | 35 function didEnableWorkerDebugging(messageObject) |
36 { | 36 { |
37 if ("error" in messageObject) { | 37 if ("error" in messageObject) { |
38 InspectorTest.log("FAIL: Couldn't enable worker debugger: " + messag
eObject.error.message); | 38 InspectorTest.log("FAIL: Couldn't enable worker debugger: " + messag
eObject.error.message); |
39 InspectorTest.completeTest(); | 39 InspectorTest.completeTest(); |
40 } | 40 } |
41 } | 41 } |
42 InspectorTest.sendCommand("Target.setAutoAttach", {autoAttach: true, waitFor
DebuggerOnStart: false}, didEnableWorkerDebugging); | 42 InspectorTest.sendCommand("Target.setAutoAttach", {autoAttach: true, waitFor
DebuggerOnStart: false}, didEnableWorkerDebugging); |
43 | 43 |
44 | 44 |
45 InspectorTest.eventHandler["Target.attachedToTarget"] = function(messageObje
ct) | 45 InspectorTest.eventHandler["Target.attachedToTarget"] = function(messageObje
ct) |
46 { | 46 { |
47 workerId = messageObject["params"]["targetInfo"]["targetId"]; | 47 workerSessionId = messageObject["params"]["sessionId"]; |
48 InspectorTest.log("Worker created"); | 48 InspectorTest.log("Worker created"); |
49 InspectorTest.log("didConnectToWorker"); | 49 InspectorTest.log("didConnectToWorker"); |
50 sendCommandToWorker("Debugger.enable", {}); | 50 sendCommandToWorker("Debugger.enable", {}); |
51 sendCommandToWorker("Debugger.pause", {}); | 51 sendCommandToWorker("Debugger.pause", {}); |
52 } | 52 } |
53 | 53 |
54 InspectorTest.eventHandler["Target.receivedMessageFromTarget"] = function(me
ssageObject) | 54 InspectorTest.eventHandler["Target.receivedMessageFromTarget"] = function(me
ssageObject) |
55 { | 55 { |
56 var message = JSON.parse(messageObject["params"]["message"]); | 56 var message = JSON.parse(messageObject["params"]["message"]); |
57 if (message["method"] === "Debugger.paused") { | 57 if (message["method"] === "Debugger.paused") { |
58 InspectorTest.log("Worker paused"); | 58 InspectorTest.log("Worker paused"); |
59 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "worke
r.terminate()" }, didTerminateWorker); | 59 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "worke
r.terminate()" }, didTerminateWorker); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 function didTerminateWorker(messageObject) | 63 function didTerminateWorker(messageObject) |
64 { | 64 { |
65 InspectorTest.log("SUCCESS: Did terminate paused worker"); | 65 InspectorTest.log("SUCCESS: Did terminate paused worker"); |
66 InspectorTest.completeTest(); | 66 InspectorTest.completeTest(); |
67 } | 67 } |
68 | 68 |
69 } | 69 } |
70 </script> | 70 </script> |
71 </head> | 71 </head> |
72 <body onLoad="startWorkerAndRunTest();">Test that inspected page won't crash if
inspected worker is terminated while it is paused. Test passes if it doesn't cra
sh. | 72 <body onLoad="startWorkerAndRunTest();">Test that inspected page won't crash if
inspected worker is terminated while it is paused. Test passes if it doesn't cra
sh. |
73 <a href="https://bugs.webkit.org/show_bug.cgi?id=101065">Bug 101065.</a> | 73 <a href="https://bugs.webkit.org/show_bug.cgi?id=101065">Bug 101065.</a> |
74 </body> | 74 </body> |
75 </html> | 75 </html> |
OLD | NEW |