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

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

Issue 2390733002: [inspector] Make InspectorTest.sendCommand* private (Closed)
Patch Set: addressed comments Created 4 years, 2 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
OLDNEW
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("Tests that CommandLineAPI is presented only while evaluation."); 5 print("Tests that CommandLineAPI is presented only while evaluation.");
6 6
7 InspectorTest.evaluateInPage( 7 InspectorTest.addScript(
8 ` 8 `
9 var methods = ["dir","dirxml","profile","profileEnd","clear","table","keys","val ues","debug","undebug","monitor","unmonitor","inspect","copy"]; 9 var methods = ["dir","dirxml","profile","profileEnd","clear","table","keys","val ues","debug","undebug","monitor","unmonitor","inspect","copy"];
10 var window = this; 10 var window = this;
11 function presentedAPIMethods() 11 function presentedAPIMethods()
12 { 12 {
13 var methodCount = 0; 13 var methodCount = 0;
14 for (var method of methods) { 14 for (var method of methods) {
15 try { 15 try {
16 if (eval("window." + method + "&&" + method + ".toString ? " + metho d + ".toString().indexOf(\\"[Command Line API]\\") !== -1 : false")) 16 if (eval("window." + method + "&&" + method + ".toString ? " + metho d + ".toString().indexOf(\\"[Command Line API]\\") !== -1 : false"))
17 ++methodCount; 17 ++methodCount;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 .then(dumpLeftMethods) 78 .then(dumpLeftMethods)
79 .then(dumpDir) 79 .then(dumpDir)
80 .then(() => runExpressionAndDumpPresentedMethods("redefineGetOwnPropertyDescri ptors()")) 80 .then(() => runExpressionAndDumpPresentedMethods("redefineGetOwnPropertyDescri ptors()"))
81 .then(dumpLeftMethods) 81 .then(dumpLeftMethods)
82 .then(dumpDir) 82 .then(dumpDir)
83 .then(() => evaluate("restoreGetOwnPropertyDescriptors()", false)) 83 .then(() => evaluate("restoreGetOwnPropertyDescriptors()", false))
84 .then(InspectorTest.completeTest); 84 .then(InspectorTest.completeTest);
85 85
86 function evaluate(expression, includeCommandLineAPI) 86 function evaluate(expression, includeCommandLineAPI)
87 { 87 {
88 var cb; 88 return Protocol.Runtime.evaluate({ expression: expression, objectGroup: "conso le", includeCommandLineAPI: includeCommandLineAPI });
89 var p = new Promise(resolver => cb = resolver);
90 InspectorTest.sendCommandOrDie("Runtime.evaluate", { expression: expression, o bjectGroup: "console", includeCommandLineAPI: includeCommandLineAPI }, cb);
91 return p;
92 } 89 }
93 90
94 function setLastEvaluationResultTo239() 91 function setLastEvaluationResultTo239()
95 { 92 {
96 return evaluate("239", false); 93 return evaluate("239", false);
97 } 94 }
98 95
99 function runExpressionAndDumpPresentedMethods(expression) 96 function runExpressionAndDumpPresentedMethods(expression)
100 { 97 {
101 InspectorTest.log(expression); 98 InspectorTest.log(expression);
102 return setLastEvaluationResultTo239() 99 return setLastEvaluationResultTo239()
103 .then(() => evaluate(expression + "; var a = presentedAPIMethods(); a", true )) 100 .then(() => evaluate(expression + "; var a = presentedAPIMethods(); a", true ))
104 .then((result) => InspectorTest.logObject(result)); 101 .then((result) => InspectorTest.logMessage(result));
105 } 102 }
106 103
107 function dumpLeftMethods() 104 function dumpLeftMethods()
108 { 105 {
109 // Should always be zero. 106 // Should always be zero.
110 return setLastEvaluationResultTo239() 107 return setLastEvaluationResultTo239()
111 .then(() => evaluate("presentedAPIMethods()", false)) 108 .then(() => evaluate("presentedAPIMethods()", false))
112 .then((result) => InspectorTest.logObject(result)); 109 .then((result) => InspectorTest.logMessage(result));
113 } 110 }
114 111
115 function dumpDir() 112 function dumpDir()
116 { 113 {
117 // Should always be presented. 114 // Should always be presented.
118 return evaluate("dir", false) 115 return evaluate("dir", false)
119 .then((result) => InspectorTest.logObject(result)); 116 .then((result) => InspectorTest.logMessage(result));
120 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698