summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/resources/sandboxed-iframe-navigator-serviceworker-iframe.html
blob: 1d682e47ef5e2aede76c8cdcecb61833d7330051 (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
<script>
window.onmessage = function(e) {
  const id = e.data['id'];
  try {
    var sw = window.navigator.serviceWorker;
  } catch (e) {
    window.top.postMessage({
        id: id,
        result: 'navigator.serviceWorker failed: ' + e.name
      }, '*');
    return;
  }

  window.navigator.serviceWorker.getRegistration()
    .then(function() {
        window.top.postMessage({id: id, result:'ok'}, '*');
      })
    .catch(function(e) {
        window.top.postMessage({
            id: id,
            result: 'getRegistration() failed: ' + e.name
          }, '*');
        });
};
</script>