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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
index 27c6654ac05900f7b7272db5b86f7dce987913c5..3965c1577a536a2775abd656cf8a238f1308a470 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
@@ -526,9 +526,34 @@ WebInspector.ExecutionContext.prototype = {
}
/**
+ * @param {?WebInspector.RemoteObject} object
+ * @return {!Promise<?WebInspector.RemoteObject>}
+ */
+ function extractTarget(object)
+ {
+ if (!object)
+ return Promise.resolve(/** @type {?WebInspector.RemoteObject} */(null));
+ if (object.type !== "object" || object.subtype !== "proxy")
+ return Promise.resolve(/** @type {?WebInspector.RemoteObject} */(object));
+ return object.getOwnPropertiesPromise().then(extractTargetFromProperties).then(extractTarget);
+ }
+
+ /**
+ * @param {!{properties: ?Array<!WebInspector.RemoteObjectProperty>, internalProperties: ?Array<!WebInspector.RemoteObjectProperty>}} properties
+ * @return {?WebInspector.RemoteObject}
+ */
+ function extractTargetFromProperties(properties)
+ {
+ var internalProperties = properties.internalProperties || [];
+ var target = internalProperties.find(property => property.name === "[[Target]]");
+ return target ? target.value : null;
+ }
+
+ /**
* @param {string=} type
+ * @return {!Object}
* @suppressReceiverCheck
- * @this {WebInspector.ExecutionContext}
+ * @this {Object}
*/
function getCompletions(type)
{
@@ -561,10 +586,21 @@ WebInspector.ExecutionContext.prototype = {
return resultSet;
}
- if (result.type === "object" || result.type === "function")
- result.callFunctionJSON(getCompletions, [WebInspector.RemoteObject.toCallArgument(result.subtype)], receivedPropertyNames.bind(this));
- else if (result.type === "string" || result.type === "number" || result.type === "boolean")
- this.evaluate("(" + getCompletions + ")(\"" + result.type + "\")", "completion", false, true, true, false, false, receivedPropertyNamesFromEval.bind(this));
+ /**
+ * @param {?WebInspector.RemoteObject} object
+ * @this {WebInspector.ExecutionContext}
+ */
+ function completionsForObject(object)
+ {
+ if (!object)
+ receivedPropertyNames.call(this, null);
+ else if (object.type === "object")
+ object.callFunctionJSON(getCompletions, [WebInspector.RemoteObject.toCallArgument(object.subtype)], receivedPropertyNames.bind(this));
+ else if (object.type === "string" || object.type === "number" || object.type === "boolean")
+ this.evaluate("(" + getCompletions + ")(\"" + result.type + "\")", "completion", false, true, true, false, false, receivedPropertyNamesFromEval.bind(this));
+ }
+
+ extractTarget(result).then(completionsForObject.bind(this));
}
/**
@@ -575,13 +611,15 @@ WebInspector.ExecutionContext.prototype = {
*/
function receivedPropertyNamesFromEval(notRelevant, wasThrown, result)
{
+ this.target().runtimeAgent().releaseObjectGroup("completion");
if (result && !wasThrown)
- receivedPropertyNames.call(this, result.value);
+ receivedPropertyNames.call(this, /** @type {!Object} */(result.value));
else
completionsReadyCallback([]);
}
/**
+ * @param {?Object} propertyNames
* @this {WebInspector.ExecutionContext}
*/
function receivedPropertyNames(propertyNames)
« 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