From ceac9fe2785653c7ee4ed9b865f150c553f77e77 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 17 Jan 2020 09:55:27 +0000 Subject: [PATCH] Bug 1609858. Stop using NS_ERROR_DOM_TYPE_ERR in TimingParams. r=smaug It's causing us to throw weird DOMExceptions instead of actual TypeErrors. Differential Revision: https://phabricator.services.mozilla.com/D60216 --HG-- extra : moz-landing-system : lando --- dom/animation/TimingParams.cpp | 3 ++- .../interfaces/KeyframeEffect/constructor.html | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dom/animation/TimingParams.cpp b/dom/animation/TimingParams.cpp index ab88c8c9e221..932c4c9cf5b4 100644 --- a/dom/animation/TimingParams.cpp +++ b/dom/animation/TimingParams.cpp @@ -48,7 +48,8 @@ TimingParams TimingParams::FromOptionsType(const OptionsType& aOptions, result.mDuration.emplace( StickyTimeDuration::FromMilliseconds(durationInMs)); } else { - aRv.Throw(NS_ERROR_DOM_TYPE_ERR); + nsPrintfCString error("Duration value %f is less than 0", durationInMs); + aRv.ThrowTypeError(NS_ConvertUTF8toUTF16(error)); return result; } result.Update(); diff --git a/testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/constructor.html b/testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/constructor.html index 8f16aa18711e..46a23b0c2e87 100644 --- a/testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/constructor.html +++ b/testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/constructor.html @@ -41,7 +41,7 @@ test(t => { test(t => { for (const invalidEasing of gInvalidEasings) { - assert_throws(new TypeError, () => { + assert_throws_js(TypeError, () => { new KeyframeEffect(target, null, { easing: invalidEasing }); }, `TypeError is thrown for easing '${invalidEasing}'`); } @@ -57,7 +57,7 @@ test(t => { `resulting composite for '${composite}'`); } for (const composite of gBadKeyframeCompositeValueTests) { - assert_throws(new TypeError, () => { + assert_throws_js(TypeError, () => { new KeyframeEffect(target, getKeyframe(composite)); }); } @@ -76,7 +76,7 @@ test(t => { `resulting composite for '${composite}'`); } for (const composite of gBadKeyframeCompositeValueTests) { - assert_throws(new TypeError, () => { + assert_throws_js(TypeError, () => { new KeyframeEffect(target, getKeyframes(composite)); }); } @@ -92,7 +92,7 @@ test(t => { `resulting composite for '${composite}'`); } for (const composite of gBadOptionsCompositeValueTests) { - assert_throws(new TypeError, () => { + assert_throws_js(TypeError, () => { new KeyframeEffect(target, { left: ['10px', '20px'] }, { composite: composite }); @@ -117,7 +117,7 @@ for (const subtest of gKeyframesTests) { for (const subtest of gInvalidKeyframesTests) { test(t => { - assert_throws(new TypeError, () => { + assert_throws_js(TypeError, () => { new KeyframeEffect(target, subtest.input); }); }, `KeyframeEffect constructor throws with ${subtest.desc}`); @@ -169,7 +169,7 @@ for (const subtest of gKeyframeEffectOptionTests) { for (const subtest of gInvalidKeyframeEffectOptionTests) { test(t => { - assert_throws(new TypeError, () => { + assert_throws_js(TypeError, () => { new KeyframeEffect(target, { left: ['10px', '20px'] }, subtest.input); }); }, `Invalid KeyframeEffect option by ${subtest.desc}`);