Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some Media Capabilities API tests #49140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 84 additions & 2 deletions media-capabilities/decodingInfo.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ promise_test(t => {
}));
}, "Test that decodingInfo rejects if the video configuration contentType doesn't parse");

// See https://mimesniff.spec.whatwg.org/#example-valid-mime-type-string
promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: {
contentType: 'video/webm;',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
},
}));
}, "Test that decodingInfo rejects if the video configuration contentType is not a valid MIME type string");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
Expand Down Expand Up @@ -172,6 +186,45 @@ promise_test(t => {
}));
}, "Test that decodingInfo rejects if the video configuration contentType has one parameter that isn't codecs");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: {
contentType: 'video/webm',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
},
}));
}, "Test that decodingInfo rejects if the video configuration contentType does not imply a single media codec but has no codecs parameter");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: {
contentType: 'video/webm; codecs="vp09.00.10.08, vp8"',
width: 800,
height: 600,
bitrate: 3000,
framerate: '24000/1001',
}
}));
}, "Test that decodingInfo() rejects if the video configuration contentType has a codecs parameter that indicates multiple video codecs");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: {
contentType: 'video/webm; codecs="vp09.00.10.08, opus"',
width: 800,
height: 600,
bitrate: 3000,
framerate: '24000/1001',
}
}));
}, "Test that decodingInfo() rejects if the video configuration contentType has a codecs parameter that indicates both an audio and a video codec");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
Expand Down Expand Up @@ -268,7 +321,15 @@ promise_test(t => {
type: 'file',
audio: { contentType: 'fgeoa' },
}));
}, "Test that decodingInfo rejects if the audio configuration contenType doesn't parse");
}, "Test that decodingInfo rejects if the audio configuration contentType doesn't parse");

// See https://mimesniff.spec.whatwg.org/#example-valid-mime-type-string
promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
audio: { contentType: 'audio/mpeg;' },
}));
}, "Test that decodingInfo rejects if the audio configuration contentType is not a valid MIME type string");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
Expand All @@ -282,7 +343,7 @@ promise_test(t => {
type: 'file',
audio: { contentType: 'audio/webm; codecs="opus"; foo="bar"' },
}));
}, "Test that decodingInfo rejects if the audio configuration contentType has more than one parameters");
}, "Test that decodingInfo rejects if the audio configuration contentType has more than one parameter");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
Expand All @@ -291,6 +352,27 @@ promise_test(t => {
}));
}, "Test that decodingInfo rejects if the audio configuration contentType has one parameter that isn't codecs");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
audio: { contentType: 'audio/webm' },
}));
}, "Test that decodingInfo rejects if the audio configuration contentType does not imply a single media codec but has no codecs parameter");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
audio: { contentType: 'audio/webm; codecs="vorbis, opus"' },
}));
}, "Test that decodingInfo() rejects if the audio configuration contentType has a codecs parameter that indicates multiple audio codecs");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
audio: { contentType: 'audio/webm; codecs="vp09.00.10.08, opus"' },
}));
}, "Test that decodingInfo() rejects if the audio configuration contentType has a codecs parameter that indicates both an audio and a video codec");

promise_test(t => {
return navigator.mediaCapabilities.decodingInfo({
type: 'file',
Expand Down