mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-08 14:03:49 +00:00
Bug 773962 - Introduce Cu.recomputeWrappers. r=mrbkap
It's sort of annoying to add this API just for tests, but there's not another great way to trigger a compartment-wide transplant with Xray waivers (since setting document.domain doesn't recompute wrappers to/from chrome, and Xray waivers will stop being accessible to content entirely in bug 742444).
This commit is contained in:
parent
3cf16c36ad
commit
f747c53f93
@ -118,7 +118,7 @@ interface ScheduledGCCallback : nsISupports
|
||||
/**
|
||||
* interface of Components.utils
|
||||
*/
|
||||
[scriptable, uuid(fc26b9e9-87a1-44a4-b774-53781b7df16b)]
|
||||
[scriptable, uuid(2df24c04-f1ef-481c-8605-433082a34e95)]
|
||||
interface nsIXPCComponents_Utils : nsISupports
|
||||
{
|
||||
|
||||
@ -311,6 +311,17 @@ interface nsIXPCComponents_Utils : nsISupports
|
||||
*/
|
||||
bool isDeadWrapper(in jsval obj);
|
||||
|
||||
/*
|
||||
* To be called from JS only. This is for Gecko internal use only, and may
|
||||
* disappear at any moment.
|
||||
*
|
||||
* Forces a recomputation of all wrappers in and out of the compartment
|
||||
* containing |obj|. If |obj| is not an object, all wrappers system-wide
|
||||
* are recomputed.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void recomputeWrappers([optional] in jsval vobj);
|
||||
|
||||
/*
|
||||
* To be called from JS only.
|
||||
*
|
||||
@ -356,7 +367,7 @@ interface nsIXPCComponents_Utils : nsISupports
|
||||
/**
|
||||
* interface of JavaScript's 'Components' object
|
||||
*/
|
||||
[scriptable, uuid(4676e9cf-2c07-423b-b161-26bb9d8067d3)]
|
||||
[scriptable, uuid(8406dedb-23cc-42db-9f69-1f18785091b5)]
|
||||
interface nsIXPCComponents : nsISupports
|
||||
{
|
||||
readonly attribute nsIXPCComponents_Interfaces interfaces;
|
||||
|
@ -4307,6 +4307,24 @@ nsXPCComponents_Utils::IsDeadWrapper(const jsval &obj, bool *out)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void recomputerWrappers(jsval vobj); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::RecomputeWrappers(const jsval &vobj, JSContext *cx)
|
||||
{
|
||||
// Determine the compartment of the given object, if any.
|
||||
JSCompartment *c = vobj.isObject()
|
||||
? js::GetObjectCompartment(js::UnwrapObject(&vobj.toObject()))
|
||||
: NULL;
|
||||
|
||||
// If no compartment was given, recompute all.
|
||||
if (!c)
|
||||
return js::RecomputeWrappers(cx, js::AllCompartments(), js::AllCompartments());
|
||||
|
||||
// Otherwise, recompute wrappers for the given compartment.
|
||||
return js::RecomputeWrappers(cx, js::SingleCompartment(c), js::AllCompartments()) &&
|
||||
js::RecomputeWrappers(cx, js::AllCompartments(), js::SingleCompartment(c));
|
||||
}
|
||||
|
||||
/* string canCreateWrapper (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::CanCreateWrapper(const nsIID * iid, char **_retval)
|
||||
|
Loading…
Reference in New Issue
Block a user