Title: [86773] branches/chromium/742
Revision
86773
Author
[email protected]
Date
2011-05-18 10:01:17 -0700 (Wed, 18 May 2011)

Log Message

Merge 86768 - 2011-05-18  Pavel Feldman  <[email protected]>

        Reviewed by Yury Semikhatsky.

        Web Inspector: [REGRESSION] Completion while on a breakpoint is not working.
        https://bugs.webkit.org/show_bug.cgi?id=60811

        * inspector/debugger/debugger-completions-on-call-frame-expected.txt: Added.
        * inspector/debugger/debugger-completions-on-call-frame.html: Added.
2011-05-18  Pavel Feldman  <[email protected]>

        Reviewed by Yury Semikhatsky.

        Web Inspector: [REGRESSION] Completion while on a breakpoint is not working.
        https://bugs.webkit.org/show_bug.cgi?id=60811

        Test: inspector/debugger/debugger-completions-on-call-frame.html

        * inspector/InjectedScriptSource.js:
        * inspector/front-end/ConsoleView.js:
        (WebInspector.ConsoleView.prototype.completions.else.evaluated):
        * inspector/front-end/DebuggerPresentationModel.js:
        (WebInspector.PresenationCallFrame.prototype.get variables):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel.prototype.selectedCallFrameVariables):

[email protected]
Review URL: http://codereview.chromium.org/7034027

Modified Paths

Added Paths

Diff

Copied: branches/chromium/742/LayoutTests/inspector/debugger/debugger-completions-on-call-frame-expected.txt (from rev 86768, trunk/LayoutTests/inspector/debugger/debugger-completions-on-call-frame-expected.txt) (0 => 86773)


--- branches/chromium/742/LayoutTests/inspector/debugger/debugger-completions-on-call-frame-expected.txt	                        (rev 0)
+++ branches/chromium/742/LayoutTests/inspector/debugger/debugger-completions-on-call-frame-expected.txt	2011-05-18 17:01:17 UTC (rev 86773)
@@ -0,0 +1,14 @@
+Test that completions in the context of the call frame will result in names of its scope variables.
+
+Debugger was enabled.
+Set timer for test function.
+Script execution paused.
+var1
+var2
+dir
+dirxml
+window
+this
+Script execution resumed.
+Debugger was disabled.
+

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/RemoteObject.js (86772 => 86773)


--- branches/chromium/742/Source/WebCore/inspector/front-end/RemoteObject.js	2011-05-18 16:12:51 UTC (rev 86772)
+++ branches/chromium/742/Source/WebCore/inspector/front-end/RemoteObject.js	2011-05-18 17:01:17 UTC (rev 86773)
@@ -125,8 +125,10 @@
         }
         function remoteObjectBinder(error, properties)
         {
-            if (error)
+            if (error) {
+                callback(null);
                 return;
+            }
             for (var i = 0; properties && i < properties.length; ++i)
                 properties[i].value = WebInspector.RemoteObject.fromPayload(properties[i].value);
             callback(properties);

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;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to