Index: Source/core/inspector/InjectedScriptSource.js |
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js |
index 2659ad24fa52c1f2df01104a82891150d97de732..7b36ad897356af8b6d2c5cc2e2bd31057c7bee89 100644 |
--- a/Source/core/inspector/InjectedScriptSource.js |
+++ b/Source/core/inspector/InjectedScriptSource.js |
@@ -340,7 +340,7 @@ InjectedScript.prototype = { |
_parseObjectId: function(objectId) |
{ |
// FIXME: upstream the change from InjectedScriptHost.evaluate to JSON.parse. |
- return /** @type {Object} */ nullifyObjectProto(JSON.parse(objectId)); |
+ return nullifyObjectProto( /** @type {!Object} */ (JSON.parse(objectId))); |
}, |
/** |
@@ -372,6 +372,46 @@ InjectedScript.prototype = { |
return result; |
}, |
+ addCompletionsHelper: function(object, completions) { |
+ if (!this._isDefined(object)) |
+ return; |
+ |
+ var type = typeof(object); |
+ if (type === "string") |
+ object = new String(""); |
+ else if (type === "number") |
+ object = new Number(0); |
+ else if (type === "boolean") |
+ object = new Boolean(false); |
+ |
+ for (var o = object; o; o = o.__proto__) { |
+ try { |
+ var names = Object.getOwnPropertyNames(o); |
+ for (var i = 0; i < names.length; ++i) |
+ completions[names[i]] = true; |
+ } catch (e) { |
+ } |
+ } |
+ }, |
+ |
+ /** |
+ * @param {string} expression |
+ * @return {!Array.<String>} |
+ */ |
+ getCompletions: function(expression) |
+ { |
+ var object; |
+ try { |
+ object = InjectedScriptHost.evaluate(expression || "this"); |
+ } catch (e) { |
+ return []; |
+ } |
+ |
+ var completions = {}; |
+ this.addCompletionsHelper(object, completions); |
+ return /** @type {!Array.<String>} */ (Object.keys(completions)); |
+ }, |
+ |
/** |
* @param {string} objectId |
* @param {boolean} ownProperties |
@@ -433,6 +473,24 @@ InjectedScript.prototype = { |
}, |
/** |
+ * @param {string} objectId |
+ * @param {Array.<String>} propertyPath |
+ * @return {Object|boolean} |
+ */ |
+ getProperty: function(objectId, propertyPath) |
+ { |
+ var parsedObjectId = this._parseObjectId(objectId); |
+ var object = this._objectForId(parsedObjectId); |
+ var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; |
+ if (!this._isDefined(object)) |
+ return false; |
+ |
+ for (var i = 0, n = propertyPath.length; i < n; ++i) |
+ object = object[propertyPath[i]]; |
+ return this._wrapObject(object, objectGroupName); |
+ }, |
+ |
+ /** |
* @param {string} functionId |
* @return {!DebuggerAgent.FunctionDetails|string} |
*/ |
@@ -758,6 +816,45 @@ InjectedScript.prototype = { |
/** |
* @param {!Object} topCallFrame |
+ * @param {!Array.<!Object>} asyncCallStacks |
+ * @param {string} callFrameId |
+ * @param {string} expression |
+ * @return {!Array.<String>} |
+ */ |
+ getCompletionsOnCallFrame: function(topCallFrame, asyncCallStacks, callFrameId, expression) |
+ { |
+ var completions = {}; |
+ var parsedCallFrameId = nullifyObjectProto(InjectedScriptHost.evaluate("(" + callFrameId + ")")); |
+ var callFrame = this._callFrameForParsedId(topCallFrame, parsedCallFrameId, asyncCallStacks); |
+ if (!callFrame) |
+ return ["Could not find call frame with given id"]; |
+ if (expression == "") { |
+ var scopeChain = callFrame.scopeChain; |
+ for (var i = 0; i < scopeChain.length; i++) { |
+ var names = Object.getOwnPropertyNames(scopeChain[i]); |
+ for (var i = 0; i < names.length; ++i) |
+ completions[names[i]] = true; |
+ } |
+ } |
+ expression = expression || "this"; |
+ var object; |
+ try { |
+ if (parsedCallFrameId["asyncOrdinal"]) { |
+ object = this._evaluateOn(InjectedScriptHost.evaluate, InjectedScriptHost, "completion", expression, false, false, callFrame.scopeChain); |
+ } else { |
+ object = this._evaluateOn(callFrame.evaluate, callFrame, "completion", expression, true, false); |
+ } |
+ } catch (e) { |
+ return []; |
+ } |
+ |
+ this.addCompletionsHelper(object, completions); |
+ return /** @type {!Array.<String>} */ (Object.keys(completions)); |
+ }, |
+ |
+ |
+ /** |
+ * @param {!Object} topCallFrame |
* @param {string} callFrameId |
* @return {*} |
*/ |