diff --git a/testing/web-platform/tests/content-security-policy/reporting/report-clips-sample.html b/testing/web-platform/tests/content-security-policy/reporting/report-clips-sample.html index cb69c930fc112..29f6aa409cc52 100644 --- a/testing/web-platform/tests/content-security-policy/reporting/report-clips-sample.html +++ b/testing/web-platform/tests/content-security-policy/reporting/report-clips-sample.html @@ -11,7 +11,7 @@ diff --git a/testing/web-platform/tests/trusted-types/block-text-node-insertion-into-script-element.tentative.html b/testing/web-platform/tests/trusted-types/block-text-node-insertion-into-script-element.tentative.html index 607a622f2b3e9..bc29f19f4c4a7 100644 --- a/testing/web-platform/tests/trusted-types/block-text-node-insertion-into-script-element.tentative.html +++ b/testing/web-platform/tests/trusted-types/block-text-node-insertion-into-script-element.tentative.html @@ -176,7 +176,7 @@ container.appendChild(new_script); assert_equals(inserted_script.textContent, "3*4"); - // We expect 3 SPV events: two for the two assert_throws cases, and one + // We expect 3 SPV events: two for the two assert_throws_js cases, and one // for script element, which will be rejected at the time of execution. return checkSecurityPolicyViolationEvent(3); }, "Spot tests around script + innerHTML interaction."); diff --git a/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting-no-unsafe-eval.tentative.https.html b/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting-no-unsafe-eval.tentative.https.html index 786731041140b..40c1ccc69a1b1 100644 --- a/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting-no-unsafe-eval.tentative.https.html +++ b/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting-no-unsafe-eval.tentative.https.html @@ -42,7 +42,7 @@ }); } - // Like assert_throws, but we don't care about the exact error. We just want + // Like assert_throws_*, but we don't care about the exact error. We just want // to run the code and continue. function expect_throws(fn) { try { fn(); assert_unreached(); } catch (err) { /* ignore */ } diff --git a/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting-report-only.tentative.https.html b/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting-report-only.tentative.https.html index 18c035215e0b9..8076ab40c8396 100644 --- a/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting-report-only.tentative.https.html +++ b/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting-report-only.tentative.https.html @@ -42,7 +42,7 @@ }); } - // Like assert_throws, but we don't care about the exact error. We just want + // Like assert_throws_*, but we don't care about the exact error. We just want // to run the code and continue. function expect_throws(fn) { try { fn(); assert_unreached(); } catch (err) { /* ignore */ } diff --git a/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting.tentative.https.html b/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting.tentative.https.html index d98b457f6aaa7..dec8a07cfc4bb 100644 --- a/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting.tentative.https.html +++ b/testing/web-platform/tests/trusted-types/trusted-types-eval-reporting.tentative.https.html @@ -36,7 +36,7 @@ }); } - // Like assert_throws, but we don't care about the exact error. We just want + // Like assert_throws_*, but we don't care about the exact error. We just want // to run the code and continue. function expect_throws(fn) { try { fn(); assert_unreached(); } catch (err) { /* ignore */ } diff --git a/testing/web-platform/tests/trusted-types/trusted-types-reporting.tentative.https.html b/testing/web-platform/tests/trusted-types/trusted-types-reporting.tentative.https.html index ef282dc609c88..bd336f3ad6844 100644 --- a/testing/web-platform/tests/trusted-types/trusted-types-reporting.tentative.https.html +++ b/testing/web-platform/tests/trusted-types/trusted-types-reporting.tentative.https.html @@ -48,7 +48,7 @@ }); } - // Like assert_throws, but we don't care about the exact error. We just want + // Like assert_throws_*, but we don't care about the exact error. We just want // to run the code and continue. function expect_throws(fn) { try { fn(); assert_unreached(); } catch (err) { /* ignore */ } diff --git a/testing/web-platform/tests/user-timing/measure_exception.html b/testing/web-platform/tests/user-timing/measure_exception.html index df674d931f48f..5c1aa086c0fc8 100644 --- a/testing/web-platform/tests/user-timing/measure_exception.html +++ b/testing/web-platform/tests/user-timing/measure_exception.html @@ -19,7 +19,7 @@

Description

