Copied: branches/chromium/742/LayoutTests/inspector/debugger/debugger-completions-on-call-frame.html (from rev 86768, trunk/LayoutTests/inspector/debugger/debugger-completions-on-call-frame.html) (0 => 86773)
--- branches/chromium/742/LayoutTests/inspector/debugger/debugger-completions-on-call-frame.html (rev 0)
+++ branches/chromium/742/LayoutTests/inspector/debugger/debugger-completions-on-call-frame.html 2011-05-18 17:01:17 UTC (rev 86773)
@@ -0,0 +1,71 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+var a = 1;
+function testFunction()
+{
+ var var1 = 2;
+ var var2 = 3;
+ debugger;
+}
+
+var test = function()
+{
+ InspectorTest.startDebuggerTest(step1);
+
+ function step1()
+ {
+ InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
+ }
+
+ function step2()
+ {
+ WebInspector.console._completions("", "var", false, checkAgainstGolden.bind(this, [ "var1", "var2" ], step3));
+ }
+
+ function step3()
+ {
+ WebInspector.console._completions("", "di", false, checkAgainstGolden.bind(this, [ "dir", "dirxml" ], step4));
+ }
+
+ function step4()
+ {
+ WebInspector.console._completions("", "win", false, checkAgainstGolden.bind(this, [ "window" ], step5));
+ }
+
+ function step5()
+ {
+ WebInspector.console._completions("", "t", false, checkAgainstGolden.bind(this, [ "this" ], step6));
+ }
+
+ function step6()
+ {
+ InspectorTest.completeDebuggerTest();
+ }
+
+ function checkAgainstGolden(golden, continuation, completions)
+ {
+ for (var i = 0; i < golden.length; ++i) {
+ if (completions.indexOf(golden[i]) !== -1)
+ InspectorTest.addResult(golden[i]);
+ else
+ InspectorTest.addResult("NOT FOUND: " + golden[i]);
+ }
+ continuation();
+ }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Test that completions in the context of the call frame will result in names
+of its scope variables.
+</p>
+
+</body>
+</html>
Modified: branches/chromium/742/Source/WebCore/inspector/front-end/ConsoleView.js (86772 => 86773)
--- branches/chromium/742/Source/WebCore/inspector/front-end/ConsoleView.js 2011-05-18 16:12:51 UTC (rev 86772)
+++ branches/chromium/742/Source/WebCore/inspector/front-end/ConsoleView.js 2011-05-18 17:01:17 UTC (rev 86773)
@@ -344,6 +344,12 @@
// Pass less stop characters to rangeOfWord so the range will be a more complete _expression_.
var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOffset, ExpressionStopCharacters, this.promptElement, "backward");
var expressionString = expressionRange.toString();
+ var prefix = wordRange.toString();
+ this._completions(expressionString, prefix, bestMatchOnly, completionsReadyCallback);
+ },
+
+ _completions: function(expressionString, prefix, bestMatchOnly, completionsReadyCallback)
+ {
var lastIndex = expressionString.length - 1;
var dotNotation = (expressionString[lastIndex] === ".");
@@ -352,11 +358,13 @@
if (dotNotation || bracketNotation)
expressionString = expressionString.substr(0, lastIndex);
- var prefix = wordRange.toString();
if (!expressionString && !prefix)
return;
- this.evalInInspectedWindow(expressionString, "completion", true, evaluated.bind(this));
+ if (!expressionString && WebInspector.panels.scripts.paused)
+ WebInspector.panels.scripts.getSelectedCallFrameVariables(reportCompletions.bind(this));
+ else
+ this.evalInInspectedWindow(expressionString, "completion", true, evaluated.bind(this));
function evaluated(result)
{
@@ -368,14 +376,22 @@
function evaluatedProperties(properties)
{
RuntimeAgent.releaseObjectGroup("completion");
- var propertyNames = [];
+ var propertyNames = {};
for (var i = 0; properties && i < properties.length; ++i)
- propertyNames.push(properties[i].name);
+ propertyNames[properties[i].name] = true;
+ reportCompletions.call(this, propertyNames);
+ }
+ function reportCompletions(propertyNames)
+ {
var includeCommandLineAPI = (!dotNotation && !bracketNotation);
- if (includeCommandLineAPI)
- propertyNames.splice(0, 0, "dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear");
- this._reportCompletions(bestMatchOnly, completionsReadyCallback, dotNotation, bracketNotation, prefix, propertyNames);
+ if (includeCommandLineAPI) {
+ const commandLineAPI = ["dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear"];
+ for (var i = 0; i < commandLineAPI.length; ++i)
+ propertyNames[commandLineAPI[i]] = true;
+ }
+
+ this._reportCompletions(bestMatchOnly, completionsReadyCallback, dotNotation, bracketNotation, prefix, Object.keys(propertyNames));
}
},
Modified: branches/chromium/742/Source/WebCore/inspector/front-end/ScriptsPanel.js (86772 => 86773)
--- branches/chromium/742/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-05-18 16:12:51 UTC (rev 86772)
+++ branches/chromium/742/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-05-18 17:01:17 UTC (rev 86773)
@@ -358,6 +358,32 @@
selectedCallFrame.evaluate(code, objectGroup, includeCommandLineAPI, callback);
},
+ getSelectedCallFrameVariables: function(callback)
+ {
+ var result = { this: true };
+
+ var selectedCallFrame = this._presentationModel.selectedCallFrame;
+ if (!selectedCallFrame)
+ callback(result);
+
+ var pendingRequests = 0;
+
+ function propertiesCollected(properties)
+ {
+ for (var i = 0; properties && i < properties.length; ++i)
+ result[properties[i].name] = true;
+ if (--pendingRequests == 0)
+ callback(result);
+ }
+
+ for (var i = 0; i < selectedCallFrame.scopeChain.length; ++i) {
+ var scope = selectedCallFrame.scopeChain[i];
+ var object = WebInspector.RemoteObject.fromPayload(scope.object);
+ pendingRequests++;
+ object.getAllProperties(propertiesCollected);
+ }
+ },
+
_debuggerPaused: function(event)
{
var callFrames = event.data.callFrames;