Bug 1186856 ServiceWorker .register() should always stop current registration from uninstalling. r=jdm

This commit is contained in:
Ben Kelly 2015-11-19 17:42:09 -08:00
parent 8d6994d6b9
commit 5d8546a611
3 changed files with 9 additions and 17 deletions

View File

@ -945,10 +945,10 @@ public:
mRegistration = swm->GetRegistration(mPrincipal, mScope);
if (mRegistration) {
mRegistration->mPendingUninstall = false;
RefPtr<ServiceWorkerInfo> newest = mRegistration->Newest();
if (newest && mScriptSpec.Equals(newest->ScriptSpec()) &&
mScriptSpec.Equals(mRegistration->mScriptSpec)) {
mRegistration->mPendingUninstall = false;
swm->StoreRegistration(mPrincipal, mRegistration);
Succeed();

View File

@ -1,8 +0,0 @@
[unregister-then-register-new-script.https.html]
type: testharness
[Registering a new script URL while an unregistered registration is in use]
expected: FAIL
[Registering a new script URL that fails to install does not resurrect an unregistered registration]
expected: FAIL

View File

@ -103,14 +103,14 @@ async_test(function(t) {
return with_iframe(scope);
})
.then(function(frame) {
assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
null,
'document should not load with a controller');
assert_equals(frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
normalizeURL(worker_url),
'register() should always abort uninstalling the registration');
frame.remove();
t.done();
})
.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');
async_test(function(t) {
@ -144,9 +144,9 @@ async_test(function(t) {
return with_iframe(scope);
})
.then(function(frame) {
assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
null,
'document should not load with a controller');
assert_equals(frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
normalizeURL(worker_url),
'register() should always abort uninstalling the registration');
frame.remove();
return registration.unregister();
})
@ -154,6 +154,6 @@ async_test(function(t) {
t.done();
})
.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');
</script>