From c0b696292a42fb40074511e3b981545b84ce042d Mon Sep 17 00:00:00 2001 From: Andrew Sutherland Date: Mon, 17 Apr 2023 23:57:53 +0000 Subject: [PATCH] Bug 1820210 - Worker improvements. r=dom-worker-reviewers,edenchuang Differential Revision: https://phabricator.services.mozilla.com/D171779 --- dom/workers/Worker.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dom/workers/Worker.cpp b/dom/workers/Worker.cpp index abddfa11c8a7..3452859c4c6d 100644 --- a/dom/workers/Worker.cpp +++ b/dom/workers/Worker.cpp @@ -86,6 +86,8 @@ void Worker::PostMessage(JSContext* aCx, JS::Handle aMessage, if (!mWorkerPrivate || mWorkerPrivate->ParentStatusProtected() > Running) { return; } + RefPtr workerPrivate = mWorkerPrivate; + Unused << workerPrivate; JS::Rooted transferable(aCx, JS::UndefinedValue()); @@ -145,6 +147,10 @@ void Worker::PostMessage(JSContext* aCx, JS::Handle aMessage, runnable->Write(aCx, aMessage, transferable, clonePolicy, aRv); + if (!mWorkerPrivate || mWorkerPrivate->ParentStatusProtected() > Running) { + return; + } + if (isTimelineRecording) { end = MakeUnique( NS_IsMainThread()