Probably you need to use "wrappedJSObject". console.log( "lastTab", lastTab.contentWindow, lastTab.contentWindow.wrappedJSObject.myVar , lastTab.contentWindow.wrappedJSObject.content, lastTab.contentWindow.wrappedJSObject.content.myVar, lastTab.contentWindow.wrappedJSObject.self, lastTab.contentWindow.wrappedJSObject.self.myVar); @see wrappedJSObject - MDC https://developer.mozilla.org/en/WrappedJSObject
Thanks for the bug report! As Makoto mentioned, this has to do with the fact that the content window is actually a "safe" version of the window's content that behaves in an expected way, but its downside is that it can't access custom JS variables. GreaseMonkey makes the original window available through an "unsafeWindow" property: http://wiki.greasespot.net/UnsafeWindow We'll probably be using a similar name, so that e.g. you can get to your JS functions by accessing jetpack.tabs.focused.unsafeContentWindow. The reason I'd like to do this instead of telling Jetpack developers to use "wrappedJSObject" is probably the same for why GreaseMonkey decided not to: the name "wrappedJSObject" isn't very meaningful to audiences who don't know what XPConnect is, and it also exposes something in the underlying platform that could change at some point.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Renamed the bug title to better reflect the root problem.
Summary: jetpack.tabs[i].contentWindow is part i'th tab / part current tab → tab.contentWindow doesn't allow access to JS globals defined on the tab's page
Assignee: nobody → avarma
Priority: -- → P3
Target Milestone: -- → 0.5
I've talked to mrbkap about this and we've agreed that friendly-yet-secure behavior is to modify XPCNativeWrappers so that they see if the property on the underlying object exists and, if so, throw an exception that says something like: "The property 'foo' exists on the object but can't be accessed for security reasons. If this is indeed the property you'd like to access, you can retrieve it by first accessing this object's 'wrappedJSObject' property. Please note that it may not behave as you expect if the web page you're accessing is coded in an unusual way." To prototype this behavior and see how well it works without waiting for another release of Firefox, we can approximate the same kind of behavior using a FlexibleWrapper.
We will be monitoring all these issues after the rebooted Jetpack code base is released in the first week of March to ensure their causes are not duplicated. Many of the bugs/issues with the prototype version of Jetpack will be made irrelevant given the structure of the new SDK.
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.