mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 08:42:13 +00:00
Bug 1425975 P8 Fix unregister-then-register-new-script.https.html to not race iframe.remove() and expect resurrection on failed scripts. r=asuth
This commit is contained in:
parent
c67746c9b2
commit
6bbdc69490
@ -90,9 +90,12 @@ async_test(function(t) {
|
|||||||
return registration.unregister();
|
return registration.unregister();
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
// Step 5.1 of Register clears the uninstall flag before fetching
|
||||||
|
// the script:
|
||||||
|
//
|
||||||
|
// https://w3c.github.io/ServiceWorker/#register-algorithm
|
||||||
var promise = navigator.serviceWorker.register('this-will-404',
|
var promise = navigator.serviceWorker.register('this-will-404',
|
||||||
{ scope: scope });
|
{ scope: scope });
|
||||||
iframe.remove();
|
|
||||||
return promise;
|
return promise;
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
@ -100,17 +103,28 @@ async_test(function(t) {
|
|||||||
assert_unreached('register should reject the promise');
|
assert_unreached('register should reject the promise');
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
|
assert_equals(registration.installing, null,
|
||||||
|
'registration.installing');
|
||||||
|
assert_equals(registration.waiting, null,
|
||||||
|
'registration.waiting');
|
||||||
|
assert_equals(registration.active.scriptURL, normalizeURL(worker_url),
|
||||||
|
'registration.active');
|
||||||
|
iframe.remove();
|
||||||
return with_iframe(scope);
|
return with_iframe(scope);
|
||||||
})
|
})
|
||||||
.then(function(frame) {
|
.then(function(frame) {
|
||||||
assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
|
assert_equals(
|
||||||
null,
|
frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
|
||||||
'document should not load with a controller');
|
normalizeURL(worker_url),
|
||||||
|
'the original worker should control a new document');
|
||||||
frame.remove();
|
frame.remove();
|
||||||
|
return registration.unregister();
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
t.done();
|
t.done();
|
||||||
})
|
})
|
||||||
.catch(unreached_rejection(t));
|
.catch(unreached_rejection(t));
|
||||||
}, 'Registering a new script URL that 404s does not resurrect an ' +
|
}, 'Registering a new script URL that 404s does resurrect an ' +
|
||||||
'unregistered registration');
|
'unregistered registration');
|
||||||
|
|
||||||
async_test(function(t) {
|
async_test(function(t) {
|
||||||
@ -131,9 +145,12 @@ async_test(function(t) {
|
|||||||
return registration.unregister();
|
return registration.unregister();
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
// Step 5.1 of Register clears the uninstall flag before firing
|
||||||
|
// the install event:
|
||||||
|
//
|
||||||
|
// https://w3c.github.io/ServiceWorker/#register-algorithm
|
||||||
var promise = navigator.serviceWorker.register(
|
var promise = navigator.serviceWorker.register(
|
||||||
'resources/reject-install-worker.js', { scope: scope });
|
'resources/reject-install-worker.js', { scope: scope });
|
||||||
iframe.remove();
|
|
||||||
return promise;
|
return promise;
|
||||||
})
|
})
|
||||||
.then(function(r) {
|
.then(function(r) {
|
||||||
@ -141,12 +158,20 @@ async_test(function(t) {
|
|||||||
return wait_for_state(t, r.installing, 'redundant');
|
return wait_for_state(t, r.installing, 'redundant');
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
assert_equals(registration.installing, null,
|
||||||
|
'registration.installing');
|
||||||
|
assert_equals(registration.waiting, null,
|
||||||
|
'registration.waiting');
|
||||||
|
assert_equals(registration.active.scriptURL, normalizeURL(worker_url),
|
||||||
|
'registration.active');
|
||||||
|
iframe.remove();
|
||||||
return with_iframe(scope);
|
return with_iframe(scope);
|
||||||
})
|
})
|
||||||
.then(function(frame) {
|
.then(function(frame) {
|
||||||
assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
|
assert_equals(
|
||||||
null,
|
frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
|
||||||
'document should not load with a controller');
|
normalizeURL(worker_url),
|
||||||
|
'the original worker should control a new document');
|
||||||
frame.remove();
|
frame.remove();
|
||||||
return registration.unregister();
|
return registration.unregister();
|
||||||
})
|
})
|
||||||
@ -154,6 +179,6 @@ async_test(function(t) {
|
|||||||
t.done();
|
t.done();
|
||||||
})
|
})
|
||||||
.catch(unreached_rejection(t));
|
.catch(unreached_rejection(t));
|
||||||
}, 'Registering a new script URL that fails to install does not resurrect ' +
|
}, 'Registering a new script URL that fails to install does resurrect ' +
|
||||||
'an unregistered registration');
|
'an unregistered registration');
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user