bug 1328964 restore fix for crash in runnable after thread shutdown
bug 1315446 r?jib
Lost in rebase of "part 2 - Worklet Thread - second part" across
https://hg.mozilla.org/mozilla-central/rev/df94a2bfc2436b00a776c9083cc3ae4dda01a1fe#l1.12
Addresses https://reviewboard.mozilla.org/r/199434/#comment296312
MozReview-Commit-ID: BEOsIwz8XZ8
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -6194,17 +6194,22 @@ nsContentUtils::GetCurrentJSContext()
JSContext *
nsContentUtils::GetCurrentJSContextForThread()
{
MOZ_ASSERT(IsInitialized());
if (MOZ_LIKELY(NS_IsMainThread())) {
return GetCurrentJSContext();
}
- return CycleCollectedJSContext::Get()->GetWorkerWorkletSafeContext();
+ CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
+ if (!ccjscx) {
+ return nullptr;
+ }
+
+ return ccjscx->GetWorkerWorkletSafeContext();
}
template<typename StringType, typename CharType>
void
_ASCIIToLowerInSitu(StringType& aStr)
{
CharType* iter = aStr.BeginWriting();
CharType* end = aStr.EndWriting();