mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 604368 - Share some code so that bug fixes fix both parts. r=peterv a=blocking beta7
--HG-- extra : rebase_source : e5b45f7353e36a0267df8d2ba1f65ec0093753b7
This commit is contained in:
parent
86245a5e28
commit
eecf8c3275
@ -216,6 +216,50 @@ GetPrincipal(JSObject *obj)
|
||||
return xpc->GetPrincipal(obj, PR_TRUE);
|
||||
}
|
||||
|
||||
bool
|
||||
AccessCheck::documentDomainMakesSameOrigin(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSObject *scope = nsnull;
|
||||
JSStackFrame *fp = nsnull;
|
||||
JS_FrameIterator(cx, &fp);
|
||||
if (fp) {
|
||||
while (fp->isDummyFrame()) {
|
||||
if (!JS_FrameIterator(cx, &fp))
|
||||
break;
|
||||
}
|
||||
|
||||
if (fp)
|
||||
scope = &fp->scopeChain();
|
||||
}
|
||||
|
||||
if (!scope)
|
||||
scope = JS_GetScopeChain(cx);
|
||||
|
||||
nsIPrincipal *subject;
|
||||
nsIPrincipal *object;
|
||||
|
||||
{
|
||||
JSAutoEnterCompartment ac;
|
||||
|
||||
if (!ac.enter(cx, scope))
|
||||
return false;
|
||||
|
||||
subject = GetPrincipal(JS_GetGlobalForObject(cx, scope));
|
||||
}
|
||||
|
||||
{
|
||||
JSAutoEnterCompartment ac;
|
||||
|
||||
if (!ac.enter(cx, obj))
|
||||
return false;
|
||||
|
||||
object = GetPrincipal(JS_GetGlobalForObject(cx, obj));
|
||||
}
|
||||
|
||||
PRBool subsumes;
|
||||
return NS_SUCCEEDED(subject->Subsumes(object, &subsumes)) && subsumes;
|
||||
}
|
||||
|
||||
bool
|
||||
AccessCheck::isCrossOriginAccessPermitted(JSContext *cx, JSObject *wrapper, jsid id,
|
||||
JSWrapper::Action act)
|
||||
@ -248,48 +292,8 @@ AccessCheck::isCrossOriginAccessPermitted(JSContext *cx, JSObject *wrapper, jsid
|
||||
|
||||
// We only reach this point for cross origin location objects (see
|
||||
// SameOriginOrCrossOriginAccessiblePropertiesOnly::check).
|
||||
if (!IsLocation(name)) {
|
||||
JSObject *scope = nsnull;
|
||||
JSStackFrame *fp = nsnull;
|
||||
JS_FrameIterator(cx, &fp);
|
||||
if (fp) {
|
||||
while (fp->isDummyFrame()) {
|
||||
if (!JS_FrameIterator(cx, &fp))
|
||||
break;
|
||||
}
|
||||
|
||||
if (fp)
|
||||
scope = &fp->scopeChain();
|
||||
}
|
||||
|
||||
if (!scope)
|
||||
scope = JS_GetScopeChain(cx);
|
||||
|
||||
nsIPrincipal *subject;
|
||||
nsIPrincipal *object;
|
||||
|
||||
{
|
||||
JSAutoEnterCompartment ac;
|
||||
|
||||
if (!ac.enter(cx, scope))
|
||||
return false;
|
||||
|
||||
subject = GetPrincipal(JS_GetGlobalForObject(cx, scope));
|
||||
}
|
||||
|
||||
{
|
||||
JSAutoEnterCompartment ac;
|
||||
|
||||
if (!ac.enter(cx, obj))
|
||||
return false;
|
||||
|
||||
object = GetPrincipal(JS_GetGlobalForObject(cx, obj));
|
||||
}
|
||||
|
||||
PRBool subsumes;
|
||||
if (NS_SUCCEEDED(subject->Subsumes(object, &subsumes)) && subsumes)
|
||||
return true;
|
||||
}
|
||||
if (!IsLocation(name) && documentDomainMakesSameOrigin(cx, obj))
|
||||
return true;
|
||||
|
||||
return (act == JSWrapper::SET)
|
||||
? nsContentUtils::IsCallerTrustedForWrite()
|
||||
|
@ -53,6 +53,7 @@ class AccessCheck {
|
||||
JSWrapper::Action act);
|
||||
static bool isSystemOnlyAccessPermitted(JSContext *cx);
|
||||
static bool isLocationObjectSameOrigin(JSContext *cx, JSObject *wrapper);
|
||||
static bool documentDomainMakesSameOrigin(JSContext *cx, JSObject *obj);
|
||||
|
||||
static bool needsSystemOnlyWrapper(JSObject *obj);
|
||||
|
||||
|
@ -415,49 +415,7 @@ Transparent(JSContext *cx, JSObject *wrapper)
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject *scope = nsnull;
|
||||
JSStackFrame *fp = nsnull;
|
||||
JS_FrameIterator(cx, &fp);
|
||||
if (fp) {
|
||||
while (fp->isDummyFrame()) {
|
||||
if (!JS_FrameIterator(cx, &fp))
|
||||
break;
|
||||
}
|
||||
|
||||
if (fp)
|
||||
scope = &fp->scopeChain();
|
||||
}
|
||||
|
||||
if (!scope)
|
||||
scope = JS_GetScopeChain(cx);
|
||||
|
||||
nsIPrincipal *subject;
|
||||
nsIPrincipal *object;
|
||||
|
||||
nsIXPConnect *xpc = nsXPConnect::GetXPConnect();
|
||||
{
|
||||
JSAutoEnterCompartment ac;
|
||||
|
||||
if (!ac.enter(cx, scope))
|
||||
return false;
|
||||
|
||||
subject = xpc->GetPrincipal(JS_GetGlobalForObject(cx, scope), PR_TRUE);
|
||||
}
|
||||
|
||||
{
|
||||
JSAutoEnterCompartment ac;
|
||||
|
||||
JSObject *obj = wrapper->unwrap();
|
||||
if (!ac.enter(cx, obj))
|
||||
return false;
|
||||
|
||||
object = xpc->GetPrincipal(JS_GetGlobalForObject(cx, obj), PR_TRUE);
|
||||
}
|
||||
|
||||
PRBool subsumes;
|
||||
if (NS_SUCCEEDED(subject->Subsumes(object, &subsumes)) && subsumes)
|
||||
return true;
|
||||
return false;
|
||||
return AccessCheck::documentDomainMakesSameOrigin(cx, wrapper->unwrap());
|
||||
}
|
||||
|
||||
namespace XrayUtils {
|
||||
|
Loading…
Reference in New Issue
Block a user