summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/background-sync/service_workers/sw.js
blob: c8515ba496420cb033e5ba52a19eaebf814860fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// The source to post setup and completion results to.
let source = null;

function sendMessageToDocument(msg) {
  source.postMessage(msg);
}

// Notify the document that the SW is registered and ready.
self.addEventListener('message', event => {
  source = event.source;
  sendMessageToDocument('ready');
});

self.addEventListener('sync', event => {
  sendMessageToDocument('sync event received!');
});