From 7b90b63d6918c73bc5b1311b5f251c8ffdf8689e Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Wed, 30 May 2018 11:50:45 +0100 Subject: [PATCH] Bug 1465385 - Enable ESLint rule require-expected-throws-or-rejects for browser/. r=MattN MozReview-Commit-ID: GoVFNM7CFDu --HG-- extra : rebase_source : f1e9bfdaa1396b2ce27ee499fc547f239ca132a9 --- .eslintrc.js | 3 --- .../formautofill/test/unit/test_storage_tombstones.js | 9 ++++++--- browser/modules/test/browser/browser_SitePermissions.js | 3 +-- .../test/browser/browser_UnsubmittedCrashHandler.js | 4 ++-- browser/tools/mozscreenshots/browser_boundingbox.js | 4 ++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index de3b477a5fc9..1dcd52094375 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -52,9 +52,6 @@ module.exports = { // XXX Bug 1452706. These directories are still being fixed, so turn off // mozilla/require-expected-throws-or-rejects for now. "files": [ - "browser/extensions/formautofill/test/unit/test_storage_tombstones.js", - "browser/modules/test/browser/**", - "browser/tools/mozscreenshots/browser_boundingbox.js", "devtools/client/inspector/extensions/test/head_devtools_inspector_sidebar.js", "storage/test/unit/**", "testing/marionette/test/unit/**", diff --git a/browser/extensions/formautofill/test/unit/test_storage_tombstones.js b/browser/extensions/formautofill/test/unit/test_storage_tombstones.js index 0a54ee5370c5..c5ff2b85002c 100644 --- a/browser/extensions/formautofill/test/unit/test_storage_tombstones.js +++ b/browser/extensions/formautofill/test/unit/test_storage_tombstones.js @@ -121,18 +121,21 @@ add_storage_task(async function test_add_tombstone(storage, record) { add_storage_task(async function test_add_tombstone_without_guid(storage, record) { info("Should not be able to add a new tombstone without specifying the guid"); - Assert.throws(() => { storage.add({deleted: true}); }); + Assert.throws(() => { storage.add({deleted: true}); }, + /Record missing GUID/); Assert.equal(storage.getAll({includeDeleted: true}).length, 0); }); add_storage_task(async function test_add_tombstone_existing_guid(storage, record) { info("Should not be able to add a new tombstone when a record with that ID exists"); let guid = storage.add(record); - Assert.throws(() => { storage.add({guid, deleted: true}); }); + Assert.throws(() => { storage.add({guid, deleted: true}); }, + /a record with this GUID already exists/); // same if the existing item is already a tombstone. storage.add({guid: "test-guid-1", deleted: true}); - Assert.throws(() => { storage.add({guid: "test-guid-1", deleted: true}); }); + Assert.throws(() => { storage.add({guid: "test-guid-1", deleted: true}); }, + /a record with this GUID already exists/); }); add_storage_task(async function test_update_tombstone(storage, record) { diff --git a/browser/modules/test/browser/browser_SitePermissions.js b/browser/modules/test/browser/browser_SitePermissions.js index f8ca6541aa8a..94121c622682 100644 --- a/browser/modules/test/browser/browser_SitePermissions.js +++ b/browser/modules/test/browser/browser_SitePermissions.js @@ -15,7 +15,7 @@ add_task(async function testTempAllowThrows() { await BrowserTestUtils.withNewTab(uri.spec, function(browser) { Assert.throws(function() { SitePermissions.set(uri, id, SitePermissions.ALLOW, SitePermissions.SCOPE_TEMPORARY, browser); - }, "'Block' is the only permission we can save temporarily on a tab"); + }, /'Block' is the only permission we can save temporarily on a browser/); }); }); @@ -91,4 +91,3 @@ add_task(async function testGetAllPermissionDetailsForBrowser() { BrowserTestUtils.removeTab(gBrowser.selectedTab); }); - diff --git a/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js b/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js index 3a873d587002..68613d4b53f1 100644 --- a/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js +++ b/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js @@ -562,8 +562,8 @@ add_task(async function test_shutdown_while_not_showing() { UnsubmittedCrashHandler.uninit(); Assert.throws(() => { UnsubmittedCrashHandler.prefs.getBoolPref("shutdownWhileShowing"); - }, "We should have noticed that the notification had closed before " + - "uninitting."); + }, /NS_ERROR_UNEXPECTED/, + "We should have noticed that the notification had closed before uninitting."); UnsubmittedCrashHandler.init(); clearPendingCrashReports(); diff --git a/browser/tools/mozscreenshots/browser_boundingbox.js b/browser/tools/mozscreenshots/browser_boundingbox.js index a5308a5015e1..802bd4343247 100644 --- a/browser/tools/mozscreenshots/browser_boundingbox.js +++ b/browser/tools/mozscreenshots/browser_boundingbox.js @@ -93,10 +93,10 @@ add_task(async function() { // Check that nonexistent selectors throws an exception Assert.throws(() => { TestRunner._findBoundingBox(["#does_not_exist"]); - }, "No element for '#does_not_exist' found.", "Checking that nonexistent selectors throws an exception"); + }, /No element for '#does_not_exist' found/, "Checking that nonexistent selectors throws an exception"); // Check that no selectors throws an exception Assert.throws(() => { TestRunner._findBoundingBox([]); - }, "No selectors specified.", "Checking that no selectors throws an exception"); + }, /No selectors specified/, "Checking that no selectors throws an exception"); });