Bug 1470455 - Add the 'expected' arguments to throws/rejects for toolkit. r?Mossop draft
authorMark Banner <standard8@mozilla.com>
Fri, 22 Jun 2018 16:02:22 +0100
changeset 812469 cce5ef0cd6000589c433bad2049bf5178f5d887a
parent 812468 3619478dc3f502d6eaa9e54879581e098c8c1bb8
push id114559
push userbmo:standard8@mozilla.com
push dateFri, 29 Jun 2018 13:19:23 +0000
reviewersMossop
bugs1470455
milestone63.0a1
Bug 1470455 - Add the 'expected' arguments to throws/rejects for toolkit. r?Mossop MozReview-Commit-ID: Ln9EpDpTR91
toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_embedding.js
toolkit/modules/tests/xpcshell/test_MatchURLFilters.js
--- a/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_embedding.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_legacy_extension_embedding.js
@@ -136,29 +136,29 @@ async function createManifestErrorTestCa
   await embeddedExtension.shutdown();
 }
 
 add_task(async function test_startup_error_empty_manifest() {
   const id = "empty-manifest@test.embedded.web.extension";
   const files = {
     "webextension/manifest.json": ``,
   };
-  const expectedError = "(NS_BASE_STREAM_CLOSED)";
+  const expectedError = /NS_BASE_STREAM_CLOSED/;
 
   let fakeHybridAddonFile = Extension.generateZipFile(files);
 
   await createManifestErrorTestCase(id, fakeHybridAddonFile, expectedError);
 });
 
 add_task(async function test_startup_error_invalid_json_manifest() {
   const id = "invalid-json-manifest@test.embedded.web.extension";
   const files = {
     "webextension/manifest.json": `{ "name": }`,
   };
-  const expectedError = "JSON.parse:";
+  const expectedError = /JSON.parse:/;
 
   let fakeHybridAddonFile = Extension.generateZipFile(files);
 
   await createManifestErrorTestCase(id, fakeHybridAddonFile, expectedError);
 });
 
 add_task(async function test_startup_error_blocking_validation_errors() {
   const id = "blocking-manifest-validation-error@test.embedded.web.extension";
--- a/toolkit/modules/tests/xpcshell/test_MatchURLFilters.js
+++ b/toolkit/modules/tests/xpcshell/test_MatchURLFilters.js
@@ -35,27 +35,27 @@ function expectThrow({url, filters, exce
 
 add_task(async function test_match_url_filters() {
   const shouldPass = true;
   const shouldFail = true;
   const shouldThrow = true;
 
   var testCases = [
     // Empty, undefined and null filters.
-    {shouldThrow, exceptionMessageContains: "filters array should not be empty",
+    {shouldThrow, exceptionMessageContains: /filters array should not be empty/,
      filters: [], url: "http://mozilla.org", },
-    {shouldThrow, exceptionMessageContains: "filters should be an array",
+    {shouldThrow, exceptionMessageContains: /filters should be an array/,
      filters: undefined, url: "http://mozilla.org"},
-    {shouldThrow, exceptionMessageContains: "filters should be an array",
+    {shouldThrow, exceptionMessageContains: /filters should be an array/,
      filters: null, url: "http://mozilla.org"},
 
     // Wrong formats (in a real webextension this will be blocked by the schema validation).
-    {shouldThrow, exceptionMessageContains: "filters should be an array", filters: {},
+    {shouldThrow, exceptionMessageContains: /filters should be an array/, filters: {},
      url: "http://mozilla.org"},
-    {shouldThrow, exceptionMessageContains: "filters should be an array",
+    {shouldThrow, exceptionMessageContains: /filters should be an array/,
      filters: {nonExistentCriteria: true}, url: "http://mozilla.org", },
     {shouldPass, filters: [{nonExistentCriteria: true}], url: "http://mozilla.org"},
 
     // Schemes filter over various url schemes.
     {shouldPass, filters: [{schemes: ["http"]}], url: "http://mozilla.org"},
     {shouldPass, filters: [{schemes: ["https"]}], url: "https://mozilla.org"},
     {shouldPass, filters: [{schemes: ["ftp"]}], url: "ftp://fake/ftp/url"},
     {shouldPass, filters: [{schemes: ["about"]}], url: "about:blank"},