@@ -213,10 +213,7 @@ class AppInspector implements AppInspectorInterface {
213213 // We use the JS pseudo-variable 'arguments' to get the list of all arguments.
214214 final send = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
215215 .callInstanceMethodJsExpression (methodName);
216- print (
217- '***YJ_TEST: _invokeMethod: receiver: $receiver , methodName: $methodName , positionalArgs: $positionalArgs , send: $send ' );
218216 final remote = await jsCallFunctionOn (receiver, send, positionalArgs);
219- print ('***YJ_TEST: _invokeMethod: remote: $remote ' );
220217 return remote;
221218 }
222219
@@ -255,8 +252,6 @@ class AppInspector implements AppInspectorInterface {
255252 List <Object > arguments, {
256253 bool returnByValue = false ,
257254 }) async {
258- print (
259- '**YJ_TEST: _jsCallFunction: evalExpression: $evalExpression , arguments: $arguments ' );
260255 final jsArguments = arguments.map (callArgumentFor).toList ();
261256 final response = await remoteDebugger.sendCommand (
262257 'Runtime.callFunctionOn' ,
@@ -285,8 +280,6 @@ class AppInspector implements AppInspectorInterface {
285280 String selector,
286281 List <dynamic > arguments,
287282 ) async {
288- print (
289- 'YJ_TEST: invoke: targetId: $targetId , selector: $selector , arguments: $arguments ' );
290283 final remoteArguments =
291284 arguments.cast <String >().map (remoteObjectFor).toList ();
292285 // We special case the Dart library, where invokeMethod won't work because
@@ -308,16 +301,14 @@ class AppInspector implements AppInspectorInterface {
308301 Library library,
309302 String selector,
310303 List <RemoteObject > arguments,
311- ) async {
312- print (
313- 'YJ_TEST: _invokeLibraryFunction: library: ${library .uri }, selector: $selector , arguments: $arguments ' ,
314- );
315- final result = await _evaluateInLibrary (
316- library,
317- 'function () { return this.$selector .apply(this, arguments);}' ,
318- arguments,
319- );
320- return result;
304+ ) {
305+ return globalToolConfiguration.loadStrategy is DdcLibraryBundleStrategy
306+ ? _evaluateWithDdcLibraryBundle (library, selector, arguments)
307+ : _evaluateInLibrary (
308+ library,
309+ 'function () { return this.$selector .apply(this, arguments); }' ,
310+ arguments,
311+ );
321312 }
322313
323314 /// Evaluate [expression] by calling Chrome's Runtime.evaluate.
@@ -352,28 +343,29 @@ class AppInspector implements AppInspectorInterface {
352343 if (libraryUri == null ) {
353344 throwInvalidParam ('invoke' , 'library uri is null' );
354345 }
355- final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
346+ final findLibraryJsExpression = globalToolConfiguration
347+ .loadStrategy.dartRuntimeDebugger
356348 .callLibraryMethodJsExpression (libraryUri, jsFunction);
357349
358- print ('YJ_TEST: Evaluating in library: $expression ' );
359- if (globalToolConfiguration.loadStrategy is DdcLibraryBundleStrategy ) {
360- print ('YJ_TEST-A-1: DdcLibraryBundleStrategy' );
361- final result = await _jsCallFunction (jsFunction, arguments);
362- print (
363- 'YJ_TEST-A-2: result: $result ' ,
364- );
365- return result;
366- } else {
367- print ('YJ_TEST-B-1: ${globalToolConfiguration .loadStrategy }' );
368- final remoteLibrary = await jsEvaluate (expression);
369- print (
370- 'YJ_TEST-B-2: remoteLibrary: ${remoteLibrary .objectId }, jsFunction: $jsFunction , arguments: $arguments ' ,
371- );
372- final result =
373- await jsCallFunctionOn (remoteLibrary, jsFunction, arguments);
374- print ('YJ_TEST-B-3: result: ${result .objectId }' );
375- return result;
350+ final remoteLibrary = await jsEvaluate (findLibraryJsExpression);
351+ return jsCallFunctionOn (remoteLibrary, jsFunction, arguments);
352+ }
353+
354+ /// Evaluates the specified method [methodName] in the context of [library]
355+ /// using the Dart Development Compiler (DDC) library bundle strategy with
356+ /// the given [arguments] .
357+ Future <RemoteObject > _evaluateWithDdcLibraryBundle (
358+ Library library,
359+ String methodName,
360+ List <RemoteObject > arguments,
361+ ) {
362+ final libraryUri = library.uri;
363+ if (libraryUri == null ) {
364+ throwInvalidParam ('invoke' , 'library uri is null' );
376365 }
366+ final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
367+ .callLibraryMethodJsExpression (libraryUri, methodName);
368+ return _jsCallFunction (expression, arguments);
377369 }
378370
379371 /// Call [function] with objects referred by [argumentIds] as arguments.
@@ -382,11 +374,7 @@ class AppInspector implements AppInspectorInterface {
382374 String function,
383375 Iterable <String > argumentIds,
384376 ) async {
385- print (
386- 'YJ_TEST-1: callFunction - function: $function , argumentIDs: $argumentIds ' ,
387- );
388377 final arguments = argumentIds.map (remoteObjectFor).toList ();
389- print ('YJ_TEST-2: callFunction - arguments: $arguments ' );
390378 final result = await _jsCallFunction (function, arguments);
391379 return result;
392380 }
0 commit comments