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

Side by Side Diff: LayoutTests/inspector-protocol/debugger/debugger-pause-dedicated-worker-loop.html

Issue 352103002: Test that DevTools commands can be handled on worker thread when it is in a tight loop (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/debugger/debugger-pause-dedicated-worker-loop-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
6 var worker; 7 var worker;
7 8
8 function testFunction()
9 {
10 debugger;
11 }
12
13 function startWorkerAndRunTest() 9 function startWorkerAndRunTest()
14 { 10 {
15 worker = new Worker("resources/dedicated-worker.js"); 11 worker = new Worker("resources/dedicated-worker-loop.js");
16 worker.onmessage = function(event) { }; 12 worker.onmessage = function(event) { };
17 worker.postMessage(1);
18 log("Started worker"); 13 log("Started worker");
19 runTest(); 14 runTest();
20 } 15 }
21 16
17
loislo 2014/06/25 07:55:04 nuke this line
yurys 2014/06/25 07:56:08 Done.
22 function test() 18 function test()
23 { 19 {
20
loislo 2014/06/25 07:55:04 ditto
yurys 2014/06/25 07:56:08 Done.
24 var workerId; 21 var workerId;
25 var workerRequestId = 1; 22 var workerRequestId = 1;
26
27 function sendCommandToWorker(method, params) 23 function sendCommandToWorker(method, params)
28 { 24 {
29 InspectorTest.sendCommand("Worker.sendMessageToWorker", 25 InspectorTest.sendCommand("Worker.sendMessageToWorker",
30 { 26 {
31 "workerId": workerId, 27 "workerId": workerId,
32 "message": { "method": method, 28 "message": { "method": method,
33 "params": params, 29 "params": params,
34 "id": workerRequestId } 30 "id": workerRequestId }
35 }); 31 });
36 return workerRequestId++; 32 return workerRequestId++;
37 } 33 }
38 34
39 InspectorTest.sendCommand("Debugger.enable", {});
40 InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedInTestFu nction;
41 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction( )" });
42
43 function handleDebuggerPausedInTestFunction(messageObject)
44 {
45 InspectorTest.log("Paused on 'debugger;'");
46 InspectorTest.sendCommand("Worker.enable", {}, didEnableWorkerDebugging) ;
47
48 }
49
50 function didEnableWorkerDebugging(messageObject) 35 function didEnableWorkerDebugging(messageObject)
51 { 36 {
52 if ("error" in messageObject) { 37 if ("error" in messageObject) {
53 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);
54 InspectorTest.completeTest(); 39 InspectorTest.completeTest();
55 } 40 }
56 } 41 }
42 InspectorTest.sendCommand("Worker.enable", {}, didEnableWorkerDebugging);
57 43
58 var savedWorkerRequestId = -1; 44 var evaluateRequestId = -1;
45 var debuggerEnableRequestId = -1;
59 InspectorTest.eventHandler["Worker.workerCreated"] = function(messageObject) 46 InspectorTest.eventHandler["Worker.workerCreated"] = function(messageObject)
60 { 47 {
61 workerId = messageObject["params"]["workerId"]; 48 workerId = messageObject["params"]["workerId"];
62 InspectorTest.log("Worker created"); 49 InspectorTest.log("Worker created");
63 InspectorTest.sendCommand("Worker.connectToWorker", { "workerId": worker Id }, didConnectToWorker); 50 InspectorTest.sendCommand("Worker.connectToWorker", { "workerId": worker Id }, didConnectToWorker);
64 51
65 function didConnectToWorker(messageObject) 52 function didConnectToWorker(messageObject)
66 { 53 {
67 InspectorTest.log("didConnectToWorker"); 54 InspectorTest.log("didConnectToWorker");
68 savedWorkerRequestId = sendCommandToWorker("Runtime.evaluate", { "ex pression": "1+1"}); 55 // Enable debugger so that V8 can interrupt and handle inspector com mands while there is a script running in a tight loop.
56 debuggerEnableRequestId = sendCommandToWorker("Debugger.enable", {}) ;
69 } 57 }
70 } 58 }
71 59
72 InspectorTest.eventHandler["Worker.dispatchMessageFromWorker"] = function(me ssageObject) 60 InspectorTest.eventHandler["Worker.dispatchMessageFromWorker"] = function(me ssageObject)
73 { 61 {
74 var message = messageObject["params"]["message"]; 62 var message = messageObject["params"]["message"];
75 if (message["id"] === savedWorkerRequestId) { 63 if (message["id"] === debuggerEnableRequestId) {
64 InspectorTest.log("Did enable debugger");
65 // Start tight loop in the worker.
66 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "worke r.postMessage(1)" }, didPostMessageToWorker);
67 function didPostMessageToWorker()
68 {
69 InspectorTest.log("Did post message to worker");
70 evaluateRequestId = sendCommandToWorker("Runtime.evaluate", { "e xpression": "message_id > 1"});
71 }
72 }
73 if (message["id"] === evaluateRequestId) {
76 var value = message["result"]["result"]["value"]; 74 var value = message["result"]["result"]["value"];
77 InspectorTest.log("Successfully evaluated, result: " + value); 75 if (value === true)
76 InspectorTest.log("SUCCESS: evaluated, result: " + value);
77 else
78 InspectorTest.log("FAIL: evaluated, result: " + value);
78 InspectorTest.completeTest(); 79 InspectorTest.completeTest();
79 } 80 }
80 } 81 }
81 } 82 }
82 </script> 83 </script>
83 </head> 84 </head>
84 <body onLoad="startWorkerAndRunTest();"> 85 <body onLoad="startWorkerAndRunTest();">
85 </body> 86 </body>
86 </html> 87 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/debugger/debugger-pause-dedicated-worker-loop-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698