forked from mirrors/gecko-dev
Bug 1833790 - Ignore StrongWorkerRef callback if mWorkerRef is already cleared. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D180072
This commit is contained in:
parent
185a9f884d
commit
a5cc86ed42
1 changed files with 11 additions and 4 deletions
|
|
@ -75,11 +75,18 @@ nsresult FetchStreamReader::Create(JSContext* aCx, nsIGlobalObject* aGlobal,
|
|||
RefPtr<StrongWorkerRef> workerRef = StrongWorkerRef::Create(
|
||||
workerPrivate, "FetchStreamReader", [streamReader]() {
|
||||
MOZ_ASSERT(streamReader);
|
||||
MOZ_ASSERT(streamReader->mWorkerRef);
|
||||
|
||||
streamReader->CloseAndRelease(
|
||||
streamReader->mWorkerRef->Private()->GetJSContext(),
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
// mAsyncWaitWorkerRef may keep the (same) StrongWorkerRef alive even
|
||||
// when mWorkerRef has already been nulled out by a previous call to
|
||||
// CloseAndRelease, we can just safely ignore this callback then
|
||||
// (as would the CloseAndRelease do on a second call).
|
||||
if (streamReader->mWorkerRef) {
|
||||
streamReader->CloseAndRelease(
|
||||
streamReader->mWorkerRef->Private()->GetJSContext(),
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
} else {
|
||||
MOZ_DIAGNOSTIC_ASSERT(streamReader->mAsyncWaitWorkerRef);
|
||||
}
|
||||
});
|
||||
|
||||
if (NS_WARN_IF(!workerRef)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue