https://github.com/web-platform-tests/wpt
Raw File
Tip revision: bf0b0da813543d6f58646c2b65a399b417a4d4ba authored by Anne van Kesteren on 11 August 2016, 12:41:28 UTC
WIP
Tip revision: bf0b0da
fetch-event-respond-with-argument.https.html
<!DOCTYPE html>
<title>Service Worker: FetchEvent.respondWith() argument type test.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<script>
var resolve_test_done;

var test_done_promise = new Promise(function(resolve) {
    resolve_test_done = resolve;
  });

// Called by the child frame.
function notify_test_done(result) {
  resolve_test_done(result);
}

promise_test(function(t) {
    var scope = 'resources/fetch-event-respond-with-argument-iframe.html';
    var script = 'resources/fetch-event-respond-with-argument-worker.js';
    var frame;

    return service_worker_unregister_and_register(t, script, scope)
      .then(function(registration) {
          return wait_for_state(t, registration.installing, 'activated');
        })
      .then(function() {
          return with_iframe(scope);
        })
      .then(function(f) {
          frame = f;
          return test_done_promise;
        })
      .then(function(result) {
          frame.remove();
          assert_equals(result, 'PASS');
          return service_worker_unregister_and_done(t, scope);
        });
  }, 'respondWith() takes either a Response or a promise that resolves ' +
     'with a Response. Other values should raise a network error.');
</script>
back to top