Within the context of a JS components or a JS module, the non-hacky way (and sometimes, the only way) to open a window is to use nsIWindowWatcher's openWindow. However, this methods takes the window arguments as an nsISupportsArray. Apart the complexity of wrapping each argument in some supports-wrapper, and then appending it to a supports array, this wrapping makes it impossible to pass JS Objects for window.arguments. Naively I though that nsIVariant would do the trick somehow. It doesn't. XPConnect wraps the JS Object as an nsISupports (probably at the time setFromVariant(nsIVariant) is called), and when window.arguemnts is accessed, the (quite useless) supports object is exposed in window.arguments. The only workaround I found is to "implement" wrappedJSObject in the object, and unwrap it later. I suppose one way to fix this is to add a JS-friendly version of openWindow to nsIWindowWatcher.
How is that supposed to work if the resulting window is not implemented in JS itself? Seems like if you happen to know that in your particular case both the caller and callee will be JS then the wrappedJSObject approach is in fact the right one....
Maybe window-watcher is not the right place for this api. My actual request here is pretty simple: Have an api similar to window.open in non-window contexts. [In fact, does window.open guarantee anything that windowwatcher doesn't]
Also, I'm almost sure that by using a nsIVariant I could pass a JS array as an argument. Couldn't we wrap other js objects in the same manner?
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 460296
You need to log in before you can comment on or make changes to this bug.