summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/back-forward-cache/resources/echo-worker.js
blob: 3e3ecb52e9f13f83053e99e3871e950937ebce05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// On receiving a message from the parent Document, send back a message to the
// parent Document. This is used to wait for worker initialization and test
// that this worker is alive and working.

// For dedicated workers.
self.addEventListener('message', event => {
  postMessage(event.data);
});

// For shared workers.
onconnect = e => {
  const port = e.ports[0];
  port.onmessage = event => {
    port.postMessage(event.data);
  }
};