diff --git a/common/bootstrap.js b/common/bootstrap.js index a3f2ac97..a438a7ff 100755 --- a/common/bootstrap.js +++ b/common/bootstrap.js @@ -95,7 +95,7 @@ FactoryProxy.prototype = { get module() { Object.defineProperty(this, "module", { value: {}, enumerable: true }); JSMLoader.load(this.url, this.module); - JSMLoader.registerGlobal(this.url, this.module.NSGetFactory); + JSMLoader.registerGlobal(this.url, this.module.global); return this.module; }, createInstance: function (iids) { diff --git a/common/components/commandline-handler.js b/common/components/commandline-handler.js index cee31646..6998b34d 100644 --- a/common/components/commandline-handler.js +++ b/common/components/commandline-handler.js @@ -4,7 +4,10 @@ // given in the LICENSE.txt file included with this file. "use strict"; -var Ci = Components.interfaces, Cc = Components.classes; +var global = this; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); @@ -48,6 +51,6 @@ if (XPCOMUtils.generateNSGetFactory) var NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandLineHandler]); else var NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]); -var EXPORTED_SYMBOLS = ["NSGetFactory"]; +var EXPORTED_SYMBOLS = ["NSGetFactory", "global"]; // vim: set fdm=marker sw=4 ts=4 et: diff --git a/common/components/protocols.js b/common/components/protocols.js index ba89090b..621403e4 100644 --- a/common/components/protocols.js +++ b/common/components/protocols.js @@ -207,6 +207,6 @@ if (XPCOMUtils.generateNSGetFactory) var NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutHandler, ChromeData, Dactyl, Shim]); else var NSGetModule = XPCOMUtils.generateNSGetModule([AboutHandler, ChromeData, Dactyl, Shim]); -var EXPORTED_SYMBOLS = ["NSGetFactory"]; +var EXPORTED_SYMBOLS = ["NSGetFactory", "global"]; // vim: set fdm=marker sw=4 ts=4 et: diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 3d1fae24..09d2aec5 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -2096,14 +2096,16 @@ const Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), if (!services.commandLineHandler) services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=" + config.name); - let commandline = services.commandLineHandler.optionValue; - if (commandline) { - let args = dactyl.parseCommandLine(commandline); - dactyl.commandLineOptions.rcFile = args["+u"]; - dactyl.commandLineOptions.noPlugins = "++noplugin" in args; - dactyl.commandLineOptions.postCommands = args["+c"]; - dactyl.commandLineOptions.preCommands = args["++cmd"]; - util.dump("Processing command-line option: " + commandline); + if (services.commandlinehandler) { + let commandline = services.commandLineHandler.optionValue; + if (commandline) { + let args = dactyl.parseCommandLine(commandline); + dactyl.commandLineOptions.rcFile = args["+u"]; + dactyl.commandLineOptions.noPlugins = "++noplugin" in args; + dactyl.commandLineOptions.postCommands = args["+c"]; + dactyl.commandLineOptions.preCommands = args["++cmd"]; + util.dump("Processing command-line option: " + commandline); + } } dactyl.log("Command-line options: " + util.objectToString(dactyl.commandLineOptions), 3); diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 6f3a27db..bc2c186c 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -18,8 +18,8 @@ if (!JSMLoader) let global = this.globals[url]; for each (let prop in Object.getOwnPropertyNames(global)) try { - if (!set.has(this.builtin, prop) && global[prop] != this && global[prop] != set) - delete global[prop] + if (!set.has(this.builtin, prop) && [this, set].indexOf(global[prop]) < 0) + delete global[prop]; } catch (e) {} @@ -36,7 +36,7 @@ if (!JSMLoader) }, registerGlobal: function registerGlobal(uri, obj) { if (Cu.getGlobalForObject) - this.globals[uri] = Cu.getGlobalForObject(obj); + this.globals[uri.replace(/.* -> /, "")] = Cu.getGlobalForObject(obj); } };