1
0
Fork 0
firefox/js/xpconnect/tests/unit/head.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

32 lines
1.1 KiB
JavaScript

"use strict";
// Wraps the given object in an XPConnect wrapper and, if an interface
// is passed, queries the result to that interface.
function xpcWrap(obj, iface) {
let ifacePointer = Cc[
"@mozilla.org/supports-interface-pointer;1"
].createInstance(Ci.nsISupportsInterfacePointer);
ifacePointer.data = obj;
if (iface) {
return ifacePointer.data.QueryInterface(iface);
}
return ifacePointer.data;
}
function createContentWindow(uri) {
const principal = Services.scriptSecurityManager
.createContentPrincipalFromOrigin(uri);
const webnav = Services.appShell.createWindowlessBrowser(false);
const docShell = webnav.docShell;
docShell.createAboutBlankDocumentViewer(principal, principal);
return webnav.document.defaultView;
}
function createChromeWindow() {
const principal = Services.scriptSecurityManager.getSystemPrincipal();
const webnav = Services.appShell.createWindowlessBrowser(true);
const docShell = webnav.docShell;
docShell.createAboutBlankDocumentViewer(principal, principal);
return webnav.document.defaultView;
}