Bug 1416250 - Remove conditional catch consumers in dom/. r=billm
authorTooru Fujisawa <arai_a@mac.com>
Sat, 18 Nov 2017 22:57:17 +0900
changeset 446857 74ced70141b30f7485a79ac69de4c64f8c462536
parent 446856 49ec21245c48ca0f4b7b1ee370a7ccfd3024140c
child 446858 d30660dbdebebf2f02304fe88de37e6cd0b12532
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1416250
milestone59.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 1416250 - Remove conditional catch consumers in dom/. r=billm
dom/base/test/chrome/cpows_parent.xul
dom/canvas/test/test_canvas.html
dom/tests/mochitest/bugs/test_bug346659.html
dom/tests/mochitest/geolocation/test_optional_api_params.html
--- a/dom/base/test/chrome/cpows_parent.xul
+++ b/dom/base/test/chrome/cpows_parent.xul
@@ -363,73 +363,88 @@
         savedMM.sendAsyncMessage("cpows:lifetime_test_3");
       });
     }
 
     function recvCancelTest(msg) {
       let failed = false;
       try {
         msg.objects.f();
-      } catch (e if /cross-process JS call failed/.test(String(e))) {
+      } catch (e) {
+        if (!/cross-process JS call failed/.test(String(e))) {
+          throw e;
+        }
         failed = true;
       }
       ok(failed, "CPOW should fail due to cancelation");
       msg.target.messageManager.sendAsyncMessage("cpows:cancel_test_done");
     }
 
     function recvCancelSyncMessage() {
       return 12;
     }
 
     function recvCancelTest2(msg) {
       let failed = false;
       try {
         msg.objects.f();
-      } catch (e if /cross-process JS call failed/.test(String(e))) {
+      } catch (e) {
+        if (!/cross-process JS call failed/.test(String(e))) {
+          throw e;
+        }
         failed = true;
       }
       ok(failed, "CPOW should fail due to cancelation");
       msg.target.messageManager.sendAsyncMessage("cpows:cancel_test2_done");
     }
 
     function recvUnsafe(msg) {
       let failed = false;
 
       const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";
       opener.wrappedJSObject.SpecialPowers.setBoolPref(PREF_UNSAFE_FORBIDDEN, true);
       try {
         msg.objects.f();
-      } catch (e if /unsafe CPOW usage forbidden/.test(String(e))) {
+      } catch (e) {
+        if (!/unsafe CPOW usage forbidden/.test(String(e))) {
+          throw e;
+        }
         failed = true;
       }
       opener.wrappedJSObject.SpecialPowers.clearUserPref(PREF_UNSAFE_FORBIDDEN);
       ok(failed, "CPOW should fail when unsafe");
       msg.target.messageManager.sendAsyncMessage("cpows:unsafe_done");
     }
 
     function recvSafe(msg) {
       const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";
       opener.wrappedJSObject.SpecialPowers.setBoolPref(PREF_UNSAFE_FORBIDDEN, true);
       try {
         msg.objects.f();
-      } catch (e if /unsafe CPOW usage forbidden/.test(String(e))) {
+      } catch (e) {
+        if (!/unsafe CPOW usage forbidden/.test(String(e))) {
+          throw e;
+        }
         ok(false, "cpow failed");
       }
       opener.wrappedJSObject.SpecialPowers.clearUserPref(PREF_UNSAFE_FORBIDDEN);
       msg.target.messageManager.sendAsyncMessage("cpows:safe_done");
     }
 
     function recvDead(msg) {
       // Need to do this in a separate turn of the event loop.
       setTimeout(() => {
         msg.objects.gcTrigger();
         try {
           msg.objects.thing.value;
           ok(false, "Should have been a dead CPOW");
-        } catch(e if /dead CPOW/.test(String(e))) {
+        } catch (e) {
+          if (!/dead CPOW/.test(String(e))) {
+            throw e;
+          }
           ok(true, "Got the expected dead CPOW");
           ok(e.stack, "The exception has a stack");
         }
         msg.target.messageManager.sendAsyncMessage("cpows:dead_done");
       }, 0);
     }
 
     function run_tests(type) {
--- a/dom/canvas/test/test_canvas.html
+++ b/dom/canvas/test/test_canvas.html
@@ -19534,26 +19534,32 @@ function test_bug397524() {
   // Should be able to get the data out of the first canvas
   $("canvas1").toDataURL("image/png");
 
   // Should not be able to get the data out of a cross-site load
   var gotData = false;  
   try {
     $("canvas2").toDataURL("image/png");
     gotData = true;
-  } catch (ex if (ex.code == 18 && ex.name == "SecurityError")) {
+  } catch (ex) {
+    if (ex.code != 18 || ex.name != "SecurityError") {
+      throw ex;
+    }
   }
   is(gotData, false, "Shouldn't be able to read images cross-site!");
 
   // Should not be able to get the data out of a redirected cross-site load
   var gotData = false;  
   try {
     $("canvas3").toDataURL("image/png");
     gotData = true;
-  } catch (ex if (ex.code == 18 && ex.name == "SecurityError")) {
+  } catch (ex) {
+    if (ex.code != 18 || ex.name != "SecurityError") {
+      throw ex;
+    }
   }
   is(gotData, false, "Shouldn't be able to read images redirected cross-site!");
 
 }
 
 </script>
 </pre>
 
--- a/dom/tests/mochitest/bugs/test_bug346659.html
+++ b/dom/tests/mochitest/bugs/test_bug346659.html
@@ -61,17 +61,20 @@ function handleCmd(evt) {
     var win = wins[testNum];
     win.childWin.x = testNum;
     try {
       if (win.childWin.opener == win) {
         win.childWin.document.write('<script>window.opener.opener.postMessage(window.opener.testNum + " - " + window.x, "http://mochi.test:8888/"); window.opener.close(); window.close();<' + '/script>');
       } else {
         win.childWin.document.write('<script>window.parent.opener.postMessage(window.parent.testNum + " - " + window.x, "http://mochi.test:8888/"); window.parent.close();<' + '/script>');
       }
-    } catch (e if (e.name == "SecurityError" && e.code == 18)) {
+    } catch (e) {
+      if (e.name != "SecurityError" || e.code != 18) {
+        throw e;
+      }
       // Security error on cross-site write() is fine
       if (win.childWin.opener == win) {
         win.childWin.close();
       }
       win.close()
       handleTestEnd();
     }
     wins[testNum] = null;
--- a/dom/tests/mochitest/geolocation/test_optional_api_params.html
+++ b/dom/tests/mochitest/geolocation/test_optional_api_params.html
@@ -27,73 +27,97 @@ resume_geolocationProvider(function() {
 
 /** Test for Bug 452566 **/
 function test1() {
   ok(navigator.geolocation, "Should have geolocation");
 
   var exception = null;
   try {
     navigator.geolocation.getCurrentPosition();
-  } catch(ex if ex instanceof TypeError) {
+  } catch (ex) {
+    if (!(ex instanceof TypeError)) {
+      throw ex;
+    }
     exception = ex;
   }
   ok(exception, "Should have got an exception");
 
   exception = null;
   try {
     navigator.geolocation.getCurrentPosition(function() {});
-  } catch(ex if ex instanceof TypeError) {
+  } catch (ex) {
+    if (!(ex instanceof TypeError)) {
+      throw ex;
+    }
     exception = ex;
   }
   ok(!exception, exception);
 
   exception = null;
   try {
     navigator.geolocation.getCurrentPosition(function() {}, function() {});
-  } catch(ex if ex instanceof TypeError) {
+  } catch (ex) {
+    if (!(ex instanceof TypeError)) {
+      throw ex;
+    }
     exception = ex;
   }
   ok(!exception, exception);
 
   exception = null;
   try {
     navigator.geolocation.getCurrentPosition(function() {}, function() {}, {});
-  } catch(ex if ex instanceof TypeError) {
+  } catch (ex) {
+    if (!(ex instanceof TypeError)) {
+      throw ex;
+    }
     exception = ex;
   }
   ok(!exception, exception);
 
   exception = null;
   try {
     navigator.geolocation.watchPosition();
-  } catch(ex if ex instanceof TypeError) {
+  } catch (ex) {
+    if (!(ex instanceof TypeError)) {
+      throw ex;
+    }
     exception = ex;
   }
   ok(exception, "Should have got an exception");
 
   exception = null;
   try {
     navigator.geolocation.watchPosition(function() {});
-  } catch(ex if ex instanceof TypeError) {
+  } catch (ex) {
+    if (!(ex instanceof TypeError)) {
+      throw ex;
+    }
     exception = ex;
   }
   ok(!exception, exception);
 
   exception = null;
   try {
     navigator.geolocation.watchPosition(function() {}, function() {});
-  } catch(ex if ex instanceof TypeError) {
+  } catch (ex) {
+    if (!(ex instanceof TypeError)) {
+      throw ex;
+    }
     exception = ex;
   }
   ok(!exception, exception);
 
   exception = null;
   try {
     navigator.geolocation.watchPosition(function() {}, function() {}, {});
-  } catch(ex if ex instanceof TypeError) {
+  } catch (ex) {
+    if (!(ex instanceof TypeError)) {
+      throw ex;
+    }
     exception = ex;
   }
   ok(!exception, exception);
 
   SimpleTest.finish();
 }
 
 </script>