summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/sanitize/example_check_and_unregister.html
blob: 8553e442d69a27232ae3369dc8fee883ad963cbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<script>
  function done(exists) {
    parent.postMessage(exists, '*');
  }

  function fail() {
    parent.postMessage("FAIL", '*');
  }

  navigator.serviceWorker.getRegistration(".").then(function(reg) {
    if (reg) {
      reg.unregister().then(done.bind(undefined, true), fail);
    } else {
      dump("getRegistration() returned undefined registration\n");
      done(false);
    }
  }, function(e) {
    dump("getRegistration() failed\n");
    fail();
  });
</script>