How To Pass an XPCOM Object to a New Window
A more useful example is available in the source code:
If you want to be able to call functions within an XPCOM object from a XUL window's code, you can do so if you pass the XPCOM object as one of the arguments to the window creation method.
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]. getService(Components.interfaces.nsIWindowWatcher); var win = ww.openWindow(null, "chrome://myextension/content/debug.xul", "debug history", "chrome,centerscreen,resizable", myObject);
Note in this example that
myObject is passed to the
openWindow() method; you can pass any XPCOM object (or any other value, for that matter) in this way. To access the XPCOM object from the window's code, you can access the
window.arguments array, as shown in the example below:
This will produce output similar to "
[xpconnect wrapped nsIMyXPCOMObject]".