tor-browser

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

controller-on-load.https.html (1616B)


      1 <!DOCTYPE html>
      2 <title>Service Worker: Controller on load</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="resources/test-helpers.sub.js"></script>
      6 <body>
      7 <script>
      8 promise_test(function(t) {
      9    var url = 'resources/empty-worker.js';
     10    var scope = 'resources/blank.html';
     11    var registration;
     12    var controller;
     13    var frame;
     14    return service_worker_unregister_and_register(t, url, scope)
     15      .then(function(swr) {
     16          t.add_cleanup(function() {
     17              return service_worker_unregister(t, scope);
     18            });
     19 
     20          registration = swr;
     21          return wait_for_state(t, registration.installing, 'activated');
     22        })
     23      .then(function() {
     24          return with_iframe(scope);
     25        })
     26      .then(function(f) {
     27          frame = f;
     28          var w = frame.contentWindow;
     29          controller = w.navigator.serviceWorker.controller;
     30          assert_true(controller instanceof w.ServiceWorker,
     31                      'controller should be a ServiceWorker object');
     32          assert_equals(controller.scriptURL, normalizeURL(url));
     33 
     34          // objects from different windows should not be equal
     35          assert_not_equals(controller, registration.active);
     36 
     37          return w.navigator.serviceWorker.getRegistration();
     38        })
     39      .then(function(frameRegistration) {
     40          // SW objects from same window should be equal
     41          assert_equals(frameRegistration.active, controller);
     42          frame.remove();
     43        });
     44 }, 'controller is set for a controlled document');
     45 </script>
     46 </body>