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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js

Issue 1952553002: [DevTools] Auto completion for proxy uses proxy target object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-property-descriptors-to-native
Patch Set: Created 4 years, 7 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 | « third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 * @this {WebInspector.ExecutionContext} 519 * @this {WebInspector.ExecutionContext}
520 */ 520 */
521 function evaluated(result, wasThrown) 521 function evaluated(result, wasThrown)
522 { 522 {
523 if (!result || wasThrown) { 523 if (!result || wasThrown) {
524 completionsReadyCallback([]); 524 completionsReadyCallback([]);
525 return; 525 return;
526 } 526 }
527 527
528 /** 528 /**
529 * @param {?WebInspector.RemoteObject} object
530 * @return {!Promise<?WebInspector.RemoteObject>}
531 */
532 function extractTarget(object)
533 {
534 if (!object)
535 return Promise.resolve(/** @type {?WebInspector.RemoteObject } */(null));
536 if (object.type !== "object" || object.subtype !== "proxy")
537 return Promise.resolve(/** @type {?WebInspector.RemoteObject } */(object));
538 return object.getOwnPropertiesPromise().then(extractTargetFromPr operties).then(extractTarget);
539 }
540
541 /**
542 * @param {!{properties: ?Array<!WebInspector.RemoteObjectProperty>, internalProperties: ?Array<!WebInspector.RemoteObjectProperty>}} properties
543 * @return {?WebInspector.RemoteObject}
544 */
545 function extractTargetFromProperties(properties)
546 {
547 var internalProperties = properties.internalProperties || [];
548 var target = internalProperties.find(property => property.name = == "[[Target]]");
549 return target ? target.value : null;
550 }
551
552 /**
529 * @param {string=} type 553 * @param {string=} type
554 * @return {!Object}
530 * @suppressReceiverCheck 555 * @suppressReceiverCheck
531 * @this {WebInspector.ExecutionContext} 556 * @this {Object}
532 */ 557 */
533 function getCompletions(type) 558 function getCompletions(type)
534 { 559 {
535 var object; 560 var object;
536 if (type === "string") 561 if (type === "string")
537 object = new String(""); 562 object = new String("");
538 else if (type === "number") 563 else if (type === "number")
539 object = new Number(0); 564 object = new Number(0);
540 else if (type === "boolean") 565 else if (type === "boolean")
541 object = new Boolean(false); 566 object = new Boolean(false);
(...skipping 12 matching lines...) Expand all
554 if (isArray && /^[0-9]/.test(names[i])) 579 if (isArray && /^[0-9]/.test(names[i]))
555 continue; 580 continue;
556 resultSet[names[i]] = true; 581 resultSet[names[i]] = true;
557 } 582 }
558 } 583 }
559 } catch (e) { 584 } catch (e) {
560 } 585 }
561 return resultSet; 586 return resultSet;
562 } 587 }
563 588
564 if (result.type === "object" || result.type === "function") 589 /**
565 result.callFunctionJSON(getCompletions, [WebInspector.RemoteObje ct.toCallArgument(result.subtype)], receivedPropertyNames.bind(this)); 590 * @param {?WebInspector.RemoteObject} object
566 else if (result.type === "string" || result.type === "number" || res ult.type === "boolean") 591 * @this {WebInspector.ExecutionContext}
567 this.evaluate("(" + getCompletions + ")(\"" + result.type + "\") ", "completion", false, true, true, false, false, receivedPropertyNamesFromEval. bind(this)); 592 */
593 function completionsForObject(object)
594 {
595 if (!object)
596 receivedPropertyNames.call(this, null);
597 else if (object.type === "object")
598 object.callFunctionJSON(getCompletions, [WebInspector.Remote Object.toCallArgument(object.subtype)], receivedPropertyNames.bind(this));
599 else if (object.type === "string" || object.type === "number" || object.type === "boolean")
600 this.evaluate("(" + getCompletions + ")(\"" + result.type + "\")", "completion", false, true, true, false, false, receivedPropertyNamesFromE val.bind(this));
601 }
602
603 extractTarget(result).then(completionsForObject.bind(this));
568 } 604 }
569 605
570 /** 606 /**
571 * @param {?WebInspector.RemoteObject} notRelevant 607 * @param {?WebInspector.RemoteObject} notRelevant
572 * @param {boolean} wasThrown 608 * @param {boolean} wasThrown
573 * @param {?RuntimeAgent.RemoteObject=} result 609 * @param {?RuntimeAgent.RemoteObject=} result
574 * @this {WebInspector.ExecutionContext} 610 * @this {WebInspector.ExecutionContext}
575 */ 611 */
576 function receivedPropertyNamesFromEval(notRelevant, wasThrown, result) 612 function receivedPropertyNamesFromEval(notRelevant, wasThrown, result)
577 { 613 {
614 this.target().runtimeAgent().releaseObjectGroup("completion");
578 if (result && !wasThrown) 615 if (result && !wasThrown)
579 receivedPropertyNames.call(this, result.value); 616 receivedPropertyNames.call(this, /** @type {!Object} */(result.v alue));
580 else 617 else
581 completionsReadyCallback([]); 618 completionsReadyCallback([]);
582 } 619 }
583 620
584 /** 621 /**
622 * @param {?Object} propertyNames
585 * @this {WebInspector.ExecutionContext} 623 * @this {WebInspector.ExecutionContext}
586 */ 624 */
587 function receivedPropertyNames(propertyNames) 625 function receivedPropertyNames(propertyNames)
588 { 626 {
589 this.target().runtimeAgent().releaseObjectGroup("completion"); 627 this.target().runtimeAgent().releaseObjectGroup("completion");
590 if (!propertyNames) { 628 if (!propertyNames) {
591 completionsReadyCallback([]); 629 completionsReadyCallback([]);
592 return; 630 return;
593 } 631 }
594 var includeCommandLineAPI = (!dotNotation && !bracketNotation); 632 var includeCommandLineAPI = (!dotNotation && !bracketNotation);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 /** 851 /**
814 * @param {string} listenerType 852 * @param {string} listenerType
815 */ 853 */
816 setListenerType: function(listenerType) 854 setListenerType: function(listenerType)
817 { 855 {
818 this._listenerType = listenerType; 856 this._listenerType = listenerType;
819 }, 857 },
820 858
821 __proto__: WebInspector.SDKObject.prototype 859 __proto__: WebInspector.SDKObject.prototype
822 } 860 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698