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 13 matching lines...) Expand all Loading... |
24 else | 24 else |
25 return (listener) => { InspectorTest._eventHandler[`${agentName}.${e
ventName}`] = listener }; | 25 return (listener) => { InspectorTest._eventHandler[`${agentName}.${e
ventName}`] = listener }; |
26 } | 26 } |
27 } | 27 } |
28 }); | 28 }); |
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(originalMessage) |
35 { | 35 { |
| 36 var message = JSON.parse(JSON.stringify(originalMessage)); |
36 if (message.id) | 37 if (message.id) |
37 message.id = "<messageId>"; | 38 message.id = "<messageId>"; |
38 | 39 |
39 const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "times
tamp", "executionContextId", "callFrameId"]); | 40 const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "times
tamp", "executionContextId", "callFrameId"]); |
40 var objects = [ message ]; | 41 var objects = [ message ]; |
41 while (objects.length) { | 42 while (objects.length) { |
42 var object = objects.shift(); | 43 var object = objects.shift(); |
43 for (var key in object) { | 44 for (var key in object) { |
44 if (nonStableFields.has(key)) | 45 if (nonStableFields.has(key)) |
45 object[key] = `<${key}>`; | 46 object[key] = `<${key}>`; |
46 else if (typeof object[key] === "object") | 47 else if (typeof object[key] === "object") |
47 objects.push(object[key]); | 48 objects.push(object[key]); |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 InspectorTest.logObject(message); | 52 InspectorTest.logObject(message); |
52 return message; | 53 return originalMessage; |
53 } | 54 } |
54 | 55 |
55 InspectorTest.logObject = function(object, title) | 56 InspectorTest.logObject = function(object, title) |
56 { | 57 { |
57 var lines = []; | 58 var lines = []; |
58 | 59 |
59 function dumpValue(value, prefix, prefixWithName) | 60 function dumpValue(value, prefix, prefixWithName) |
60 { | 61 { |
61 if (typeof value === "object" && value !== null) { | 62 if (typeof value === "object" && value !== null) { |
62 if (value instanceof Array) | 63 if (value instanceof Array) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 var eventName = messageObject["method"]; | 205 var eventName = messageObject["method"]; |
205 var eventHandler = InspectorTest._eventHandler[eventName]; | 206 var eventHandler = InspectorTest._eventHandler[eventName]; |
206 if (eventHandler) | 207 if (eventHandler) |
207 eventHandler(messageObject); | 208 eventHandler(messageObject); |
208 } | 209 } |
209 } catch (e) { | 210 } catch (e) { |
210 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac
k + "\n message = " + JSON.stringify(messageObject, null, 2)); | 211 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac
k + "\n message = " + JSON.stringify(messageObject, null, 2)); |
211 InspectorTest.completeTest(); | 212 InspectorTest.completeTest(); |
212 } | 213 } |
213 } | 214 } |
OLD | NEW |