Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / serviceworker / fetch-event-after-navigation-within-page.html
blobd30eb7cc4a009939d0633ec53ee77152cfbb5b36
1 <!DOCTYPE html>
2 <title>ServiceWorker: navigator.serviceWorker.waiting</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script>
6 <body>
7 <script>
9 promise_test(function(t) {
10 var scope =
11 'resources/fetch-event-after-navigation-within-page-iframe.html' +
12 '?hashchange';
13 var worker = 'resources/simple-intercept-worker.js';
14 var frame;
16 return service_worker_unregister_and_register(t, worker, scope)
17 .then(function(reg) {
18 return wait_for_state(t, reg.installing, 'activated');
20 .then(function() { return with_iframe(scope); })
21 .then(function(f) {
22 frame = f;
23 return frame.contentWindow.fetch_url('simple.txt');
25 .then(function(response) {
26 assert_equals(response, 'intercepted by service worker');
27 frame.contentWindow.location.hash = 'foo';
28 return frame.contentWindow.fetch_url('simple.txt');
30 .then(function(response) {
31 assert_equals(response, 'intercepted by service worker');
32 frame.remove();
33 return service_worker_unregister_and_done(t, scope);
35 }, 'Service Worker should respond to fetch event after the hash changes');
37 promise_test(function(t) {
38 var scope =
39 'resources/fetch-event-after-navigation-within-page-iframe.html' +
40 '?pushState';
41 var worker = 'resources/simple-intercept-worker.js';
42 var frame;
44 return service_worker_unregister_and_register(t, worker, scope)
45 .then(function(reg) {
46 return wait_for_state(t, reg.installing, 'activated');
48 .then(function() { return with_iframe(scope); })
49 .then(function(f) {
50 frame = f;
51 return frame.contentWindow.fetch_url('simple.txt');
53 .then(function(response) {
54 assert_equals(response, 'intercepted by service worker');
55 frame.contentWindow.history.pushState('', '', 'bar');
56 return frame.contentWindow.fetch_url('simple.txt');
58 .then(function(response) {
59 assert_equals(response, 'intercepted by service worker');
60 frame.remove();
61 return service_worker_unregister_and_done(t, scope);
63 }, 'Service Worker should respond to fetch event after the pushState');
65 </script>