Using Cu.getGlobalForObject on wrappers seems to produce very strange results, e.g. returning the current global (of the wrapper?) rather than the global of the underlying object. mrbkap suggests that nsXPCComponents_Utils::GetGlobalForObject() needs to do some unwrapping magic before just calling into JS_GetGlobalForObject.
...And then re-wrapping afterwards, of course. Cc-ing Waldo since this is his baby. Also I want to ask him to consider the ramifications for removing JSObject::parent when fixing this. :)
Created attachment 492173 [details] [diff] [review] strawman This seems to get me the behavior that I want. I don't understand the security implications of this, or what the "re-wrapping" from comment 1 would entail, though.
Created attachment 492281 [details] [diff] [review] strawman, v2 This is mostly guesswork :)
Comment on attachment 492281 [details] [diff] [review] strawman, v2 Seems reasonable. I assume none of the methods here are fallible so as to need testing for null return or something? (I didn't look.)
Comment on attachment 492281 [details] [diff] [review] strawman, v2 Looks good, thanks.
Created attachment 539596 [details] [diff] [review] updated patch
I'm pretty sure I fixed this over in bug 736316.
sure looks like it!