https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 7b89105f042755ba3ef1c346cba087cfb758d0d6 authored by Luke Bjerring on 23 March 2018, 17:36:39 UTC
Support partial dictionaries
Tip revision: 7b89105
waiting.https.html
<!DOCTYPE html>
<title>ServiceWorker: navigator.serviceWorker.waiting</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<body>
<script>
promise_test(t => {
    var script = 'resources/empty-worker.js';
    var scope = 'resources/blank.html';
    var frame;
    var registration;

    return service_worker_unregister(t, scope)
      .then(() => { return with_iframe(scope); })
      .then(f => {
          frame = f;
          return navigator.serviceWorker.register(script, {scope: scope});
        })
      .then(r => {
          registration = r;
          add_result_callback(() => { registration.unregister(); });
          return wait_for_state(t, r.installing, 'installed');
        })
      .then(() => {
          const controller =
            frame.contentWindow.navigator.serviceWorker.controller;
          assert_equals(controller, null, '.controller');

          assert_equals(registration.active, null, '.active');
          assert_equals(registration.waiting.state, 'installed', '.waiting');
          assert_equals(registration.installing, null, '.installing');
        })
      .then(() => {
          frame.remove();
          return registration.unregister();
        });
  }, 'waiting is set after installation');
</script>
</body>
back to top