Chromium Code Reviews| 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 worker; | 6 var worker; |
| 7 var onMessageCallbacks = {}; | 7 var onMessageCallbacks = {}; |
| 8 | 8 |
| 9 function startWorker(callback) | 9 function startWorker(callback) |
| 10 { | 10 { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 { | 34 { |
| 35 worker.terminate(); | 35 worker.terminate(); |
| 36 worker = null; | 36 worker = null; |
| 37 } | 37 } |
| 38 | 38 |
| 39 function test() | 39 function test() |
| 40 { | 40 { |
| 41 var workerEventHandler = {}; | 41 var workerEventHandler = {}; |
| 42 InspectorTest.eventHandler["Worker.workerCreated"] = onWorkerCreated; | 42 InspectorTest.eventHandler["Worker.workerCreated"] = onWorkerCreated; |
| 43 InspectorTest.eventHandler["Worker.dispatchMessageFromWorker"] = onWorkerMes sage; | 43 InspectorTest.eventHandler["Worker.dispatchMessageFromWorker"] = onWorkerMes sage; |
| 44 workerEventHandler["Console.messageAdded"] = onConsoleMessageFromWorker; | 44 workerEventHandler["Runtime.consoleAPICall"] = onConsoleAPICallFromWorker; |
| 45 | 45 |
| 46 var workerId; | 46 var workerId; |
| 47 | 47 |
| 48 function onWorkerCreated(payload) | 48 function onWorkerCreated(payload) |
| 49 { | 49 { |
| 50 InspectorTest.log("Worker.created"); | 50 InspectorTest.log("Worker.created"); |
| 51 workerId = payload.params.workerId; | 51 workerId = payload.params.workerId; |
| 52 } | 52 } |
| 53 | 53 |
| 54 var requestId = 0; | 54 var requestId = 0; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 InspectorTest.log("Got console message from page: " + payload.params .message.text); | 98 InspectorTest.log("Got console message from page: " + payload.params .message.text); |
| 99 delete InspectorTest.eventHandler["Console.messageAdded"]; | 99 delete InspectorTest.eventHandler["Console.messageAdded"]; |
| 100 next(); | 100 next(); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 var gotMessages = []; | 104 var gotMessages = []; |
| 105 var waitingForMessage; | 105 var waitingForMessage; |
| 106 var waitingForMessageCallback; | 106 var waitingForMessageCallback; |
| 107 | 107 |
| 108 function onConsoleMessageFromWorker(payload) | 108 function onConsoleAPICallFromWorker(payload) |
| 109 { | 109 { |
| 110 var message = payload.params.message.text; | 110 var message = payload.params.callArguments[0].value; |
|
kozy
2016/07/13 18:26:39
Please rename callArguments into args.
dgozman
2016/07/13 21:08:07
Done.
| |
| 111 InspectorTest.log("Got console message from worker: " + message); | 111 InspectorTest.log("Got console API call from worker: " + message); |
| 112 gotMessages.push(message); | 112 gotMessages.push(message); |
| 113 if (message === waitingForMessage) | 113 if (message === waitingForMessage) |
| 114 waitingForMessageCallback(); | 114 waitingForMessageCallback(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 function waitForMessage(message, next) | 117 function waitForMessage(message, next) |
| 118 { | 118 { |
| 119 if (gotMessages.indexOf(message) !== -1) { | 119 if (gotMessages.indexOf(message) !== -1) { |
| 120 next(); | 120 next(); |
| 121 return; | 121 return; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 }, | 159 }, |
| 160 | 160 |
| 161 function enable1(next) | 161 function enable1(next) |
| 162 { | 162 { |
| 163 InspectorTest.log("Sending Worker.enable"); | 163 InspectorTest.log("Sending Worker.enable"); |
| 164 InspectorTest.sendCommandOrDie("Worker.enable", {}, next); | 164 InspectorTest.sendCommandOrDie("Worker.enable", {}, next); |
| 165 }, | 165 }, |
| 166 | 166 |
| 167 function consoleEnable1(next) | 167 function consoleEnable1(next) |
| 168 { | 168 { |
| 169 InspectorTest.log("Sending Console.enable to worker"); | 169 InspectorTest.log("Sending Runtime.enable to worker"); |
| 170 waitForMessage("message1", next); | 170 waitForMessage("message1", next); |
| 171 sendCommandToWorker("Console.enable", {}); | 171 sendCommandToWorker("Runtime.enable", {}); |
| 172 }, | 172 }, |
| 173 | 173 |
| 174 function log2(next) | 174 function log2(next) |
| 175 { | 175 { |
| 176 logInWorker("message2", next); | 176 logInWorker("message2", next); |
| 177 }, | 177 }, |
| 178 | 178 |
| 179 function waitForMessage2(next) | 179 function waitForMessage2(next) |
| 180 { | 180 { |
| 181 waitForMessage("message2", next); | 181 waitForMessage("message2", next); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 InspectorTest.evaluateInPageAsync("startWorker(%callback)", next); | 216 InspectorTest.evaluateInPageAsync("startWorker(%callback)", next); |
| 217 }, | 217 }, |
| 218 | 218 |
| 219 function log4(next) | 219 function log4(next) |
| 220 { | 220 { |
| 221 logInWorker("message4", next); | 221 logInWorker("message4", next); |
| 222 }, | 222 }, |
| 223 | 223 |
| 224 function consoleEnable2(next) | 224 function consoleEnable2(next) |
| 225 { | 225 { |
| 226 InspectorTest.log("Sending Console.enable to worker"); | 226 InspectorTest.log("Sending Runtime.enable to worker"); |
| 227 waitForMessage("message4", next); | 227 waitForMessage("message4", next); |
| 228 sendCommandToWorker("Console.enable", {}); | 228 sendCommandToWorker("Runtime.enable", {}); |
| 229 }, | 229 }, |
| 230 | 230 |
| 231 function log5(next) | 231 function log5(next) |
| 232 { | 232 { |
| 233 logInWorker("message5", next); | 233 logInWorker("message5", next); |
| 234 }, | 234 }, |
| 235 | 235 |
| 236 function waitForMessage5(next) | 236 function waitForMessage5(next) |
| 237 { | 237 { |
| 238 waitForMessage("message5", next); | 238 waitForMessage("message5", next); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 InspectorTest.safeWrap(nextStep)(runNextStep); | 278 InspectorTest.safeWrap(nextStep)(runNextStep); |
| 279 } | 279 } |
| 280 | 280 |
| 281 runNextStep(); | 281 runNextStep(); |
| 282 } | 282 } |
| 283 </script> | 283 </script> |
| 284 </head> | 284 </head> |
| 285 <body onload="runTest()"> | 285 <body onload="runTest()"> |
| 286 </body> | 286 </body> |
| 287 </html> | 287 </html> |
| OLD | NEW |