summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/resources/frame-for-getregistrations.html
blob: 7fc35f18914c1345e0f5ccab93305938180fe9eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html>
<title>Service Worker: frame for getRegistrations()</title>
<script>
var scope = 'scope-for-getregistrations';
var script = 'empty-worker.js';
var registration;

navigator.serviceWorker.register(script, { scope: scope })
  .then(function(r) { registration = r; window.parent.postMessage('ready', '*'); })

self.onmessage = function(e) {
  if (e.data == 'unregister') {
    registration.unregister()
      .then(function() {
          e.ports[0].postMessage('unregistered');
        });
  }
};
</script>