tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

head.js (1076B)


      1 "use strict";
      2 
      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) {
      6  let ifacePointer = Cc[
      7    "@mozilla.org/supports-interface-pointer;1"
      8  ].createInstance(Ci.nsISupportsInterfacePointer);
      9 
     10  ifacePointer.data = obj;
     11  if (iface) {
     12    return ifacePointer.data.QueryInterface(iface);
     13  }
     14  return ifacePointer.data;
     15 }
     16 
     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;
     24 }
     25 
     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;
     32 }