diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 9d02a96ca494..8cd33aa4e5c9 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -2195,7 +2195,6 @@ typedef nsCharSeparatedTokenizerTemplate class NS_STACK_CLASS nsCxPusher { public: - enum PushBehavior { ALWAYS_PUSH, REQUIRE_SCRIPT_CONTEXT, ASSERT_SCRIPT_CONTEXT }; nsCxPusher(); ~nsCxPusher(); // Calls Pop(); @@ -2206,7 +2205,7 @@ public: bool RePush(nsIDOMEventTarget *aCurrentTarget); // If a null JSContext is passed to Push(), that will cause no // push to happen and false to be returned. - bool Push(JSContext *cx, PushBehavior behavior); + bool Push(JSContext *cx); // Explicitly push a null JSContext on the the stack bool PushNull(); diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 10eff7573904..18af30ac0efe 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -3021,7 +3021,7 @@ nsCxPusher::Push(nsIDOMEventTarget *aCurrentTarget) // in the process or being torn down. We don't want to notify the // script context about scripts having been evaluated in such a // case, calling with a null cx is fine in that case. - return Push(cx, ASSERT_SCRIPT_CONTEXT); + return Push(cx); } bool @@ -3053,7 +3053,7 @@ nsCxPusher::RePush(nsIDOMEventTarget *aCurrentTarget) } bool -nsCxPusher::Push(JSContext *cx, PushBehavior behavior) +nsCxPusher::Push(JSContext *cx) { if (mPushedSomething) { NS_ERROR("Whaaa! No double pushing with nsCxPusher::Push()!"); @@ -3069,11 +3069,6 @@ nsCxPusher::Push(JSContext *cx, PushBehavior behavior) // XXXbz do we really need to? If we don't get one of these in Pop(), is // that really a problem? Or do we need to do this to effectively root |cx|? mScx = GetScriptContextFromJSContext(cx); - MOZ_ASSERT_IF(behavior == ASSERT_SCRIPT_CONTEXT, mScx); - if (!mScx && behavior == REQUIRE_SCRIPT_CONTEXT) { - // Should probably return false. See bug 416916. - return true; - } return DoPush(cx); } @@ -6855,7 +6850,7 @@ AutoJSContext::Init(bool aSafe MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL) if (!mCx) { mCx = nsContentUtils::GetSafeJSContext(); - bool result = mPusher.Push(mCx, nsCxPusher::ALWAYS_PUSH); + bool result = mPusher.Push(mCx); if (!result || !mCx) { MOZ_CRASH(); } diff --git a/content/base/src/nsFrameMessageManager.cpp b/content/base/src/nsFrameMessageManager.cpp index 354016a2ea3a..73ca5cfed62c 100644 --- a/content/base/src/nsFrameMessageManager.cpp +++ b/content/base/src/nsFrameMessageManager.cpp @@ -651,7 +651,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget, continue; } nsCxPusher pusher; - NS_ENSURE_STATE(pusher.Push(ctx, nsCxPusher::ALWAYS_PUSH)); + NS_ENSURE_STATE(pusher.Push(ctx)); JSAutoRequest ar(ctx); JSAutoCompartment ac(ctx, object); diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index bddc61267e77..db728d831821 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -2577,7 +2577,7 @@ nsObjectLoadingContent::NotifyContentObjectWrapper() JSContext *cx = scx->GetNativeContext(); nsCxPusher pusher; - pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT); + pusher.Push(cx); nsCOMPtr wrapper; nsContentUtils::XPConnect()-> diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 70c6f6b5774a..f67d223dbd8a 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -818,7 +818,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS } nsCxPusher pusher; - if (aNeedsCxPush && !pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT)) { + if (aNeedsCxPush && !pusher.Push(cx)) { return NS_ERROR_FAILURE; } diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index 0e18197e45b6..4658fa192edf 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -943,7 +943,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen JSContext *cx = context->GetNativeContext(); nsCxPusher pusher; - pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT); + pusher.Push(cx); JSObject* scriptObject = mBoundElement->GetWrapper(); if (scriptObject) { diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 65bfac7f3b90..ccb0a7d426cc 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -10206,7 +10206,7 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle, nsCxPusher pusher; if (!cx) { cx = nsContentUtils::GetContextFromDocument(document); - pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT); + pusher.Push(cx); } rv = scContainer->InitFromVariant(aData, cx); diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index b521eb278127..198852b6a349 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -4765,7 +4765,7 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner, } nsCxPusher pusher; - NS_ENSURE_STATE(pusher.Push(cx, nsCxPusher::ALWAYS_PUSH)); + NS_ENSURE_STATE(pusher.Push(cx)); JSAutoRequest ar(cx); JSAutoCompartment ac(cx, object); @@ -8513,7 +8513,7 @@ public: nsCxPusher pusher; JSContext* cx = mContext ? mContext->GetNativeContext() : nsContentUtils::GetSafeJSContext(); - pusher.Push(cx, nsCxPusher::ALWAYS_PUSH); + pusher.Push(cx); JSObject* obj = nullptr; mWrapper->GetJSObject(&obj); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 7b25bbe7398f..1a40895e4294 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2085,7 +2085,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, bool thisChrome = IsChromeWindow(); nsCxPusher cxPusher; - if (!cxPusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT)) { + if (!cxPusher.Push(cx)) { return NS_ERROR_FAILURE; } diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index a604e74c957b..3584fc2f4513 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1260,7 +1260,7 @@ nsJSContext::EvaluateString(const nsAString& aScript, } nsCxPusher pusher; - if (!pusher.Push(mContext, nsCxPusher::ASSERT_SCRIPT_CONTEXT)) + if (!pusher.Push(mContext)) return NS_ERROR_FAILURE; xpc_UnmarkGrayObject(&aScopeObject); @@ -1515,7 +1515,7 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, JSObject* aScope, // all now, and never were in some cases. nsCxPusher pusher; - if (!pusher.Push(mContext, nsCxPusher::ASSERT_SCRIPT_CONTEXT)) + if (!pusher.Push(mContext)) return NS_ERROR_FAILURE; // check if the event handler can be run on the object in question diff --git a/dom/bindings/CallbackObject.cpp b/dom/bindings/CallbackObject.cpp index 4b9473a9bc72..dd923660655e 100644 --- a/dom/bindings/CallbackObject.cpp +++ b/dom/bindings/CallbackObject.cpp @@ -87,7 +87,7 @@ CallbackObject::CallSetup::CallSetup(JSObject* const aCallback) mAr.construct(cx); // Make sure our JSContext is pushed on the stack. - if (!mCxPusher.Push(cx, nsCxPusher::ALWAYS_PUSH)) { + if (!mCxPusher.Push(cx)) { return; } diff --git a/dom/sms/src/SmsRequest.cpp b/dom/sms/src/SmsRequest.cpp index 5ebe90482dad..b0e4f9aae298 100644 --- a/dom/sms/src/SmsRequest.cpp +++ b/dom/sms/src/SmsRequest.cpp @@ -523,7 +523,7 @@ SmsRequest::NotifyThreadList(const InfallibleTArray& aItems) NS_ENSURE_TRUE_VOID(ownerObj); nsCxPusher pusher; - NS_ENSURE_TRUE_VOID(pusher.Push(cx, nsCxPusher::ALWAYS_PUSH)); + NS_ENSURE_TRUE_VOID(pusher.Push(cx)); JSAutoRequest ar(cx); JSAutoCompartment ac(cx, ownerObj); diff --git a/js/ipc/ObjectWrapperChild.cpp b/js/ipc/ObjectWrapperChild.cpp index 36351ad6790e..6751ec968c34 100644 --- a/js/ipc/ObjectWrapperChild.cpp +++ b/js/ipc/ObjectWrapperChild.cpp @@ -42,7 +42,7 @@ namespace { JSOPTION_DONT_REPORT_UNCAUGHT))) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; - mStack.Push(cx, nsCxPusher::ALWAYS_PUSH); + mStack.Push(cx); } ~AutoContextPusher() { diff --git a/js/xpconnect/src/dictionary_helper_gen.py b/js/xpconnect/src/dictionary_helper_gen.py index e5d362a2ea53..e14428b395bc 100644 --- a/js/xpconnect/src/dictionary_helper_gen.py +++ b/js/xpconnect/src/dictionary_helper_gen.py @@ -428,7 +428,7 @@ def write_cpp(iface, fd): " }\n\n" " JSObject* obj = &aVal->toObject();\n" " nsCxPusher pusher;\n" - " NS_ENSURE_STATE(pusher.Push(aCx, nsCxPusher::ALWAYS_PUSH));\n" + " NS_ENSURE_STATE(pusher.Push(aCx));\n" " JSAutoRequest ar(aCx);\n" " JSAutoCompartment ac(aCx, obj);\n")