OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 }); | 30 }); |
31 | 31 |
32 InspectorTest.log = print.bind(null); | 32 InspectorTest.log = print.bind(null); |
33 | 33 |
34 InspectorTest.logMessage = function(message) | 34 InspectorTest.logMessage = function(message) |
35 { | 35 { |
36 if (message.id) | 36 if (message.id) |
37 message.id = "<messageId>"; | 37 message.id = "<messageId>"; |
38 | 38 |
39 const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "times
tamp"]); | 39 const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "times
tamp", "executionContextId"]); |
40 var objects = [ message ]; | 40 var objects = [ message ]; |
41 while (objects.length) { | 41 while (objects.length) { |
42 var object = objects.shift(); | 42 var object = objects.shift(); |
43 for (var key in object) { | 43 for (var key in object) { |
44 if (nonStableFields.has(key)) | 44 if (nonStableFields.has(key)) |
45 object[key] = `<${key}>`; | 45 object[key] = `<${key}>`; |
46 else if (typeof object[key] === "object") | 46 else if (typeof object[key] === "object") |
47 objects.push(object[key]); | 47 objects.push(object[key]); |
48 } | 48 } |
49 } | 49 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 | 98 |
99 dumpValue(object, "", title); | 99 dumpValue(object, "", title); |
100 InspectorTest.log(lines.join("\n")); | 100 InspectorTest.log(lines.join("\n")); |
101 } | 101 } |
102 | 102 |
103 InspectorTest.completeTest = quit.bind(null); | 103 InspectorTest.completeTest = quit.bind(null); |
104 | 104 |
105 InspectorTest.completeTestAfterPendingTimeouts = function() | 105 InspectorTest.completeTestAfterPendingTimeouts = function() |
106 { | 106 { |
107 InspectorTest.sendCommand("Runtime.evaluate", { | 107 Protocol.Runtime.evaluate({ |
108 expression: "new Promise(resolve => setTimeout(resolve, 0))", | 108 expression: "new Promise(resolve => setTimeout(resolve, 0))", |
109 awaitPromise: true }, InspectorTest.completeTest); | 109 awaitPromise: true }).then(InspectorTest.completeTest); |
110 } | 110 } |
111 | 111 |
112 InspectorTest.addScript = function(string) | 112 InspectorTest.addScript = function(string) |
113 { | 113 { |
114 return InspectorTest._sendCommandPromise("Runtime.evaluate", { "expression": s
tring }).then(dumpErrorIfNeeded); | 114 return InspectorTest._sendCommandPromise("Runtime.evaluate", { "expression": s
tring }).then(dumpErrorIfNeeded); |
115 | 115 |
116 function dumpErrorIfNeeded(message) | 116 function dumpErrorIfNeeded(message) |
117 { | 117 { |
118 if (message.error) { | 118 if (message.error) { |
119 InspectorTest.log("Error while executing '" + string + "': " + message.err
or.message); | 119 InspectorTest.log("Error while executing '" + string + "': " + message.err
or.message); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 var eventName = messageObject["method"]; | 201 var eventName = messageObject["method"]; |
202 var eventHandler = InspectorTest._eventHandler[eventName]; | 202 var eventHandler = InspectorTest._eventHandler[eventName]; |
203 if (eventHandler) | 203 if (eventHandler) |
204 eventHandler(messageObject); | 204 eventHandler(messageObject); |
205 } | 205 } |
206 } catch (e) { | 206 } catch (e) { |
207 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac
k + "\n message = " + JSON.stringify(messageObject, null, 2)); | 207 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac
k + "\n message = " + JSON.stringify(messageObject, null, 2)); |
208 InspectorTest.completeTest(); | 208 InspectorTest.completeTest(); |
209 } | 209 } |
210 } | 210 } |
OLD | NEW |