tor-browser

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

index.html (2749B)


      1 <!--
      2  Any copyright is dedicated to the Public Domain.
      3  http://creativecommons.org/publicdomain/zero/1.0/
      4 -->
      5 <!DOCTYPE HTML>
      6 <html>
      7 <head>
      8  <title>Bug 94048 - test install event.</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <p id="display"></p>
     14 <div id="content" style="display: none"></div>
     15 <pre id="test"></pre>
     16 <script class="testbody" type="text/javascript">
     17 
     18  // Make sure to use good, unique messages, since the actual expression will not show up in test results.
     19  function my_ok(result, msg) {
     20    parent.postMessage({status: "ok", result, message: msg}, "*");
     21  }
     22 
     23  function finish() {
     24    parent.postMessage({status: "done"}, "*");
     25  }
     26 
     27  navigator.serviceWorker.ready.then(function(swr) {
     28    my_ok(swr.scope.match(/serviceworkers\/test\/control$/),
     29          "This page should be controlled by upper level registration");
     30    my_ok(swr.installing == undefined,
     31          "Upper level registration should not have a installing worker.");
     32    if (navigator.serviceWorker.controller) {
     33      // We are controlled.
     34      // Register a new worker for this sub-scope. After that, controller should still be for upper level, but active should change to be this scope's.
     35      navigator.serviceWorker.register("../worker2.js", { scope: "./" }).then(function(e) {
     36        my_ok("installing" in e, "ServiceWorkerRegistration.installing exists.");
     37        my_ok(e.installing instanceof ServiceWorker, "ServiceWorkerRegistration.installing is a ServiceWorker.");
     38 
     39        my_ok("waiting" in e, "ServiceWorkerRegistration.waiting exists.");
     40        my_ok("active" in e, "ServiceWorkerRegistration.active exists.");
     41 
     42        my_ok(e.installing &&
     43              e.installing.scriptURL.match(/worker2.js$/),
     44              "Installing is serviceworker/controller");
     45 
     46        my_ok("scope" in e, "ServiceWorkerRegistration.scope exists.");
     47        my_ok(e.scope.match(/serviceworkers\/test\/controller\/$/), "Scope is serviceworker/test/controller " + e.scope);
     48 
     49        my_ok("unregister" in e, "ServiceWorkerRegistration.unregister exists.");
     50 
     51        my_ok(navigator.serviceWorker.controller.scriptURL.match(/worker\.js$/),
     52              "Controller is still worker.js");
     53 
     54        e.unregister().then(function(result) {
     55          my_ok(result, "Unregistering the SW should succeed");
     56          finish();
     57        }, function(error) {
     58          dump("Error unregistering the SW: " + error + "\n");
     59        });
     60      });
     61    } else {
     62      my_ok(false, "Should've been controlled!");
     63      finish();
     64    }
     65  }).catch(function(e) {
     66    my_ok(false, "Some test threw an error " + e);
     67    finish();
     68  });
     69 </script>
     70 </pre>
     71 </body>
     72 </html>