diff --git a/testing/web-platform/tests/user-timing/resources/webperftestharnessextension.js b/testing/web-platform/tests/user-timing/resources/webperftestharnessextension.js index 822376be24c2f..b682f02544ebe 100644 --- a/testing/web-platform/tests/user-timing/resources/webperftestharnessextension.js +++ b/testing/web-platform/tests/user-timing/resources/webperftestharnessextension.js @@ -32,9 +32,17 @@ function test_method_exists(method, method_name, properties) function test_method_throw_exception(func_str, exception, msg) { - var exception_name = typeof exception === "object" ? exception.name : exception; + let exception_name; + let test_func; + if (typeof exception == "function") { + exception_name = exception.name; + test_func = assert_throws_js; + } else { + exception_name = exception; + test_func = assert_throws_dom; + } var msg = 'Invocation of ' + func_str + ' should throw ' + exception_name + ' Exception.'; - wp_test(function() { assert_throws(exception, function() {eval(func_str)}, msg); }, msg); + wp_test(function() { test_func(exception, function() {eval(func_str)}, msg); }, msg); } function test_noless_than(value, greater_than, msg, properties) diff --git a/testing/web-platform/tests/video-raf/video-request-animation-frame.html b/testing/web-platform/tests/video-raf/video-request-animation-frame.html index 195f5edbe949e..76b986ecb66d7 100644 --- a/testing/web-platform/tests/video-raf/video-request-animation-frame.html +++ b/testing/web-platform/tests/video-raf/video-request-animation-frame.html @@ -58,12 +58,12 @@ let video = document.createElement('video'); // requestAnimationFrame() expects 1 function as a parameter. - assert_throws(new TypeError(), _ => { video.requestAnimationFrame() } ); - assert_throws(new TypeError(), _ => { video.requestAnimationFrame(0) }); - assert_throws(new TypeError(), _ => { video.requestAnimationFrame("foo") }); + assert_throws_js(TypeError, _ => { video.requestAnimationFrame() } ); + assert_throws_js(TypeError, _ => { video.requestAnimationFrame(0) }); + assert_throws_js(TypeError, _ => { video.requestAnimationFrame("foo") }); // cancelAnimationFrame() expects 1 number as a parameter - assert_throws(new TypeError(), _ => { video.cancelAnimationFrame() } ); + assert_throws_js(TypeError, _ => { video.cancelAnimationFrame() } ); // Invalid calls are just noops video.cancelAnimationFrame(_ => {}); diff --git a/testing/web-platform/tests/wasm/jsapi/bad-imports.js b/testing/web-platform/tests/wasm/jsapi/bad-imports.js index bbed037851e8a..a44c23b467a0a 100644 --- a/testing/web-platform/tests/wasm/jsapi/bad-imports.js +++ b/testing/web-platform/tests/wasm/jsapi/bad-imports.js @@ -2,7 +2,7 @@ * `t` should be a function that takes at least three arguments: * * - the name of the test; - * - the expected error (to be passed to `assert_throws` or similar); + * - the expected error (to be passed to `assert_throws_js`); * - a function that takes a `WasmModuleBuilder` and initializes it; * - (optionally) an options object. * diff --git a/testing/web-platform/tests/webrtc-extensions/RTCRtpParameters-maxFramerate.html b/testing/web-platform/tests/webrtc-extensions/RTCRtpParameters-maxFramerate.html index 7067fbc799807..dfefed4e93c0c 100644 --- a/testing/web-platform/tests/webrtc-extensions/RTCRtpParameters-maxFramerate.html +++ b/testing/web-platform/tests/webrtc-extensions/RTCRtpParameters-maxFramerate.html @@ -11,7 +11,7 @@ test(function(t) { const pc = new RTCPeerConnection(); t.add_cleanup(() => pc.close()); - assert_throws(new RangeError(), () => pc.addTransceiver('video', { + assert_throws_js(RangeError, () => pc.addTransceiver('video', { sendEncodings: [{ maxFramerate: -10 }] diff --git a/testing/web-platform/tests/webrtc/RTCConfiguration-iceCandidatePoolSize.html b/testing/web-platform/tests/webrtc/RTCConfiguration-iceCandidatePoolSize.html index 0dccf4c11d2ca..495b043e12df3 100644 --- a/testing/web-platform/tests/webrtc/RTCConfiguration-iceCandidatePoolSize.html +++ b/testing/web-platform/tests/webrtc/RTCConfiguration-iceCandidatePoolSize.html @@ -89,7 +89,7 @@ /* The following tests include an explicit assertion for the existence of a -setConfiguration function to prevent the assert_throws from catching the +setConfiguration function to prevent the assert_throws_js from catching the TypeError object that will be thrown when attempting to call the non-existent setConfiguration method (in cases where it has not yet been implemented). Without this check, these tests will pass incorrectly. diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-constructor.html b/testing/web-platform/tests/webrtc/RTCPeerConnection-constructor.html index 0336837f8131d..1708b2705f823 100644 --- a/testing/web-platform/tests/webrtc/RTCPeerConnection-constructor.html +++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-constructor.html @@ -14,7 +14,7 @@ const toNumberThrows = Symbol(); // Test the first argument of the constructor. The key is the argument itself, -// and the value is the first argument for assert_throws, or false if no +// and the value is the first argument for assert_throws_js, or false if no // exception should be thrown. const testArgs = { // No argument or equivalent. diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-track-stats.https.html b/testing/web-platform/tests/webrtc/RTCPeerConnection-track-stats.https.html index 2c5c8aecdc15c..b56982fda4bc3 100644 --- a/testing/web-platform/tests/webrtc/RTCPeerConnection-track-stats.https.html +++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-track-stats.https.html @@ -648,15 +648,4 @@ } } } - - async function async_assert_throws(exceptionName, promise, description) { - try { - await promise; - } catch (e) { - assert_equals(e.name, exceptionName); - return; - } - assert_unreached('No exception was thrown.'); - } - diff --git a/testing/web-platform/tests/webrtc/tools/.eslintrc.js b/testing/web-platform/tests/webrtc/tools/.eslintrc.js index 914a09dc32c74..c710d1d781c03 100644 --- a/testing/web-platform/tests/webrtc/tools/.eslintrc.js +++ b/testing/web-platform/tests/webrtc/tools/.eslintrc.js @@ -24,7 +24,6 @@ module.exports = { assert_array_equals: true, assert_in_array: true, assert_unreached: true, - assert_throws: true, assert_idl_attribute: true, assert_own_property: true, assert_greater_than: true,