/usr/share/xul-ext/tabmixplus/modules/AsyncUtils.jsm is in xul-ext-tabmixplus 0.5.0.0-1~deb8u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | "use strict";
this.EXPORTED_SYMBOLS = ["AsyncUtils"];
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TabmixSvc",
"resource://tabmixplus/Services.jsm");
this.AsyncUtils = {
/* PromiseUtils.defer exist since Firefox 39 */
defer: function() {
return new Deferred();
},
spawnFn: function(thisArg, fn, index) {
return this.promisify(thisArg, fn, index)();
},
asyncFn: function(thisArg, fn, index) {
return this.promisify(thisArg, fn, index);
},
promisify: function(thisArg, fn, index) {
return function() {
let deferred = new Deferred();
let args = Array.prototype.slice.call(arguments);
if (typeof index == "undefined")
index = args.length;
args.splice(index, 0, deferred.callback);
try {
fn.apply(thisArg, args);
} catch (ex) {
deferred.reject(ex);
}
return deferred.promise;
};
}
};
function Deferred() {
let defer = Promise.defer();
this.promise = defer.promise;
this.resolve = defer.resolve;
this.reject = defer.reject;
this.callback = (result, error) => {
if (error)
return this.reject(error);
return this.resolve(result);
};
}
|