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>
9 promise_test(function(t
) {
11 'resources/fetch-event-after-navigation-within-page-iframe.html' +
13 var worker
= 'resources/simple-intercept-worker.js';
16 return service_worker_unregister_and_register(t
, worker
, scope
)
18 return wait_for_state(t
, reg
.installing
, 'activated');
20 .then(function() { return with_iframe(scope
); })
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');
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
) {
39 'resources/fetch-event-after-navigation-within-page-iframe.html' +
41 var worker
= 'resources/simple-intercept-worker.js';
44 return service_worker_unregister_and_register(t
, worker
, scope
)
46 return wait_for_state(t
, reg
.installing
, 'activated');
48 .then(function() { return with_iframe(scope
); })
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');
61 return service_worker_unregister_and_done(t
, scope
);
63 }, 'Service Worker should respond to fetch event after the pushState');