Bug 156919 - Web Inspector: Debugger statement in console does not provide any call frames and debugger UI is confused
Summary: Web Inspector: Debugger statement in console does not provide any call frames...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Timothy Hatcher
URL:
Keywords: InRadar
Depends on:
Blocks: 156924
  Show dependency treegraph
 
Reported: 2016-04-22 10:56 PDT by Timothy Hatcher
Modified: 2016-04-22 13:42 PDT (History)
7 users (show)

See Also:


Attachments
Patch (10.60 KB, patch)
2016-04-22 11:13 PDT, Timothy Hatcher
joepeck: review+
joepeck: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Hatcher 2016-04-22 10:56:32 PDT
Steps:

1. In the console, make a method call that has an anonymous callback function with a debugger statement. Example method call below:

navigator.geolocation.getCurrentPosition(function(position){ console.log(position); debugger;}, function(error){ console.log(error); debugger; });

2. When prompted for user location access, deny permission.

3. Type `error` in the console to access the `error` argument of the callback function.

Results:

I expect to see the error (PositionError object) and have the ability to access its properties, but I get "ReferenceError: Can't find variable: error". 

The debugger is paused, but it is not paused on any specific point. I also expect to see the debugger paused on the debugger statement within the anonymous function.

<rdar://problem/25857118>
Comment 1 Timothy Hatcher 2016-04-22 11:13:39 PDT
Created attachment 277079 [details]
Patch
Comment 2 Joseph Pecoraro 2016-04-22 11:34:27 PDT
Comment on attachment 277079 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=277079&action=review

> Source/WebInspectorUI/ChangeLog:6
> +        Web Inspector: Debugger statement in console does not provide any call frames and debugger UI is confused
> +
> +        https://bugs.webkit.org/show_bug.cgi?id=156919
> +        rdar://problem/25857118

Unexpected empty line (changes git log --oneline when committed).

> Source/WebInspectorUI/UserInterface/Base/Utilities.js:1260
> +    if (string.includes("//# sourceURL"))
> +        return string;

I worry about how expensive this could get, but at the moment I don't think we ever have very large strings.

> Source/WebInspectorUI/UserInterface/Base/Utilities.js:1276
> +function isWebInspectorConsoleExpressionScript(url)

Maybe "isWebInspectorConsoleEvaluationScript". s/Expression/Evaluation/

> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:-583
> -        if (isWebInspectorInternalScript(sourceURL))
> -            return;
> -

I think this can be left in. Now that you have separated Console Evaluations from other Internal Scripts. I don't think we want to create and keep around a WebInspector.Script for every internal script.

> Source/WebInspectorUI/UserInterface/Models/Script.js:103
> +            return WebInspector.UIString("Console Expression %d").format(this._uniqueDisplayNameNumber);

Nit: I like "Console Evaluation %d" instead of "Expression". Since you can evaluate more then just a single expression in the console, its technically a whole program evaluation.

> Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js:211
> +        var treeElement = this.contentTreeOutline.findTreeElement(representedObject);

Style: `let`

> Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js:466
> +        return treeElement;

The other returns here should probably return `null` now.
Comment 3 Radar WebKit Bug Importer 2016-04-22 11:36:32 PDT
<rdar://problem/25881551>
Comment 4 Joseph Pecoraro 2016-04-22 11:50:06 PDT
Comment on attachment 277079 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=277079&action=review

> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:551
> +        if (!this._activeCallFrame) {
> +            this._didResumeInternal();
> +            return;
> +        }

Maybe we should add an assert / warning for our purposes. This might catch something in the future where we expected to pause and didn't.
Comment 5 Joseph Pecoraro 2016-04-22 11:57:34 PDT
Comment on attachment 277079 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=277079&action=review

> Source/WebInspectorUI/UserInterface/Models/Script.js:53
>      static resetUniqueDisplayNameNumbers()

It doesn't look like this ever gets called the first time the inspector opens. Only after page loads. I think DebuggerManager should call this in its constructor.
Comment 6 Timothy Hatcher 2016-04-22 12:53:37 PDT
https://trac.webkit.org/r199897
Comment 7 Timothy Hatcher 2016-04-22 13:28:58 PDT
Follow up: https://trac.webkit.org/r199899