Don't push call contexts when we don't have to. r=jst

This commit is contained in:
Blake Kaplan 2010-05-19 18:26:29 -07:00
Родитель 40794f5a9b
Коммит e5bf036bd9
1 изменённых файлов: 11 добавлений и 36 удалений

Просмотреть файл

@ -608,11 +608,6 @@ XPC_XOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx); return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx);
} }
XPCCallContext ccx(JS_CALLER, cx);
if (!ccx.IsValid()) {
return ThrowException(NS_ERROR_FAILURE, cx);
}
JSBool privilegeEnabled = JS_FALSE; JSBool privilegeEnabled = JS_FALSE;
nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, &privilegeEnabled); nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, &privilegeEnabled);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@ -635,11 +630,6 @@ XPC_XOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx); return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx);
} }
XPCCallContext ccx(JS_CALLER, cx);
if (!ccx.IsValid()) {
return ThrowException(NS_ERROR_FAILURE, cx);
}
nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, nsnull); nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, nsnull);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
if (rv == NS_ERROR_DOM_PROP_ACCESS_DENIED) { if (rv == NS_ERROR_DOM_PROP_ACCESS_DENIED) {
@ -678,12 +668,7 @@ XPC_XOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx); return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx);
} }
XPCCallContext ccx(JS_CALLER, cx); js::AutoArrayRooter rooter(cx, 1, vp);
if (!ccx.IsValid()) {
return ThrowException(NS_ERROR_FAILURE, cx);
}
AUTO_MARK_JSVAL(ccx, vp);
JSObject *wrappedObj = GetWrappedObject(cx, obj); JSObject *wrappedObj = GetWrappedObject(cx, obj);
if (!wrappedObj) { if (!wrappedObj) {
@ -697,6 +682,11 @@ XPC_XOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
return JS_FALSE; return JS_FALSE;
} }
XPCCallContext ccx(JS_CALLER, cx);
if (!ccx.IsValid()) {
return ThrowException(NS_ERROR_FAILURE, cx);
}
// This is a request to get a property across origins. We need to // This is a request to get a property across origins. We need to
// determine if this property is allAccess. If it is, then we need to // determine if this property is allAccess. If it is, then we need to
// actually get the property. If not, we simply need to throw an // actually get the property. If not, we simply need to throw an
@ -798,11 +788,6 @@ XPC_XOW_Enumerate(JSContext *cx, JSObject *obj)
return JS_TRUE; return JS_TRUE;
} }
XPCCallContext ccx(JS_CALLER, cx);
if (!ccx.IsValid()) {
return ThrowException(NS_ERROR_FAILURE, cx);
}
nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, nsnull); nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, nsnull);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
if (rv == NS_ERROR_DOM_PROP_ACCESS_DENIED) { if (rv == NS_ERROR_DOM_PROP_ACCESS_DENIED) {
@ -894,11 +879,6 @@ XPC_XOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
return JS_TRUE; return JS_TRUE;
} }
XPCCallContext ccx(JS_CALLER, cx);
if (!ccx.IsValid()) {
return ThrowException(NS_ERROR_FAILURE, cx);
}
JSBool privilegeEnabled; JSBool privilegeEnabled;
nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, &privilegeEnabled); nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, &privilegeEnabled);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@ -906,6 +886,11 @@ XPC_XOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
return JS_FALSE; return JS_FALSE;
} }
XPCCallContext ccx(JS_CALLER, cx);
if (!ccx.IsValid()) {
return ThrowException(NS_ERROR_FAILURE, cx);
}
// We're dealing with a cross-origin lookup. Ensure that we're allowed to // We're dealing with a cross-origin lookup. Ensure that we're allowed to
// resolve this property and resolve it if so. Otherwise, we deny access // resolve this property and resolve it if so. Otherwise, we deny access
// and throw a security error. Note that this code does not actually check // and throw a security error. Note that this code does not actually check
@ -1062,11 +1047,6 @@ XPC_XOW_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return JS_TRUE; return JS_TRUE;
} }
XPCCallContext ccx(JS_CALLER, cx);
if (!ccx.IsValid()) {
return ThrowException(NS_ERROR_FAILURE, cx);
}
nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, nsnull); nsresult rv = CanAccessWrapper(cx, obj, wrappedObj, nsnull);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
if (rv == NS_ERROR_DOM_PROP_ACCESS_DENIED) { if (rv == NS_ERROR_DOM_PROP_ACCESS_DENIED) {
@ -1099,11 +1079,6 @@ XPC_XOW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return JS_TRUE; return JS_TRUE;
} }
XPCCallContext ccx(JS_CALLER, cx);
if (!ccx.IsValid()) {
return ThrowException(NS_ERROR_FAILURE, cx);
}
nsresult rv = CanAccessWrapper(cx, realObj, wrappedObj, nsnull); nsresult rv = CanAccessWrapper(cx, realObj, wrappedObj, nsnull);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
if (rv == NS_ERROR_DOM_PROP_ACCESS_DENIED) { if (rv == NS_ERROR_DOM_PROP_ACCESS_DENIED) {