зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1557732 - Don't create worker for discarded document. r=dom-workers-and-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D62608 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6d32b7af50
Коммит
88ad97f84e
|
@ -29,6 +29,16 @@ already_AddRefed<Worker> Worker::Constructor(const GlobalObject& aGlobal,
|
|||
ErrorResult& aRv) {
|
||||
JSContext* cx = aGlobal.Context();
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> globalObject =
|
||||
do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
||||
if (globalObject->AsInnerWindow() &&
|
||||
!globalObject->AsInnerWindow()->IsCurrentInnerWindow()) {
|
||||
aRv.ThrowInvalidStateError(
|
||||
"Cannot create worker for a going to be discarded document");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<WorkerPrivate> workerPrivate = WorkerPrivate::Constructor(
|
||||
cx, aScriptURL, false /* aIsChromeWorker */, WorkerTypeDedicated,
|
||||
aOptions.mName, VoidCString(), nullptr /*aLoadInfo */, aRv);
|
||||
|
@ -36,9 +46,6 @@ already_AddRefed<Worker> Worker::Constructor(const GlobalObject& aGlobal,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> globalObject =
|
||||
do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
||||
RefPtr<Worker> worker = new Worker(globalObject, workerPrivate.forget());
|
||||
return worker.forget();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче