| 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() |
| 10 { | 10 { |
| 11 var callback; |
| 12 var promise = new Promise((fulfill) => callback = fulfill); |
| 11 worker = new Worker("../resources/worker-console-worker.js"); | 13 worker = new Worker("../resources/worker-console-worker.js"); |
| 12 worker.onmessage = function(event) { | 14 worker.onmessage = function(event) { |
| 13 worker.onmessage = onMessageFromWorker; | 15 worker.onmessage = onMessageFromWorker; |
| 14 if (callback) | 16 callback(); |
| 15 callback(); | |
| 16 }; | 17 }; |
| 18 return promise; |
| 17 } | 19 } |
| 18 | 20 |
| 19 function logInWorkerFromPage(message, callback) | 21 function logInWorkerFromPage(message, callback) |
| 20 { | 22 { |
| 21 onMessageCallbacks[message] = callback; | 23 onMessageCallbacks[message] = callback; |
| 22 worker.postMessage(message); | 24 worker.postMessage(message); |
| 23 } | 25 } |
| 24 | 26 |
| 25 function onMessageFromWorker(event) | 27 function onMessageFromWorker(event) |
| 26 { | 28 { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 128 |
| 127 var steps = [ | 129 var steps = [ |
| 128 function listenToConsole(next) | 130 function listenToConsole(next) |
| 129 { | 131 { |
| 130 InspectorTest.sendCommandOrDie("Log.enable", {}, next); | 132 InspectorTest.sendCommandOrDie("Log.enable", {}, next); |
| 131 }, | 133 }, |
| 132 | 134 |
| 133 function start0(next) | 135 function start0(next) |
| 134 { | 136 { |
| 135 InspectorTest.log("Starting worker"); | 137 InspectorTest.log("Starting worker"); |
| 136 InspectorTest.evaluateInPageAsync("startWorker(%callback)", next); | 138 InspectorTest.evaluateInPageAsync("startWorker()").then(next); |
| 137 }, | 139 }, |
| 138 | 140 |
| 139 function log0(next) | 141 function log0(next) |
| 140 { | 142 { |
| 141 logInWorker("message0", next); | 143 logInWorker("message0", next); |
| 142 }, | 144 }, |
| 143 | 145 |
| 144 function stop0(next) | 146 function stop0(next) |
| 145 { | 147 { |
| 146 InspectorTest.log("Stopping worker"); | 148 InspectorTest.log("Stopping worker"); |
| 147 InspectorTest.evaluateInPage("stopWorker()", next); | 149 InspectorTest.evaluateInPage("stopWorker()", next); |
| 148 }, | 150 }, |
| 149 | 151 |
| 150 function start1(next) | 152 function start1(next) |
| 151 { | 153 { |
| 152 InspectorTest.log("Starting worker"); | 154 InspectorTest.log("Starting worker"); |
| 153 InspectorTest.evaluateInPageAsync("startWorker(%callback)", next); | 155 InspectorTest.evaluateInPageAsync("startWorker()").then(next); |
| 154 }, | 156 }, |
| 155 | 157 |
| 156 function log1(next) | 158 function log1(next) |
| 157 { | 159 { |
| 158 logInWorker("message1", next); | 160 logInWorker("message1", next); |
| 159 }, | 161 }, |
| 160 | 162 |
| 161 function enable1(next) | 163 function enable1(next) |
| 162 { | 164 { |
| 163 InspectorTest.log("Sending Worker.enable"); | 165 InspectorTest.log("Sending Worker.enable"); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 208 |
| 207 function enable2(next) | 209 function enable2(next) |
| 208 { | 210 { |
| 209 InspectorTest.log("Sending Worker.enable"); | 211 InspectorTest.log("Sending Worker.enable"); |
| 210 InspectorTest.sendCommandOrDie("Worker.enable", {}, next); | 212 InspectorTest.sendCommandOrDie("Worker.enable", {}, next); |
| 211 }, | 213 }, |
| 212 | 214 |
| 213 function start2(next) | 215 function start2(next) |
| 214 { | 216 { |
| 215 InspectorTest.log("Starting worker"); | 217 InspectorTest.log("Starting worker"); |
| 216 InspectorTest.evaluateInPageAsync("startWorker(%callback)", next); | 218 InspectorTest.evaluateInPageAsync("startWorker()").then(next); |
| 217 }, | 219 }, |
| 218 | 220 |
| 219 function log4(next) | 221 function log4(next) |
| 220 { | 222 { |
| 221 logInWorker("message4", next); | 223 logInWorker("message4", next); |
| 222 }, | 224 }, |
| 223 | 225 |
| 224 function consoleEnable2(next) | 226 function consoleEnable2(next) |
| 225 { | 227 { |
| 226 InspectorTest.log("Sending Runtime.enable to worker"); | 228 InspectorTest.log("Sending Runtime.enable to worker"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 240 | 242 |
| 241 function stop2(next) | 243 function stop2(next) |
| 242 { | 244 { |
| 243 InspectorTest.log("Stopping worker"); | 245 InspectorTest.log("Stopping worker"); |
| 244 InspectorTest.evaluateInPage("stopWorker()", next); | 246 InspectorTest.evaluateInPage("stopWorker()", next); |
| 245 }, | 247 }, |
| 246 | 248 |
| 247 function start3(next) | 249 function start3(next) |
| 248 { | 250 { |
| 249 InspectorTest.log("Starting worker"); | 251 InspectorTest.log("Starting worker"); |
| 250 InspectorTest.evaluateInPageAsync("startWorker(%callback)", next); | 252 InspectorTest.evaluateInPageAsync("startWorker()").then(next); |
| 251 }, | 253 }, |
| 252 | 254 |
| 253 function log6(next) | 255 function log6(next) |
| 254 { | 256 { |
| 255 logInWorker("message6", next); | 257 logInWorker("message6", next); |
| 256 }, | 258 }, |
| 257 | 259 |
| 258 function stop3(next) | 260 function stop3(next) |
| 259 { | 261 { |
| 260 InspectorTest.log("Stopping worker"); | 262 InspectorTest.log("Stopping worker"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 278 InspectorTest.safeWrap(nextStep)(runNextStep); | 280 InspectorTest.safeWrap(nextStep)(runNextStep); |
| 279 } | 281 } |
| 280 | 282 |
| 281 runNextStep(); | 283 runNextStep(); |
| 282 } | 284 } |
| 283 </script> | 285 </script> |
| 284 </head> | 286 </head> |
| 285 <body onload="runTest()"> | 287 <body onload="runTest()"> |
| 286 </body> | 288 </body> |
| 287 </html> | 289 </html> |
| OLD | NEW |