hugomrdias/playwright-test

Prepare service worker without registering it

Opened this issue · 0 comments

Is your feature request related to a problem? Please describe.
I want to test a script in a service worker's both presence and absence. However, there are something blocking this:

  1. When using the sw option, playwright-test registers the service worker immediately on the page load.
  2. Unlike workers, service workers can't be terminated.
  3. Unregistering a service worker only take effects after the page unload. There isn't a reliable way to unregister immediately yet. (discuss in w3c/ServiceWorker#614.)
  4. Using a controllable iframe or new window doesn't help, it inherits the service worker.
  5. When not using the sw option, I have to create my own bundle to pass it as an asset to playwright-test.

So there seems no easy way to tun tests in both the service worker's presence and absence.

Describe the solution you'd like

An option, that stops playwright-test from registering the service worker but keeps playwright-test preparing the bundle. Also, the path of the bundled sw should be exposed somewhere (maybe like PW_TEST.env.swURL) so that we can register it later. The user will have more control on the register option, too.

Describe alternatives you've considered

Stop using sw option, and prepare my own bundle for service worker before running playwright-test.

Additional context

None yet.