Bug 29616 - Web Inspector: completions are always evaluated against window (discarding call frames)
Summary: Web Inspector: completions are always evaluated against window (discarding ca...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Pavel Feldman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-21 14:47 PDT by Pavel Feldman
Modified: 2009-09-21 15:59 PDT (History)
2 users (show)

See Also:


Attachments
patch (3.85 KB, patch)
2009-09-21 15:44 PDT, Pavel Feldman
timothy: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Feldman 2009-09-21 14:47:07 PDT
1. While on web inspector stop on a breakpoint
2. Type "<some-scope-var>." to see completions

Expected: completions
Actual: nothing

The reason is that getCompletions is working against window only.
Comment 1 Pavel Feldman 2009-09-21 15:44:45 PDT
Created attachment 39889 [details]
patch
Comment 2 Timothy Hatcher 2009-09-21 15:54:11 PDT
Comment on attachment 39889 [details]
patch


> +        var callFrameId = WebInspector.panels.scripts && WebInspector.panels.scripts.paused ? WebInspector.panels.scripts.selectedCallFrameId() : null;

Thats a bit long. Maybe just have it be:

if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused)
    var callFrameId = WebInspector.panels.scripts.selectedCallFrameId();

And it will be undefined by default for the normal case.

> +        InjectedScriptAccess.getCompletions(expressionString, includeInspectorCommandLineAPI, callFrameId, reportCompletions);
>      },
>  
>      _reportCompletions: function(bestMatchOnly, completionsReadyCallback, dotNotation, bracketNotation, prefix, result, isException) {
> diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js
> index 4d96f68..726c7cc 100644
> --- a/WebCore/inspector/front-end/InjectedScript.js
> +++ b/WebCore/inspector/front-end/InjectedScript.js
> @@ -499,11 +499,20 @@ InjectedScript.setPropertyValue = function(objectProxy, propertyName, expression
>  }
>  
>  
> -InjectedScript.getCompletions = function(expression, includeInspectorCommandLineAPI)
> +InjectedScript.getCompletions = function(expression, includeInspectorCommandLineAPI, callFrameId)
>  {
>      var props = {};
>      try {
> -        var expressionResult = InjectedScript._evaluateOn(InjectedScript._window().eval, InjectedScript._window(), expression);
> +        var expressionResult;
> +        // Evaluate on call frame if call frame id is available.
> +        if (typeof callFrameId === "number") {
> +            var callFrame = InjectedScript._callFrameForId(callFrameId);
> +            if (!callFrame)
> +                return props;
> +            expressionResult = InjectedScript._evaluateOn(callFrame.evaluate, callFrame, expression);
> +        } else {
> +            expressionResult = InjectedScript._evaluateOn(InjectedScript._window().eval, InjectedScript._window(), expression);
> +        }
>          for (var prop in expressionResult)
>              props[prop] = true;
>          if (includeInspectorCommandLineAPI)
> diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js
> index 04f27bb..ae918d1 100644
> --- a/WebCore/inspector/front-end/ScriptsPanel.js
> +++ b/WebCore/inspector/front-end/ScriptsPanel.js
> @@ -351,6 +351,14 @@ WebInspector.ScriptsPanel.prototype = {
>              sourceFrame.removeBreakpoint(breakpoint);
>      },
>  
> +    selectedCallFrameId: function()
> +    {
> +        var selectedCallFrame = this.sidebarPanes.callstack.selectedCallFrame;
> +        if (!selectedCallFrame)
> +            return null;
> +        return selectedCallFrame.id;
> +    },
> +
>      evaluateInSelectedCallFrame: function(code, updateInterface, callback)
>      {
>          var selectedCallFrame = this.sidebarPanes.callstack.selectedCallFrame;
Comment 3 Pavel Feldman 2009-09-21 15:56:14 PDT
(In reply to comment #2)
> (From update of attachment 39889 [details])
> 
> > +        var callFrameId = WebInspector.panels.scripts && WebInspector.panels.scripts.paused ? WebInspector.panels.scripts.selectedCallFrameId() : null;
> 
> Thats a bit long. Maybe just have it be:

Done!
Comment 4 Pavel Feldman 2009-09-21 15:59:13 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	WebCore/ChangeLog
	M	WebCore/inspector/front-end/ConsoleView.js
	M	WebCore/inspector/front-end/InjectedScript.js
	M	WebCore/inspector/front-end/ScriptsPanel.js
Committed r48608