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

Side by Side Diff: test/inspector/runtime/command-line-api.js

Issue 2784713002: [inspector] console get all information from inspector when needed (Closed)
Patch Set: fixed last test Created 3 years, 8 months 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
« no previous file with comments | « test/inspector/protocol-test.js ('k') | test/inspector/runtime/command-line-api-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 InspectorTest.log('Checks command line API.');
6
7 InspectorTest.runAsyncTestSuite([
8 async function testKeys() {
9 InspectorTest.logMessage(await Protocol.Runtime.evaluate({
10 expression: 'keys', includeCommandLineAPI: true}));
11 InspectorTest.logMessage(await Protocol.Runtime.evaluate({
12 expression: 'keys({a : 1})', includeCommandLineAPI: true, returnByValue: t rue}));
13
14 Protocol.Runtime.evaluate({expression: 'this.keys = keys', includeCommandLin eAPI: true});
15 InspectorTest.logMessage(await Protocol.Runtime.evaluate({
16 expression: 'this.keys({a : 1})', returnByValue: true}));
17 },
18
19 async function testInspect() {
20 InspectorTest.log(await Protocol.Runtime.evaluate({expression: 'inspect', in cludeCommandLineAPI: true}));
21 await Protocol.Runtime.enable();
22 Protocol.Runtime.onInspectRequested(InspectorTest.logMessage);
23 await Protocol.Runtime.evaluate({expression: 'inspect({})', includeCommandLi neAPI: true});
24 await Protocol.Runtime.evaluate({expression: 'inspect(239)', includeCommandL ineAPI: true});
25 await Protocol.Runtime.evaluate({expression: 'inspect(-0)', includeCommandLi neAPI: true});
26 await Protocol.Runtime.evaluate({expression: 'copy(\'hello\')', includeComma ndLineAPI: true});
27 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: '$0', includeCommandLineAPI: true}));
28
29 Protocol.Runtime.evaluate({expression: 'this.inspect = inspect', includeComm andLineAPI: true});
30 await Protocol.Runtime.evaluate({expression: 'this.inspect({})'});
31
32 Protocol.Runtime.onInspectRequested(null);
33 await Protocol.Runtime.disable();
34 },
35
36 async function testEvaluationResult() {
37 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true}));
38 await Protocol.Runtime.evaluate({expression: '42', objectGroup: 'console', i ncludeCommandLineAPI: true});
39 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true}));
40 await Protocol.Runtime.evaluate({expression: '239', includeCommandLineAPI: t rue});
41 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true}));
42 await Protocol.Runtime.evaluate({expression: '-0', objectGroup: 'console', i ncludeCommandLineAPI: true});
43 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true}));
44 await Protocol.Runtime.evaluate({expression: '({})', objectGroup: 'console', includeCommandLineAPI: true});
45 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: '$_', includeCommandLineAPI: true, returnByValue: true}));
46 },
47
48 async function testDebug() {
49 InspectorTest.setupScriptMap();
50 await Protocol.Debugger.enable();
51 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'debug ', includeCommandLineAPI: true}));
52 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'undeb ug', includeCommandLineAPI: true}));
53 await Protocol.Runtime.evaluate({expression: 'function foo() {}'});
54 await Protocol.Runtime.evaluate({expression: 'debug(foo)', includeCommandLin eAPI: true});
55 Protocol.Runtime.evaluate({ expression: 'foo()'});
56 let message = await Protocol.Debugger.oncePaused();
57 InspectorTest.logCallFrames(message.params.callFrames);
58 InspectorTest.logMessage(message.params.hitBreakpoints);
59 await Protocol.Debugger.resume();
60 await Protocol.Runtime.evaluate({expression: 'undebug(foo)', includeCommandL ineAPI: true});
61 await Protocol.Runtime.evaluate({ expression: 'foo()'});
62
63 Protocol.Runtime.evaluate({
64 expression: 'this.debug = debug; this.undebug = undebug;', includeCommandL ineAPI: true});
65 await Protocol.Runtime.evaluate({expression: 'this.debug(foo)'});
66 Protocol.Runtime.evaluate({ expression: 'foo()'});
67 message = await Protocol.Debugger.oncePaused();
68 InspectorTest.logCallFrames(message.params.callFrames);
69 InspectorTest.logMessage(message.params.hitBreakpoints);
70 await Protocol.Debugger.resume();
71 await Protocol.Runtime.evaluate({expression: 'this.undebug(foo)'});
72 await Protocol.Runtime.evaluate({expression: 'foo()'});
73
74 await Protocol.Debugger.disable();
75 },
76
77 async function testMonitor() {
78 await Protocol.Debugger.enable();
79 await Protocol.Runtime.enable();
80 Protocol.Runtime.onConsoleAPICalled(message => InspectorTest.log(message.par ams.args[0].value));
81 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'monit or', includeCommandLineAPI: true}));
82 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'unmon itor', includeCommandLineAPI: true}));
83 await Protocol.Runtime.evaluate({expression: 'function foo() {}'});
84
85 await Protocol.Runtime.evaluate({expression: 'monitor(foo)', includeCommandL ineAPI: true});
86 Protocol.Runtime.evaluate({ expression: 'foo(); console.log(\'after first ca ll\')'});
87 await Protocol.Runtime.evaluate({expression: 'unmonitor(foo)', includeComman dLineAPI: true});
88 await Protocol.Runtime.evaluate({ expression: 'foo()'});
89
90 Protocol.Runtime.evaluate({
91 expression: 'console.log(\'store functions..\'); this.monitor = monitor; t his.unmonitor = unmonitor;', includeCommandLineAPI: true});
92 await Protocol.Runtime.evaluate({expression: 'this.monitor(foo)'});
93 Protocol.Runtime.evaluate({ expression: 'foo(); console.log(\'after first ca ll\')'});
94 await Protocol.Runtime.evaluate({expression: 'this.unmonitor(foo)'});
95 await Protocol.Runtime.evaluate({ expression: 'foo()'});
96
97 Protocol.Runtime.onConsoleAPICalled(null);
98 await Protocol.Debugger.disable();
99 await Protocol.Runtime.disable();
100 },
101
102 async function testProfile() {
103 await Protocol.Profiler.enable();
104 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'profi le', includeCommandLineAPI: true}));
105 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'profi leEnd', includeCommandLineAPI: true}));
106
107 Protocol.Runtime.evaluate({expression: 'profile(42)', includeCommandLineAPI: true});
108 InspectorTest.logMessage(await Protocol.Profiler.onceConsoleProfileStarted() );
109 Protocol.Runtime.evaluate({expression: 'profileEnd(42)', includeCommandLineA PI: true});
110 let message = await Protocol.Profiler.onceConsoleProfileFinished();
111 message.params.profile = '<profile>';
112 InspectorTest.logMessage(message);
113
114 Protocol.Runtime.evaluate({
115 expression: 'this.profile = profile; this.profileEnd = profileEnd;', inclu deCommandLineAPI: true});
116 Protocol.Runtime.evaluate({expression: 'this.profile(239)'});
117 InspectorTest.logMessage(await Protocol.Profiler.onceConsoleProfileStarted() );
118 Protocol.Runtime.evaluate({expression: 'this.profileEnd(239)'});
119 message = await Protocol.Profiler.onceConsoleProfileFinished();
120 message.params.profile = '<profile>';
121 InspectorTest.logMessage(message);
122
123 await Protocol.Profiler.disable();
124 },
125
126 async function testDir() {
127 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'dir', includeCommandLineAPI: true}));
128
129 await Protocol.Runtime.enable();
130 Protocol.Runtime.evaluate({expression: 'dir({})', includeCommandLineAPI: tru e});
131 InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
132 Protocol.Runtime.evaluate({expression: 'dir(42)', includeCommandLineAPI: tru e});
133 InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
134
135 Protocol.Runtime.evaluate({expression: 'this.dir = dir', includeCommandLineA PI: true});
136 Protocol.Runtime.evaluate({expression: 'this.dir({})'});
137 InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
138 await Protocol.Runtime.disable();
139 },
140
141 async function testDirXML() {
142 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'dirxm l', includeCommandLineAPI: true}));
143
144 await Protocol.Runtime.enable();
145 Protocol.Runtime.evaluate({expression: 'dirxml({})', includeCommandLineAPI: true});
146 InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
147 Protocol.Runtime.evaluate({expression: 'dirxml(42)', includeCommandLineAPI: true});
148 InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
149 await Protocol.Runtime.disable();
150 },
151
152 async function testTable() {
153 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'table ', includeCommandLineAPI: true}));
154
155 await Protocol.Runtime.enable();
156 Protocol.Runtime.evaluate({expression: 'table({})', includeCommandLineAPI: t rue});
157 InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
158 Protocol.Runtime.evaluate({expression: 'table(42)', includeCommandLineAPI: t rue});
159 InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
160 await Protocol.Runtime.disable();
161 },
162
163 async function testClear() {
164 InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'clear ', includeCommandLineAPI: true}));
165
166 await Protocol.Runtime.enable();
167 Protocol.Runtime.evaluate({expression: 'clear()', includeCommandLineAPI: tru e});
168 InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
169
170 Protocol.Runtime.evaluate({expression: 'this.clear = clear', includeCommandL ineAPI: true});
171 Protocol.Runtime.evaluate({expression: 'this.clear()'});
172 InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());
173 await Protocol.Runtime.disable();
174 }
175 ]);
OLDNEW
« no previous file with comments | « test/inspector/protocol-test.js ('k') | test/inspector/runtime/command-line-api-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698