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..a5331fe454d6cb8987240b25bc995867a6f5d857 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js |
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js |
@@ -511,11 +511,13 @@ WebInspector.ExecutionContext.prototype = { |
} |
if (!expressionString && this.debuggerModel.selectedCallFrame()) |
- this.debuggerModel.selectedCallFrame().variableNames(receivedPropertyNames.bind(this)); |
+ this.debuggerModel.selectedCallFrame().variableNames((names) => receivedPropertyNames.call(this, Object.keys(names))); |
else |
this.evaluate(expressionString, "completion", true, true, false, false, false, evaluated.bind(this)); |
/** |
+ * @param {?WebInspector.RemoteObject} result |
+ * @param {boolean} wasThrown |
* @this {WebInspector.ExecutionContext} |
*/ |
function evaluated(result, wasThrown) |
@@ -524,64 +526,11 @@ WebInspector.ExecutionContext.prototype = { |
completionsReadyCallback([]); |
return; |
} |
- |
- /** |
- * @param {string=} type |
- * @suppressReceiverCheck |
- * @this {WebInspector.ExecutionContext} |
- */ |
- function getCompletions(type) |
- { |
- var object; |
- if (type === "string") |
- object = new String(""); |
- else if (type === "number") |
- object = new Number(0); |
- else if (type === "boolean") |
- object = new Boolean(false); |
- else |
- object = this; |
- |
- var resultSet = {}; |
- try { |
- 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 isArray = Array.isArray(o); |
- for (var i = 0; i < names.length; ++i) { |
- // Skip array elements indexes. |
- if (isArray && /^[0-9]/.test(names[i])) |
- continue; |
- resultSet[names[i]] = true; |
- } |
- } |
- } catch (e) { |
- } |
- 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} notRelevant |
- * @param {boolean} wasThrown |
- * @param {?RuntimeAgent.RemoteObject=} result |
- * @this {WebInspector.ExecutionContext} |
- */ |
- function receivedPropertyNamesFromEval(notRelevant, wasThrown, result) |
- { |
- if (result && !wasThrown) |
- receivedPropertyNames.call(this, result.value); |
- else |
- completionsReadyCallback([]); |
+ result.getCompletionsPromise().then(receivedPropertyNames.bind(this)); |
} |
/** |
+ * @param {?Array<string>} propertyNames |
* @this {WebInspector.ExecutionContext} |
*/ |
function receivedPropertyNames(propertyNames) |
@@ -596,9 +545,10 @@ WebInspector.ExecutionContext.prototype = { |
const commandLineAPI = ["dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", |
"getEventListeners", "debug", "undebug", "monitor", "unmonitor", "table", "$", "$$", "$x"]; |
for (var i = 0; i < commandLineAPI.length; ++i) |
- propertyNames[commandLineAPI[i]] = true; |
+ propertyNames.push(commandLineAPI[i]); |
} |
- this._reportCompletions(completionsReadyCallback, dotNotation, bracketNotation, expressionString, prefix, Object.keys(propertyNames)); |
+ propertyNames.sort(); |
+ this._reportCompletions(completionsReadyCallback, dotNotation, bracketNotation, expressionString, prefix, propertyNames); |
} |
}, |