blob: 7459f592861bee94ea55c66b080de46afc0a6b7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<!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>
|