New issue
Advanced search Search tips

Issue 771527 link

Starred by 0 users

Issue metadata

Status: Duplicate
Merged: issue 814583
Owner: ----
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 756312



Sign in to add a comment

S13nServiceWorker: multiple importScripts() calls with the same URL should import the same script

Project Member Reported by nhiroki@chromium.org, Oct 4 2017

Issue description

See a following service worker script.

  importScripts("foo.js");
  importScripts("foo.js");

The second importScripts() call should import the script installed by the first importScripts() call. However, this doesn't work when we enable the SW script streaming and S13nSW. It is because InstalledScriptsManager doesn't exist on the installation phase and importScripts() always goes to the network.
 
There're 2 options for now:

1) Instantiate InstalledScriptManager even on the installation phase. A list of installed scripts are dynamically updated, so the InstalledScriptManager in the renderer may need to keep the list by itself and ask the browser to read an installed script if necessary.

2) Make ServiceWorkerScriptURLLoader read an installed script from the script storage if it's already installed.

I'd slightly prefer the 1) because it can encapsulate the code to read an installed script from the script storage in InstalledScriptManager.
Blocking: 756312
Labels: -Pri-3 Pri-2
Mergedinto: 814583
Status: Duplicate (was: Available)
Ah, I discovered this bug after filing  issue 814583  for the same thing. Sorry.

I ended up doing something like #2 since it was simpler than #1, getting InstalledScriptManager used for non-installed service workers and dynamically changing the avilable scripts looked quite a bit harder, and this is just a minor corner case.

We might also need to use the new SWInstalledScriptLoader more generally for updates, which is moving in the spec to download and cache the scripts first before spawning a worker since the byte-to-byte check has to cover importScripts too.

Sign in to add a comment