summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/fetch/https/register.html
blob: fa666fe95734185a853e2eab3130e2c98a99aedf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<script>
  function ok(v, msg) {
    window.parent.postMessage({status: "ok", result: !!v, message: msg}, "*");
  }

  function done(reg) {
    ok(reg.active, "The active worker should be available.");
    window.parent.postMessage({status: "registrationdone"}, "*");
  }

  navigator.serviceWorker.ready.then(reg => {
    return window.caches.open("cache").then(function(cache) {
      var synth = new Response('<!DOCTYPE html><script>window.parent.postMessage({status: "done-synth-window"}, "*");</scri' + 'pt>',
                               {headers:{"Content-Type": "text/html"}});
      return cache.put('synth-window.html', synth).then(_ => done(reg));
    });
  });
  navigator.serviceWorker.register("https_test.js", {scope: "."});
</script>