tor-browser

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

index.html (2375B)


      1 <html>
      2  <head></head>
      3  <body>
      4      <script type="text/javascript">
      5          var expectedEvents = 2;
      6          function eventReceived() {
      7            window.parent.postMessage({ type: "check", status: expectedEvents > 0, msg: "updatefound received" }, "*");
      8 
      9            if (--expectedEvents) {
     10              window.parent.postMessage({ type: "finish" }, "*");
     11            }
     12          }
     13 
     14          navigator.serviceWorker.getRegistrations().then(function(a) {
     15            window.parent.postMessage({ type: "check", status: Array.isArray(a),
     16                                        msg: "getRegistrations returns an array" }, "*");
     17            window.parent.postMessage({ type: "check", status: !!a.length,
     18                                        msg: "getRegistrations returns an array with 1 item" }, "*");
     19            for (var i = 0; i < a.length; ++i) {
     20              window.parent.postMessage({ type: "check", status: a[i] instanceof ServiceWorkerRegistration,
     21                                          msg: "getRegistrations returns an array of ServiceWorkerRegistration objects" }, "*");
     22              if (a[i].scope.match(/simpleregister\//)) {
     23                a[i].onupdatefound = function(e) {
     24                  eventReceived();
     25                }
     26              }
     27            }
     28          });
     29 
     30          navigator.serviceWorker.getRegistration('http://mochi.test:8888/tests/dom/serviceworkers/test/simpleregister/')
     31            .then(function(a) {
     32            window.parent.postMessage({ type: "check", status: a instanceof ServiceWorkerRegistration,
     33                                        msg: "getRegistration returns a ServiceWorkerRegistration" }, "*");
     34            a.onupdatefound = function(e) {
     35              eventReceived();
     36            }
     37          });
     38 
     39          navigator.serviceWorker.getRegistration('http://www.something_else.net/')
     40            .then(function(a) {
     41            window.parent.postMessage({ type: "check", status: false,
     42                                        msg: "getRegistration should throw for security error!" }, "*");
     43          }, function(a) {
     44            window.parent.postMessage({ type: "check", status: true,
     45                                        msg: "getRegistration should throw for security error!" }, "*");
     46          });
     47 
     48          window.parent.postMessage({ type: "ready" }, "*");
     49      </script>
     50  </body>
     51 </html>