Cc = Components.classes; Ci = Components.interfaces; Cr = Components.results; Cu = Components.utils; loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader); load = function(fileURI, moduleScope) { try { loader.loadSubScript(fileURI, moduleScope); } catch (e) { throw({name: "LoadError", message: "Failed to load " + fileURI + ": " + e.message}); } }; print = dump; puts = function(str) { print(str + "\n"); }; // Much love to http://ejohn.org/blog/__file__-in-javascript/ this.__defineGetter__("__FILE__", function() { var stack = (new Error).stack; // FIXME - Great. All this is a dance around the fact line #289 of mozJSSubScriptLoader.cpp in mozilla 1.9.1 // thinks that the best way to delimit script files is with a fucking ASCII arrow YOU FUCKS var fileURI = stack.split("\n")[2].split("@")[1].split(" -> ").slice(-1)[0].split(/:[0-9]/)[0]; return fileURI; });