Skip to content

Instantly share code, notes, and snippets.

@jeffgca
Forked from anonymous/gist:2933173
Created June 14, 2012 21:46
Show Gist options
  • Save jeffgca/2933176 to your computer and use it in GitHub Desktop.
Save jeffgca/2933176 to your computer and use it in GitHub Desktop.
var { Cc, Ci } = require("chrome");
var L = console.log;
var pp = function(o) { return JSON.stringify(o,null,' '); };
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
var gWin = wm.getEnumerator("navigator:browser").getNext();
L(pp(Object.keys(gWin)));
var _getChromeWindow = function (aWindow) {
var chromeWin = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell).chromeEventHandler.ownerDocument.defaultView;
return chromeWin;
};
var _getNativeWindow = function (gWin) {
var nativeWindow = null;
try {
var chromeWin = _getChromeWindow(gWin).wrappedJSObject;
if (chromeWin.NativeWindow) {
nativeWindow = chromeWin.NativeWindow;
} else {
L("NativeWindow not available on window");
}
} catch (e) {
// If any errors happen, just assume no native window helper.
L("No NativeWindow available: " + e);
}
return nativeWindow;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment