Back out 9aac714775b9 (bug 723111) for make check orange

This commit is contained in:
Phil Ringnalda 2012-02-01 10:25:04 -08:00
parent 19ee81d3dd
commit 5a0b40ee93
9 changed files with 11 additions and 28 deletions

View File

@ -216,7 +216,7 @@ JSCompartment::wrap(JSContext *cx, Value *vp)
/* Don't unwrap an outer window proxy. */
if (!obj->getClass()->ext.innerObject) {
obj = UnwrapObject(&vp->toObject(), true, &flags);
obj = UnwrapObject(&vp->toObject(), &flags);
vp->setObject(*obj);
if (obj->compartment() == this)
return true;

View File

@ -76,13 +76,13 @@ js::IsWrapper(const JSObject *wrapper)
}
JS_FRIEND_API(JSObject *)
js::UnwrapObject(JSObject *wrapped, bool stopAtOuter, uintN *flagsp)
js::UnwrapObject(JSObject *wrapped, uintN *flagsp)
{
uintN flags = 0;
while (wrapped->isWrapper()) {
flags |= static_cast<Wrapper *>(GetProxyHandler(wrapped))->flags();
wrapped = GetProxyPrivate(wrapped).toObjectOrNull();
if (stopAtOuter && wrapped->getClass()->ext.innerObject)
if (wrapped->getClass()->ext.innerObject)
break;
}
if (flagsp)

View File

@ -206,14 +206,7 @@ TransparentObjectWrapper(JSContext *cx, JSObject *obj, JSObject *wrappedProto, J
uintN flags);
JS_FRIEND_API(bool) IsWrapper(const JSObject *obj);
// Given a JSObject, returns that object stripped of wrappers. If
// stopAtOuter is true, then this returns the outer window if it was
// previously wrapped. Otherwise, this returns the first object for
// which JSObject::isWrapper returns false.
JS_FRIEND_API(JSObject *) UnwrapObject(JSObject *obj, bool stopAtOuter = true,
uintN *flagsp = NULL);
JS_FRIEND_API(JSObject *) UnwrapObject(JSObject *obj, uintN *flagsp = NULL);
bool IsCrossCompartmentWrapper(const JSObject *obj);
} /* namespace js */

View File

@ -1220,7 +1220,7 @@ XPCConvert::JSObject2NativeInterface(XPCCallContext& ccx,
// we aren't, throw an exception eagerly.
JSObject* inner = nsnull;
if (XPCWrapper::IsSecurityWrapper(src)) {
inner = XPCWrapper::Unwrap(cx, src, false);
inner = XPCWrapper::Unwrap(cx, src);
if (!inner) {
if (pErr)
*pErr = NS_ERROR_XPC_SECURITY_MANAGER_VETO;

View File

@ -788,7 +788,7 @@ getWrapper(JSContext *cx,
XPCWrappedNativeTearOff **tearoff)
{
if (XPCWrapper::IsSecurityWrapper(obj) &&
!(obj = XPCWrapper::Unwrap(cx, obj, false))) {
!(obj = XPCWrapper::Unwrap(cx, obj))) {
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
}

View File

@ -123,12 +123,12 @@ AttachNewConstructorObject(XPCCallContext &ccx, JSObject *aGlobalObject)
namespace XPCWrapper {
JSObject *
Unwrap(JSContext *cx, JSObject *wrapper, bool stopAtOuter)
Unwrap(JSContext *cx, JSObject *wrapper)
{
if (js::IsWrapper(wrapper)) {
if (xpc::AccessCheck::isScriptAccessOnly(cx, wrapper))
return nsnull;
return js::UnwrapObject(wrapper, stopAtOuter);
return js::UnwrapObject(wrapper);
}
return nsnull;

View File

@ -93,7 +93,7 @@ IsSecurityWrapper(JSObject *wrapper)
* exception on |cx|.
*/
JSObject *
Unwrap(JSContext *cx, JSObject *wrapper, bool stopAtOuter = true);
Unwrap(JSContext *cx, JSObject *wrapper);
JSObject *
UnsafeUnwrapSecurityWrapper(JSObject *obj);

View File

@ -90,22 +90,12 @@ AccessCheck::isSameOrigin(JSCompartment *a, JSCompartment *b)
bool
AccessCheck::isLocationObjectSameOrigin(JSContext *cx, JSObject *wrapper)
{
// Location objects are parented to the outer window for which they
// were created. This gives us an easy way to determine whether our
// object is same origin with the current inner window:
// Grab the outer window...
JSObject *obj = js::GetObjectParent(js::UnwrapObject(wrapper));
if (!js::GetObjectClass(obj)->ext.innerObject) {
// ...which might be wrapped in a security wrapper.
obj = js::UnwrapObject(obj);
JS_ASSERT(js::GetObjectClass(obj)->ext.innerObject);
}
// Now innerize it to find the *current* inner window for our outer.
obj = JS_ObjectToInnerObject(cx, obj);
// Which lets us compare the current compartment against the old one.
return obj &&
(isSameOrigin(js::GetObjectCompartment(wrapper),
js::GetObjectCompartment(obj)) ||
@ -394,7 +384,7 @@ AccessCheck::isScriptAccessOnly(JSContext *cx, JSObject *wrapper)
JS_ASSERT(js::IsWrapper(wrapper));
uintN flags;
JSObject *obj = js::UnwrapObject(wrapper, true, &flags);
JSObject *obj = js::UnwrapObject(wrapper, &flags);
// If the wrapper indicates script-only access, we are done.
if (flags & WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG) {

View File

@ -53,7 +53,7 @@ class WrapperFactory {
// Return true if any of any of the nested wrappers have the flag set.
static bool HasWrapperFlag(JSObject *wrapper, uintN flag) {
uintN flags = 0;
js::UnwrapObject(wrapper, true, &flags);
js::UnwrapObject(wrapper, &flags);
return !!(flags & flag);
}