• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1let promise_func = null;
2let promise = new Promise(resolve => promise_func = resolve);
3
4const SERVICE_WORKER_TEST_CHANNEL_NAME = 'service worker';
5const bc3 = new BroadcastChannel(SERVICE_WORKER_TEST_CHANNEL_NAME);
6bc3.onmessage = e => {
7  bc3.postMessage('done');
8  promise_func();
9};
10bc3.postMessage('from worker');
11
12// Ensure that the worker stays alive for the duration of the test
13self.addEventListener('install', evt => {
14  evt.waitUntil(promise);
15});
16