Bug 722775 - rm sameGroupAs. r=mrbkap

This commit is contained in:
Luke Wagner 2012-05-03 09:10:10 +02:00
parent 5b2a978d28
commit 8cef559f81
2 changed files with 6 additions and 38 deletions

View File

@ -3156,7 +3156,7 @@ xpc::SandboxProxyHandler::getOwnPropertyDescriptor(JSContext *cx,
nsresult
xpc_CreateSandboxObject(JSContext * cx, jsval * vp, nsISupports *prinOrSop, JSObject *proto,
bool wantXrays, const nsACString &sandboxName, nsISupports *identityPtr)
bool wantXrays, const nsACString &sandboxName)
{
// Create the sandbox global object
nsresult rv;
@ -3193,13 +3193,8 @@ xpc_CreateSandboxObject(JSContext * cx, jsval * vp, nsISupports *prinOrSop, JSOb
JSCompartment *compartment;
JSObject *sandbox;
nsRefPtr<Identity> identity;
if (!identityPtr) {
identity = new Identity();
identityPtr = identity;
}
rv = xpc_CreateGlobalObject(cx, &SandboxClass, principal, identityPtr,
nsRefPtr<Identity> identity = new Identity();
rv = xpc_CreateGlobalObject(cx, &SandboxClass, principal, identity,
wantXrays, &sandbox, &compartment);
NS_ENSURE_SUCCESS(rv, rv);
@ -3321,7 +3316,6 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe
nsCOMPtr<nsIScriptObjectPrincipal> sop;
nsCOMPtr<nsIPrincipal> principal;
nsISupports *prinOrSop = nsnull;
nsISupports *identity = nsnull;
if (JSVAL_IS_STRING(argv[0])) {
JSString *codebaseStr = JSVAL_TO_STRING(argv[0]);
size_t codebaseLength;
@ -3426,32 +3420,6 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe
sandboxName.Adopt(tmp, strlen(tmp));
}
// see Bug 677294:
if (!JS_HasProperty(cx, optionsObject, "sameGroupAs", &found))
return NS_ERROR_INVALID_ARG;
if (found) {
if (!JS_GetProperty(cx, optionsObject, "sameGroupAs", &option) ||
JSVAL_IS_PRIMITIVE(option))
return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval);
JSObject* unwrapped = UnwrapObject(JSVAL_TO_OBJECT(option));
JSObject* global = GetGlobalForObjectCrossCompartment(unwrapped);
if (GetObjectJSClass(unwrapped) != &SandboxClass &&
GetObjectJSClass(global) != &SandboxClass)
return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval);
void* privateValue =
JS_GetCompartmentPrivate(GetObjectCompartment(unwrapped));
xpc::CompartmentPrivate *compartmentPrivate =
static_cast<xpc::CompartmentPrivate*>(privateValue);
if (!compartmentPrivate || !compartmentPrivate->key)
return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval);
identity = compartmentPrivate->key->GetPtr();
}
}
// If there is no options object given, or no sandboxName property
@ -3477,7 +3445,7 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe
frame->GetFilename(getter_Copies(sandboxName));
}
rv = xpc_CreateSandboxObject(cx, vp, prinOrSop, proto, wantXrays, sandboxName, identity);
rv = xpc_CreateSandboxObject(cx, vp, prinOrSop, proto, wantXrays, sandboxName);
if (NS_FAILED(rv)) {
return ThrowAndFail(rv, cx, _retval);

View File

@ -4393,8 +4393,8 @@ xpc_GetJSPrivate(JSObject *obj)
// and used.
nsresult
xpc_CreateSandboxObject(JSContext * cx, jsval * vp, nsISupports *prinOrSop,
JSObject *proto, bool preferXray, const nsACString &sandboxName,
nsISupports *identityPtr = nsnull);
JSObject *proto, bool preferXray, const nsACString &sandboxName);
// Helper for evaluating scripts in a sandbox object created with
// xpc_CreateSandboxObject(). The caller is responsible of ensuring
// that *rval doesn't get collected during the call or usage after the