Bug 1581278 part 4. Stop incorrectly rejecting promises in MediaCapabilities. r=jya

Differential Revision: https://phabricator.services.mozilla.com/D46385

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-09-19 02:03:07 +00:00
Родитель 2e33a36d6f
Коммит b544880d43
3 изменённых файлов: 26 добавлений и 23 удалений

Просмотреть файл

@ -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.")

Просмотреть файл

@ -168,7 +168,8 @@ already_AddRefed<Promise> 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<MSG_NO_CODECS_PARAMETER>(
NS_ConvertUTF8toUTF16(videoContainer->OriginalString()));
return promise.forget();
}
MOZ_DIAGNOSTIC_ASSERT(videoTracks.ElementAt(0),
@ -183,7 +184,8 @@ already_AddRefed<Promise> 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<MSG_NO_CODECS_PARAMETER>(
NS_ConvertUTF8toUTF16(audioContainer->OriginalString()));
return promise.forget();
}
MOZ_DIAGNOSTIC_ASSERT(audioTracks.ElementAt(0),

Просмотреть файл

@ -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"' },
}));