mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1065452 - Add an API to access the associated window of addon scopes. r=billm
This commit is contained in:
parent
ba247c6cd4
commit
c0c7f8a06e
@ -395,6 +395,14 @@ js::GetGlobalForObjectCrossCompartment(JSObject *obj)
|
||||
return &obj->global();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSObject *)
|
||||
js::GetPrototypeNoProxy(JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(!obj->is<js::ProxyObject>());
|
||||
JS_ASSERT(!obj->getTaggedProto().isLazy());
|
||||
return obj->getTaggedProto().toObjectOrNull();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::SetPendingExceptionCrossContext(JSContext *cx, JS::HandleValue v)
|
||||
{
|
||||
|
@ -706,6 +706,9 @@ GetObjectParentMaybeScope(JSObject *obj);
|
||||
JS_FRIEND_API(JSObject *)
|
||||
GetGlobalForObjectCrossCompartment(JSObject *obj);
|
||||
|
||||
JS_FRIEND_API(JSObject *)
|
||||
GetPrototypeNoProxy(JSObject *obj);
|
||||
|
||||
// Sidestep the activeContext checking implicitly performed in
|
||||
// JS_SetPendingException.
|
||||
JS_FRIEND_API(void)
|
||||
|
@ -575,6 +575,25 @@ WindowGlobalOrNull(JSObject *aObj)
|
||||
return WindowOrNull(glob);
|
||||
}
|
||||
|
||||
nsGlobalWindow*
|
||||
AddonWindowOrNull(JSObject *aObj)
|
||||
{
|
||||
if (!IsInAddonScope(aObj))
|
||||
return nullptr;
|
||||
|
||||
JSObject *global = js::GetGlobalForObjectCrossCompartment(aObj);
|
||||
JSObject *proto = js::GetPrototypeNoProxy(global);
|
||||
|
||||
// Addons could theoretically change the prototype of the addon scope, but
|
||||
// we pretty much just want to crash if that happens so that we find out
|
||||
// about it and get them to change their code.
|
||||
MOZ_RELEASE_ASSERT(js::IsCrossCompartmentWrapper(proto));
|
||||
JSObject *mainGlobal = js::UncheckedUnwrap(proto, /* stopAtOuter = */ false);
|
||||
MOZ_RELEASE_ASSERT(JS_IsGlobalObject(mainGlobal));
|
||||
|
||||
return WindowOrNull(mainGlobal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -472,6 +472,14 @@ WindowOrNull(JSObject *aObj);
|
||||
nsGlobalWindow*
|
||||
WindowGlobalOrNull(JSObject *aObj);
|
||||
|
||||
/**
|
||||
* If |aObj| is in an addon scope and that addon scope is associated with a
|
||||
* live DOM Window, returns the associated nsGlobalWindow. Otherwise, returns
|
||||
* null.
|
||||
*/
|
||||
nsGlobalWindow*
|
||||
AddonWindowOrNull(JSObject *aObj);
|
||||
|
||||
// Error reporter used when there is no associated DOM window on to which to
|
||||
// report errors and warnings.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user