tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

register.html (798B)


      1 <!DOCTYPE html>
      2 <script>
      3  function ok(v, msg) {
      4    window.parent.postMessage({status: "ok", result: !!v, message: msg}, "*");
      5  }
      6 
      7  var isDone = false;
      8  function done(reg) {
      9    if (!isDone) {
     10      ok(reg.waiting || reg.active,
     11         "Either active or waiting worker should be available.");
     12      window.parent.postMessage({status: "registrationdone"}, "*");
     13      isDone = true;
     14    }
     15  }
     16 
     17  navigator.serviceWorker.register("sw.js", {scope: "."})
     18    .then(function(registration) {
     19      if (registration.installing) {
     20        registration.installing.onstatechange = function(e) {
     21          done(registration);
     22        };
     23      } else {
     24        done(registration);
     25      }
     26    }).catch(function(e) {
     27      window.parent.postMessage({status: "registrationfailed"}, "*");
     28    });
     29 </script>