Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/worker/worker-console.html

Issue 2442083002: [DevTools] Merge Worker domain to Target, migrate clients. (Closed)
Patch Set: rebased all tests Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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() 9 function startWorker()
10 { 10 {
(...skipping 23 matching lines...) Expand all
34 34
35 function stopWorker() 35 function stopWorker()
36 { 36 {
37 worker.terminate(); 37 worker.terminate();
38 worker = null; 38 worker = null;
39 } 39 }
40 40
41 function test() 41 function test()
42 { 42 {
43 var workerEventHandler = {}; 43 var workerEventHandler = {};
44 InspectorTest.eventHandler["Worker.workerCreated"] = onWorkerCreated; 44 InspectorTest.eventHandler["Target.attachedToTarget"] = onWorkerCreated;
45 InspectorTest.eventHandler["Worker.dispatchMessageFromWorker"] = onWorkerMes sage; 45 InspectorTest.eventHandler["Target.receivedMessageFromTarget"] = onWorkerMes sage;
46 workerEventHandler["Runtime.consoleAPICalled"] = onConsoleAPICalledFromWorke r; 46 workerEventHandler["Runtime.consoleAPICalled"] = onConsoleAPICalledFromWorke r;
47 47
48 var workerId; 48 var workerId;
49 49
50 function onWorkerCreated(payload) 50 function onWorkerCreated(payload)
51 { 51 {
52 InspectorTest.log("Worker.created"); 52 InspectorTest.log("Worker.created");
53 workerId = payload.params.workerId; 53 workerId = payload.params.targetInfo.targetId;
54 } 54 }
55 55
56 var requestId = 0; 56 var requestId = 0;
57 var dispatchTable = []; 57 var dispatchTable = [];
58 58
59 function sendCommandToWorker(method, params, callback) 59 function sendCommandToWorker(method, params, callback)
60 { 60 {
61 dispatchTable[++requestId] = callback; 61 dispatchTable[++requestId] = callback;
62 var messageObject = { 62 var messageObject = {
63 "method": method, 63 "method": method,
64 "params": params, 64 "params": params,
65 "id": requestId 65 "id": requestId
66 }; 66 };
67 InspectorTest.sendCommandOrDie("Worker.sendMessageToWorker", { 67 InspectorTest.sendCommandOrDie("Target.sendMessageToTarget", {
68 workerId: workerId, 68 targetId: workerId,
69 message: JSON.stringify(messageObject) 69 message: JSON.stringify(messageObject)
70 }); 70 });
71 } 71 }
72 72
73 function onWorkerMessage(payload) 73 function onWorkerMessage(payload)
74 { 74 {
75 if (payload.params.workerId !== workerId) 75 if (payload.params.targetId !== workerId)
76 InspectorTest.log("workerId mismatch"); 76 InspectorTest.log("targetId mismatch");
77 var messageObject = JSON.parse(payload.params.message); 77 var messageObject = JSON.parse(payload.params.message);
78 var messageId = messageObject["id"]; 78 var messageId = messageObject["id"];
79 if (typeof messageId === "number") { 79 if (typeof messageId === "number") {
80 var handler = dispatchTable[messageId]; 80 var handler = dispatchTable[messageId];
81 dispatchTable[messageId] = null; 81 dispatchTable[messageId] = null;
82 if (handler && typeof handler === "function") 82 if (handler && typeof handler === "function")
83 handler(messageObject); 83 handler(messageObject);
84 } else { 84 } else {
85 var eventName = messageObject["method"]; 85 var eventName = messageObject["method"];
86 var eventHandler = workerEventHandler[eventName]; 86 var eventHandler = workerEventHandler[eventName];
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 InspectorTest.evaluateInPageAsync("startWorker()").then(next); 155 InspectorTest.evaluateInPageAsync("startWorker()").then(next);
156 }, 156 },
157 157
158 function log1(next) 158 function log1(next)
159 { 159 {
160 logInWorker("message1", next); 160 logInWorker("message1", next);
161 }, 161 },
162 162
163 function enable1(next) 163 function enable1(next)
164 { 164 {
165 InspectorTest.log("Sending Worker.enable"); 165 InspectorTest.log("Starting autoattach");
166 InspectorTest.sendCommandOrDie("Worker.enable", {}, next); 166 InspectorTest.sendCommandOrDie("Target.setAutoAttach", {autoAttach: true, waitForDebuggerOnStart: false}, next);
167 }, 167 },
168 168
169 function consoleEnable1(next) 169 function consoleEnable1(next)
170 { 170 {
171 InspectorTest.log("Sending Runtime.enable to worker"); 171 InspectorTest.log("Sending Runtime.enable to worker");
172 waitForMessage("message1", next); 172 waitForMessage("message1", next);
173 sendCommandToWorker("Runtime.enable", {}); 173 sendCommandToWorker("Runtime.enable", {});
174 }, 174 },
175 175
176 function log2(next) 176 function log2(next)
177 { 177 {
178 logInWorker("message2", next); 178 logInWorker("message2", next);
179 }, 179 },
180 180
181 function waitForMessage2(next) 181 function waitForMessage2(next)
182 { 182 {
183 waitForMessage("message2", next); 183 waitForMessage("message2", next);
184 }, 184 },
185 185
186 function throw1(next) 186 function throw1(next)
187 { 187 {
188 logInWorker("throw1", next); 188 logInWorker("throw1", next);
189 }, 189 },
190 190
191 function disable1(next) 191 function disable1(next)
192 { 192 {
193 InspectorTest.log("Sending Worker.disable"); 193 InspectorTest.log("Stopping autoattach");
194 InspectorTest.sendCommandOrDie("Worker.disable", {}, next); 194 InspectorTest.sendCommandOrDie("Target.setAutoAttach", {autoAttach: false, waitForDebuggerOnStart: false}, next);
195 }, 195 },
196 196
197 function log3(next) 197 function log3(next)
198 { 198 {
199 logInWorker("message3", next); 199 logInWorker("message3", next);
200 }, 200 },
201 201
202 function stop1(next) 202 function stop1(next)
203 { 203 {
204 InspectorTest.log("Stopping worker"); 204 InspectorTest.log("Stopping worker");
205 InspectorTest.evaluateInPage("stopWorker()", next); 205 InspectorTest.evaluateInPage("stopWorker()", next);
206 }, 206 },
207 207
208 208
209 function enable2(next) 209 function enable2(next)
210 { 210 {
211 InspectorTest.log("Sending Worker.enable"); 211 InspectorTest.log("Starting autoattach");
212 InspectorTest.sendCommandOrDie("Worker.enable", {}, next); 212 InspectorTest.sendCommandOrDie("Target.setAutoAttach", {autoAttach: true, waitForDebuggerOnStart: false}, next);
213 }, 213 },
214 214
215 function start2(next) 215 function start2(next)
216 { 216 {
217 InspectorTest.log("Starting worker"); 217 InspectorTest.log("Starting worker");
218 InspectorTest.evaluateInPageAsync("startWorker()").then(next); 218 InspectorTest.evaluateInPageAsync("startWorker()").then(next);
219 }, 219 },
220 220
221 function log4(next) 221 function log4(next)
222 { 222 {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 }, 258 },
259 259
260 function stop3(next) 260 function stop3(next)
261 { 261 {
262 InspectorTest.log("Stopping worker"); 262 InspectorTest.log("Stopping worker");
263 InspectorTest.evaluateInPage("stopWorker()", next); 263 InspectorTest.evaluateInPage("stopWorker()", next);
264 }, 264 },
265 265
266 function disable2(next) 266 function disable2(next)
267 { 267 {
268 InspectorTest.log("Sending Worker.disable"); 268 InspectorTest.log("Stopping autoattach");
269 InspectorTest.sendCommandOrDie("Worker.disable", {}, next); 269 InspectorTest.sendCommandOrDie("Target.setAutoAttach", {autoAttach: false, waitForDebuggerOnStart: false}, next);
270 } 270 }
271 ]; 271 ];
272 272
273 function runNextStep() 273 function runNextStep()
274 { 274 {
275 if (!steps.length) { 275 if (!steps.length) {
276 InspectorTest.completeTest(); 276 InspectorTest.completeTest();
277 return; 277 return;
278 } 278 }
279 var nextStep = steps.shift(); 279 var nextStep = steps.shift();
280 InspectorTest.safeWrap(nextStep)(runNextStep); 280 InspectorTest.safeWrap(nextStep)(runNextStep);
281 } 281 }
282 282
283 runNextStep(); 283 runNextStep();
284 } 284 }
285 </script> 285 </script>
286 </head> 286 </head>
287 <body onload="runTest()"> 287 <body onload="runTest()">
288 </body> 288 </body>
289 </html> 289 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698