From c1ab51f11c4dfd76e9c9a02080bf8ecbe42eb033 Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Mon, 19 Aug 2019 17:02:54 +0000 Subject: [PATCH] Bug 1574915 - Fix useless try-catch issues in dom/. r=hsivonen Differential Revision: https://phabricator.services.mozilla.com/D42509 --HG-- extra : moz-landing-system : lando --- dom/browser-element/mochitest/async.js | 6 +---- ..._composite_canvaspattern_setTransform.html | 3 +-- dom/canvas/test/test_canvas.html | 6 ++--- dom/canvas/test/test_canvas_focusring.html | 2 +- dom/canvas/test/test_hitregion_canvas.html | 2 +- dom/websocket/tests/websocket_helpers.js | 26 ++++++++----------- 6 files changed, 18 insertions(+), 27 deletions(-) diff --git a/dom/browser-element/mochitest/async.js b/dom/browser-element/mochitest/async.js index 269a04811405..dfbc3a0f2406 100644 --- a/dom/browser-element/mochitest/async.js +++ b/dom/browser-element/mochitest/async.js @@ -62,11 +62,7 @@ .then( result => step(gen.next(result)), error => { - try { - step(gen.throw(error)); - } catch (err) { - throw err; - } + step(gen.throw(error)); } ) .catch(err => reject(err)); diff --git a/dom/canvas/test/test_2d_composite_canvaspattern_setTransform.html b/dom/canvas/test/test_2d_composite_canvaspattern_setTransform.html index 6e46774d04da..2c525c2362e8 100644 --- a/dom/canvas/test/test_2d_composite_canvaspattern_setTransform.html +++ b/dom/canvas/test/test_2d_composite_canvaspattern_setTransform.html @@ -60,8 +60,8 @@ function runTests() { try { test_2d_canvaspattern_setTransform(); } catch(e) { - throw e; ok(false, "unexpected exception thrown in: test_2d_canvaspattern_setTransform"); + throw e; } SimpleTest.finish(); } @@ -75,4 +75,3 @@ document.all; window.p = new Path2D(); - diff --git a/dom/canvas/test/test_canvas.html b/dom/canvas/test/test_canvas.html index 95ceda4db3c0..9426667bfc7f 100644 --- a/dom/canvas/test/test_canvas.html +++ b/dom/canvas/test/test_canvas.html @@ -25606,14 +25606,14 @@ function runTests() { try { test_getImageData_after_zero_canvas(); } catch(e) { - throw e; ok(false, "unexpected exception thrown in: test_getImageData_after_zero_canvas"); + throw e; } try { test_opaque(); } catch(e) { - throw e; ok(false, "unexpected exception thrown in: test_opaque"); + throw e; } try { test_2d_transformation_reset_transform(); @@ -25764,8 +25764,8 @@ function runTests() { try { test_2d_clearRect_testdoubleprecision(); } catch(e) { - throw e; ok(false, "unexpected exception thrown in: test_2d_clearRect_testdoubleprecision"); + throw e; } //run the asynchronous tests diff --git a/dom/canvas/test/test_canvas_focusring.html b/dom/canvas/test/test_canvas_focusring.html index ef7cddd2e895..0e9566ac2914 100644 --- a/dom/canvas/test/test_canvas_focusring.html +++ b/dom/canvas/test/test_canvas_focusring.html @@ -60,8 +60,8 @@ function runTests() { try { test_drawFocusIfNeeded_canvas(); } catch(e) { - throw e; ok(false, "unexpected exception thrown in: test_drawFocusIfNeeded_canvas"); + throw e; } SpecialPowers.setBoolPref("canvas.focusring.enabled", false); diff --git a/dom/canvas/test/test_hitregion_canvas.html b/dom/canvas/test/test_hitregion_canvas.html index 49cefb0b46c6..0ac826164377 100644 --- a/dom/canvas/test/test_hitregion_canvas.html +++ b/dom/canvas/test/test_hitregion_canvas.html @@ -72,8 +72,8 @@ function runTests() { try { test_hitregions(); } catch(e) { - throw e; ok(false, "unexpected exception thrown in: test_hitregions"); + throw e; } SimpleTest.finish(); } diff --git a/dom/websocket/tests/websocket_helpers.js b/dom/websocket/tests/websocket_helpers.js index 24ef3ba4a43a..18f9f5a835f5 100644 --- a/dom/websocket/tests/websocket_helpers.js +++ b/dom/websocket/tests/websocket_helpers.js @@ -28,23 +28,19 @@ function ignoreError(e) {} function CreateTestWS(ws_location, ws_protocol) { var ws; - try { - if (ws_protocol == undefined) { - ws = new WebSocket(ws_location); - } else { - ws = new WebSocket(ws_location, ws_protocol); - } - - ws._testNumber = current_test; - ok(true, "Created websocket for test " + ws._testNumber + "\n"); - - ws.onerror = function(e) { - ok(false, "onerror called on test " + e.target._testNumber + "!"); - }; - } catch (e) { - throw e; + if (ws_protocol == undefined) { + ws = new WebSocket(ws_location); + } else { + ws = new WebSocket(ws_location, ws_protocol); } + ws._testNumber = current_test; + ok(true, "Created websocket for test " + ws._testNumber + "\n"); + + ws.onerror = function(e) { + ok(false, "onerror called on test " + e.target._testNumber + "!"); + }; + return ws; }