tor-browser

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

update-after-oneday.https.html (2148B)


      1 <!DOCTYPE html>
      2 <!-- This test requires browser to treat all registrations are older than 24 hours.
      3     Preference 'dom.serviceWorkers.testUpdateOverOneDay' should be enabled during
      4     the execution of the test -->
      5 <title>Service Worker: Functional events should trigger update if last update time is over 24 hours</title>
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script src="resources/test-helpers.sub.js"></script>
      9 <script>
     10 
     11 promise_test(function(t) {
     12    var script = 'resources/update-nocookie-worker.py';
     13    var scope = 'resources/update/update-after-oneday.https.html';
     14    var expected_url = normalizeURL(script);
     15    var registration;
     16    var frame;
     17 
     18    return service_worker_unregister_and_register(t, expected_url, scope)
     19      .then(function(r) {
     20          t.add_cleanup(function() {
     21              return service_worker_unregister(t, scope);
     22            });
     23 
     24          registration = r;
     25          return wait_for_state(t, registration.installing, 'activated');
     26        })
     27      .then(function() { return with_iframe(scope); })
     28      .then(function(f) {
     29          frame = f;
     30          return wait_for_update(t, registration);
     31        })
     32      .then(function() {
     33          assert_equals(registration.installing.scriptURL, expected_url,
     34                        'new installing should be set after update resolves.');
     35          assert_equals(registration.waiting, null,
     36                        'waiting should still be null after update resolves.');
     37          assert_equals(registration.active.scriptURL, expected_url,
     38                        'active should still exist after update found.');
     39          return wait_for_state(t, registration.installing, 'installed');
     40        })
     41      .then(function() {
     42          // Trigger a non-navigation fetch event
     43          frame.contentWindow.load_image(normalizeURL('resources/update/sample'));
     44          return wait_for_update(t, registration);
     45       })
     46       .then(function() {
     47          frame.remove();
     48       })
     49  }, 'Update should be triggered after a functional event when last update time is over 24 hours');
     50 
     51 </script>