From 4f6ed4314aa0a0f745fdc29af8c506cf4ba87b17 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Thu, 25 Oct 2012 17:01:07 +0200 Subject: [PATCH] Bug 797821 - Stop passing wantXrays directly to CreateGlobalObject. r=mrbkap This can happen after the fact where it needs to. --- content/xbl/src/nsXBLDocumentInfo.cpp | 3 +-- content/xul/document/src/nsXULPrototypeDocument.cpp | 2 +- js/xpconnect/src/XPCComponents.cpp | 3 ++- js/xpconnect/src/XPCJSContextStack.cpp | 3 +-- js/xpconnect/src/XPCWrappedNative.cpp | 2 +- js/xpconnect/src/nsXPConnect.cpp | 5 ++--- js/xpconnect/src/xpcprivate.h | 4 ++-- js/xpconnect/src/xpcpublic.h | 3 +-- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/content/xbl/src/nsXBLDocumentInfo.cpp b/content/xbl/src/nsXBLDocumentInfo.cpp index c2348ea532a..c3e0f2caead 100644 --- a/content/xbl/src/nsXBLDocumentInfo.cpp +++ b/content/xbl/src/nsXBLDocumentInfo.cpp @@ -281,8 +281,7 @@ nsXBLDocGlobalObject::EnsureScriptEnvironment() // why - see bug 339647) JS_SetErrorReporter(cx, XBL_ProtoErrorReporter); - mJSObject = xpc::CreateGlobalObject(cx, &gSharedGlobalClass, - GetPrincipal(), false); + mJSObject = xpc::CreateGlobalObject(cx, &gSharedGlobalClass, GetPrincipal()); if (!mJSObject) return NS_OK; diff --git a/content/xul/document/src/nsXULPrototypeDocument.cpp b/content/xul/document/src/nsXULPrototypeDocument.cpp index a70d92b72b5..96676a5de17 100644 --- a/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -753,7 +753,7 @@ nsXULPDGlobalObject::EnsureScriptEnvironment() JSAutoRequest ar(cx); JSObject *newGlob = xpc::CreateGlobalObject(cx, &gSharedGlobalClass, - GetPrincipal(), false); + GetPrincipal()); if (!newGlob) return NS_OK;; diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index b12733e596e..50813e80533 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -3258,10 +3258,11 @@ xpc_CreateSandboxObject(JSContext *cx, jsval *vp, nsISupports *prinOrSop, Sandbo JSObject *sandbox; - sandbox = xpc::CreateGlobalObject(cx, &SandboxClass, principal, options.wantXrays); + sandbox = xpc::CreateGlobalObject(cx, &SandboxClass, principal); if (!sandbox) return NS_ERROR_FAILURE; NS_ENSURE_SUCCESS(rv, rv); + xpc::GetCompartmentPrivate(sandbox)->wantXrays = options.wantXrays; JS::AutoObjectRooter tvr(cx, sandbox); diff --git a/js/xpconnect/src/XPCJSContextStack.cpp b/js/xpconnect/src/XPCJSContextStack.cpp index 532256b5d19..8f3b84793b9 100644 --- a/js/xpconnect/src/XPCJSContextStack.cpp +++ b/js/xpconnect/src/XPCJSContextStack.cpp @@ -181,8 +181,7 @@ XPCJSContextStack::GetSafeJSContext() JS_SetErrorReporter(mSafeJSContext, mozJSLoaderErrorReporter); - glob = xpc::CreateGlobalObject(mSafeJSContext, &global_class, - principal, false); + glob = xpc::CreateGlobalObject(mSafeJSContext, &global_class, principal); if (glob) { // Make sure the context is associated with a proper compartment diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index 0fd0aeed080..3ac2a176058 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -312,7 +312,7 @@ XPCWrappedNative::WrapNewGlobal(XPCCallContext &ccx, xpcObjectHelper &nativeHelp MOZ_ASSERT(clasp->flags & JSCLASS_IS_GLOBAL); // Create the global. - JSObject *global = xpc::CreateGlobalObject(ccx, clasp, principal, false); + JSObject *global = xpc::CreateGlobalObject(ccx, clasp, principal); if (!global) return NS_ERROR_FAILURE; diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index 770ae0a6d2b..9271e210d4d 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -1076,8 +1076,7 @@ CheckTypeInference(JSContext *cx, JSClass *clasp, nsIPrincipal *principal) namespace xpc { JSObject* -CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal, - bool wantXrays) +CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal) { // Make sure that Type Inference is enabled for everything non-chrome. // Sandboxes and compilation scopes are exceptions. See bug 744034. @@ -1089,7 +1088,7 @@ CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal, if (!global) return nullptr; JSCompartment *compartment = js::GetObjectCompartment(global); - JS_SetCompartmentPrivate(compartment, new xpc::CompartmentPrivate(wantXrays)); + JS_SetCompartmentPrivate(compartment, new xpc::CompartmentPrivate()); XPCCompartmentSet& set = nsXPConnect::GetRuntimeInstance()->GetCompartmentSet(); if (!set.put(compartment)) diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 3a38561e6cf..487e95498c4 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -4322,8 +4322,8 @@ class CompartmentPrivate public: typedef nsTHashtable > DOMExpandoMap; - CompartmentPrivate(bool wantXrays) - : wantXrays(wantXrays) + CompartmentPrivate() + : wantXrays(false) , universalXPConnectEnabled(false) { MOZ_COUNT_CTOR(xpc::CompartmentPrivate); diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index d06db7f6e45..e8e52647bba 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -42,8 +42,7 @@ TransplantObjectWithWrapper(JSContext *cx, JSObject *targetobj, JSObject *targetwrapper); JSObject * -CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal, - bool wantXrays); +CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal); } /* namespace xpc */ #define XPCONNECT_GLOBAL_FLAGS \