summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/anonymous-iframe/resources/sharedworker-partitioning-helper.js
blob: 8b416c33d72cf55f080e1a1011bdb45718c8f258 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let messages = {};

onconnect = function(e) {
  let port = e.ports[0];

  port.addEventListener('message', function(e) {
    const action = e.data.action;
    const from = e.data.from;

    if (action === 'record') {
      messages[from] = true;
      port.postMessage({ack: from});
    }

    if (action === 'retrieve') {
      port.postMessage({ack: from, messages: messages});
    }
  });

  port.start();
};