mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 23:27:30 +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
|
|
@ -5161,7 +5161,9 @@ WorkerPrivate::ScheduleDeletion(WorkerRanOrNot aRanOrNot)
|
||||||
if (WorkerRan == aRanOrNot) {
|
if (WorkerRan == aRanOrNot) {
|
||||||
nsIThread* currentThread = NS_GetCurrentThread();
|
nsIThread* currentThread = NS_GetCurrentThread();
|
||||||
MOZ_ASSERT(currentThread);
|
MOZ_ASSERT(currentThread);
|
||||||
MOZ_ASSERT(!NS_HasPendingEvents(currentThread));
|
// On the worker thread WorkerRunnable will refuse to run if not nested
|
||||||
|
// on top of a WorkerThreadPrimaryRunnable.
|
||||||
|
Unused << NS_WARN_IF(NS_HasPendingEvents(currentThread));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include "nsIRunnable.h"
|
#include "nsIRunnable.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
|
|
||||||
|
#include "mozilla/CycleCollectedJSContext.h"
|
||||||
#include "mozilla/DebugOnly.h"
|
#include "mozilla/DebugOnly.h"
|
||||||
#include "mozilla/ErrorResult.h"
|
#include "mozilla/ErrorResult.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
|
|
@ -231,6 +232,19 @@ WorkerRunnable::Run()
|
||||||
bool targetIsWorkerThread = mBehavior == WorkerThreadModifyBusyCount ||
|
bool targetIsWorkerThread = mBehavior == WorkerThreadModifyBusyCount ||
|
||||||
mBehavior == WorkerThreadUnchangedBusyCount;
|
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
|
#ifdef DEBUG
|
||||||
MOZ_ASSERT_IF(mCallingCancelWithinRun, targetIsWorkerThread);
|
MOZ_ASSERT_IF(mCallingCancelWithinRun, targetIsWorkerThread);
|
||||||
if (targetIsWorkerThread) {
|
if (targetIsWorkerThread) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue