Bug 196996 - Web Inspector: Extension scripts with parse errors do not show up in Web Inspector
Summary: Web Inspector: Extension scripts with parse errors do not show up in Web Insp...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-04-16 18:05 PDT by Joseph Pecoraro
Modified: 2019-04-17 12:59 PDT (History)
5 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (2.44 KB, patch)
2019-04-16 18:09 PDT, Joseph Pecoraro
hi: review-
Details | Formatted Diff | Diff
[PATCH] Proposed Fix (3.63 KB, patch)
2019-04-17 11:51 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2019-04-16 18:05:11 PDT
Extension scripts with parse errors do not show up in Web Inspector

Steps to Reproduce:
1. Create a Safari extension with a script with a syntax error
2. Load a page where the content script loads
  => Syntax Error in console but no location and no resource content to link to

Notes:
• There is a Debugger message we ignore, such as:

    {
        "method": "Debugger.scriptFailedToParse",
        "params": {
            "url": "safari-extension://com.apple.Safari.Test.../script.js",
            "scriptSource":"…",
            "startLine": 1,
            "errorLine": 27,
            "errorMessage": "Unexpected end of script"
        }
    }
Comment 1 Joseph Pecoraro 2019-04-16 18:05:21 PDT
<rdar://problem/47054804>
Comment 2 Joseph Pecoraro 2019-04-16 18:09:21 PDT
Created attachment 367597 [details]
[PATCH] Proposed Fix

For now this is useful for extension which I don't know how to test...

The only thing this might eventually be useful for would be anonymous evals:

    setTimeout(() => {
        eval("console.log(1) }}}");
    });

Which after the above still won't have a URL so the later parse error won't handle this.

---

We could create a console message error here if `url` is null and ignore the `Console.messageAdded` in that case. This seems pretty edge casey at the moment.
Comment 3 Devin Rousso 2019-04-17 11:50:53 PDT
Comment on attachment 367597 [details]
[PATCH] Proposed Fix

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

r-, missing ChangeLog :(

> Source/WebInspectorUI/UserInterface/Models/Script.js:-32
> -        console.assert(id);

Why was this removed?
Comment 4 Joseph Pecoraro 2019-04-17 11:51:21 PDT
Created attachment 367659 [details]
[PATCH] Proposed Fix
Comment 5 Devin Rousso 2019-04-17 11:52:23 PDT
Comment on attachment 367659 [details]
[PATCH] Proposed Fix

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

rs=me

> Source/WebInspectorUI/ChangeLog:20
> +        Local scripts provide a null id and id is not required below.

Along these lines, I'd remove the `|| null` from `this._range = range || null;` since it's asserted that it's a `WI.TextRange`.
Comment 6 WebKit Commit Bot 2019-04-17 12:59:30 PDT
Comment on attachment 367659 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 367659

Committed r244398: <https://trac.webkit.org/changeset/244398>
Comment 7 WebKit Commit Bot 2019-04-17 12:59:31 PDT
All reviewed patches have been landed.  Closing bug.