The default bug view has changed. See this FAQ.

Cu.getGlobalForObject should unwrap wrappers

RESOLVED DUPLICATE of bug 736316

Status

()

Core
XPConnect
RESOLVED DUPLICATE of bug 736316
6 years ago
5 years ago

People

(Reporter: Gavin, Unassigned)

Tracking

(Blocks: 1 bug)

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

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 :)
Attachment #492173 - Attachment is obsolete: true
Attachment #492281 - Flags: feedback?(jwalden+bmo)
Attachment #492281 - Flags: feedback?(mrbkap)
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.)
Attachment #492281 - Flags: feedback?(jwalden+bmo) → feedback+
Attachment #492281 - Flags: feedback?(mrbkap) → review?(mrbkap)
Comment on attachment 492281 [details] [diff] [review]
strawman, v2

Looks good, thanks.
Attachment #492281 - Flags: review?(mrbkap) → review+
Created attachment 539596 [details] [diff] [review]
updated patch
Attachment #492281 - Attachment is obsolete: true
Blocks: 664426
I'm pretty sure I fixed this over in bug 736316.
sure looks like it!
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 736316
You need to log in before you can comment on or make changes to this bug.