Skip to content
Snippets Groups Projects
Commit 4929e1cf authored by Jens Stutte's avatar Jens Stutte
Browse files

Bug 1833790 - Ignore StrongWorkerRef callback if mWorkerRef is already...

Bug 1833790 - Ignore StrongWorkerRef callback if mWorkerRef is already cleared. r=dom-worker-reviewers,asuth, a=dmeehan

Differential Revision: https://phabricator.services.mozilla.com/D180072
parent 61bc19ae
No related branches found
No related tags found
No related merge requests found
......@@ -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)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment