Bug 774607 - Remove use of JS_{Is,Make}SystemObject from Gecko. r=bz

We currently set this for system globals and anything whose parent
chain leads to a system global. Maybe this was relevant before, but
with CPG this is just equivalent to asking whether the object is in
a system compartment. And the only place where we _check_ this bit
is immediately after checking for a system compartment, in
WrapperFactory. So AFAICT this can go away entirely.
This commit is contained in:
Bobby Holley 2012-08-23 16:44:53 -07:00
parent fb072823ff
commit be79576daa
9 changed files with 8 additions and 33 deletions

View File

@ -895,8 +895,7 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope)
JSAutoRequest ar(cx);
nsIXPConnect* xpc = nsContentUtils::XPConnect();
const uint32_t flags = nsIXPConnect::INIT_JS_STANDARD_CLASSES |
nsIXPConnect::FLAG_SYSTEM_GLOBAL_OBJECT;
const uint32_t flags = nsIXPConnect::INIT_JS_STANDARD_CLASSES;
JS_SetContextPrivate(cx, aScope);

View File

@ -1712,7 +1712,6 @@ CreateNativeGlobalForInner(JSContext* aCx,
MOZ_ASSERT(aHolder);
nsIXPConnect* xpc = nsContentUtils::XPConnect();
uint32_t flags = aIsChrome ? nsIXPConnect::FLAG_SYSTEM_GLOBAL_OBJECT : 0;
nsCOMPtr<nsIPrincipal> systemPrincipal;
if (aIsChrome) {
@ -1724,7 +1723,7 @@ CreateNativeGlobalForInner(JSContext* aCx,
nsRefPtr<nsIXPConnectJSObjectHolder> jsholder;
nsresult rv = xpc->InitClassesWithNewWrappedGlobal(
aCx, static_cast<nsIScriptGlobalObject*>(aNewInner),
aIsChrome ? systemPrincipal.get() : aPrincipal, flags,
aIsChrome ? systemPrincipal.get() : aPrincipal, 0,
getter_AddRefs(jsholder));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -1098,9 +1098,7 @@ XPCShellEnvironment::Init()
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->InitClassesWithNewWrappedGlobal(cx, backstagePass,
principal,
nsIXPConnect::
FLAG_SYSTEM_GLOBAL_OBJECT,
principal, 0,
getter_AddRefs(holder));
if (NS_FAILED(rv)) {
NS_ERROR("InitClassesWithNewWrappedGlobal failed!");

View File

@ -303,7 +303,7 @@ interface nsIXPCFunctionThisTranslator : nsISupports
{ 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
%}
[uuid(26efd266-3e33-4dc9-8233-e13bb8d9c452)]
[uuid(bd300b18-1c34-4589-8285-23a12cc580ea)]
interface nsIXPConnect : nsISupports
{
%{ C++
@ -339,7 +339,7 @@ interface nsIXPConnect : nsISupports
in uint32_t aFlags);
const uint32_t INIT_JS_STANDARD_CLASSES = 1 << 0;
const uint32_t FLAG_SYSTEM_GLOBAL_OBJECT = 1 << 1;
// Free bit here!
const uint32_t OMIT_COMPONENTS_OBJECT = 1 << 2;
/**

View File

@ -647,8 +647,7 @@ mozJSComponentLoader::GlobalForLocation(nsIFile *aComponentFile,
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->InitClassesWithNewWrappedGlobal(cx, backstagePass,
mSystemPrincipal,
nsIXPConnect::
FLAG_SYSTEM_GLOBAL_OBJECT,
0,
getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -1863,8 +1863,7 @@ main(int argc, char **argv, char **envp)
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->InitClassesWithNewWrappedGlobal(cx, backstagePass,
systemprincipal,
nsIXPConnect::
FLAG_SYSTEM_GLOBAL_OBJECT,
0,
getter_AddRefs(holder));
if (NS_FAILED(rv))
return 1;

View File

@ -611,8 +611,6 @@ xpc_NewSystemInheritingJSObject(JSContext *cx, JSClass *clasp, JSObject *proto,
} else {
obj = JS_NewObject(cx, clasp, proto, parent);
}
if (obj && JS_IsSystemObject(cx, parent) && !JS_MakeSystemObject(cx, obj))
obj = NULL;
return obj;
}

View File

@ -1180,11 +1180,6 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
if (!ac.enter(ccx, global))
return NS_ERROR_UNEXPECTED;
// Apply the system flag, if requested.
bool system = (aFlags & nsIXPConnect::FLAG_SYSTEM_GLOBAL_OBJECT) != 0;
if (system && !JS_MakeSystemObject(aJSContext, global))
return UnexpectedFailure(NS_ERROR_FAILURE);
if (!(aFlags & nsIXPConnect::OMIT_COMPONENTS_OBJECT)) {
// XPCCallContext gives us an active request needed to save/restore.
if (!nsXPCComponents::AttachComponentsObject(ccx, wrappedGlobal->GetScope(), global))

View File

@ -334,19 +334,7 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSO
if (AccessCheck::isChrome(origin)) {
wrapper = &CrossCompartmentWrapper::singleton;
} else {
bool isSystem;
{
JSAutoEnterCompartment ac;
if (!ac.enter(cx, obj))
return nullptr;
JSObject *globalObj = JS_GetGlobalForObject(cx, obj);
JS_ASSERT(globalObj);
isSystem = JS_IsSystemObject(cx, globalObj);
}
if (isSystem) {
wrapper = &CrossCompartmentWrapper::singleton;
} else if (flags & WAIVE_XRAY_WRAPPER_FLAG) {
if (flags & WAIVE_XRAY_WRAPPER_FLAG) {
// If we waived the X-ray wrapper for this object, wrap it into a
// special wrapper to transitively maintain the X-ray waiver.
wrapper = &WaiveXrayWrapper::singleton;