Files
Sam PoderandGitHub 6065bf6fcf [turbopack] Add E2E tests for service workers (#94924)
This PR adds E2E test for the new service worker syntax introduced in
https://github.com/vercel/next.js/pull/94923. The tests do the
following:

`service-worker-multiple` tests that you can not have multiple service
workers with the same scope. this is because their file names would
clash; additionally, this is generally a bad practise.

`service-worker-scopes` tests that you register multiple service workers
with different scopes and they will be different files

`service-worker` tests that service workers work when registered using
the new syntax.
2026-07-06 08:57:17 -07:00

13 lines
469 B
JavaScript

'use client'
import { useEffect } from 'react'
export default function Page() {
useEffect(() => {
// Registering two different service-worker files is unsupported: a single app
// serves one worker at /sw.js, so this must fail the build.
navigator.serviceWorker.register(new URL('../lib/pwa-a', import.meta.url))
navigator.serviceWorker.register(new URL('../lib/pwa-b', import.meta.url))
}, [])
return <p id="page">multiple service workers</p>
}