File: index.html

package info (click to toggle)
node-cross-fetch 4.0.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 548 kB
  • sloc: javascript: 1,017; makefile: 122; sh: 50
file content (37 lines) | stat: -rw-r--r-- 983 bytes parent folder | download
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
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <link href="../../../node_modules/mocha/mocha.css" rel="stylesheet" />
</head>

<body>
  <div id="mocha">
    <h1>Please check console!</h1>
  </div>

  <script>
  const registration = navigator.serviceWorker.register('/test/fetch-api/service-worker/sw.bundle.js', {
    scope: '/test/fetch-api/service-worker/'
  })
    .catch(err => console.error(`Registration failed with ${error}`));

  const logChannel = new BroadcastChannel('sw-logger');
  logChannel.addEventListener('message', event => {
    console.log(...event.data);
  });

  const resChannel = new BroadcastChannel('sw-result');
  resChannel.addEventListener('message', event => {
    window.__mochaResult__ = JSON.parse(event.data);

    // Avoids manually unregister to see output in the console
    registration
      .then(reg => reg.unregister())
      .catch(err => console.error(`Unregistration failed with ${error}`));
  });
  </script>
</body>

</html>