From 1ee5668cac9b3e545b359a7736041b20e2ce662f Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 21 Feb 2015 22:43:41 -0800 Subject: [PATCH] Cleanup crufty `apply` code. --- common/content/commandline.js | 4 ++-- common/content/editor.js | 2 +- common/content/events.js | 8 ++++---- common/content/history.js | 2 +- common/content/key-processors.js | 4 ++-- common/content/mappings.js | 4 ++-- common/content/modes.js | 4 ++-- common/content/mow.js | 2 +- common/content/statusline.js | 2 +- common/modules/addons.jsm | 2 +- common/modules/base.jsm | 18 +++++++++--------- common/modules/buffer.jsm | 2 +- common/modules/commands.jsm | 4 ++-- common/modules/completion.jsm | 10 +++++----- common/modules/contexts.jsm | 2 +- common/modules/dom.jsm | 7 +------ common/modules/io.jsm | 4 ++-- common/modules/javascript.jsm | 4 ++-- common/modules/options.jsm | 24 ++++++++++++------------ common/modules/overlay.jsm | 4 ++-- common/modules/sanitizer.jsm | 2 +- common/modules/services.jsm | 2 +- common/modules/storage.jsm | 6 +++--- common/modules/styles.jsm | 4 ++-- common/modules/template.jsm | 4 ++-- common/modules/util.jsm | 3 ++- 26 files changed, 65 insertions(+), 69 deletions(-) diff --git a/common/content/commandline.js b/common/content/commandline.js index f876e413..e02bcd5a 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -957,7 +957,7 @@ var CommandLine = Module("commandline", { } this.savingOutput = true; - dactyl.trapErrors.apply(dactyl, [fn, self].concat(args)); + apply(dactyl, "trapErrors", [fn, self].concat(args)); this.savingOutput = false; return output.map(elem => elem instanceof Node ? DOM.stringify(elem) : elem) .join("\n"); @@ -1755,7 +1755,7 @@ var CommandLine = Module("commandline", { return Events.PASS; }); - let bind = function bind(...args) mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(args)); + let bind = function bind(...args) apply(mappings, "add", [[modes.COMMAND_LINE]].concat(args)); bind(["", ""], "Stop waiting for completions or exit Command Line mode", function ({ self }) { diff --git a/common/content/editor.js b/common/content/editor.js index 8344b7ed..1d711034 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -1334,7 +1334,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { }, { count: true }); - bind = function bind(...args) mappings.add.apply(mappings, [[modes.AUTOCOMPLETE]].concat(args)); + bind = function bind(...args) apply(mappings, "add", [[modes.AUTOCOMPLETE]].concat(args)); bind([""], "Return to Insert mode", () => Events.PASS_THROUGH); diff --git a/common/content/events.js b/common/content/events.js index 80599821..52dbf392 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -57,7 +57,7 @@ var EventHive = Class("EventHive", Contexts.Hive, { capture, allowUntrusted]; - target.addEventListener.apply(target, args.slice(2)); + apply(target, "addEventListener", args.slice(2)); this.sessionListeners.push(args); } }, @@ -83,7 +83,7 @@ var EventHive = Class("EventHive", Contexts.Hive, { && args[3].wrapped == events[args[2]] && args[4] == capture) { - elem.removeEventListener.apply(elem, args.slice(2)); + apply(elem, "removeEventListener", args.slice(2)); return false; } return elem; @@ -426,7 +426,7 @@ var Events = Module("events", { canonicalKeys: deprecated("DOM.Event.canonicalKeys", { get: function canonicalKeys() DOM.Event.bound.canonicalKeys }), create: deprecated("DOM.Event", function create() DOM.Event.apply(null, arguments)), - dispatch: deprecated("DOM.Event.dispatch", function dispatch() DOM.Event.dispatch.apply(DOM.Event, arguments)), + dispatch: deprecated("DOM.Event.dispatch", function dispatch() apply(DOM.Event, "dispatch", arguments)), fromString: deprecated("DOM.Event.parse", { get: function fromString() DOM.Event.bound.parse }), iterKeys: deprecated("DOM.Event.iterKeys", { get: function iterKeys() DOM.Event.bound.iterKeys }), @@ -435,7 +435,7 @@ var Events = Module("events", { return toString.supercall(this); deprecated.warn(toString, "toString", "DOM.Event.stringify"); - return DOM.Event.stringify.apply(DOM.Event, arguments); + return apply(DOM.Event, "stringify", arguments); }, get defaultTarget() dactyl.focusedElement || content.document.body || document.documentElement, diff --git a/common/content/history.js b/common/content/history.js index 0e2883e6..875a487c 100644 --- a/common/content/history.js +++ b/common/content/history.js @@ -354,7 +354,7 @@ var History = Module("history", { completion.addUrlCompleter("history", "History", completion.history); }, mappings: function initMappings() { - function bind(...args) mappings.add.apply(mappings, [config.browserModes].concat(args)); + function bind(...args) apply(mappings, "add", [config.browserModes].concat(args)); bind([""], "Go to an older position in the jump list", function ({ count }) { history.stepTo(-Math.max(count, 1), true); }, diff --git a/common/content/key-processors.js b/common/content/key-processors.js index 5487d7cf..dfe60035 100644 --- a/common/content/key-processors.js +++ b/common/content/key-processors.js @@ -252,13 +252,13 @@ var KeyProcessor = Class("KeyProcessor", { execute: function execute(map, args) () => { if (this.preExecute) - this.preExecute.apply(this, args); + apply(this, "preExecute", args); args.self = this.main.params.mappingSelf || this.main.mappingSelf || map; let res = map.execute.call(map, args); if (this.postExecute) - this.postExecute.apply(this, args); + apply(this, "postExecute", args); return res; }, diff --git a/common/content/mappings.js b/common/content/mappings.js index 11d73c9b..67221f32 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -414,7 +414,7 @@ var Mappings = Module("mappings", { group = this.user; } - let map = group.add.apply(group, arguments); + let map = apply(group, "add", arguments); map.definedAt = contexts.getCaller(Components.stack.caller); return map; }, @@ -431,7 +431,7 @@ var Mappings = Module("mappings", { * @optional */ addUserMap: deprecated("group.mappings.add", function addUserMap() { - let map = this.user.add.apply(this.user, arguments); + let map = apply(this.user, "add", arguments); map.definedAt = contexts.getCaller(Components.stack.caller); return map; }), diff --git a/common/content/modes.js b/common/content/modes.js index bd534030..177a08bd 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -450,7 +450,7 @@ var Modes = Module("modes", { for (let mode of array.iterValues(queue)) if (!seen.add(mode)) { res.push(mode); - queue.push.apply(queue, mode.bases); + apply(queue, "push", mode.bases); } return res; }), @@ -649,7 +649,7 @@ var Modes = Module("modes", { }, prefs: function initPrefs() { prefs.watch("accessibility.browsewithcaret", - function () { modes.onCaretChange.apply(modes, arguments); }); + function () { apply(modes, "onCaretChange", arguments); }); } }); diff --git a/common/content/mow.js b/common/content/mow.js index fa30fc22..4f98ec17 100644 --- a/common/content/mow.js +++ b/common/content/mow.js @@ -66,7 +66,7 @@ var MOW = Module("mow", { }); }, - __noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)), + __noSuchMethod__: function (meth, args) apply(Buffer, meth, [this.body].concat(args)), get widget() this.widgets.multilineOutput, diff --git a/common/content/statusline.js b/common/content/statusline.js index c83a98db..529c06a7 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -237,7 +237,7 @@ var StatusLine = Module("statusline", { }, unsafeURI: deprecated("util.unsafeURI", { get: function unsafeURI() util.unsafeURI }), - losslessDecodeURI: deprecated("util.losslessDecodeURI", function losslessDecodeURI() util.losslessDecodeURI.apply(util, arguments)), + losslessDecodeURI: deprecated("util.losslessDecodeURI", function losslessDecodeURI() apply(util, "losslessDecodeURI", arguments)), /** * Update the URL displayed in the status line. Also displays status diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index 60973dd7..023b502d 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -238,7 +238,7 @@ var Addon = Class("Addon", { ["cancelUninstall", "findUpdates", "getResourceURI", "hasResource", "isCompatibleWith", "uninstall"].forEach(function (prop) { - Addon.prototype[prop] = function proxy() this.addon[prop].apply(this.addon, arguments); + Addon.prototype[prop] = function proxy() apply(this.addon, prop, arguments); }); ["aboutURL", "appDisabled", "applyBackgroundUpdates", "blocklistState", "contributors", "creator", diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 7e5de80c..40fb1d90 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -270,7 +270,7 @@ function literal(comment) { function apply(obj, meth, args) { // The function's own apply method breaks in strange ways // when using CPOWs. - Function.prototype.apply.call(obj[meth], obj, args); + return Function.prototype.apply.call(obj[meth], obj, args); } /** @@ -354,7 +354,7 @@ function deprecated(alternative, fn) { let name, func = callable(fn) ? fn - : function () this[fn].apply(this, arguments); + : function () apply(this, fn, arguments); function deprecatedMethod() { let obj = !this ? "" : @@ -561,7 +561,7 @@ function set() { Object.keys(Set).forEach(function (meth) { set[meth] = function proxy() { deprecated.warn(proxy, "set." + meth, "Set." + meth); - return Set[meth].apply(Set, arguments); + return apply(Set, meth, arguments); }; }); @@ -617,7 +617,7 @@ function curry(fn, length, self, acc) { var bind = function bind(meth, self, ...args) { let func = callable(meth) ? meth : self[meth]; - return func.bind.apply(func, [self].concat(args)); + return apply(func, "bind", [self].concat(args)); } /** @@ -1728,12 +1728,12 @@ const Iter = Class("Iter", { this.iter = iter.__iterator__(); if (this.iter.finalize) - this.finalize = function finalize() this.iter.finalize.apply(this.iter, arguments); + this.finalize = function finalize() apply(this.iter, "finalize", arguments); }, next: function next() this.iter.next(), - send: function send() this.iter.send.apply(this.iter, arguments), + send: function send() apply(this.iter, "send", arguments), "@@iterator": function () this.iter, }); @@ -1915,7 +1915,7 @@ var array = Class("array", Array, { let iterProto = Iter.prototype; Object.keys(iter).forEach(function (k) { iterProto[k] = function (...args) { - let res = iter[k].apply(iter, [this].concat(args)); + let res = apply(iter, k, [this].concat(args)); if (isinstance(res, ["Iterator", "Generator"])) return Iter(res); return res; @@ -1925,7 +1925,7 @@ Object.keys(iter).forEach(function (k) { Object.keys(array).forEach(function (k) { if (!(k in iterProto)) iterProto[k] = function (...args) { - let res = array[k].apply(array, [this.toArray()].concat(args)); + let res = apply(array, k, [this.toArray()].concat(args)); if (isinstance(res, ["Iterator", "Generator"])) return Iter(res); if (isArray(res)) @@ -1938,7 +1938,7 @@ Object.getOwnPropertyNames(Array.prototype).forEach(function (k) { if (!(k in iterProto) && callable(Array.prototype[k])) iterProto[k] = function () { let ary = iter(this).toArray(); - let res = ary[k].apply(ary, arguments); + let res = apply(ary, k, arguments); if (isArray(res)) return array(res); return res; diff --git a/common/modules/buffer.jsm b/common/modules/buffer.jsm index 79c44281..5db7d45a 100644 --- a/common/modules/buffer.jsm +++ b/common/modules/buffer.jsm @@ -204,7 +204,7 @@ var Buffer = Module("Buffer", { /** * @property {number} True when the buffer is fully loaded. */ - get loaded() Math.min.apply(null, + get loaded() apply(Math, "min", this.allFrames() .map(frame => ["loading", "interactive", "complete"] .indexOf(frame.document.readyState))), diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm index 297bd0e1..1336449a 100644 --- a/common/modules/commands.jsm +++ b/common/modules/commands.jsm @@ -596,7 +596,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, { _add: function _add(names, description, action, extra={}, replace=false) { const { contexts } = this.modules; extra.definedAt = contexts.getCaller(Components.stack.caller.caller); - return this.add.apply(this, arguments); + return apply(this, "add", arguments); }, /** @@ -837,7 +837,7 @@ var Commands = Module("commands", { group = this.user; } - return group._add.apply(group, arguments); + return apply(group, "_add", arguments); }, addUserCommand: deprecated("group.commands.add", { get: function addUserCommand() this.user.bound._add }), getUserCommands: deprecated("iter(group.commands)", function getUserCommands() iter(this.user).toArray()), diff --git a/common/modules/completion.jsm b/common/modules/completion.jsm index fe96ce6b..b6b3c4b8 100644 --- a/common/modules/completion.jsm +++ b/common/modules/completion.jsm @@ -241,7 +241,7 @@ var CompletionContext = Class("CompletionContext", { return this.cache.allItemsResult; this.cache.allItems = allItems; - let minStart = Math.min.apply(Math, this.activeContexts.map(function m(c) c.offset)); + let minStart = apply(Math, "min", this.activeContexts.map(function m(c) c.offset)); if (minStart == Infinity) minStart = 0; @@ -271,7 +271,7 @@ var CompletionContext = Class("CompletionContext", { // Temporary get allSubstrings() { let contexts = this.activeContexts; - let minStart = Math.min.apply(Math, contexts.map(function m(c) c.offset)); + let minStart = apply(Math, "min", contexts.map(function m(c) c.offset)); let lists = contexts.map(function m(context) { let prefix = context.value.substring(minStart, context.offset); return context.substrings.map(function m(s) prefix + s); @@ -906,7 +906,7 @@ var Completion = Module("completion", { _runCompleter: function _runCompleter(name, filter, maxItems, ...args) { let context = modules.CompletionContext(filter); context.maxItems = maxItems; - let res = context.fork.apply(context, ["run", 0, this, name].concat(args)); + let res = apply(context, "fork", ["run", 0, this, name].concat(args)); if (res) { if (Components.stack.caller.name === "runCompleter") // FIXME return { items: res.map(function m(i) ({ item: i })) }; @@ -917,14 +917,14 @@ var Completion = Module("completion", { }, runCompleter: function runCompleter(name, filter, maxItems) { - return this._runCompleter.apply(this, arguments) + return apply(this, "_runCompleter", arguments) .items.map(function m(i) i.item); }, listCompleter: function listCompleter(name, filter, maxItems, ...args) { let context = modules.CompletionContext(filter || ""); context.maxItems = maxItems; - context.fork.apply(context, ["list", 0, this, name].concat(args)); + apply(context, "fork", ["list", 0, this, name].concat(args)); context = context.contexts["/list"]; context.wait(null, true); diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index 1eed3b5f..2b19d6af 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -553,7 +553,7 @@ var Contexts = Module("contexts", { if (callable(params)) action = dactyl.userEval("(function action() { with (action.makeParams(this, arguments)) {" + args.literalArg + "} })"); else - action = dactyl.userFunc.apply(dactyl, params.concat(args.literalArg)); + action = apply(dactyl, "userFunc", params.concat(args.literalArg)); process = param => isObject(param) && param.valueOf ? param.valueOf() : param; action.params = params; action.makeParams = makeParams; diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index 5a4d2598..c531e6b8 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -1002,12 +1002,7 @@ var DOM = Class("DOM", { for (k in opts) if (k in params))); - // Because security boundaries :/ - let ary = new doc.defaultView.Array; - for (let arg of args) - ary.push(params[arg]); - - evt["init" + t + "Event"].apply(evt, ary); + apply(evt, "init" + t + "Event", args.map(arg => params[arg])); return evt; } }, { diff --git a/common/modules/io.jsm b/common/modules/io.jsm index 6b062500..418a22d5 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -306,7 +306,7 @@ var IO = Module("io", { */ sourcing: null, - expandPath: deprecated("File.expandPath", function expandPath() File.expandPath.apply(File, arguments)), + expandPath: deprecated("File.expandPath", function expandPath() apply(File, "expandPath", arguments)), /** * Returns the first user RC file found in *dir*. @@ -523,7 +523,7 @@ var IO = Module("io", { stdin.write(input); function result(status, output) ({ - __noSuchMethod__: function (meth, args) this.output[meth].apply(this.output, args), + __noSuchMethod__: function (meth, args) apply(this.output, meth, args), valueOf: function () this.output, output: output.replace(/^(.*)\n$/, "$1"), returnValue: status, diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm index de163acf..7ba40fe4 100644 --- a/common/modules/javascript.jsm +++ b/common/modules/javascript.jsm @@ -760,7 +760,7 @@ var JavaScript = Module("javascript", { return this.rootNode; }), - __noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.rootNode].concat(args)) + __noSuchMethod__: function (meth, args) apply(Buffer, meth, [this.rootNode].concat(args)) }); modules.CommandREPLMode = Class("CommandREPLMode", modules.CommandMode, { @@ -859,7 +859,7 @@ var JavaScript = Module("javascript", { mappings: function initMappings(dactyl, modules, window) { const { mappings, modes } = modules; - function bind(...args) mappings.add.apply(mappings, [[modes.REPL]].concat(args)) + function bind(...args) apply(mappings, "add", [[modes.REPL]].concat(args)) bind([""], "Accept the current input", function ({ self }) { self.accept(); }); diff --git a/common/modules/options.jsm b/common/modules/options.jsm index 32b32497..7a1f51ae 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -985,18 +985,18 @@ var Options = Module("options", { "@@iterator": function __iterator__() values(this._options.sort((a, b) => String.localeCompare(a.name, b.name))), - allPrefs: deprecated("prefs.getNames", function allPrefs() prefs.getNames.apply(prefs, arguments)), - getPref: deprecated("prefs.get", function getPref() prefs.get.apply(prefs, arguments)), - invertPref: deprecated("prefs.invert", function invertPref() prefs.invert.apply(prefs, arguments)), - listPrefs: deprecated("prefs.list", function listPrefs() { this.modules.commandline.commandOutput(prefs.list.apply(prefs, arguments)); }), - observePref: deprecated("prefs.observe", function observePref() prefs.observe.apply(prefs, arguments)), - popContext: deprecated("prefs.popContext", function popContext() prefs.popContext.apply(prefs, arguments)), - pushContext: deprecated("prefs.pushContext", function pushContext() prefs.pushContext.apply(prefs, arguments)), - resetPref: deprecated("prefs.reset", function resetPref() prefs.reset.apply(prefs, arguments)), - safeResetPref: deprecated("prefs.safeReset", function safeResetPref() prefs.safeReset.apply(prefs, arguments)), - safeSetPref: deprecated("prefs.safeSet", function safeSetPref() prefs.safeSet.apply(prefs, arguments)), - setPref: deprecated("prefs.set", function setPref() prefs.set.apply(prefs, arguments)), - withContext: deprecated("prefs.withContext", function withContext() prefs.withContext.apply(prefs, arguments)), + allPrefs: deprecated("prefs.getNames", function allPrefs() apply(prefs, "getNames", arguments)), + getPref: deprecated("prefs.get", function getPref() apply(prefs, "get", arguments)), + invertPref: deprecated("prefs.invert", function invertPref() apply(prefs, "invert", arguments)), + listPrefs: deprecated("prefs.list", function listPrefs() { this.modules.commandline.commandOutput(apply(prefs, "list", arguments)); }), + observePref: deprecated("prefs.observe", function observePref() apply(prefs, "observe", arguments)), + popContext: deprecated("prefs.popContext", function popContext() apply(prefs, "popContext", arguments)), + pushContext: deprecated("prefs.pushContext", function pushContext() apply(prefs, "pushContext", arguments)), + resetPref: deprecated("prefs.reset", function resetPref() apply(prefs, "reset", arguments)), + safeResetPref: deprecated("prefs.safeReset", function safeResetPref() apply(prefs, "safeReset", arguments)), + safeSetPref: deprecated("prefs.safeSet", function safeSetPref() apply(prefs, "safeSet", arguments)), + setPref: deprecated("prefs.set", function setPref() apply(prefs, "set", arguments)), + withContext: deprecated("prefs.withContext", function withContext() apply(prefs, "withContext", arguments)), cleanupPrefs: Class.Memoize(() => config.prefs.Branch("cleanup.option.")), diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm index a3f7cc53..c71d2a22 100644 --- a/common/modules/overlay.jsm +++ b/common/modules/overlay.jsm @@ -82,7 +82,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen capture, allowUntrusted]; - target.addEventListener.apply(target, args.slice(1)); + apply(target, "addEventListener", args.slice(1)); listeners.push(args); } }, @@ -105,7 +105,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen this.setData(doc, "listeners", listeners.filter(function (args) { let elem = args[0].get(); if (target == null || elem == target && args[1] == event && args[2].wrapped == callback && args[3] == capture) { - elem.removeEventListener.apply(elem, args.slice(1)); + apply(elem, "removeEventListener", args.slice(1)); return false; } return elem; diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm index a03a133a..053ffbc6 100644 --- a/common/modules/sanitizer.jsm +++ b/common/modules/sanitizer.jsm @@ -265,7 +265,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef storage.addObserver("sanitizer", function (key, event, arg) { if (names.has(event)) - params.action.apply(params, arg); + apply(params, "action", arg); }, getWindow(params.action)); diff --git a/common/modules/services.jsm b/common/modules/services.jsm index c0f229d1..5de5d3c2 100644 --- a/common/modules/services.jsm +++ b/common/modules/services.jsm @@ -130,7 +130,7 @@ var Services = Module("Services", { if (service.init && args.length) { if (service.callable) - res[service.init].apply(res, args); + apply(res, service.init, args); else res[service.init] = args[0]; } diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index f269b011..51e18747 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -134,7 +134,7 @@ var ArrayStore = Class("ArrayStore", StoreBase, { mutate: function mutate(funcName) { var _funcName = funcName; arguments[0] = this._object; - this._object = Array[_funcName].apply(Array, arguments) + this._object = apply(Array, _funcName, arguments) .map(this.makeOwn.bind(this)); this.fireEvent("change", null); }, @@ -271,7 +271,7 @@ var Storage = Module("Storage", { throw Error("Invalid argument type"); if (this.isLocalModule) { - this.globalInstance.newObject.apply(this.globalInstance, arguments); + apply(this.globalInstance, "newObject", arguments); if (!(key in this.keys) && this.privateMode && key in this.globalInstance.keys) { let obj = this.globalInstance.keys[key]; @@ -799,7 +799,7 @@ var File = Class("File", { catch (e) {} if (isFunction) - File.prototype[prop] = util.wrapCallback(function wrapper() this.file[prop].apply(this.file, arguments)); + File.prototype[prop] = util.wrapCallback(function wrapper() apply(this.file, prop, arguments)); else Object.defineProperty(File.prototype, prop, { configurable: true, diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index c852e379..65d4d9b7 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -299,7 +299,7 @@ var Styles = Module("Styles", { _proxy: function (name, args) { let obj = this[args[0] ? "system" : "user"]; - return obj[name].apply(obj, Array.slice(args, 1)); + return apply(obj, name, Array.slice(args, 1)); }, addSheet: deprecated("Styles#{user,system}.add", function addSheet() this._proxy("add", arguments)), @@ -720,7 +720,7 @@ var Styles = Module("Styles", { get sites() this.hive.sites, __noSuchMethod__: function __noSuchMethod__(meth, args) { - return this.hive[meth].apply(this.hive, args); + return apply(this.hive, meth, args); }, destroy: function () { diff --git a/common/modules/template.jsm b/common/modules/template.jsm index 3fdb6fc2..b6666bb9 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -36,7 +36,7 @@ var Binding = Class("Binding", { configurable: true, writeable: true, value: function __noSuchMethod__(meth, args) { - return this.node[meth].apply(this.node, args); + return apply(this.node, meth, args); } }) }, { @@ -88,7 +88,7 @@ var Binding = Class("Binding", { Object.defineProperty(Binding.prototype, key, { configurable: true, enumerable: false, - value: function () this.node[key].apply(this.node, arguments), + value: function () apply(this.node, key, arguments), writable: true }); }); diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 95493500..a64674e5 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -799,7 +799,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), args.push(params.user); if (params.pass != null) args.push(prams.pass); - xmlhttp.open.apply(xmlhttp, args); + + apply(xmlhttp, "open", args); for (let [header, val] of iter(params.headers || {})) xmlhttp.setRequestHeader(header, val);