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

Merged
Merged
Show file tree
Hide file tree
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
100 changes: 91 additions & 9 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: 24,
}
}));
}, "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: 24,
}
}));
}, "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 All @@ -183,7 +236,7 @@ promise_test(t => {
framerate: '24000/1001',
}
}));
}, "Test that decodingInfo() rejects framerate in the form of x/y");
}, "Test that decodingInfo rejects framerate in the form of x/y");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
Expand All @@ -196,7 +249,7 @@ promise_test(t => {
framerate: '24000/0',
}
}));
}, "Test that decodingInfo() rejects framerate in the form of x/0");
}, "Test that decodingInfo rejects framerate in the form of x/0");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
Expand All @@ -209,7 +262,7 @@ promise_test(t => {
framerate: '0/10001',
}
}));
}, "Test that decodingInfo() rejects framerate in the form of 0/y");
}, "Test that decodingInfo rejects framerate in the form of 0/y");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
Expand All @@ -222,7 +275,7 @@ promise_test(t => {
framerate: '-24000/10001',
}
}));
}, "Test that decodingInfo() rejects framerate in the form of -x/y");
}, "Test that decodingInfo rejects framerate in the form of -x/y");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
Expand All @@ -235,7 +288,7 @@ promise_test(t => {
framerate: '24000/-10001',
}
}));
}, "Test that decodingInfo() rejects framerate in the form of x/-y");
}, "Test that decodingInfo rejects framerate in the form of x/-y");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
Expand All @@ -248,7 +301,7 @@ promise_test(t => {
framerate: '24000/',
}
}));
}, "Test that decodingInfo() rejects framerate in the form of x/");
}, "Test that decodingInfo rejects framerate in the form of x/");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
Expand All @@ -261,14 +314,22 @@ promise_test(t => {
framerate: '1/3x',
}
}));
}, "Test that decodingInfo() rejects framerate with trailing unallowed characters");
}, "Test that decodingInfo rejects framerate with trailing unallowed characters");

promise_test(t => {
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");
}, "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
90 changes: 82 additions & 8 deletions media-capabilities/encodingInfo.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ promise_test(t => {
}));
}, "Test that encodingInfo 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.encodingInfo({
type: 'record',
video: {
contentType: 'video/webm;',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
},
}));
}, "Test that encodingInfo rejects if the video configuration contentType is not a valid MIME type string");

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

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({
type: 'record',
video: {
contentType: 'video/webm',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
},
}));
}, "Test that encodingInfo 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.encodingInfo({
type: 'record',
video: {
contentType: 'video/webm; codecs="vp09.00.10.08, vp8"',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
}
}));
}, "Test that encodingInfo 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.encodingInfo({
type: 'record',
video: {
contentType: 'video/webm; codecs="vp09.00.10.08, opus"',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
}
}));
}, "Test that encodingInfo 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.encodingInfo({
type: 'record',
Expand All @@ -153,7 +206,7 @@ promise_test(t => {
framerate: '24000/1001',
}
}));
}, "Test that encodingInfo() rejects framerate in the form of x/y");
}, "Test that encodingInfo rejects framerate in the form of x/y");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({
Expand All @@ -166,7 +219,7 @@ promise_test(t => {
framerate: '24000/0',
}
}));
}, "Test that encodingInfo() rejects framerate in the form of x/0");
}, "Test that encodingInfo rejects framerate in the form of x/0");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({
Expand All @@ -179,7 +232,7 @@ promise_test(t => {
framerate: '0/10001',
}
}));
}, "Test that encodingInfo() rejects framerate in the form of 0/y");
}, "Test that encodingInfo rejects framerate in the form of 0/y");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({
Expand All @@ -192,7 +245,7 @@ promise_test(t => {
framerate: '-24000/10001',
}
}));
}, "Test that encodingInfo() rejects framerate in the form of -x/y");
}, "Test that encodingInfo rejects framerate in the form of -x/y");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({
Expand All @@ -205,7 +258,7 @@ promise_test(t => {
framerate: '24000/-10001',
}
}));
}, "Test that encodingInfo() rejects framerate in the form of x/-y");
}, "Test that encodingInfo rejects framerate in the form of x/-y");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({
Expand All @@ -218,7 +271,7 @@ promise_test(t => {
framerate: '24000/',
}
}));
}, "Test that encodingInfo() rejects framerate in the form of x/");
}, "Test that encodingInfo rejects framerate in the form of x/");

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({
Expand All @@ -231,7 +284,7 @@ promise_test(t => {
framerate: '1/3x',
}
}));
}, "Test that encodingInfo() rejects framerate with trailing unallowed characters");
}, "Test that encodingInfo rejects framerate with trailing unallowed characters");

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

promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({
type: 'record',
audio: { contentType: 'audio/webm' },
}));
}, "Test that encodingInfo 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.encodingInfo({
type: 'record',
audio: { contentType: 'audio/webm; codecs="vorbis, opus"' },
}));
}, "Test that encodingInfo 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.encodingInfo({
type: 'record',
audio: { contentType: 'audio/webm; codecs="vp09.00.10.08, opus"' },
}));
}, "Test that encodingInfo 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.encodingInfo({
type: 'record',
Expand All @@ -271,7 +345,7 @@ promise_test(t => {
assert_equals(typeof ability.smooth, "boolean");
assert_equals(typeof ability.powerEfficient, "boolean");
});
}, "Test that encodingInfo returns a valid MediaCapabilitiesInfo objects for record type");
}, "Test that encodingInfo returns a valid MediaCapabilitiesInfo object for record type");

async_test(t => {
var validTypes = [ 'record', 'webrtc' ];
Expand Down