diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 44485bf6715..5675cd32995 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -13398,15 +13398,11 @@ nsGlobalWindow::GetMessageManager(ErrorResult& aError) nsGlobalChromeWindow* myself = static_cast(this); if (!myself->mMessageManager) { nsIScriptContext* scx = GetContextInternal(); - if (NS_WARN_IF(!scx)) { - aError.Throw(NS_ERROR_UNEXPECTED); - return nullptr; - } - AutoPushJSContext cx(scx->GetNativeContext()); - if (NS_WARN_IF(!cx)) { + if (NS_WARN_IF(!scx || !(scx->GetNativeContext()))) { aError.Throw(NS_ERROR_UNEXPECTED); return nullptr; } + nsCOMPtr globalMM = do_GetService("@mozilla.org/globalmessagemanager;1"); myself->mMessageManager =