зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1319334 - Resolve ready promise *after* updating registration.state properties. r=bkelly
This commit is contained in:
Родитель
531d98d41c
Коммит
e991f36d9f
|
@ -240,10 +240,8 @@ ServiceWorkerRegistrationInfo::Activate()
|
||||||
|
|
||||||
// FIXME(nsm): Unlink appcache if there is one.
|
// FIXME(nsm): Unlink appcache if there is one.
|
||||||
|
|
||||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
|
||||||
swm->CheckPendingReadyPromises();
|
|
||||||
|
|
||||||
// "Queue a task to fire a simple event named controllerchange..."
|
// "Queue a task to fire a simple event named controllerchange..."
|
||||||
|
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||||
nsCOMPtr<nsIRunnable> controllerChangeRunnable =
|
nsCOMPtr<nsIRunnable> controllerChangeRunnable =
|
||||||
NewRunnableMethod<RefPtr<ServiceWorkerRegistrationInfo>>(
|
NewRunnableMethod<RefPtr<ServiceWorkerRegistrationInfo>>(
|
||||||
swm, &ServiceWorkerManager::FireControllerChange, this);
|
swm, &ServiceWorkerManager::FireControllerChange, this);
|
||||||
|
@ -319,6 +317,10 @@ ServiceWorkerRegistrationInfo::AsyncUpdateRegistrationStateProperties(WhichServi
|
||||||
} else {
|
} else {
|
||||||
MOZ_ASSERT(aTransition == TransitionToNextState);
|
MOZ_ASSERT(aTransition == TransitionToNextState);
|
||||||
swm->TransitionServiceWorkerRegistrationWorker(this, aWorker);
|
swm->TransitionServiceWorkerRegistrationWorker(this, aWorker);
|
||||||
|
|
||||||
|
if (aWorker == WhichServiceWorker::WAITING_WORKER) {
|
||||||
|
swm->CheckPendingReadyPromises();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ add_task(function setupPrefs() {
|
||||||
]});
|
]});
|
||||||
});
|
});
|
||||||
|
|
||||||
//var worker;
|
|
||||||
add_task(function* test_worker_ref_gc() {
|
add_task(function* test_worker_ref_gc() {
|
||||||
let registration = yield navigator.serviceWorker.register(
|
let registration = yield navigator.serviceWorker.register(
|
||||||
"lazy_worker.js", { scope: "./lazy_worker_scope_timeout"} )
|
"lazy_worker.js", { scope: "./lazy_worker_scope_timeout"} )
|
||||||
|
@ -45,10 +44,32 @@ add_task(function* test_worker_ref_gc() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ok(true, "Got activated event!");
|
ok(true, "Got activated event!");
|
||||||
|
|
||||||
yield registration.unregister();
|
yield registration.unregister();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* test_worker_ref_gc_ready_promise() {
|
||||||
|
let wait_active = navigator.serviceWorker.ready.then(function(reg) {
|
||||||
|
SpecialPowers.exactGC();
|
||||||
|
ok(reg.active, "Got active worker.");
|
||||||
|
ok(reg.active.state === "activating", "Worker is in activating state");
|
||||||
|
return new Promise(function(res) {
|
||||||
|
reg.active.onstatechange = function(e) {
|
||||||
|
reg.active.onstatechange = null;
|
||||||
|
ok(reg.active.state === "activated", "Worker was activated");
|
||||||
|
res();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
let registration = yield navigator.serviceWorker.register(
|
||||||
|
"lazy_worker.js", { scope: "."} );
|
||||||
|
yield wait_active;
|
||||||
|
yield registration.unregister();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* cleanup() {
|
||||||
yield SpecialPowers.popPrefEnv();
|
yield SpecialPowers.popPrefEnv();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче