mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 860438 - Straightforward cases. r=gabor
This commit is contained in:
parent
e9525d65cd
commit
288399f5c0
@ -25,7 +25,6 @@
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsITextControlFrame.h"
|
||||
|
||||
@ -472,19 +471,12 @@ HTMLTextFieldAccessible::GetEditor() const
|
||||
// nsGenericHTMLElement::GetEditor has a security check.
|
||||
// Make sure we're not restricted by the permissions of
|
||||
// whatever script is currently running.
|
||||
nsCOMPtr<nsIJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
bool pushed = stack && NS_SUCCEEDED(stack->Push(nullptr));
|
||||
nsCxPusher pusher;
|
||||
pusher.PushNull();
|
||||
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
editableElt->GetEditor(getter_AddRefs(editor));
|
||||
|
||||
if (pushed) {
|
||||
JSContext* cx;
|
||||
stack->Pop(&cx);
|
||||
NS_ASSERTION(!cx, "context should be null");
|
||||
}
|
||||
|
||||
return editor.forget();
|
||||
}
|
||||
|
||||
|
@ -260,28 +260,6 @@ private:
|
||||
bool mMustFreeName;
|
||||
};
|
||||
|
||||
class AutoCxPusher {
|
||||
public:
|
||||
AutoCxPusher(nsIJSContextStack *aStack, JSContext *cx)
|
||||
: mStack(aStack), mContext(cx)
|
||||
{
|
||||
if (NS_FAILED(mStack->Push(mContext))) {
|
||||
mStack = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
~AutoCxPusher()
|
||||
{
|
||||
if (mStack) {
|
||||
mStack->Pop(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIJSContextStack> mStack;
|
||||
JSContext *mContext;
|
||||
};
|
||||
|
||||
JSContext *
|
||||
nsScriptSecurityManager::GetCurrentJSContext()
|
||||
{
|
||||
@ -2612,9 +2590,7 @@ nsScriptSecurityManager::InitPolicies()
|
||||
}
|
||||
|
||||
// Get a JS context - we need it to create internalized strings later.
|
||||
JSContext* cx = GetSafeJSContext();
|
||||
NS_ASSERTION(cx, "failed to get JS context");
|
||||
AutoCxPusher autoPusher(sJSContextStack, cx);
|
||||
SafeAutoJSContext cx;
|
||||
rv = InitDomainPolicy(cx, "default", mDefaultPolicy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -3197,10 +3197,7 @@ nsCxPusher::Pop()
|
||||
MOZ_ASSERT_IF(mPushedContext, mCompartmentDepthOnEntry ==
|
||||
js::GetEnterCompartmentDepth(mPushedContext));
|
||||
|
||||
JSContext *unused;
|
||||
stack->Pop(&unused);
|
||||
|
||||
NS_ASSERTION(unused == mPushedContext, "Unexpected context popped");
|
||||
stack->Pop(nullptr);
|
||||
|
||||
if (!mScriptIsRunning && mScx) {
|
||||
// No JS is running in the context, but executing the event handler might have
|
||||
|
@ -1010,7 +1010,8 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
|
||||
}
|
||||
|
||||
if (holder) {
|
||||
nsContentUtils::ThreadJSContextStack()->Push(mCx);
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(mCx);
|
||||
{
|
||||
// Need to scope JSAutoRequest to happen after Push but before Pop,
|
||||
// at least for now. See bug 584673.
|
||||
@ -1021,9 +1022,6 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
|
||||
(void) JS_ExecuteScript(mCx, global, holder->mScript, nullptr);
|
||||
}
|
||||
}
|
||||
JSContext* unused;
|
||||
nsContentUtils::ThreadJSContextStack()->Pop(&unused);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1071,7 +1069,8 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
}
|
||||
|
||||
if (!dataString.IsEmpty()) {
|
||||
nsContentUtils::ThreadJSContextStack()->Push(mCx);
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(mCx);
|
||||
{
|
||||
// Need to scope JSAutoRequest to happen after Push but before Pop,
|
||||
// at least for now. See bug 584673.
|
||||
@ -1105,8 +1104,6 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
}
|
||||
}
|
||||
}
|
||||
JSContext* unused;
|
||||
nsContentUtils::ThreadJSContextStack()->Pop(&unused);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsDOMClassInfoID.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using mozilla::SafeAutoJSContext;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_1(nsEventListenerInfo, mListener)
|
||||
|
||||
@ -110,30 +111,22 @@ nsEventListenerInfo::ToSource(nsAString& aResult)
|
||||
{
|
||||
aResult.SetIsVoid(true);
|
||||
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
nsContentUtils::ThreadJSContextStack();
|
||||
if (stack) {
|
||||
JSContext* cx = stack->GetSafeJSContext();
|
||||
if (cx && NS_SUCCEEDED(stack->Push(cx))) {
|
||||
{
|
||||
// Extra block to finish the auto request before calling pop
|
||||
JSAutoRequest ar(cx);
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
JS::Value v = JSVAL_NULL;
|
||||
if (GetJSVal(cx, ac, &v)) {
|
||||
JSString* str = JS_ValueToSource(cx, v);
|
||||
if (str) {
|
||||
nsDependentJSString depStr;
|
||||
if (depStr.init(cx, str)) {
|
||||
aResult.Assign(depStr);
|
||||
}
|
||||
}
|
||||
SafeAutoJSContext cx;
|
||||
{
|
||||
// Extra block to finish the auto request before calling pop
|
||||
JSAutoRequest ar(cx);
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
JS::Value v = JSVAL_NULL;
|
||||
if (GetJSVal(cx, ac, &v)) {
|
||||
JSString* str = JS_ValueToSource(cx, v);
|
||||
if (str) {
|
||||
nsDependentJSString depStr;
|
||||
if (depStr.init(cx, str)) {
|
||||
aResult.Assign(depStr);
|
||||
}
|
||||
}
|
||||
stack->Pop(&cx);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -152,24 +145,17 @@ nsEventListenerInfo::GetDebugObject(nsISupports** aRetVal)
|
||||
jsd->GetIsOn(&isOn);
|
||||
NS_ENSURE_TRUE(isOn, NS_OK);
|
||||
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
nsContentUtils::ThreadJSContextStack();
|
||||
if (stack) {
|
||||
JSContext* cx = stack->GetSafeJSContext();
|
||||
if (cx && NS_SUCCEEDED(stack->Push(cx))) {
|
||||
{
|
||||
// Extra block to finish the auto request before calling pop
|
||||
JSAutoRequest ar(cx);
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
JS::Value v = JSVAL_NULL;
|
||||
if (GetJSVal(cx, ac, &v)) {
|
||||
nsCOMPtr<jsdIValue> jsdValue;
|
||||
rv = jsd->WrapValue(v, getter_AddRefs(jsdValue));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
jsdValue.forget(aRetVal);
|
||||
}
|
||||
}
|
||||
stack->Pop(&cx);
|
||||
SafeAutoJSContext cx;
|
||||
{
|
||||
// Extra block to finish the auto request before calling pop
|
||||
JSAutoRequest ar(cx);
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
JS::Value v = JSVAL_NULL;
|
||||
if (GetJSVal(cx, ac, &v)) {
|
||||
nsCOMPtr<jsdIValue> jsdValue;
|
||||
rv = jsd->WrapValue(v, getter_AddRefs(jsdValue));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
jsdValue.forget(aRetVal);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIXPCSecurityManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIConsoleService.h"
|
||||
@ -1640,12 +1639,7 @@ nsDOMClassInfo::Init()
|
||||
sSecMan = sm;
|
||||
NS_ADDREF(sSecMan);
|
||||
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSContext* cx = stack->GetSafeJSContext();
|
||||
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
||||
SafeAutoJSContext cx;
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
|
||||
DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
|
||||
|
@ -106,7 +106,6 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
@ -7097,15 +7096,7 @@ nsGlobalWindow::FinalClose()
|
||||
// Flag that we were closed.
|
||||
mIsClosed = true;
|
||||
|
||||
nsCOMPtr<nsIJSContextStack> stack =
|
||||
do_GetService(sJSStackContractID);
|
||||
|
||||
JSContext *cx = nullptr;
|
||||
|
||||
if (stack) {
|
||||
stack->Peek(&cx);
|
||||
}
|
||||
|
||||
JSContext *cx = nsContentUtils::GetCurrentJSContext();
|
||||
if (cx) {
|
||||
nsIScriptContext *currentCX = nsJSUtils::GetDynamicScriptContext(cx);
|
||||
|
||||
@ -7426,8 +7417,7 @@ public:
|
||||
JSObject* obj = currentInner->FastGetGlobalJSObject();
|
||||
// We only want to nuke wrappers for the chrome->content case
|
||||
if (obj && !js::IsSystemCompartment(js::GetObjectCompartment(obj))) {
|
||||
JSContext* cx =
|
||||
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
js::NukeCrossCompartmentWrappers(cx,
|
||||
@ -9930,27 +9920,22 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
||||
// up. We do NOT want this case looking at the JS context on the stack
|
||||
// when searching. Compare comments on
|
||||
// nsIDOMWindow::OpenWindow and nsIWindowWatcher::OpenWindow.
|
||||
nsCOMPtr<nsIJSContextStack> stack;
|
||||
|
||||
// Note: Because nsWindowWatcher is so broken, it's actually important
|
||||
// that we don't push a null cx here, because that screws it up when it
|
||||
// tries to compute the caller principal to associate with dialog
|
||||
// arguments. That whole setup just really needs to be rewritten. :-(
|
||||
nsCxPusher pusher;
|
||||
if (!aContentModal) {
|
||||
stack = do_GetService(sJSStackContractID);
|
||||
pusher.PushNull();
|
||||
}
|
||||
|
||||
if (stack) {
|
||||
rv = stack->Push(nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = pwwatch->OpenWindow2(this, url.get(), name_ptr, options_ptr,
|
||||
/* aCalledFromScript = */ false,
|
||||
aDialog, aNavigate, aExtraArgument,
|
||||
getter_AddRefs(domReturn));
|
||||
|
||||
if (stack) {
|
||||
JSContext* cx;
|
||||
stack->Pop(&cx);
|
||||
NS_ASSERTION(!cx, "Unexpected JSContext popped!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10871,9 +10856,7 @@ nsGlobalWindow::BuildURIfromBase(const char *aURL, nsIURI **aBuiltURI,
|
||||
cx = scx->GetNativeContext();
|
||||
} else {
|
||||
// get the JSContext from the call stack
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack(do_GetService(sJSStackContractID));
|
||||
if (stack)
|
||||
stack->Peek(&cx);
|
||||
cx = nsContentUtils::GetCurrentJSContext();
|
||||
}
|
||||
|
||||
/* resolve the URI, which could be relative to the calling window
|
||||
|
@ -1311,12 +1311,11 @@ MainThreadDictionaryBase::ParseJSON(const nsAString& aJSON,
|
||||
Maybe<JSAutoCompartment>& aAc,
|
||||
Maybe< JS::Rooted<JS::Value> >& aVal)
|
||||
{
|
||||
JSContext* cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
|
||||
NS_ENSURE_TRUE(cx, nullptr);
|
||||
SafeAutoJSContext cx;
|
||||
JSObject* global = JS_GetGlobalObject(cx);
|
||||
aAr.construct(cx);
|
||||
aAc.construct(cx, global);
|
||||
aVal.construct(cx, JS::UndefinedValue());
|
||||
aAr.construct(static_cast<JSContext*>(cx));
|
||||
aAc.construct(static_cast<JSContext*>(cx), global);
|
||||
aVal.construct(static_cast<JSContext*>(cx), JS::UndefinedValue());
|
||||
if (aJSON.IsEmpty()) {
|
||||
return cx;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "IDBFactory.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIXPConnect.h"
|
||||
@ -202,20 +201,7 @@ IDBFactory::Create(ContentParent* aContentParent,
|
||||
NS_ASSERTION(nsContentUtils::IsCallerChrome(), "Only for chrome!");
|
||||
NS_ASSERTION(aContentParent, "Null ContentParent!");
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsIThreadJSContextStack* cxStack = nsContentUtils::ThreadJSContextStack();
|
||||
NS_ASSERTION(cxStack, "Couldn't get ThreadJSContextStack!");
|
||||
|
||||
JSContext* lastCx;
|
||||
if (NS_SUCCEEDED(cxStack->Peek(&lastCx))) {
|
||||
NS_ASSERTION(!lastCx, "We should only be called from C++!");
|
||||
}
|
||||
else {
|
||||
NS_ERROR("nsIThreadJSContextStack::Peek should never fail!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
NS_ASSERTION(!nsContentUtils::GetCurrentJSContext(), "Should be called from C++");
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "IDBIndex.h"
|
||||
|
||||
#include "nsIIDBKeyRange.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "IDBObjectStore.h"
|
||||
|
||||
#include "mozilla/dom/ipc/nsIRemoteBlob.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIOutputStream.h"
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "IDBRequest.h"
|
||||
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
#include "nsComponentManagerUtils.h"
|
||||
@ -178,13 +177,7 @@ IDBRequest::GetJSContext()
|
||||
JSContext* cx;
|
||||
|
||||
if (GetScriptOwner()) {
|
||||
nsIThreadJSContextStack* cxStack = nsContentUtils::ThreadJSContextStack();
|
||||
NS_ASSERTION(cxStack, "Failed to get thread context stack!");
|
||||
|
||||
cx = cxStack->GetSafeJSContext();
|
||||
NS_ENSURE_TRUE(cx, nullptr);
|
||||
|
||||
return cx;
|
||||
return nsContentUtils::GetSafeJSContext();
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
@ -1967,22 +1968,7 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
|
||||
|
||||
// Use the safe JSContext here as we're not always able to find the
|
||||
// JSContext associated with the NPP any more.
|
||||
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack) {
|
||||
NS_ERROR("No context stack available!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
JSContext* cx = stack->GetSafeJSContext();
|
||||
if (!cx) {
|
||||
NS_ERROR("No safe JS context available!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SafeAutoJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (sNPObjWrappers.ops) {
|
||||
|
@ -1264,16 +1264,7 @@ _getstringidentifier(const NPUTF8* name)
|
||||
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifier called from the wrong thread\n"));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack)
|
||||
return NULL;
|
||||
|
||||
JSContext* cx = stack->GetSafeJSContext();
|
||||
if (!cx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SafeAutoJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
return doGetIdentifier(cx, name);
|
||||
}
|
||||
@ -1285,16 +1276,8 @@ _getstringidentifiers(const NPUTF8** names, int32_t nameCount,
|
||||
if (!NS_IsMainThread()) {
|
||||
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifiers called from the wrong thread\n"));
|
||||
}
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack)
|
||||
return;
|
||||
|
||||
JSContext* cx = stack->GetSafeJSContext();
|
||||
if (!cx) {
|
||||
return;
|
||||
}
|
||||
|
||||
SafeAutoJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
for (int32_t i = 0; i < nameCount; ++i) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsNPAPIPlugin.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "PluginScriptableObjectUtils.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
@ -30,17 +29,7 @@ PluginIdentifierParent::RecvRetain()
|
||||
|
||||
// The following is what nsNPAPIPlugin.cpp does. Gross, but the API doesn't
|
||||
// give you a NPP to play with.
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JSContext* cx = stack->GetSafeJSContext();
|
||||
if (!cx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SafeAutoJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
JSString* str = JSID_TO_STRING(id);
|
||||
JSString* str2 = JS_InternJSString(cx, str);
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/unused.h"
|
||||
@ -282,10 +281,8 @@ void
|
||||
PositionError::NotifyCallback(const GeoPositionErrorCallback& aCallback)
|
||||
{
|
||||
// Ensure that the proper context is on the stack (bug 452762)
|
||||
nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
||||
if (!stack || NS_FAILED(stack->Push(nullptr))) {
|
||||
return;
|
||||
}
|
||||
nsCxPusher pusher;
|
||||
pusher.PushNull();
|
||||
|
||||
nsAutoMicroTask mt;
|
||||
if (aCallback.HasWebIDLCallback()) {
|
||||
@ -301,10 +298,6 @@ PositionError::NotifyCallback(const GeoPositionErrorCallback& aCallback)
|
||||
callback->HandleEvent(this);
|
||||
}
|
||||
}
|
||||
|
||||
// remove the stack
|
||||
JSContext* cx;
|
||||
stack->Pop(&cx);
|
||||
}
|
||||
////////////////////////////////////////////////////
|
||||
// nsGeolocationRequest
|
||||
@ -558,11 +551,8 @@ nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition, bool aCachePosi
|
||||
}
|
||||
|
||||
// Ensure that the proper context is on the stack (bug 452762)
|
||||
nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
||||
if (!stack || NS_FAILED(stack->Push(nullptr))) {
|
||||
return; // silently fail
|
||||
}
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.PushNull();
|
||||
nsAutoMicroTask mt;
|
||||
if (mCallback.HasWebIDLCallback()) {
|
||||
ErrorResult err;
|
||||
@ -577,10 +567,6 @@ nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition, bool aCachePosi
|
||||
callback->HandleEvent(aPosition);
|
||||
}
|
||||
|
||||
// remove the stack
|
||||
JSContext* cx;
|
||||
stack->Pop(&cx);
|
||||
|
||||
if (mIsWatchPositionRequest) {
|
||||
SetTimeoutTimer();
|
||||
}
|
||||
@ -788,15 +774,7 @@ nsGeolocationService::HandleMozsettingChanged(const PRUnichar* aData)
|
||||
// The string that we're interested in will be a JSON string that looks like:
|
||||
// {"key":"gelocation.enabled","value":true}
|
||||
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack = do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSContext *cx = stack->GetSafeJSContext();
|
||||
if (!cx) {
|
||||
return;
|
||||
}
|
||||
SafeAutoJSContext cx;
|
||||
|
||||
nsDependentString dataStr(aData);
|
||||
JS::Value val;
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptChannel.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIObjectInputStream.h"
|
||||
@ -299,16 +298,8 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
|
||||
|
||||
// Push our JSContext on the context stack so the JS_ValueToString call (and
|
||||
// JS_ReportPendingException, if relevant) will use the principal of cx.
|
||||
// Note that we do this as late as possible to make popping simpler.
|
||||
nsCOMPtr<nsIJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = stack->Push(cx);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
rv = xpc->EvalInSandboxObject(NS_ConvertUTF8toUTF16(script),
|
||||
/* filename = */ nullptr, cx,
|
||||
sandboxObj, true, &v);
|
||||
@ -318,8 +309,6 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
|
||||
if (JS_IsExceptionPending(cx)) {
|
||||
JS_ReportPendingException(cx);
|
||||
}
|
||||
|
||||
stack->Pop(nullptr);
|
||||
} else {
|
||||
// No need to use the sandbox, evaluate the script directly in
|
||||
// the given scope.
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsISettingsService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
@ -109,17 +109,7 @@ AutoMounterSetting::Observe(nsISupports* aSubject,
|
||||
// The string that we're interested in will be a JSON string that looks like:
|
||||
// {"key":"ums.autoMount","value":true}
|
||||
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack) {
|
||||
ERR("Failed to get JSContextStack");
|
||||
return NS_OK;
|
||||
}
|
||||
JSContext* cx = stack->GetSafeJSContext();
|
||||
if (!cx) {
|
||||
ERR("Failed to GetSafeJSContext");
|
||||
return NS_OK;
|
||||
}
|
||||
mozilla::SafeAutoJSContext cx;
|
||||
nsDependentString dataStr(aData);
|
||||
JS::Value val;
|
||||
if (!JS_ParseJSON(cx, dataStr.get(), dataStr.Length(), &val) ||
|
||||
|
@ -169,18 +169,7 @@ TimeZoneSettingObserver::Observe(nsISupports *aSubject,
|
||||
// The string that we're interested in will be a JSON string that looks like:
|
||||
// {"key":"time.timezone","value":"America/Chicago"}
|
||||
|
||||
// Get the safe JS context.
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack) {
|
||||
ERR("Failed to get JSContextStack");
|
||||
return NS_OK;
|
||||
}
|
||||
JSContext *cx = stack->GetSafeJSContext();
|
||||
if (!cx) {
|
||||
ERR("Failed to GetSafeJSContext");
|
||||
return NS_OK;
|
||||
}
|
||||
SafeAutoJSContext cx;
|
||||
|
||||
// Parse the JSON value.
|
||||
nsDependentString dataStr(aData);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "DateCacheCleaner.h"
|
||||
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
||||
using namespace mozilla::hal;
|
||||
@ -30,15 +30,7 @@ public:
|
||||
}
|
||||
void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
|
||||
{
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
||||
if (!stack) {
|
||||
NS_WARNING("Failed to get JSContextStack");
|
||||
}
|
||||
JSContext *cx = stack->GetSafeJSContext();
|
||||
if (!cx) {
|
||||
NS_WARNING("Failed to GetSafeJSContext");
|
||||
}
|
||||
mozilla::SafeAutoJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
JS_ClearDateCaches(cx);
|
||||
}
|
||||
|
@ -55,23 +55,8 @@ DOMBindingBase::_finalize(JSFreeOp* aFop)
|
||||
}
|
||||
|
||||
JSContext*
|
||||
DOMBindingBase::GetJSContextFromContextStack() const
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(!mJSContext);
|
||||
|
||||
if (!mContextStack) {
|
||||
mContextStack = nsContentUtils::ThreadJSContextStack();
|
||||
MOZ_ASSERT(mContextStack);
|
||||
}
|
||||
|
||||
JSContext* cx;
|
||||
if (NS_FAILED(mContextStack->Peek(&cx))) {
|
||||
MOZ_NOT_REACHED("This should never fail!");
|
||||
}
|
||||
|
||||
MOZ_ASSERT(cx);
|
||||
return cx;
|
||||
DOMBindingBase::GetJSContext() const {
|
||||
return mJSContext ? mJSContext : nsContentUtils::GetCurrentJSContext();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsIThreadJSContextStack;
|
||||
|
||||
BEGIN_WORKERS_NAMESPACE
|
||||
|
||||
#define BINDING_ENSURE_TRUE(_cond, _result, _retval) \
|
||||
@ -31,7 +29,6 @@ class DOMBindingBase : public nsWrapperCache,
|
||||
public nsISupports
|
||||
{
|
||||
JSContext* mJSContext;
|
||||
mutable nsCOMPtr<nsIThreadJSContextStack> mContextStack;
|
||||
|
||||
protected:
|
||||
DOMBindingBase(JSContext* aCx);
|
||||
@ -43,17 +40,11 @@ protected:
|
||||
virtual void
|
||||
_finalize(JSFreeOp* aFop);
|
||||
|
||||
JSContext*
|
||||
GetJSContextFromContextStack() const;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
JSContext*
|
||||
GetJSContext() const
|
||||
{
|
||||
return mJSContext ? mJSContext : GetJSContextFromContextStack();
|
||||
}
|
||||
GetJSContext() const;
|
||||
|
||||
#ifdef DEBUG
|
||||
JSObject*
|
||||
|
@ -1600,7 +1600,7 @@ WorkerRunnable::Run()
|
||||
{
|
||||
JSContext* cx;
|
||||
JSObject* targetCompartmentObject;
|
||||
nsIThreadJSContextStack* contextStack = nullptr;
|
||||
nsCxPusher pusher;
|
||||
|
||||
nsRefPtr<WorkerPrivate> kungFuDeathGrip;
|
||||
|
||||
@ -1616,14 +1616,7 @@ WorkerRunnable::Run()
|
||||
|
||||
if (!mWorkerPrivate->GetParent()) {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
contextStack = nsContentUtils::ThreadJSContextStack();
|
||||
NS_ASSERTION(contextStack, "This should never be null!");
|
||||
|
||||
if (NS_FAILED(contextStack->Push(cx))) {
|
||||
NS_WARNING("Failed to push context!");
|
||||
contextStack = nullptr;
|
||||
}
|
||||
pusher.Push(cx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1637,19 +1630,7 @@ WorkerRunnable::Run()
|
||||
}
|
||||
|
||||
bool result = WorkerRun(cx, mWorkerPrivate);
|
||||
|
||||
PostRun(cx, mWorkerPrivate, result);
|
||||
|
||||
if (contextStack) {
|
||||
JSContext* otherCx;
|
||||
if (NS_FAILED(contextStack->Pop(&otherCx))) {
|
||||
NS_WARNING("Failed to pop context!");
|
||||
}
|
||||
else if (otherCx != cx) {
|
||||
NS_WARNING("Popped a different context!");
|
||||
}
|
||||
}
|
||||
|
||||
return result ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIRunnable.h"
|
||||
@ -46,7 +47,6 @@
|
||||
#include "nsIGenKeypairInfoDlg.h"
|
||||
#include "nsIDOMCryptoDialogs.h"
|
||||
#include "nsIFormSigningDialog.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include <ctype.h>
|
||||
@ -2182,10 +2182,8 @@ nsCryptoRunnable::Run()
|
||||
JSAutoCompartment ac(cx, m_args->m_scope);
|
||||
|
||||
// make sure the right context is on the stack. must not return w/out popping
|
||||
nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
||||
if (!stack || NS_FAILED(stack->Push(cx))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
|
||||
JSBool ok =
|
||||
JS_EvaluateScriptForPrincipals(cx, m_args->m_scope,
|
||||
@ -2193,7 +2191,6 @@ nsCryptoRunnable::Run()
|
||||
m_args->m_jsCallback,
|
||||
strlen(m_args->m_jsCallback),
|
||||
nullptr, 0, nullptr);
|
||||
stack->Pop(nullptr);
|
||||
return ok ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
#include "nsJSInspector.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsdbgapi.h"
|
||||
@ -42,26 +42,18 @@ nsJSInspector::~nsJSInspector()
|
||||
NS_IMETHODIMP
|
||||
nsJSInspector::EnterNestedEventLoop(const JS::Value& requestor, uint32_t *out)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
mLastRequestor = requestor;
|
||||
mRequestors.AppendElement(requestor);
|
||||
|
||||
uint32_t nestLevel = ++mNestedLoopLevel;
|
||||
if (NS_SUCCEEDED(stack->Push(nullptr))) {
|
||||
while (NS_SUCCEEDED(rv) && mNestedLoopLevel >= nestLevel) {
|
||||
if (!NS_ProcessNextEvent())
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
nsCxPusher pusher;
|
||||
pusher.PushNull();
|
||||
|
||||
JSContext *cx;
|
||||
stack->Pop(&cx);
|
||||
NS_ASSERTION(cx == nullptr, "JSContextStack mismatch");
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
uint32_t nestLevel = ++mNestedLoopLevel;
|
||||
while (NS_SUCCEEDED(rv) && mNestedLoopLevel >= nestLevel) {
|
||||
if (!NS_ProcessNextEvent())
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_ASSERTION(mNestedLoopLevel <= nestLevel,
|
||||
|
@ -1609,50 +1609,6 @@ HWND hwndForDOMWindow( nsISupports *window ) {
|
||||
return (HWND)( ppWidget->GetNativeData( NS_NATIVE_WIDGET ) );
|
||||
}
|
||||
|
||||
static const char sJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1";
|
||||
|
||||
class SafeJSContext {
|
||||
public:
|
||||
SafeJSContext();
|
||||
~SafeJSContext();
|
||||
|
||||
nsresult Push();
|
||||
JSContext *get() { return mContext; }
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIThreadJSContextStack> mService;
|
||||
JSContext *mContext;
|
||||
};
|
||||
|
||||
SafeJSContext::SafeJSContext() : mContext(nullptr) {
|
||||
}
|
||||
|
||||
SafeJSContext::~SafeJSContext() {
|
||||
JSContext *cx;
|
||||
nsresult rv;
|
||||
|
||||
if(mContext) {
|
||||
rv = mService->Pop(&cx);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && cx == mContext, "JSContext push/pop mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
nsresult SafeJSContext::Push() {
|
||||
if (mContext) // only once
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mService = do_GetService(sJSStackContractID);
|
||||
if (mService) {
|
||||
JSContext* cx = mService->GetSafeJSContext();
|
||||
if (cx && NS_SUCCEEDED(mService->Push(cx))) {
|
||||
// Save cx in mContext to indicate need to pop.
|
||||
mContext = cx;
|
||||
}
|
||||
}
|
||||
return mContext ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// As of Jan, 2005, most of the code in this method is pointless and
|
||||
// will never be used. It is only called by ActivateLastWindow() and
|
||||
// only when there is no existing window. Consequently, the first test
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIDOMLocation.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
@ -1454,50 +1453,6 @@ HWND hwndForDOMWindow( nsISupports *window ) {
|
||||
return (HWND)( ppWidget->GetNativeData( NS_NATIVE_WIDGET ) );
|
||||
}
|
||||
|
||||
static const char sJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1";
|
||||
|
||||
class SafeJSContext {
|
||||
public:
|
||||
SafeJSContext();
|
||||
~SafeJSContext();
|
||||
|
||||
nsresult Push();
|
||||
JSContext *get() { return mContext; }
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIThreadJSContextStack> mService;
|
||||
JSContext *mContext;
|
||||
};
|
||||
|
||||
SafeJSContext::SafeJSContext() : mContext(nullptr) {
|
||||
}
|
||||
|
||||
SafeJSContext::~SafeJSContext() {
|
||||
JSContext *cx;
|
||||
DebugOnly<nsresult> rv;
|
||||
|
||||
if(mContext) {
|
||||
rv = mService->Pop(&cx);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && cx == mContext, "JSContext push/pop mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
nsresult SafeJSContext::Push() {
|
||||
if (mContext) // only once
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mService = do_GetService(sJSStackContractID);
|
||||
if (mService) {
|
||||
JSContext* cx = mService->GetSafeJSContext();
|
||||
if (cx && NS_SUCCEEDED(mService->Push(cx))) {
|
||||
// Save cx in mContext to indicate need to pop.
|
||||
mContext = cx;
|
||||
}
|
||||
}
|
||||
return mContext ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsNativeAppSupportWin::OpenBrowserWindow()
|
||||
{
|
||||
|
@ -12,6 +12,7 @@
|
||||
// Helper Classes
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
// Interfaces needed to be included
|
||||
#include "nsIDOMNode.h"
|
||||
@ -30,7 +31,6 @@
|
||||
#include "nsIURIFixup.h"
|
||||
#include "nsCDefaultURIFixup.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "mozilla/BrowserElementParent.h"
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
@ -47,8 +47,6 @@ using namespace mozilla;
|
||||
// CIDs
|
||||
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
||||
|
||||
static const char *sJSStackContractID="@mozilla.org/js/xpc/ContextStack;1";
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsSiteWindow declaration
|
||||
//*****************************************************************************
|
||||
@ -787,34 +785,6 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const PRUnichar* aTitle)
|
||||
return mXULWindow->SetTitle(title.get());
|
||||
}
|
||||
|
||||
class MOZ_STACK_CLASS NullJSContextPusher {
|
||||
public:
|
||||
NullJSContextPusher() {
|
||||
mService = do_GetService(sJSStackContractID);
|
||||
if (mService) {
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
mService->Push(nullptr);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Mismatched push/pop");
|
||||
}
|
||||
}
|
||||
|
||||
~NullJSContextPusher() {
|
||||
if (mService) {
|
||||
JSContext *cx;
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
mService->Pop(&cx);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && !cx, "Bad pop!");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIThreadJSContextStack> mService;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// nsContentTreeOwner: nsIWindowProvider
|
||||
//*****************************************************************************
|
||||
@ -942,7 +912,8 @@ nsContentTreeOwner::ProvideWindow(nsIDOMWindow* aParent,
|
||||
*aWindowIsNew = (containerPref != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW);
|
||||
|
||||
{
|
||||
NullJSContextPusher pusher;
|
||||
nsCxPusher pusher;
|
||||
pusher.PushNull();
|
||||
|
||||
// Get a new rendering area from the browserDOMWin. We don't want
|
||||
// to be starting any loads here, so get it with a null URI.
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
@ -360,16 +359,14 @@ NS_IMETHODIMP nsXULWindow::ShowModal()
|
||||
mContinueModalLoop = true;
|
||||
EnableParent(false);
|
||||
|
||||
nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
||||
if (stack && NS_SUCCEEDED(stack->Push(nullptr))) {
|
||||
{
|
||||
nsCxPusher pusher;
|
||||
pusher.PushNull();
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
while (mContinueModalLoop) {
|
||||
if (!NS_ProcessNextEvent(thread))
|
||||
break;
|
||||
}
|
||||
JSContext* cx;
|
||||
stack->Pop(&cx);
|
||||
NS_ASSERTION(cx == nullptr, "JSContextStack mismatch");
|
||||
}
|
||||
|
||||
mContinueModalLoop = false;
|
||||
@ -1815,17 +1812,15 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(int32_t aChromeFlags,
|
||||
xulWin->LockUntilChromeLoad();
|
||||
|
||||
// Push nullptr onto the JSContext stack before we dispatch a native event.
|
||||
nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
||||
if (stack && NS_SUCCEEDED(stack->Push(nullptr))) {
|
||||
{
|
||||
nsCxPusher pusher;
|
||||
pusher.PushNull();
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
while (xulWin->IsLocked()) {
|
||||
if (!NS_ProcessNextEvent(thread))
|
||||
break;
|
||||
}
|
||||
JSContext *cx;
|
||||
stack->Pop(&cx);
|
||||
NS_ASSERTION(cx == nullptr, "JSContextStack mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_STATE(xulWin->mPrimaryContentShell);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user