Bug 1536659 - docshell/ automated ESLint no-throw-literal fixes. r=nika
authorIan Moody <moz-ian@perix.co.uk>
Thu, 21 Mar 2019 16:53:45 +0000
changeset 465978 621f825b37e816da9e19364af21f88a281284bfd
parent 465977 0ebb51472ce4081235fea82701839bcdfc10642c
child 465979 35240b0ae4a5af0c329b40e1a453cfb397f809f1
push id112550
push userrgurzau@mozilla.com
push dateTue, 26 Mar 2019 09:57:15 +0000
treeherdermozilla-inbound@b8be99473610 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1536659
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1536659 - docshell/ automated ESLint no-throw-literal fixes. r=nika Result of running: $ mach eslint -funix docshell/ | sed -Ee 's/:.+//' - | xargs sed -E \ -e 's/throw ((["`])[^"]+\2);/throw new Error(\1);/g' \ -e 's/throw ((["`])[^"]+\2 \+ [^ ";]+);/throw new Error(\1);/g' \ -e 's/throw \(/throw new Error(/g' -i Differential Revision: https://phabricator.services.mozilla.com/D24367
docshell/test/chrome/docshell_helpers.js
docshell/test/navigation/NavigationUtils.js
--- a/docshell/test/chrome/docshell_helpers.js
+++ b/docshell/test/chrome/docshell_helpers.js
@@ -107,35 +107,35 @@ function doPageNavigation(params) {
     eventsToListenFor.length == 0 ? undefined : params.unexpectedEvents;
   let preventBFCache = (typeof[params.preventBFCache] == "undefined") ?
     false : params.preventBFCache;
   let waitOnly = (typeof(params.waitForEventsOnly) == "boolean"
     && params.waitForEventsOnly);
 
   // Do some sanity checking on arguments.
   if (back && forward)
-    throw "Can't specify both back and forward";
+    throw new Error("Can't specify both back and forward");
   if (back && uri)
-    throw "Can't specify both back and a uri";
+    throw new Error("Can't specify both back and a uri");
   if (forward && uri)
-    throw "Can't specify both forward and a uri";
+    throw new Error("Can't specify both forward and a uri");
   if (reload && (forward || back || uri))
-    throw "Can't specify reload and another navigation type";
+    throw new Error("Can't specify reload and another navigation type");
   if (!back && !forward && !uri && !reload && !waitOnly)
-    throw "Must specify back or foward or reload or uri";
+    throw new Error("Must specify back or foward or reload or uri");
   if (params.onNavComplete && eventsToListenFor.length == 0)
-    throw "Can't use onNavComplete when eventsToListenFor == []";
+    throw new Error("Can't use onNavComplete when eventsToListenFor == []");
   if (params.preventBFCache && eventsToListenFor.length == 0)
-    throw "Can't use preventBFCache when eventsToListenFor == []";
+    throw new Error("Can't use preventBFCache when eventsToListenFor == []");
   if (params.preventBFCache && waitOnly)
-    throw "Can't prevent bfcaching when only waiting for events";
+    throw new Error("Can't prevent bfcaching when only waiting for events");
   if (waitOnly && typeof(params.onNavComplete) == "undefined")
-    throw "Must specify onNavComplete when specifying waitForEventsOnly";
+    throw new Error("Must specify onNavComplete when specifying waitForEventsOnly");
   if (waitOnly && (back || forward || reload || uri))
-    throw "Can't specify a navigation type when using waitForEventsOnly";
+    throw new Error("Can't specify a navigation type when using waitForEventsOnly");
   for (let anEventType of eventsToListenFor) {
     let eventFound = false;
     if ( (anEventType == "pageshow") && (!gExpectedEvents) )
       eventFound = true;
     if (gExpectedEvents) {
       for (let anExpectedEvent of gExpectedEvents) {
         if (anExpectedEvent.type == anEventType)
           eventFound = true;
@@ -175,17 +175,17 @@ function doPageNavigation(params) {
     gNavType = NAV_URI;
     BrowserTestUtils.loadURI(TestWindow.getBrowser(), uri);
   } else if (reload) {
     gNavType = NAV_RELOAD;
     TestWindow.getBrowser().reload();
   } else if (waitOnly) {
     gNavType = NAV_NONE;
   } else {
-    throw "No valid navigation type passed to doPageNavigation!";
+    throw new Error("No valid navigation type passed to doPageNavigation!");
   }
 
   // If we're listening for events and there is an .onNavComplete callback,
   // wait for all events to occur, and then call doPageNavigation_complete().
   if (eventsToListenFor.length > 0 && params.onNavComplete) {
     waitForTrue(
       function() { return gFinalEvent; },
       function() {
--- a/docshell/test/navigation/NavigationUtils.js
+++ b/docshell/test/navigation/NavigationUtils.js
@@ -158,17 +158,17 @@ function xpcWaitForFinishedFrames(callba
 
     if (finishedFrameCount == numFrames) {
       clearInterval(frameWaitInterval);
       setTimeout(callback, 0);
       return;
     }
 
     if (finishedFrameCount > numFrames)
-      throw "Too many frames loaded.";
+      throw new Error("Too many frames loaded.");
   }
 
   var finishedWindows = [];
 
   function contains(obj, arr) {
     for (var i = 0; i < arr.length; i++) {
       if (obj === arr[i])
         return true;