mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 08:42:13 +00:00
Back out 9aac714775b9 (bug 723111) for make check orange
This commit is contained in:
parent
19ee81d3dd
commit
5a0b40ee93
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user