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

Side by Side Diff: test/inspector/protocol-test.js

Issue 2574803002: [inspector] add async instrumentation for setTimeout in tests (Closed)
Patch Set: Created 4 years 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 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 InspectorTest = {}; 5 InspectorTest = {};
6 InspectorTest._dispatchTable = new Map(); 6 InspectorTest._dispatchTable = new Map();
7 InspectorTest._requestId = 0; 7 InspectorTest._requestId = 0;
8 InspectorTest._dumpInspectorProtocolMessages = false; 8 InspectorTest._dumpInspectorProtocolMessages = false;
9 InspectorTest._eventHandler = {}; 9 InspectorTest._eventHandler = {};
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 lines.push(firstLinePrefix + "["); 94 lines.push(firstLinePrefix + "[");
95 for (var i = 0; i < object.length; ++i) 95 for (var i = 0; i < object.length; ++i)
96 dumpValue(object[i], " " + prefix, " " + prefix + "[" + i + "] : "); 96 dumpValue(object[i], " " + prefix, " " + prefix + "[" + i + "] : ");
97 lines.push(prefix + "]"); 97 lines.push(prefix + "]");
98 } 98 }
99 99
100 dumpValue(object, "", title || ""); 100 dumpValue(object, "", title || "");
101 InspectorTest.log(lines.join("\n")); 101 InspectorTest.log(lines.join("\n"));
102 } 102 }
103 103
104 InspectorTest.logCallFrames = function(callFrames, urlByScriptId)
105 {
106 for (var frame of callFrames) {
107 var functionName = frame.functionName || '(anonymous)';
108 var url = frame.url ? frame.url : urlByScriptId.get(frame.location.scriptId) ;
109 var lineNumber = frame.location ? frame.location.lineNumber : frame.lineNumb er;
110 var columnNumber = frame.location ? frame.location.columnNumber : frame.colu mnNumber;
111 InspectorTest.log(`${functionName} (${url}:${lineNumber}:${columnNumber})`);
112 }
113 }
114
104 InspectorTest.completeTest = function() 115 InspectorTest.completeTest = function()
105 { 116 {
106 Protocol.Debugger.disable().then(() => quit()); 117 Protocol.Debugger.disable().then(() => quit());
107 } 118 }
108 119
109 InspectorTest.completeTestAfterPendingTimeouts = function() 120 InspectorTest.completeTestAfterPendingTimeouts = function()
110 { 121 {
111 Protocol.Runtime.evaluate({ 122 Protocol.Runtime.evaluate({
112 expression: "new Promise(resolve => setTimeout(resolve, 0))", 123 expression: "new Promise(resolve => setTimeout(resolve, 0))",
113 awaitPromise: true }).then(InspectorTest.completeTest); 124 awaitPromise: true }).then(InspectorTest.completeTest);
114 } 125 }
115 126
116 InspectorTest.addScript = (string) => compileAndRunWithOrigin(string, "", 0, 0); 127 InspectorTest.addScript = (string, lineOffset, columnOffset) => compileAndRunWit hOrigin(string, "", lineOffset, columnOffset);
117 InspectorTest.addScriptWithUrl = (string, url) => compileAndRunWithOrigin(string , url, 0, 0); 128 InspectorTest.addScriptWithUrl = (string, url) => compileAndRunWithOrigin(string , url, 0, 0);
118 129
119 InspectorTest.startDumpingProtocolMessages = function() 130 InspectorTest.startDumpingProtocolMessages = function()
120 { 131 {
121 InspectorTest._dumpInspectorProtocolMessages = true; 132 InspectorTest._dumpInspectorProtocolMessages = true;
122 } 133 }
123 134
124 InspectorTest.sendRawCommand = function(requestId, command, handler) 135 InspectorTest.sendRawCommand = function(requestId, command, handler)
125 { 136 {
126 if (InspectorTest._dumpInspectorProtocolMessages) 137 if (InspectorTest._dumpInspectorProtocolMessages)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 var eventName = messageObject["method"]; 206 var eventName = messageObject["method"];
196 var eventHandler = InspectorTest._eventHandler[eventName]; 207 var eventHandler = InspectorTest._eventHandler[eventName];
197 if (eventHandler) 208 if (eventHandler)
198 eventHandler(messageObject); 209 eventHandler(messageObject);
199 } 210 }
200 } catch (e) { 211 } catch (e) {
201 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac k + "\n message = " + JSON.stringify(messageObject, null, 2)); 212 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac k + "\n message = " + JSON.stringify(messageObject, null, 2));
202 InspectorTest.completeTest(); 213 InspectorTest.completeTest();
203 } 214 }
204 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698