summaryrefslogtreecommitdiffstats
path: root/dom/workers/WorkerRunnable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/workers/WorkerRunnable.cpp')
-rw-r--r--dom/workers/WorkerRunnable.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp
index ec461d3cfb..f5aaa759ef 100644
--- a/dom/workers/WorkerRunnable.cpp
+++ b/dom/workers/WorkerRunnable.cpp
@@ -13,6 +13,7 @@
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/AppShutdown.h"
#include "mozilla/Assertions.h"
+#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Maybe.h"
@@ -224,6 +225,33 @@ 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()) {
+#if (defined(MOZ_COLLECTING_RUNNABLE_TELEMETRY) && defined(DEBUG))
+ // Temporarily set the LogLevel high enough to be certain the messages
+ // are visible.
+ LogModule* module = sWorkerRunnableLog;
+ LogLevel prevLevel = module->Level();
+ if (prevLevel < LogLevel::Error) {
+ module->SetLevel(LogLevel::Error);
+ }
+ MOZ_LOG(sWorkerRunnableLog, LogLevel::Error,
+ ("Runnable '%s' was executed after WorkerThreadPrimaryRunnable "
+ "ended.",
+ "WorkerRunnable"));
+ module->SetLevel(prevLevel);
+#endif
+ MOZ_DIAGNOSTIC_ASSERT(false,
+ "A WorkerRunnable was executed after "
+ "WorkerThreadPrimaryRunnable ended.");
+
+ return NS_OK;
+ }
+ }
+
#ifdef DEBUG
MOZ_ASSERT_IF(mCallingCancelWithinRun, targetIsWorkerThread);
if (targetIsWorkerThread) {