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 print("Check that console.log is reported through Console domain as well."); | 5 print("Check that console.log is reported through Console domain as well."); |
6 | 6 |
7 var expectedMessages = 4; | 7 var expectedMessages = 4; |
8 var messages = []; | 8 var messages = []; |
9 | 9 |
10 InspectorTest.eventHandler["Runtime.consoleAPICalled"] = consoleAPICalled; | 10 Protocol.Runtime.onConsoleAPICalled(consoleAPICalled); |
11 InspectorTest.eventHandler["Console.messageAdded"] = messageAdded; | 11 Protocol.Console.onMessageAdded(messageAdded); |
12 InspectorTest.sendCommandOrDie("Runtime.enable", {}); | 12 Protocol.Runtime.enable(); |
13 InspectorTest.sendCommandOrDie("Console.enable", {}); | 13 Protocol.Console.enable(); |
14 InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "console.log(
42)" }); | 14 Protocol.Runtime.evaluate({ "expression": "console.log(42)" }); |
15 InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "console.erro
r('abc')" }); | 15 Protocol.Runtime.evaluate({ "expression": "console.error('abc')" }); |
16 | 16 |
17 function consoleAPICalled(result) | 17 function consoleAPICalled(result) |
18 { | 18 { |
19 messages.push("api call: " + result.params.args[0].value); | 19 messages.push("api call: " + result.params.args[0].value); |
20 if (!(--expectedMessages)) | 20 if (!(--expectedMessages)) |
21 done(); | 21 done(); |
22 } | 22 } |
23 | 23 |
24 function messageAdded(result) | 24 function messageAdded(result) |
25 { | 25 { |
26 messages.push("console message: " + result.params.message.text); | 26 messages.push("console message: " + result.params.message.text); |
27 if (!(--expectedMessages)) | 27 if (!(--expectedMessages)) |
28 done(); | 28 done(); |
29 } | 29 } |
30 | 30 |
31 function done() | 31 function done() |
32 { | 32 { |
33 messages.sort(); | 33 messages.sort(); |
34 for (var message of messages) | 34 for (var message of messages) |
35 InspectorTest.log(message); | 35 InspectorTest.log(message); |
36 InspectorTest.completeTest(); | 36 InspectorTest.completeTest(); |
37 } | 37 } |
OLD | NEW |