Skip to content

Instantly share code, notes, and snippets.

@Gozala
Created December 20, 2012 17:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gozala/4347249 to your computer and use it in GitHub Desktop.
Save Gozala/4347249 to your computer and use it in GitHub Desktop.
Create an addon's own hidden window.
let Cc = Components.classes;
let Ci = Components.interfaces;
let appShellService = Cc['@mozilla.org/appshell/appShellService;1'].
getService(Ci.nsIAppShellService);
let ioService = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService);
let uri = "data:application/xhtml+xml;charset=utf-8,<html/>"
let xulWindow = appShellService.createTopLevelWindow(
null, // (Also tried no visible diff) appShellService.hiddenWindow
ioService.newURI(uri, null, null),
false,
false,
null,
null,
null,
null);
appShellService.unregisterTopLevelWindow(xulWindow);
let domWindow = xulWindow.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindow)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment