mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
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
10
.eslintrc.js
10
.eslintrc.js
@ -39,15 +39,5 @@ module.exports = {
|
||||
"env": {
|
||||
"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);
|
||||
|
||||
Assert.rejects(waitRejection, /Extension not found/,
|
||||
"Reject with the expected message for non existent addons");
|
||||
await Assert.rejects(waitRejection, /Extension not found/,
|
||||
"Reject with the expected message for non existent addons");
|
||||
|
||||
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.
|
||||
await Assert.rejects(
|
||||
testnamespace.async_required(), /ONE/,
|
||||
"should reject testnamespace.async_required()").catch(() => {});
|
||||
"should reject testnamespace.async_required()");
|
||||
await Assert.rejects(
|
||||
testnamespace.async_optional(), /TWO/,
|
||||
"should reject testnamespace.async_optional()").catch(() => {});
|
||||
"should reject testnamespace.async_optional()");
|
||||
}
|
||||
|
||||
Assert.equal(await runFailCallback(testnamespace.async_required), "ONE");
|
||||
|
@ -119,7 +119,7 @@ add_task(async function testStartRequiredArguments() {
|
||||
for (const key in requiredArguments) {
|
||||
const args = Object.assign({}, requiredArguments);
|
||||
delete args[key];
|
||||
Assert.rejects(
|
||||
await Assert.rejects(
|
||||
AddonStudies.start(args),
|
||||
/Required arguments/,
|
||||
`start rejects when missing required argument ${key}.`
|
||||
@ -132,7 +132,7 @@ decorate_task(
|
||||
studyFactory(),
|
||||
]),
|
||||
async function testStartExisting([study]) {
|
||||
Assert.rejects(
|
||||
await Assert.rejects(
|
||||
AddonStudies.start(startArgsFactory({recipeId: study.recipeId})),
|
||||
/already exists/,
|
||||
"start rejects when a study exists with the given recipeId already."
|
||||
|
@ -106,7 +106,7 @@ decorate_task(
|
||||
await action.runRecipe(recipe1);
|
||||
await action.finalize();
|
||||
|
||||
Assert.rejects(
|
||||
await Assert.rejects(
|
||||
action.runRecipe(recipe2),
|
||||
/^Error: Action has already been finalized$/,
|
||||
"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() {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||
"test_osfile_win_async_setPermissions_path.tmp");
|
||||
Assert.rejects(OS.File.setPermissions(path, {winAttributes: {readOnly: true}}),
|
||||
/The system cannot find the file specified/,
|
||||
"setPermissions failed as expected on a non-existant file path");
|
||||
await Assert.rejects(OS.File.setPermissions(path, {winAttributes: {readOnly: true}}),
|
||||
/The system cannot find the file specified/,
|
||||
"setPermissions failed as expected on a non-existant file path");
|
||||
});
|
||||
|
||||
// Test application to Check setPermissions on a invalid file handle.
|
||||
@ -101,9 +101,9 @@ add_task(async function test_closed_file_handle_setPermissions() {
|
||||
try {
|
||||
let fd = await OS.File.open(path, { write: true });
|
||||
await fd.close();
|
||||
Assert.rejects(fd.setPermissions(path, {winAttributes: {readOnly: true}}),
|
||||
/The handle is invalid/,
|
||||
"setPermissions failed as expected on a invalid file handle");
|
||||
await Assert.rejects(fd.setPermissions(path, {winAttributes: {readOnly: true}}),
|
||||
/The handle is invalid/,
|
||||
"setPermissions failed as expected on a invalid file handle");
|
||||
} finally {
|
||||
await OS.File.remove(path);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ add_task(async function move_roots_fail() {
|
||||
PlacesUtils.bookmarks.tagsGuid,
|
||||
PlacesUtils.bookmarks.mobileGuid];
|
||||
for (let guid of guids) {
|
||||
Assert.rejects(PlacesUtils.bookmarks.update({
|
||||
await Assert.rejects(PlacesUtils.bookmarks.update({
|
||||
guid,
|
||||
index: -1,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
|
@ -228,7 +228,7 @@ add_task(async function test_html_restore_nonexist() {
|
||||
info("HTML restore: nonexistent file should fail");
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
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.");
|
||||
|
||||
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");
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
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.");
|
||||
|
||||
await checkObservers(expectPromises, expectedData);
|
||||
|
@ -383,26 +383,26 @@ add_task(async function() {
|
||||
Services.prefs.setBoolPref("browser.formfill.enable", false);
|
||||
|
||||
// Cannot use arrow functions, see bug 1237961.
|
||||
Assert.rejects(promiseUpdate(
|
||||
await Assert.rejects(promiseUpdate(
|
||||
{ op: "bump", fieldname: "field5", value: "value5" }),
|
||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||
"bumping when form history is disabled should fail");
|
||||
Assert.rejects(promiseUpdate(
|
||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||
"bumping when form history is disabled should fail");
|
||||
await Assert.rejects(promiseUpdate(
|
||||
{ op: "add", fieldname: "field5", value: "value5" }),
|
||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||
"Adding when form history is disabled should fail");
|
||||
Assert.rejects(promiseUpdate([
|
||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||
"Adding when form history is disabled should fail");
|
||||
await Assert.rejects(promiseUpdate([
|
||||
{ op: "update", fieldname: "field5", value: "value5" },
|
||||
{ op: "remove", fieldname: "field5", value: "value5" },
|
||||
]),
|
||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||
"mixed operations when form history is disabled should fail");
|
||||
Assert.rejects(promiseUpdate([
|
||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||
"mixed operations when form history is disabled should fail");
|
||||
await Assert.rejects(promiseUpdate([
|
||||
null, undefined, "", 1, {},
|
||||
{ op: "remove", fieldname: "field5", value: "value5" },
|
||||
]),
|
||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||
"Invalid entries when form history is disabled should fail");
|
||||
function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
|
||||
"Invalid entries when form history is disabled should fail");
|
||||
|
||||
// Remove should work though.
|
||||
await promiseUpdate([{ op: "remove", fieldname: "field5", value: null },
|
||||
|
Loading…
Reference in New Issue
Block a user