summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/fetch-event-network-error.https.html
blob: f6a3d0776e59fbbed8c790b53352781928ac951f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<title>Service Worker: Fetch event network error</title>
<script src="/resources/testharness.js"></script>
<script src="resources/testharness-helpers.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-network-error-controllee-iframe.html';
    var script = 'resources/fetch-event-network-error-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);
        });
  }, 'Rejecting the fetch event or using preventDefault() causes a network ' +
     'error');
</script>