mirror of
https://github.com/ManchildProductions/UXP-Fixed.git
synced 2026-06-20 18:08:43 +00:00
66 lines
2.3 KiB
HTML
66 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<title>ServiceWorker: navigator.serviceWorker.waiting</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="resources/test-helpers.sub.js"></script>
|
|
<body>
|
|
<script>
|
|
|
|
promise_test(function(t) {
|
|
var scope =
|
|
'resources/fetch-event-after-navigation-within-page-iframe.html' +
|
|
'?hashchange';
|
|
var worker = 'resources/simple-intercept-worker.js';
|
|
var frame;
|
|
|
|
return service_worker_unregister_and_register(t, worker, scope)
|
|
.then(function(reg) {
|
|
return wait_for_state(t, reg.installing, 'activated');
|
|
})
|
|
.then(function() { return with_iframe(scope); })
|
|
.then(function(f) {
|
|
frame = f;
|
|
return frame.contentWindow.fetch_url('simple.txt');
|
|
})
|
|
.then(function(response) {
|
|
assert_equals(response, 'intercepted by service worker');
|
|
frame.contentWindow.location.hash = 'foo';
|
|
return frame.contentWindow.fetch_url('simple.txt');
|
|
})
|
|
.then(function(response) {
|
|
assert_equals(response, 'intercepted by service worker');
|
|
frame.remove();
|
|
return service_worker_unregister_and_done(t, scope);
|
|
})
|
|
}, 'Service Worker should respond to fetch event after the hash changes');
|
|
|
|
promise_test(function(t) {
|
|
var scope =
|
|
'resources/fetch-event-after-navigation-within-page-iframe.html' +
|
|
'?pushState';
|
|
var worker = 'resources/simple-intercept-worker.js';
|
|
var frame;
|
|
|
|
return service_worker_unregister_and_register(t, worker, scope)
|
|
.then(function(reg) {
|
|
return wait_for_state(t, reg.installing, 'activated');
|
|
})
|
|
.then(function() { return with_iframe(scope); })
|
|
.then(function(f) {
|
|
frame = f;
|
|
return frame.contentWindow.fetch_url('simple.txt');
|
|
})
|
|
.then(function(response) {
|
|
assert_equals(response, 'intercepted by service worker');
|
|
frame.contentWindow.history.pushState('', '', 'bar');
|
|
return frame.contentWindow.fetch_url('simple.txt');
|
|
})
|
|
.then(function(response) {
|
|
assert_equals(response, 'intercepted by service worker');
|
|
frame.remove();
|
|
return service_worker_unregister_and_done(t, scope);
|
|
})
|
|
}, 'Service Worker should respond to fetch event after the pushState');
|
|
|
|
</script>
|