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

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/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt ('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..9b35e0e03aa181ab40d50fc250de41938eb7e68e 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,53 @@ WebInspector.ExecutionContext.prototype = {
}
/**
+ * @param {!WebInspector.RemoteObject} object
+ * @return {!Promise<?WebInspector.RemoteObject>}
+ */
+ function extractTarget(object)
+ {
+ if (object.type !== "object" || object.subtype !== "proxy")
+ return Promise.resolve(/** @type {?WebInspector.RemoteObject} */(object));
+ var callback;
+ var promise = new Promise(fullfill => callback = fullfill);
+ object.getOwnProperties(extractTargetFromProperties);
lushnikov 2016/05/05 01:06:03 return object.getOwnPropertiesPromise() .then(f
kozy 2016/05/05 01:35:22 Done.
+ return promise;
+
+ /**
+ * @param {?Array<!WebInspector.RemoteObjectProperty>} properties
+ * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties
+ */
+ function extractTargetFromProperties(properties, internalProperties)
+ {
+ internalProperties = internalProperties || [];
lushnikov 2016/05/05 01:06:04 var target = internalProperties.find(property => p
kozy 2016/05/05 01:35:22 Done.
+ for (var property of internalProperties) {
+ if (property.name === "[[Target]]") {
+ extractTarget(property.value).then(callback);
+ return;
+ }
+ }
+ callback(null);
+ }
+ }
+
+ /**
+ * @param {?WebInspector.RemoteObject} object
+ * @return {!Promise<?Object>}
+ */
+ function completionsForObject(object)
+ {
+ if (!object)
+ return Promise.resolve(/** @type {?Object} */(null));
+ var callback;
+ var promise = new Promise(fullfill => callback = fullfill);
+ object.callFunctionJSON(getCompletions, [WebInspector.RemoteObject.toCallArgument(object.subtype)], callback);
+ return promise;
+ }
+
+ /**
* @param {string=} type
* @suppressReceiverCheck
- * @this {WebInspector.ExecutionContext}
+ * @this {*}
*/
function getCompletions(type)
{
@@ -547,7 +591,7 @@ WebInspector.ExecutionContext.prototype = {
for (var o = object; o; o = o.__proto__) {
if (type === "array" && o === object && ArrayBuffer.isView(o) && o.length > 9999)
continue;
- var names = Object.getOwnPropertyNames(o);
+ var names = Object.getOwnPropertyNames(/** @type{!Object} */(o));
var isArray = Array.isArray(o);
for (var i = 0; i < names.length; ++i) {
// Skip array elements indexes.
@@ -561,8 +605,8 @@ WebInspector.ExecutionContext.prototype = {
return resultSet;
}
- if (result.type === "object" || result.type === "function")
- result.callFunctionJSON(getCompletions, [WebInspector.RemoteObject.toCallArgument(result.subtype)], receivedPropertyNames.bind(this));
+ if (result.type === "object")
+ extractTarget(result).then(completionsForObject).then(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));
}
@@ -576,12 +620,13 @@ WebInspector.ExecutionContext.prototype = {
function receivedPropertyNamesFromEval(notRelevant, wasThrown, result)
{
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/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698