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-request-xhr.https.html
<!DOCTYPE html>
<title>Service Worker: the body of FetchEvent using XMLHttpRequest</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<script>
async_test(function(t) {
    var SCOPE = 'resources/fetch-request-xhr-iframe.https.html';
    var SCRIPT = 'resources/fetch-request-xhr-worker.js';
    var host_info = get_host_info();
    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(frame) {
          t.add_cleanup(function() { frame.remove(); });
          var channel = new MessageChannel();
          channel.port1.onmessage = t.step_func(function(e) {
              if (e.data.results === 'finish') {
                service_worker_unregister_and_done(t, SCOPE);
              } else if (e.data.results == 'equals') {
                assert_equals(e.data.got, e.data.expected);
              } else if (e.data.results == 'array_equals') {
                assert_array_equals(e.data.got, e.data.expected, e.data.msg);
              } else if (e.data.results == 'failure') {
                throw e.data.error;
              }
            });
          frame.contentWindow.postMessage({},
                                          host_info['HTTPS_ORIGIN'],
                                          [channel.port2]);
        })
      .catch(unreached_rejection(t));
  }, 'Verify the body of FetchEvent using XMLHttpRequest');
</script>
back to top