| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/inspector-protocol-test.js"></script> | |
| 4 <script> | |
| 5 | |
| 6 var worker; | |
| 7 function startWorkerAndRunTest() | |
| 8 { | |
| 9 worker = new Worker("resources/dedicated-worker-string-setTimeout.js"); | |
| 10 log("Started worker"); | |
| 11 runTest(); | |
| 12 } | |
| 13 | |
| 14 function test() | |
| 15 { | |
| 16 var workerId; | |
| 17 var workerRequestId = 1; | |
| 18 function sendCommandToWorker(method, params) | |
| 19 { | |
| 20 InspectorTest.sendCommand("Target.sendMessageToTarget", | |
| 21 { | |
| 22 "targetId": workerId, | |
| 23 "message": JSON.stringify({ "method": method, | |
| 24 "params": params, | |
| 25 "id": workerRequestId }) | |
| 26 }); | |
| 27 return workerRequestId++; | |
| 28 } | |
| 29 | |
| 30 function didEnableWorkerDebugging(messageObject) | |
| 31 { | |
| 32 if ("error" in messageObject) { | |
| 33 InspectorTest.log("FAIL: Couldn't enable worker debugger: " + messag
eObject.error.message); | |
| 34 InspectorTest.completeTest(); | |
| 35 } | |
| 36 } | |
| 37 InspectorTest.sendCommand("Target.setAutoAttach", {autoAttach: true, waitFor
DebuggerOnStart: false}, didEnableWorkerDebugging); | |
| 38 | |
| 39 var debuggerEnableRequestId = -1; | |
| 40 InspectorTest.eventHandler["Target.attachedToTarget"] = function(messageObje
ct) | |
| 41 { | |
| 42 workerId = messageObject["params"]["targetInfo"]["targetId"]; | |
| 43 InspectorTest.log("Worker created"); | |
| 44 InspectorTest.log("didConnectToWorker"); | |
| 45 debuggerEnableRequestId = sendCommandToWorker("Debugger.enable", {}); | |
| 46 } | |
| 47 | |
| 48 var postMessageToWorker = false; | |
| 49 | |
| 50 InspectorTest.eventHandler["Target.receivedMessageFromTarget"] = function(me
ssageObject) | |
| 51 { | |
| 52 var message = JSON.parse(messageObject["params"]["message"]); | |
| 53 if (message["id"] === debuggerEnableRequestId) { | |
| 54 InspectorTest.log("Did enable debugger"); | |
| 55 // Start setTimeout. | |
| 56 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "worke
r.postMessage(1)" }, didPostMessageToWorker); | |
| 57 function didPostMessageToWorker() | |
| 58 { | |
| 59 postMessageToWorker = true; | |
| 60 InspectorTest.log("Did post message to worker"); | |
| 61 } | |
| 62 } | |
| 63 | |
| 64 if (postMessageToWorker && message["method"] === "Debugger.scriptParsed"
) { | |
| 65 var sourceUrl = message["params"]["url"]; | |
| 66 if (!sourceUrl) | |
| 67 InspectorTest.log("SUCCESS: script created from string parameter
of setTimeout has no url"); | |
| 68 else | |
| 69 InspectorTest.log("FAIL: script created from string parameter of
setTimeout has url " + sourceUrl); | |
| 70 InspectorTest.completeTest(); | |
| 71 } | |
| 72 } | |
| 73 } | |
| 74 </script> | |
| 75 </head> | |
| 76 <body onLoad="startWorkerAndRunTest();"> | |
| 77 </body> | |
| 78 </html> | |
| OLD | NEW |