Revision 614c1ccac5f885e58444fe74a2aedd120d2ca73f authored by Marcos Cáceres on 21 August 2018, 05:04:44 UTC, committed by GitHub on 21 August 2018, 05:04:44 UTC
1 parent 4797b9c
Raw File
data-url-shared-window.html
<!DOCTYPE html>
<head>
<title>data URL shared worker</title>
</head>
<body>
<script>
onmessage = event => {
  const port = event.ports[0];
  // This shared worker counts the total number of connected documents and
  // notifies the connector of it.
  const kScript =
      "onconnect = e => {" +
      "  if (self.count === undefined)" +
      "    self.count = 0;" +
      "  self.count++;" +
      "  e.ports[0].postMessage(self.count);" +
      "};";
  const worker = new SharedWorker('data:application/javascript,' + kScript);
  worker.port.onmessage = e => port.postMessage(e.data);
};

window.opener.postMessage('LOADED', '*');
</script>
</body>
</html>
back to top