Skip to content

Commit

Permalink
Bug 1465385 - Enable ESLint rule require-expected-throws-or-rejects f…
Browse files Browse the repository at this point in the history
…or browser/. r=MattN

MozReview-Commit-ID: GoVFNM7CFDu
  • Loading branch information
Standard8 committed May 30, 2018
1 parent a98aede commit 74b4a48
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/**",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions browser/modules/test/browser/browser_SitePermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/);
});
});

Expand Down Expand Up @@ -91,4 +91,3 @@ add_task(async function testGetAllPermissionDetailsForBrowser() {

BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions browser/tools/mozscreenshots/browser_boundingbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});

0 comments on commit 74b4a48

Please sign in to comment.