feat: service worker preload scripts for improved extensions support (#44411)
* feat: preload scripts for service workers * feat: service worker IPC * test: service worker preload scripts and ipc
This commit is contained in:
parent
bc22ee7897
commit
26da3c5d6e
67 changed files with 2103 additions and 298 deletions
|
@ -107,8 +107,6 @@ Returns `Promise<ServiceWorkerMain>` - Resolves with the service worker when it'
|
|||
|
||||
Starts the service worker or does nothing if already running.
|
||||
|
||||
<!-- TODO(samuelmaddock): extend example to send IPC after starting worker -->
|
||||
|
||||
```js
|
||||
const { app, session } = require('electron')
|
||||
const { serviceWorkers } = session.defaultSession
|
||||
|
@ -120,7 +118,8 @@ app.on('browser-window-created', async (event, window) => {
|
|||
for (const scope of workerScopes) {
|
||||
try {
|
||||
// Ensure worker is started
|
||||
await serviceWorkers.startWorkerForScope(scope)
|
||||
const serviceWorker = await serviceWorkers.startWorkerForScope(scope)
|
||||
serviceWorker.send('window-created', { windowId: window.id })
|
||||
} catch (error) {
|
||||
console.error(`Failed to start service worker for ${scope}`)
|
||||
console.error(error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue