mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1229519: Fix toolkit/modules to pass eslint checks. r=mak
This commit is contained in:
parent
d4116628a4
commit
642e343414
@ -186,12 +186,12 @@ var CharsetMenu = {
|
||||
},
|
||||
|
||||
getCharsetInfo: function(charsets, sort=true) {
|
||||
let list = [{
|
||||
let list = Array.from(charsets, charset => ({
|
||||
label: this._getCharsetLabel(charset),
|
||||
accesskey: this._getCharsetAccessKey(charset),
|
||||
name: "charset",
|
||||
value: charset
|
||||
} for (charset of charsets)];
|
||||
}));
|
||||
|
||||
if (sort) {
|
||||
list.sort(CharsetComparator);
|
||||
|
@ -277,7 +277,7 @@ this.DeferredTask.prototype = {
|
||||
this._armed = false;
|
||||
this._runningPromise = runningDeferred.promise;
|
||||
|
||||
runningDeferred.resolve(Task.spawn(function () {
|
||||
runningDeferred.resolve(Task.spawn(function* () {
|
||||
// Execute the provided function asynchronously.
|
||||
yield Task.spawn(this._taskFn).then(null, Cu.reportError);
|
||||
|
||||
|
@ -68,7 +68,10 @@ this.FileUtils = {
|
||||
if (shouldCreate) {
|
||||
try {
|
||||
dir.create(Ci.nsIFile.DIRECTORY_TYPE, this.PERMS_DIRECTORY);
|
||||
} catch (ex if ex.result == Cr.NS_ERROR_FILE_ALREADY_EXISTS) {
|
||||
} catch (ex) {
|
||||
if (ex.result != Cr.NS_ERROR_FILE_ALREADY_EXISTS) {
|
||||
throw ex;
|
||||
}
|
||||
// Ignore the exception due to a directory that already exists.
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ GMPInstallManager.prototype = {
|
||||
this._deferred.resolve([]);
|
||||
}
|
||||
else {
|
||||
this._deferred.resolve([for (a of addons) new GMPAddon(a)]);
|
||||
this._deferred.resolve(addons.map(a => new GMPAddon(a)));
|
||||
}
|
||||
delete this._deferred;
|
||||
}, (ex) => {
|
||||
|
@ -867,7 +867,7 @@ FileAppender.prototype = {
|
||||
__proto__: Appender.prototype,
|
||||
|
||||
_openFile: function () {
|
||||
return Task.spawn(function _openFile() {
|
||||
return Task.spawn(function* _openFile() {
|
||||
try {
|
||||
this._file = yield OS.File.open(this._path,
|
||||
{truncate: true});
|
||||
|
@ -236,8 +236,7 @@ var PendingErrors = {
|
||||
flush: function() {
|
||||
// Since we are going to modify the map while walking it,
|
||||
// let's copying the keys first.
|
||||
let keys = [key for (key of this._map.keys())];
|
||||
for (let key of keys) {
|
||||
for (let key of Array.from(this._map.keys())) {
|
||||
this.report(key);
|
||||
}
|
||||
},
|
||||
|
@ -50,4 +50,4 @@ function Deferred() {
|
||||
this.resolve = resolve;
|
||||
this.reject = reject;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ XMLPropertyListReader.prototype = {
|
||||
// Strip spaces and new lines.
|
||||
let base64str = aDOMElt.textContent.replace(/\s*/g, "");
|
||||
let decoded = atob(base64str);
|
||||
return new Uint8Array([decoded.charCodeAt(i) for (i in decoded)]);
|
||||
return new Uint8Array(Array.from(decoded, c => c.charCodeAt(0)));
|
||||
case "dict":
|
||||
return this._wrapDictionary(aDOMElt);
|
||||
case "array":
|
||||
|
@ -465,7 +465,7 @@ var RemotePageManagerInternal = {
|
||||
|
||||
// A listener is requesting the list of currently registered urls
|
||||
initListener: function({ target: messageManager }) {
|
||||
messageManager.sendAsyncMessage("RemotePage:Register", { urls: [u for (u of this.pages.keys())] })
|
||||
messageManager.sendAsyncMessage("RemotePage:Register", { urls: Array.from(this.pages.keys()) })
|
||||
},
|
||||
|
||||
// A remote page has been created and a port is ready in the content side
|
||||
|
@ -24,9 +24,11 @@ XPCOMUtils.defineLazyGetter(Services, "appinfo", function () {
|
||||
.getService(Ci.nsIXULRuntime);
|
||||
try {
|
||||
appinfo.QueryInterface(Ci.nsIXULAppInfo);
|
||||
} catch (ex if ex instanceof Components.Exception &&
|
||||
ex.result == Cr.NS_NOINTERFACE) {
|
||||
} catch (ex) {
|
||||
// Not all applications implement nsIXULAppInfo (e.g. xpcshell doesn't).
|
||||
if (!(ex instanceof Components.Exception) || ex.result != Cr.NS_NOINTERFACE) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return appinfo;
|
||||
});
|
||||
|
@ -604,4 +604,4 @@ var PrefObserver = {
|
||||
}
|
||||
};
|
||||
|
||||
PrefObserver.register();
|
||||
PrefObserver.register();
|
||||
|
@ -769,13 +769,15 @@ ConnectionData.prototype = Object.freeze({
|
||||
|
||||
try {
|
||||
onRow(row);
|
||||
} catch (e if e instanceof StopIteration) {
|
||||
userCancelled = true;
|
||||
pending.cancel();
|
||||
break;
|
||||
} catch (ex) {
|
||||
} catch (e) {
|
||||
if (e instanceof StopIteration) {
|
||||
userCancelled = true;
|
||||
pending.cancel();
|
||||
break;
|
||||
}
|
||||
|
||||
self._log.warn("Exception when calling onRow callback: " +
|
||||
CommonUtils.exceptionStr(ex));
|
||||
CommonUtils.exceptionStr(e));
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -811,7 +813,7 @@ ConnectionData.prototype = Object.freeze({
|
||||
break;
|
||||
|
||||
case Ci.mozIStorageStatementCallback.REASON_ERROR:
|
||||
let error = new Error("Error(s) encountered during statement execution: " + [error.message for (error of errors)].join(", "));
|
||||
let error = new Error("Error(s) encountered during statement execution: " + errors.map(e => e.message).join(", "));
|
||||
error.errors = errors;
|
||||
deferred.reject(error);
|
||||
break;
|
||||
|
@ -237,9 +237,10 @@ function createAsyncFunction(aTask) {
|
||||
try {
|
||||
// Let's call into the function ourselves.
|
||||
result = aTask.apply(this, arguments);
|
||||
} catch (ex if ex instanceof Task.Result) {
|
||||
return Promise.resolve(ex.value);
|
||||
} catch (ex) {
|
||||
if (ex instanceof Task.Result) {
|
||||
return Promise.resolve(ex.value);
|
||||
}
|
||||
return Promise.reject(ex);
|
||||
}
|
||||
}
|
||||
@ -330,16 +331,18 @@ TaskImpl.prototype = {
|
||||
let yielded = aSendResolved ? this._iterator.send(aSendValue)
|
||||
: this._iterator.throw(aSendValue);
|
||||
this._handleResultValue(yielded);
|
||||
} catch (ex if ex instanceof Task.Result) {
|
||||
// The generator function threw the special exception that allows it to
|
||||
// return a specific value on resolution.
|
||||
this.deferred.resolve(ex.value);
|
||||
} catch (ex if ex instanceof StopIteration) {
|
||||
// The generator function terminated with no specific result.
|
||||
this.deferred.resolve(undefined);
|
||||
} catch (ex) {
|
||||
// The generator function failed with an uncaught exception.
|
||||
this._handleException(ex);
|
||||
if (ex instanceof Task.Result) {
|
||||
// The generator function threw the special exception that allows it to
|
||||
// return a specific value on resolution.
|
||||
this.deferred.resolve(ex.value);
|
||||
} else if (ex instanceof StopIteration) {
|
||||
// The generator function terminated with no specific result.
|
||||
this.deferred.resolve(undefined);
|
||||
} else {
|
||||
// The generator function failed with an uncaught exception.
|
||||
this._handleException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
@ -79,11 +79,11 @@ function saveStreamAsync(aPath, aStream, aFile) {
|
||||
input.asyncWait(readData, 0, 0, Services.tm.currentThread);
|
||||
}, readFailed);
|
||||
}
|
||||
catch (e if e.result == Cr.NS_BASE_STREAM_CLOSED) {
|
||||
deferred.resolve(aFile.close());
|
||||
}
|
||||
catch (e) {
|
||||
readFailed(e);
|
||||
if (e.result == Cr.NS_BASE_STREAM_CLOSED)
|
||||
deferred.resolve(aFile.close());
|
||||
else
|
||||
readFailed(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ this.ZipUtils = {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
|
||||
return Task.spawn(function() {
|
||||
return Task.spawn(function* () {
|
||||
// Get all of the entries in the zip and sort them so we create directories
|
||||
// before files
|
||||
let entries = zipReader.findEntries(null);
|
||||
|
@ -99,7 +99,7 @@ this.MatchPattern = function(pat)
|
||||
} else if (pat instanceof String || typeof(pat) == "string") {
|
||||
this.matchers = [new SingleMatchPattern(pat)];
|
||||
} else {
|
||||
this.matchers = [for (p of pat) new SingleMatchPattern(p)];
|
||||
this.matchers = pat.map(p => new SingleMatchPattern(p));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,11 @@ var ContentPolicy = {
|
||||
try {
|
||||
// If e10s is disabled, this throws NS_NOINTERFACE for closed tabs.
|
||||
mm = ir.getInterface(Ci.nsIContentFrameMessageManager);
|
||||
} catch (e if e.result == Cr.NS_NOINTERFACE) {}
|
||||
} catch (e) {
|
||||
if (e.result != Cr.NS_NOINTERFACE) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let data = {ids,
|
||||
|
@ -156,7 +156,7 @@ add_test(function test_arm_async()
|
||||
let finishedExecutionAgain = false;
|
||||
|
||||
// Create a task that will run later.
|
||||
let deferredTask = new DeferredTask(function () {
|
||||
let deferredTask = new DeferredTask(function* () {
|
||||
yield promiseTimeout(4*T);
|
||||
if (!finishedExecution) {
|
||||
finishedExecution = true;
|
||||
@ -247,7 +247,7 @@ add_test(function test_disarm_async()
|
||||
{
|
||||
let finishedExecution = false;
|
||||
|
||||
let deferredTask = new DeferredTask(function () {
|
||||
let deferredTask = new DeferredTask(function* () {
|
||||
deferredTask.arm();
|
||||
yield promiseTimeout(2*T);
|
||||
finishedExecution = true;
|
||||
@ -277,7 +277,7 @@ add_test(function test_disarm_immediate_async()
|
||||
{
|
||||
let executed = false;
|
||||
|
||||
let deferredTask = new DeferredTask(function () {
|
||||
let deferredTask = new DeferredTask(function* () {
|
||||
do_check_false(executed);
|
||||
executed = true;
|
||||
yield promiseTimeout(2*T);
|
||||
@ -353,7 +353,7 @@ add_test(function test_finalize_executes_entirely()
|
||||
let executedAgain = false;
|
||||
let timePassed = false;
|
||||
|
||||
let deferredTask = new DeferredTask(function () {
|
||||
let deferredTask = new DeferredTask(function* () {
|
||||
// The first time, we arm the timer again and set up the finalization.
|
||||
if (!executed) {
|
||||
deferredTask.arm();
|
||||
|
@ -233,7 +233,7 @@ function fileContents(path) {
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function test_FileAppender() {
|
||||
add_task(function* test_FileAppender() {
|
||||
// This directory does not exist yet
|
||||
let dir = OS.Path.join(do_get_profile().path, "test_Log");
|
||||
do_check_false(yield OS.File.exists(dir));
|
||||
@ -287,7 +287,7 @@ add_task(function test_FileAppender() {
|
||||
"test.FileAppender\tINFO\t5\n");
|
||||
});
|
||||
|
||||
add_task(function test_BoundedFileAppender() {
|
||||
add_task(function* test_BoundedFileAppender() {
|
||||
let dir = OS.Path.join(do_get_profile().path, "test_Log");
|
||||
|
||||
if (!(yield OS.File.exists(dir))) {
|
||||
@ -338,7 +338,7 @@ add_task(function test_BoundedFileAppender() {
|
||||
/*
|
||||
* Test parameter formatting.
|
||||
*/
|
||||
add_task(function log_message_with_params() {
|
||||
add_task(function* log_message_with_params() {
|
||||
let formatter = new Log.BasicFormatter();
|
||||
|
||||
function formatMessage(text, params) {
|
||||
@ -487,7 +487,7 @@ add_task(function log_message_with_params() {
|
||||
* with the object argument as parameters. This makes the log useful when the
|
||||
* caller does "catch(err) {logger.error(err)}"
|
||||
*/
|
||||
add_task(function test_log_err_only() {
|
||||
add_task(function* test_log_err_only() {
|
||||
let log = Log.repository.getLogger("error.only");
|
||||
let testFormatter = { format: msg => msg };
|
||||
let appender = new MockAppender(testFormatter);
|
||||
@ -513,7 +513,7 @@ add_task(function test_log_err_only() {
|
||||
/*
|
||||
* Test logStructured() messages through basic formatter.
|
||||
*/
|
||||
add_task(function test_structured_basic() {
|
||||
add_task(function* test_structured_basic() {
|
||||
let log = Log.repository.getLogger("test.logger");
|
||||
let appender = new MockAppender(new Log.BasicFormatter());
|
||||
|
||||
@ -538,7 +538,7 @@ add_task(function test_structured_basic() {
|
||||
/*
|
||||
* Test that all the basic logger methods pass the message and params through to the appender.
|
||||
*/
|
||||
add_task(function log_message_with_params() {
|
||||
add_task(function* log_message_with_params() {
|
||||
let log = Log.repository.getLogger("error.logger");
|
||||
let testFormatter = { format: msg => msg };
|
||||
let appender = new MockAppender(testFormatter);
|
||||
@ -562,7 +562,7 @@ add_task(function log_message_with_params() {
|
||||
/*
|
||||
* Check that we format JS Errors reasonably.
|
||||
*/
|
||||
add_task(function format_errors() {
|
||||
add_task(function* format_errors() {
|
||||
let pFormat = new Log.ParameterFormatter();
|
||||
|
||||
// Test that subclasses of Error are recognized as errors.
|
||||
|
@ -16,7 +16,7 @@ function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(function validCacheMidPopulation() {
|
||||
add_task(function* validCacheMidPopulation() {
|
||||
let expectedLinks = makeLinks(0, 3, 1);
|
||||
|
||||
let provider = new TestProvider(done => done(expectedLinks));
|
||||
@ -39,7 +39,7 @@ add_task(function validCacheMidPopulation() {
|
||||
NewTabUtils.links.removeProvider(provider);
|
||||
});
|
||||
|
||||
add_task(function notifyLinkDelete() {
|
||||
add_task(function* notifyLinkDelete() {
|
||||
let expectedLinks = makeLinks(0, 3, 1);
|
||||
|
||||
let provider = new TestProvider(done => done(expectedLinks));
|
||||
@ -74,7 +74,7 @@ add_task(function notifyLinkDelete() {
|
||||
NewTabUtils.links.removeProvider(provider);
|
||||
});
|
||||
|
||||
add_task(function populatePromise() {
|
||||
add_task(function* populatePromise() {
|
||||
let count = 0;
|
||||
let expectedLinks = makeLinks(0, 10, 2);
|
||||
|
||||
@ -98,7 +98,7 @@ add_task(function populatePromise() {
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function isTopSiteGivenProvider() {
|
||||
add_task(function* isTopSiteGivenProvider() {
|
||||
let expectedLinks = makeLinks(0, 10, 2);
|
||||
|
||||
// The lowest 2 frecencies have the same base domain.
|
||||
@ -137,7 +137,7 @@ add_task(function isTopSiteGivenProvider() {
|
||||
NewTabUtils.links.removeProvider(provider);
|
||||
});
|
||||
|
||||
add_task(function multipleProviders() {
|
||||
add_task(function* multipleProviders() {
|
||||
// Make each provider generate NewTabUtils.links.maxNumLinks links to check
|
||||
// that no more than maxNumLinks are actually returned in the merged list.
|
||||
let evenLinks = makeLinks(0, 2 * NewTabUtils.links.maxNumLinks, 2);
|
||||
@ -162,7 +162,7 @@ add_task(function multipleProviders() {
|
||||
NewTabUtils.links.removeProvider(oddProvider);
|
||||
});
|
||||
|
||||
add_task(function changeLinks() {
|
||||
add_task(function* changeLinks() {
|
||||
let expectedLinks = makeLinks(0, 20, 2);
|
||||
let provider = new TestProvider(done => done(expectedLinks));
|
||||
|
||||
@ -220,7 +220,7 @@ add_task(function changeLinks() {
|
||||
NewTabUtils.links.removeProvider(provider);
|
||||
});
|
||||
|
||||
add_task(function oneProviderAlreadyCached() {
|
||||
add_task(function* oneProviderAlreadyCached() {
|
||||
let links1 = makeLinks(0, 10, 1);
|
||||
let provider1 = new TestProvider(done => done(links1));
|
||||
|
||||
@ -241,7 +241,7 @@ add_task(function oneProviderAlreadyCached() {
|
||||
NewTabUtils.links.removeProvider(provider2);
|
||||
});
|
||||
|
||||
add_task(function newLowRankedLink() {
|
||||
add_task(function* newLowRankedLink() {
|
||||
// Init a provider with 10 links and make its maximum number also 10.
|
||||
let links = makeLinks(0, 10, 1);
|
||||
let provider = new TestProvider(done => done(links));
|
||||
@ -268,7 +268,7 @@ add_task(function newLowRankedLink() {
|
||||
NewTabUtils.links.removeProvider(provider);
|
||||
});
|
||||
|
||||
add_task(function extractSite() {
|
||||
add_task(function* extractSite() {
|
||||
// All these should extract to the same site
|
||||
[ "mozilla.org",
|
||||
"m.mozilla.org",
|
||||
|
@ -102,4 +102,4 @@ add_task(function* test_reject_resolved_promise() {
|
||||
let p = new Promise((resolve, reject) => reject(new Error("This on rejects")));
|
||||
def.reject(p);
|
||||
yield Assert.rejects(def.promise, Promise, "Rejection with a rejected promise uses the passed promise itself as the reason of rejection");
|
||||
});
|
||||
});
|
||||
|
@ -60,7 +60,7 @@ add_task(function test_extractFiles() {
|
||||
ensureHasSymlink(target);
|
||||
});
|
||||
|
||||
add_task(function test_extractFilesAsync() {
|
||||
add_task(function* test_extractFilesAsync() {
|
||||
let target = dir.clone();
|
||||
target.append("test_extractFilesAsync");
|
||||
target.create(Components.interfaces.nsIFile.DIRECTORY_TYPE,
|
||||
|
@ -53,7 +53,7 @@ add_test(function test_basic() {
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_task(function test_current_properties() {
|
||||
add_task(function* test_current_properties() {
|
||||
let now = new Date();
|
||||
let recorder = getRecorder("current_properties", now);
|
||||
yield sleep(25);
|
||||
@ -78,7 +78,7 @@ add_task(function test_current_properties() {
|
||||
|
||||
// If startup info isn't present yet, we should install a timer and get
|
||||
// it eventually.
|
||||
add_task(function test_current_availability() {
|
||||
add_task(function* test_current_availability() {
|
||||
let recorder = new SessionRecorder("testing.current_availability.");
|
||||
let now = new Date();
|
||||
|
||||
@ -156,7 +156,7 @@ add_test(function test_timer_clear_on_shutdown() {
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_task(function test_previous_clean() {
|
||||
add_task(function* test_previous_clean() {
|
||||
let now = new Date();
|
||||
let recorder = getRecorder("previous_clean", now);
|
||||
yield sleep(25);
|
||||
@ -196,7 +196,7 @@ add_task(function test_previous_clean() {
|
||||
recorder2.onShutdown();
|
||||
});
|
||||
|
||||
add_task(function test_previous_abort() {
|
||||
add_task(function* test_previous_abort() {
|
||||
let now = new Date();
|
||||
let recorder = getRecorder("previous_abort", now);
|
||||
yield sleep(25);
|
||||
@ -222,7 +222,7 @@ add_task(function test_previous_abort() {
|
||||
recorder2.onShutdown();
|
||||
});
|
||||
|
||||
add_task(function test_multiple_sessions() {
|
||||
add_task(function* test_multiple_sessions() {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
let recorder = getRecorder("multiple_sessions");
|
||||
yield sleep(25);
|
||||
@ -264,7 +264,7 @@ add_task(function test_multiple_sessions() {
|
||||
recorder.onShutdown();
|
||||
});
|
||||
|
||||
add_task(function test_record_activity() {
|
||||
add_task(function* test_record_activity() {
|
||||
let recorder = getRecorder("record_activity");
|
||||
yield sleep(25);
|
||||
recorder.onStartup();
|
||||
|
@ -126,7 +126,9 @@ add_task(function* test_schema_version() {
|
||||
yield db.setSchemaVersion(v);
|
||||
do_print("Schema version " + v + " should have been rejected");
|
||||
success = false;
|
||||
} catch (ex if ex.message.startsWith("Schema version must be an integer.")) {
|
||||
} catch (ex) {
|
||||
if (!ex.message.startsWith("Schema version must be an integer."))
|
||||
throw ex;
|
||||
success = true;
|
||||
}
|
||||
do_check_true(success);
|
||||
@ -918,7 +920,11 @@ add_task(function* test_cloneStorageConnection() {
|
||||
try {
|
||||
let clone = yield Sqlite.cloneStorageConnection({ connection: null });
|
||||
do_throw(new Error("Should throw on invalid connection"));
|
||||
} catch (ex if ex.name == "TypeError") {}
|
||||
} catch (ex) {
|
||||
if (ex.name != "TypeError") {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Test clone() method.
|
||||
|
@ -25,7 +25,7 @@ function getConnection(dbName, extraOptions={}) {
|
||||
return Sqlite.openConnection(options);
|
||||
}
|
||||
|
||||
function getDummyDatabase(name, extraOptions={}) {
|
||||
function* getDummyDatabase(name, extraOptions={}) {
|
||||
const TABLES = {
|
||||
dirs: "id INTEGER PRIMARY KEY AUTOINCREMENT, path TEXT",
|
||||
files: "id INTEGER PRIMARY KEY AUTOINCREMENT, dir_id INTEGER, path TEXT",
|
||||
@ -39,7 +39,7 @@ function getDummyDatabase(name, extraOptions={}) {
|
||||
c._initialStatementCount++;
|
||||
}
|
||||
|
||||
throw new Task.Result(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
|
Loading…
Reference in New Issue
Block a user