mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
[DOM] Check if WorkerRunnable::Run runs on top of WorkerThreadPrimaryRunnable::Run in a worker thread.
This commit is contained in:
parent
58525f05f2
commit
d1b0f59de4
2 changed files with 17 additions and 1 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsIRunnable.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
|
@ -231,6 +232,19 @@ WorkerRunnable::Run()
|
|||
bool targetIsWorkerThread = mBehavior == WorkerThreadModifyBusyCount ||
|
||||
mBehavior == WorkerThreadUnchangedBusyCount;
|
||||
|
||||
if (targetIsWorkerThread) {
|
||||
// On a worker thread, a WorkerRunnable should only run when there is an
|
||||
// underlying WorkerThreadPrimaryRunnable active, which means we should
|
||||
// find a CycleCollectedJSContext.
|
||||
if (!CycleCollectedJSContext::Get()) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(false,
|
||||
"A WorkerRunnable was executed after "
|
||||
"WorkerThreadPrimaryRunnable ended.");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
MOZ_ASSERT_IF(mCallingCancelWithinRun, targetIsWorkerThread);
|
||||
if (targetIsWorkerThread) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue