forked from mirrors/gecko-dev
Bug 1481932 - Fully enable ESLint rule mozilla/reject-requires-await. r=mossop
MozReview-Commit-ID: 7pYfD6Ax5VX Differential Revision: https://phabricator.services.mozilla.com/D2971 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
dfe849c923
commit
21236ee00f
9 changed files with 28 additions and 38 deletions
10
.eslintrc.js
10
.eslintrc.js
|
|
@ -39,15 +39,5 @@ module.exports = {
|
||||||
"env": {
|
"env": {
|
||||||
"mozilla/browser-window": true
|
"mozilla/browser-window": true
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
// XXX Bug 1452706. These directories are still being fixed, so turn off
|
|
||||||
// mozilla/require-expected-throws-or-rejects for now.
|
|
||||||
"files": [
|
|
||||||
"services/fxaccounts/**",
|
|
||||||
"toolkit/components/**",
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"mozilla/rejects-requires-await": "off",
|
|
||||||
}
|
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ add_task(async function testExtensionDebuggingUtilsCleanup() {
|
||||||
|
|
||||||
const waitRejection = ExtensionParent.DebugUtils.getExtensionProcessBrowser(nonExistentAddonActor);
|
const waitRejection = ExtensionParent.DebugUtils.getExtensionProcessBrowser(nonExistentAddonActor);
|
||||||
|
|
||||||
Assert.rejects(waitRejection, /Extension not found/,
|
await Assert.rejects(waitRejection, /Extension not found/,
|
||||||
"Reject with the expected message for non existent addons");
|
"Reject with the expected message for non existent addons");
|
||||||
|
|
||||||
equal(debugBrowserPromises.size, 1, "No additional debugging resources has been allocated");
|
equal(debugBrowserPromises.size, 1, "No additional debugging resources has been allocated");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -273,10 +273,10 @@ add_task(async function testAsyncResults() {
|
||||||
if (!isChromeCompat) { // No promises for chrome.
|
if (!isChromeCompat) { // No promises for chrome.
|
||||||
await Assert.rejects(
|
await Assert.rejects(
|
||||||
testnamespace.async_required(), /ONE/,
|
testnamespace.async_required(), /ONE/,
|
||||||
"should reject testnamespace.async_required()").catch(() => {});
|
"should reject testnamespace.async_required()");
|
||||||
await Assert.rejects(
|
await Assert.rejects(
|
||||||
testnamespace.async_optional(), /TWO/,
|
testnamespace.async_optional(), /TWO/,
|
||||||
"should reject testnamespace.async_optional()").catch(() => {});
|
"should reject testnamespace.async_optional()");
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.equal(await runFailCallback(testnamespace.async_required), "ONE");
|
Assert.equal(await runFailCallback(testnamespace.async_required), "ONE");
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ add_task(async function testStartRequiredArguments() {
|
||||||
for (const key in requiredArguments) {
|
for (const key in requiredArguments) {
|
||||||
const args = Object.assign({}, requiredArguments);
|
const args = Object.assign({}, requiredArguments);
|
||||||
delete args[key];
|
delete args[key];
|
||||||
Assert.rejects(
|
await Assert.rejects(
|
||||||
AddonStudies.start(args),
|
AddonStudies.start(args),
|
||||||
/Required arguments/,
|
/Required arguments/,
|
||||||
`start rejects when missing required argument ${key}.`
|
`start rejects when missing required argument ${key}.`
|
||||||
|
|
@ -132,7 +132,7 @@ decorate_task(
|
||||||
studyFactory(),
|
studyFactory(),
|
||||||
]),
|
]),
|
||||||
async function testStartExisting([study]) {
|
async function testStartExisting([study]) {
|
||||||
Assert.rejects(
|
await Assert.rejects(
|
||||||
AddonStudies.start(startArgsFactory({recipeId: study.recipeId})),
|
AddonStudies.start(startArgsFactory({recipeId: study.recipeId})),
|
||||||
/already exists/,
|
/already exists/,
|
||||||
"start rejects when a study exists with the given recipeId already."
|
"start rejects when a study exists with the given recipeId already."
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ decorate_task(
|
||||||
await action.runRecipe(recipe1);
|
await action.runRecipe(recipe1);
|
||||||
await action.finalize();
|
await action.finalize();
|
||||||
|
|
||||||
Assert.rejects(
|
await Assert.rejects(
|
||||||
action.runRecipe(recipe2),
|
action.runRecipe(recipe2),
|
||||||
/^Error: Action has already been finalized$/,
|
/^Error: Action has already been finalized$/,
|
||||||
"running recipes after finalization is an error",
|
"running recipes after finalization is an error",
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,9 @@ add_task(async function test_file_setPermissions() {
|
||||||
add_task(async function test_non_existant_file_path_setPermissions() {
|
add_task(async function test_non_existant_file_path_setPermissions() {
|
||||||
let path = OS.Path.join(OS.Constants.Path.tmpDir,
|
let path = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||||
"test_osfile_win_async_setPermissions_path.tmp");
|
"test_osfile_win_async_setPermissions_path.tmp");
|
||||||
Assert.rejects(OS.File.setPermissions(path, {winAttributes: {readOnly: true}}),
|
await Assert.rejects(OS.File.setPermissions(path, {winAttributes: {readOnly: true}}),
|
||||||
/The system cannot find the file specified/,
|
/The system cannot find the file specified/,
|
||||||
"setPermissions failed as expected on a non-existant file path");
|
"setPermissions failed as expected on a non-existant file path");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test application to Check setPermissions on a invalid file handle.
|
// Test application to Check setPermissions on a invalid file handle.
|
||||||
|
|
@ -101,9 +101,9 @@ add_task(async function test_closed_file_handle_setPermissions() {
|
||||||
try {
|
try {
|
||||||
let fd = await OS.File.open(path, { write: true });
|
let fd = await OS.File.open(path, { write: true });
|
||||||
await fd.close();
|
await fd.close();
|
||||||
Assert.rejects(fd.setPermissions(path, {winAttributes: {readOnly: true}}),
|
await Assert.rejects(fd.setPermissions(path, {winAttributes: {readOnly: true}}),
|
||||||
/The handle is invalid/,
|
/The handle is invalid/,
|
||||||
"setPermissions failed as expected on a invalid file handle");
|
"setPermissions failed as expected on a invalid file handle");
|
||||||
} finally {
|
} finally {
|
||||||
await OS.File.remove(path);
|
await OS.File.remove(path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ add_task(async function move_roots_fail() {
|
||||||
PlacesUtils.bookmarks.tagsGuid,
|
PlacesUtils.bookmarks.tagsGuid,
|
||||||
PlacesUtils.bookmarks.mobileGuid];
|
PlacesUtils.bookmarks.mobileGuid];
|
||||||
for (let guid of guids) {
|
for (let guid of guids) {
|
||||||
Assert.rejects(PlacesUtils.bookmarks.update({
|
await Assert.rejects(PlacesUtils.bookmarks.update({
|
||||||
guid,
|
guid,
|
||||||
index: -1,
|
index: -1,
|
||||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ add_task(async function test_html_restore_nonexist() {
|
||||||
info("HTML restore: nonexistent file should fail");
|
info("HTML restore: nonexistent file should fail");
|
||||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||||
file.append("this file doesn't exist because nobody created it 2");
|
file.append("this file doesn't exist because nobody created it 2");
|
||||||
Assert.rejects(BookmarkHTMLUtils.importFromFile(file.path),
|
await Assert.rejects(BookmarkHTMLUtils.importFromFile(file.path),
|
||||||
/Cannot import from nonexisting html file/, "Restore should reject for a non-existent file.");
|
/Cannot import from nonexisting html file/, "Restore should reject for a non-existent file.");
|
||||||
|
|
||||||
await checkObservers(expectPromises, expectedData);
|
await checkObservers(expectPromises, expectedData);
|
||||||
|
|
@ -288,7 +288,7 @@ add_task(async function test_html_init_restore_nonexist() {
|
||||||
info("HTML initial restore: nonexistent file should fail");
|
info("HTML initial restore: nonexistent file should fail");
|
||||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||||
file.append("this file doesn't exist because nobody created it 3");
|
file.append("this file doesn't exist because nobody created it 3");
|
||||||
Assert.rejects(BookmarkHTMLUtils.importFromFile(file.path, { replace: true }),
|
await Assert.rejects(BookmarkHTMLUtils.importFromFile(file.path, { replace: true }),
|
||||||
/Cannot import from nonexisting html file/, "Restore should reject for a non-existent file.");
|
/Cannot import from nonexisting html file/, "Restore should reject for a non-existent file.");
|
||||||
|
|
||||||
await checkObservers(expectPromises, expectedData);
|
await checkObservers(expectPromises, expectedData);
|
||||||
|
|
|
||||||
|
|
@ -383,26 +383,26 @@ add_task(async function() {
|
||||||
Services.prefs.setBoolPref("browser.formfill.enable", false);
|
Services.prefs.setBoolPref("browser.formfill.enable", false);
|
||||||
|
|
||||||
// Cannot use arrow functions, see bug 1237961.
|
// Cannot use arrow functions, see bug 1237961.
|
||||||
Assert.rejects(promiseUpdate(
|
await Assert.rejects(promiseUpdate(
|
||||||
{ op: "bump", fieldname: "field5", value: "value5" }),
|
{ op: "bump", fieldname: "field5", value: "value5" }),
|
||||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||||
"bumping when form history is disabled should fail");
|
"bumping when form history is disabled should fail");
|
||||||
Assert.rejects(promiseUpdate(
|
await Assert.rejects(promiseUpdate(
|
||||||
{ op: "add", fieldname: "field5", value: "value5" }),
|
{ op: "add", fieldname: "field5", value: "value5" }),
|
||||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||||
"Adding when form history is disabled should fail");
|
"Adding when form history is disabled should fail");
|
||||||
Assert.rejects(promiseUpdate([
|
await Assert.rejects(promiseUpdate([
|
||||||
{ op: "update", fieldname: "field5", value: "value5" },
|
{ op: "update", fieldname: "field5", value: "value5" },
|
||||||
{ op: "remove", fieldname: "field5", value: "value5" },
|
{ op: "remove", fieldname: "field5", value: "value5" },
|
||||||
]),
|
]),
|
||||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||||
"mixed operations when form history is disabled should fail");
|
"mixed operations when form history is disabled should fail");
|
||||||
Assert.rejects(promiseUpdate([
|
await Assert.rejects(promiseUpdate([
|
||||||
null, undefined, "", 1, {},
|
null, undefined, "", 1, {},
|
||||||
{ op: "remove", fieldname: "field5", value: "value5" },
|
{ op: "remove", fieldname: "field5", value: "value5" },
|
||||||
]),
|
]),
|
||||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||||
"Invalid entries when form history is disabled should fail");
|
"Invalid entries when form history is disabled should fail");
|
||||||
|
|
||||||
// Remove should work though.
|
// Remove should work though.
|
||||||
await promiseUpdate([{ op: "remove", fieldname: "field5", value: null },
|
await promiseUpdate([{ op: "remove", fieldname: "field5", value: null },
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue