MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / register

Function register

javascript/grid-ui/src/serviceWorker.ts:42–75  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

40)
41
42export function register (config) {
43 if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
44 // The URL constructor is available in all browsers that support SW.
45 // @ts-ignore
46 const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href)
47 if (publicUrl.origin !== window.location.origin) {
48 // Our service worker won't work if PUBLIC_URL is on a different origin
49 // from what our page is served on. This might happen if a CDN is used to
50 // serve assets; see https://github.com/facebook/create-react-app/issues/2374
51 return
52 }
53
54 window.addEventListener('load', () => {
55 const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`
56
57 if (isLocalhost) {
58 // This is running on localhost. Let's check if a service worker still exists or not.
59 checkValidServiceWorker(swUrl, config)
60
61 // Add some additional logging to localhost, pointing developers to the
62 // service worker/PWA documentation.
63 navigator.serviceWorker.ready.then(() => {
64 console.log(
65 'This web app is being served cache-first by a service ' +
66 'worker. To learn more, visit https://bit.ly/CRA-PWA'
67 )
68 })
69 } else {
70 // Is not localhost. Just register service worker
71 registerValidSW(swUrl, config)
72 }
73 })
74 }
75}
76
77function registerValidSW (swUrl, config) {
78 navigator.serviceWorker

Callers

nothing calls this directly

Calls 3

checkValidServiceWorkerFunction · 0.85
registerValidSWFunction · 0.85
logMethod · 0.65

Tested by

no test coverage detected