3 // Wraps the given object in an XPConnect wrapper and, if an interface
4 // is passed, queries the result to that interface.
5 function xpcWrap(obj, iface) {
7 "@mozilla.org/supports-interface-pointer;1"
8 ].createInstance(Ci.nsISupportsInterfacePointer);
10 ifacePointer.data = obj;
12 return ifacePointer.data.QueryInterface(iface);
14 return ifacePointer.data;
17 function createContentWindow(uri) {
18 const principal = Services.scriptSecurityManager
19 .createContentPrincipalFromOrigin(uri);
20 const webnav = Services.appShell.createWindowlessBrowser(false);
21 const docShell = webnav.docShell;
22 docShell.createAboutBlankDocumentViewer(principal, principal);
23 return webnav.document.defaultView;
26 function createChromeWindow() {
27 const principal = Services.scriptSecurityManager.getSystemPrincipal();
28 const webnav = Services.appShell.createWindowlessBrowser(true);
29 const docShell = webnav.docShell;
30 docShell.createAboutBlankDocumentViewer(principal, principal);
31 return webnav.document.defaultView;