tor-browser

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

update.https.html (1576B)


      1 <!DOCTYPE html>
      2 <title>ServiceWorkerGlobalScope: update</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 <script>
      7 
      8 promise_test(function(t) {
      9    var script = 'resources/update-worker.py';
     10    var scope = 'resources/scope/update';
     11    var registration;
     12    var frame1;
     13 
     14    return service_worker_unregister_and_register(t, script, scope)
     15      .then(function(r) {
     16          t.add_cleanup(function() {
     17              return service_worker_unregister(t, scope);
     18            });
     19 
     20          registration = r;
     21          return wait_for_state(t, registration.installing, 'activated');
     22        })
     23      .then(function() { return with_iframe(scope); })
     24      .then(function(f) {
     25          frame1 = f;
     26          registration.active.postMessage('update');
     27          return wait_for_update(t, registration);
     28        })
     29      .then(function() { return with_iframe(scope); })
     30      .then(function(frame2) {
     31          var expected_events_seen = [
     32            'updatefound',  // by register().
     33            'activate',
     34            'fetch',
     35            'message',
     36            'updatefound',  // by update() in the message handler.
     37            'fetch',
     38          ];
     39          assert_equals(
     40              frame2.contentDocument.body.textContent,
     41              expected_events_seen.toString(),
     42              'events seen by the worker');
     43          frame1.remove();
     44          frame2.remove();
     45        });
     46  }, 'Update a registration on ServiceWorkerGlobalScope');
     47 
     48 </script>