Bug 185258 - Web Inspector: Scripts imported by both main page and web worker are duplicated in debugger sources
Summary: Web Inspector: Scripts imported by both main page and web worker are duplicat...
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: Safari 11
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-05-03 10:09 PDT by Owen Shaw
Modified: 2018-05-07 11:53 PDT (History)
4 users (show)

See Also:


Attachments
Screenshot of duplicate debugger sources (24.75 KB, image/png)
2018-05-03 10:09 PDT, Owen Shaw
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Shaw 2018-05-03 10:09:19 PDT
Created attachment 339422 [details]
Screenshot of duplicate debugger sources

Duplicate entries are shown in the debugger sources list when the same script is imported by both the HTML page and a web worker created by the page.

For example:

1. bug.html includes lib.js via a script tag
2. bug.html starts a new worker via new Worker('worker.js')
3. worker.js also imports lib.js via importScripts('lib.js')

lib.js will appear twice in the debugger sources list.  See attached screenshot.  The two entries seem to behave as if they are one (e.g., add a breakpoint to one of the duplicate entries, and that breakpoint will be there in the other duplicate).

Expected: A script should only show up once in the debugger sources list.

Chrome and Firefox inspectors basically have separate lists for each page/worker, so no list has two entries for the same script.

Safari 11.1 and Safari Technology Preview Release 55

bug.html
--------
<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="lib.js"></script>
    <script type="text/javascript">
        var worker = new Worker('./worker.js');
    </script>
</head>
<body>
</body>
</html>

worker.js
----------
importScripts('lib.js');

lib.js
------
function test(){
}
Comment 1 Radar WebKit Bug Importer 2018-05-03 10:19:01 PDT
<rdar://problem/39945088>
Comment 2 BJ Burg 2018-05-07 11:53:30 PDT
This is as expected given the current design. We show one script for each copy that's evaluated into a VM.

Breakpoints are file and line number based, and don't take into account the specific instance/content view of the script.

I agree we could improve the categorization of scripts as belonging to a SW, worker, main page, etc.