blob: 4ece274a3e5f2d9693a37a46a5b8097f20d1c6b5 [file] [log] [blame]
<!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.js"></script>
<body>
<script>
// "waiting" is set
async_test(function(t) {
var step = t.step_func.bind(t);
var url = 'resources/empty-worker.js';
var scope = 'resources/blank.html';
var frame;
var registration;
service_worker_unregister(t, scope)
.then(function() { return with_iframe(scope); })
.then(function(f) {
frame = f;
return navigator.serviceWorker.register(url, {scope: scope});
})
.then(function(r) {
registration = r;
return wait_for_state(t, r.installing, 'installed');
}, unreached_rejection(t, 'Registration should not fail'))
.then(function() {
var controller = frame.contentWindow.navigator.serviceWorker.controller;
assert_equals(controller, null);
assert_equals(registration.active, null);
assert_equals(registration.waiting.scriptURL, normalizeURL(url));
assert_equals(registration.installing, null);
// FIXME: Add a test for a frame created after installation.
// Should the existing frame ("frame") block activation?
})
.then(function() {
frame.remove();
return service_worker_unregister_and_done(t, scope);
});
}, 'waiting is set');
</script>