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.sendCommand("Runtime.enable", {}); | 5 Protocol.Runtime.enable(); |
6 | 6 |
7 addConsoleMessagePromise("console.log(239)") | 7 addConsoleMessagePromise("console.log(239)") |
8 .then(dumpMessage) | 8 .then(message => InspectorTest.logMessage(message)) |
9 .then(() => addConsoleMessagePromise("var l = console.log;\n l(239)")) | 9 .then(() => addConsoleMessagePromise("var l = console.log;\n l(239)")) |
10 .then(dumpMessage) | 10 .then(message => InspectorTest.logMessage(message)) |
11 .then(() => InspectorTest.completeTest()); | 11 .then(() => InspectorTest.completeTest()); |
12 | 12 |
13 function addConsoleMessagePromise(expression) | 13 function addConsoleMessagePromise(expression) |
14 { | 14 { |
15 var cb; | 15 var wait = Protocol.Runtime.onceConsoleAPICalled(); |
16 var p = new Promise((resolver) => cb = resolver); | 16 Protocol.Runtime.evaluate({ expression: expression }); |
17 InspectorTest.eventHandler["Runtime.consoleAPICalled"] = (messageObject) => cb
(messageObject); | 17 return wait; |
18 InspectorTest.sendCommand("Runtime.evaluate", { expression: expression }); | |
19 return p; | |
20 } | 18 } |
21 | |
22 function dumpMessage(messageObject) | |
23 { | |
24 var msg = messageObject.params; | |
25 delete msg.executionContextId; | |
26 delete msg.args; | |
27 delete msg.timestamp; | |
28 for (var frame of msg.stackTrace.callFrames) | |
29 frame.scriptId = 0; | |
30 if (!frame.functionName) | |
31 frame.functionName = "(anonymous)"; | |
32 if (!frame.url) | |
33 frame.url = "(empty)"; | |
34 InspectorTest.logObject(msg); | |
35 } | |
OLD | NEW |