diff --git a/dom/bindings/Errors.msg b/dom/bindings/Errors.msg index e330a5e5680d..7f4f0d14ba7f 100644 --- a/dom/bindings/Errors.msg +++ b/dom/bindings/Errors.msg @@ -92,3 +92,4 @@ MSG_DEF(MSG_NOT_ARRAY_NOR_UNDEFINED, 1, JSEXN_TYPEERR, "{0} is neither an array MSG_DEF(MSG_URL_NOT_LOADABLE, 1, JSEXN_TYPEERR, "Access to '{0}' from script denied.") MSG_DEF(MSG_ONE_OFF_TYPEERR, 1, JSEXN_TYPEERR, "{0}") MSG_DEF(MSG_ONE_OFF_RANGEERR, 1, JSEXN_RANGEERR, "{0}") +MSG_DEF(MSG_NO_CODECS_PARAMETER, 1, JSEXN_TYPEERR, "The provided type '{0}' does not have a 'codecs' parameter.") \ No newline at end of file diff --git a/dom/media/mediacapabilities/MediaCapabilities.cpp b/dom/media/mediacapabilities/MediaCapabilities.cpp index 725c07eaa8c8..693a40808f77 100644 --- a/dom/media/mediacapabilities/MediaCapabilities.cpp +++ b/dom/media/mediacapabilities/MediaCapabilities.cpp @@ -168,7 +168,8 @@ already_AddRefed MediaCapabilities::DecodingInfo( // describing a single media codec. Otherwise, it MUST contain no // parameters. if (videoTracks.Length() != 1) { - promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR); + promise->MaybeRejectWithTypeError( + NS_ConvertUTF8toUTF16(videoContainer->OriginalString())); return promise.forget(); } MOZ_DIAGNOSTIC_ASSERT(videoTracks.ElementAt(0), @@ -183,7 +184,8 @@ already_AddRefed MediaCapabilities::DecodingInfo( // describing a single media codec. Otherwise, it MUST contain no // parameters. if (audioTracks.Length() != 1) { - promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR); + promise->MaybeRejectWithTypeError( + NS_ConvertUTF8toUTF16(audioContainer->OriginalString())); return promise.forget(); } MOZ_DIAGNOSTIC_ASSERT(audioTracks.ElementAt(0), diff --git a/testing/web-platform/tests/media-capabilities/decodingInfo.any.js b/testing/web-platform/tests/media-capabilities/decodingInfo.any.js index 737ded18c9f3..edd58ac3409b 100644 --- a/testing/web-platform/tests/media-capabilities/decodingInfo.any.js +++ b/testing/web-platform/tests/media-capabilities/decodingInfo.any.js @@ -17,28 +17,28 @@ var minimalAudioConfiguration = { }; promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo()); + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo()); }, "Test that decodingInfo rejects if it doesn't get a configuration"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({})); + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({})); }, "Test that decodingInfo rejects if the MediaConfiguration isn't valid"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ video: minimalVideoConfiguration, audio: minimalAudioConfiguration, })); }, "Test that decodingInfo rejects if the MediaConfiguration does not have a type"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', })); }, "Test that decodingInfo rejects if the configuration doesn't have an audio or video field"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"', @@ -51,7 +51,7 @@ promise_test(t => { }, "Test that decodingInfo rejects if the video configuration has a negative framerate"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"', @@ -64,7 +64,7 @@ promise_test(t => { }, "Test that decodingInfo rejects if the video configuration has a framerate set to 0"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"', @@ -77,7 +77,7 @@ promise_test(t => { }, "Test that decodingInfo rejects if the video configuration has a framerate set to Infinity"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'fgeoa', @@ -90,7 +90,7 @@ promise_test(t => { }, "Test that decodingInfo rejects if the video configuration contentType doesn't parse"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'audio/fgeoa', @@ -103,7 +103,7 @@ promise_test(t => { }, "Test that decodingInfo rejects if the video configuration contentType isn't of type video"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"; foo="bar"', @@ -116,7 +116,7 @@ promise_test(t => { }, "Test that decodingInfo rejects if the video configuration contentType has more than one parameter"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; foo="bar"', @@ -142,7 +142,7 @@ promise_test(t => { }, "Test that decodingInfo() accepts framerate in the form of x/y"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"', @@ -155,7 +155,7 @@ promise_test(t => { }, "Test that decodingInfo() rejects framerate in the form of x/0"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"', @@ -168,7 +168,7 @@ promise_test(t => { }, "Test that decodingInfo() rejects framerate in the form of 0/y"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"', @@ -181,7 +181,7 @@ promise_test(t => { }, "Test that decodingInfo() rejects framerate in the form of -x/y"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"', @@ -194,7 +194,7 @@ promise_test(t => { }, "Test that decodingInfo() rejects framerate in the form of x/-y"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"', @@ -233,7 +233,7 @@ promise_test(t => { }, "Test that decodingInfo() accepts framerate as fraction with decimals"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/webm; codecs="vp09.00.10.08"', @@ -246,28 +246,28 @@ promise_test(t => { }, "Test that decodingInfo() rejects framerate with trailing unallowed characters"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'fgeoa' }, })); }, "Test that decodingInfo rejects if the audio configuration contenType doesn't parse"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'video/fgeoa' }, })); }, "Test that decodingInfo rejects if the audio configuration contentType isn't of type audio"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/webm; codecs="opus"; foo="bar"' }, })); }, "Test that decodingInfo rejects if the audio configuration contentType has more than one parameters"); promise_test(t => { - return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodingInfo({ + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/webm; foo="bar"' }, }));