From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../web-platform/tests/media-capabilities/META.yml | 3 + .../tests/media-capabilities/README.md | 14 + .../tests/media-capabilities/decodingInfo.any.js | 406 +++++++++++++++++++++ .../media-capabilities/decodingInfo.webrtc.html | 217 +++++++++++ .../decodingInfoEncryptedMedia.http.html | 31 ++ .../decodingInfoEncryptedMedia.https.html | 262 +++++++++++++ .../tests/media-capabilities/encodingInfo.any.js | 310 ++++++++++++++++ .../media-capabilities/encodingInfo.webrtc.html | 217 +++++++++++ .../tests/media-capabilities/idlharness.any.js | 25 ++ 9 files changed, 1485 insertions(+) create mode 100644 testing/web-platform/tests/media-capabilities/META.yml create mode 100644 testing/web-platform/tests/media-capabilities/README.md create mode 100644 testing/web-platform/tests/media-capabilities/decodingInfo.any.js create mode 100644 testing/web-platform/tests/media-capabilities/decodingInfo.webrtc.html create mode 100644 testing/web-platform/tests/media-capabilities/decodingInfoEncryptedMedia.http.html create mode 100644 testing/web-platform/tests/media-capabilities/decodingInfoEncryptedMedia.https.html create mode 100644 testing/web-platform/tests/media-capabilities/encodingInfo.any.js create mode 100644 testing/web-platform/tests/media-capabilities/encodingInfo.webrtc.html create mode 100644 testing/web-platform/tests/media-capabilities/idlharness.any.js (limited to 'testing/web-platform/tests/media-capabilities') diff --git a/testing/web-platform/tests/media-capabilities/META.yml b/testing/web-platform/tests/media-capabilities/META.yml new file mode 100644 index 0000000000..2bd00efb9a --- /dev/null +++ b/testing/web-platform/tests/media-capabilities/META.yml @@ -0,0 +1,3 @@ +spec: https://w3c.github.io/media-capabilities/ +suggested_reviewers: + - mounirlamouri diff --git a/testing/web-platform/tests/media-capabilities/README.md b/testing/web-platform/tests/media-capabilities/README.md new file mode 100644 index 0000000000..cfe994976c --- /dev/null +++ b/testing/web-platform/tests/media-capabilities/README.md @@ -0,0 +1,14 @@ +# Media Capabilities specification Tests + +The Media Capabilities specification is available here: https://wicg.github.io/media-capabilities + +GitHub repository: https://github.com/WICG/media-capabilities + +File an issue: https://github.com/wicg/media-capabilities/issues/new + +## Status of these tests + +These tests are still very early. The specification is still WIP and they try to +reflect as much as possible the current state of the specification. Please file +issues if there are inconsistencies between the specification and the tests or +if tests are obviously missing. diff --git a/testing/web-platform/tests/media-capabilities/decodingInfo.any.js b/testing/web-platform/tests/media-capabilities/decodingInfo.any.js new file mode 100644 index 0000000000..061a226e3f --- /dev/null +++ b/testing/web-platform/tests/media-capabilities/decodingInfo.any.js @@ -0,0 +1,406 @@ +// META: timeout=long +'use strict'; + +// Minimal VideoConfiguration that will be allowed per spec. All optional +// properties are missing. +var minimalVideoConfiguration = { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, +}; + +// Minimal AudioConfiguration that will be allowed per spec. All optional +// properties are missing. +var minimalAudioConfiguration = { + contentType: 'audio/webm; codecs="opus"', +}; + +// AudioConfiguration with optional spatialRendering param. +var audioConfigurationWithSpatialRendering = { + contentType: 'audio/webm; codecs="opus"', + spatialRendering: true, +}; + +// VideoConfiguration with optional hdrMetadataType, colorGamut, and +// transferFunction properties. +var videoConfigurationWithDynamicRange = { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + hdrMetadataType: "smpteSt2086", + colorGamut: "srgb", + transferFunction: "srgb", +} + +promise_test(t => { + 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_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({})); +}, "Test that decodingInfo rejects if the MediaConfiguration isn't valid"); + +promise_test(t => { + 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_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_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: -1, + }, + })); +}, "Test that decodingInfo rejects if the video configuration has a negative framerate"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 0, + }, + })); +}, "Test that decodingInfo rejects if the video configuration has a framerate set to 0"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: Infinity, + }, + })); +}, "Test that decodingInfo rejects if the video configuration has a framerate set to Infinity"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'fgeoa', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + }, + })); +}, "Test that decodingInfo rejects if the video configuration contentType doesn't parse"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'audio/fgeoa', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + }, + })); +}, "Test that decodingInfo rejects if the video configuration contentType isn't of type video"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'application/ogg; codec=vorbis', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + }, + })); +}, "Test that decodingInfo rejects if the video configuration contentType is of type audio"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + audio: { + contentType: 'application/ogg; codec=theora', + channels: 2, + }, + })); +}, "Test that decodingInfo rejects if the audio configuration contentType is of type video"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"; foo="bar"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + }, + })); +}, "Test that decodingInfo rejects if the video configuration contentType has more than one parameter"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; foo="bar"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + }, + })); +}, "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; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '24000/1001', + } + })); +}, "Test that decodingInfo() rejects framerate in the form of x/y"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '24000/0', + } + })); +}, "Test that decodingInfo() rejects framerate in the form of x/0"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '0/10001', + } + })); +}, "Test that decodingInfo() rejects framerate in the form of 0/y"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '-24000/10001', + } + })); +}, "Test that decodingInfo() rejects framerate in the form of -x/y"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '24000/-10001', + } + })); +}, "Test that decodingInfo() rejects framerate in the form of x/-y"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '24000/', + } + })); +}, "Test that decodingInfo() rejects framerate in the form of x/"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '1/3x', + } + })); +}, "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"); + +promise_test(t => { + 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_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_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + audio: { contentType: 'audio/webm; foo="bar"' }, + })); +}, "Test that decodingInfo rejects if the audio configuration contentType has one parameter that isn't codecs"); + +promise_test(t => { + return navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: minimalVideoConfiguration, + audio: minimalAudioConfiguration, + }).then(ability => { + assert_equals(typeof ability.supported, "boolean"); + assert_equals(typeof ability.smooth, "boolean"); + assert_equals(typeof ability.powerEfficient, "boolean"); + assert_equals(typeof ability.keySystemAccess, "object"); + }); +}, "Test that decodingInfo returns a valid MediaCapabilitiesInfo objects"); + +async_test(t => { + var validTypes = [ 'file', 'media-source' ]; + var invalidTypes = [ undefined, null, '', 'foobar', 'mse', 'MediaSource', + 'record', 'transmission' ]; + + var validPromises = []; + var invalidCaught = 0; + + validTypes.forEach(type => { + validPromises.push(navigator.mediaCapabilities.decodingInfo({ + type: type, + video: minimalVideoConfiguration, + audio: minimalAudioConfiguration, + })); + }); + + // validTypes are tested via Promise.all(validPromises) because if one of the + // promises fail, Promise.all() will reject. This mechanism can't be used for + // invalid types which will be tested individually and increment invalidCaught + // when rejected until the amount of rejection matches the expectation. + Promise.all(validPromises).then(t.step_func(() => { + for (var i = 0; i < invalidTypes.length; ++i) { + navigator.mediaCapabilities.decodingInfo({ + type: invalidTypes[i], + video: minimalVideoConfiguration, + audio: minimalAudioConfiguration, + }).then(t.unreached_func(), t.step_func(e => { + assert_equals(e.name, 'TypeError'); + ++invalidCaught; + if (invalidCaught == invalidTypes.length) + t.done(); + })); + } + }), t.unreached_func('Promise.all should not reject for valid types')); +}, "Test that decodingInfo rejects if the MediaConfiguration does not have a valid type"); + +promise_test(t => { + return navigator.mediaCapabilities.decodingInfo({ + type: 'file', + audio: audioConfigurationWithSpatialRendering, + }).then(ability => { + assert_equals(typeof ability.supported, "boolean"); + assert_equals(typeof ability.smooth, "boolean"); + assert_equals(typeof ability.powerEfficient, "boolean"); + assert_equals(typeof ability.keySystemAccess, "object"); + }); +}, "Test that decodingInfo with spatialRendering set returns a valid MediaCapabilitiesInfo objects"); + +promise_test(t => { + return navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: videoConfigurationWithDynamicRange, + }).then(ability => { + assert_equals(typeof ability.supported, "boolean"); + assert_equals(typeof ability.smooth, "boolean"); + assert_equals(typeof ability.powerEfficient, "boolean"); + assert_equals(typeof ability.keySystemAccess, "object"); + }); +}, "Test that decodingInfo with hdrMetadataType, colorGamut, and transferFunction set returns a valid MediaCapabilitiesInfo objects"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + hdrMetadataType: "" + }, + })); +}, "Test that decodingInfo rejects if the video configuration has an empty hdrMetadataType"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + colorGamut: true + }, + })); +}, "Test that decodingInfo rejects if the video configuration has a colorGamut set to true"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({ + type: 'file', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + transferFunction: 3 + }, + })); +}, "Test that decodingInfo rejects if the video configuration has a transferFunction set to 3"); diff --git a/testing/web-platform/tests/media-capabilities/decodingInfo.webrtc.html b/testing/web-platform/tests/media-capabilities/decodingInfo.webrtc.html new file mode 100644 index 0000000000..f283956100 --- /dev/null +++ b/testing/web-platform/tests/media-capabilities/decodingInfo.webrtc.html @@ -0,0 +1,217 @@ + +MediaCapabilities.decodingInfo() for webrtc + + + diff --git a/testing/web-platform/tests/media-capabilities/decodingInfoEncryptedMedia.http.html b/testing/web-platform/tests/media-capabilities/decodingInfoEncryptedMedia.http.html new file mode 100644 index 0000000000..267b23431b --- /dev/null +++ b/testing/web-platform/tests/media-capabilities/decodingInfoEncryptedMedia.http.html @@ -0,0 +1,31 @@ + +MediaCapabilities.decodingInfo() for encrypted media (non-secure context) + + + diff --git a/testing/web-platform/tests/media-capabilities/decodingInfoEncryptedMedia.https.html b/testing/web-platform/tests/media-capabilities/decodingInfoEncryptedMedia.https.html new file mode 100644 index 0000000000..7ac914de89 --- /dev/null +++ b/testing/web-platform/tests/media-capabilities/decodingInfoEncryptedMedia.https.html @@ -0,0 +1,262 @@ + +MediaCapabilities.decodingInfo() for encrypted media + + + + diff --git a/testing/web-platform/tests/media-capabilities/encodingInfo.any.js b/testing/web-platform/tests/media-capabilities/encodingInfo.any.js new file mode 100644 index 0000000000..6882b0ae91 --- /dev/null +++ b/testing/web-platform/tests/media-capabilities/encodingInfo.any.js @@ -0,0 +1,310 @@ +// Minimal VideoConfiguration that will be allowed per spec. All optional +// properties are missing. +var minimalVideoConfiguration = { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, +}; + +// Minimal WebRTC VideoConfiguration that will be allowed per spec. All optional +// properties are missing. +var minimalWebrtcVideoConfiguration = { + contentType: 'video/VP9', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, +}; + +// Minimal AudioConfiguration that will be allowed per spec. All optional +// properties are missing. +var minimalAudioConfiguration = { + contentType: 'audio/webm; codecs="opus"', +}; + +// Minimal WebRTC AudioConfiguration that will be allowed per spec. All optional +// properties are missing. +var minimalWebrtcAudioConfiguration = { + contentType: 'audio/opus', +}; + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo()); +}, "Test that encodingInfo rejects if it doesn't get a configuration"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({})); +}, "Test that encodingInfo rejects if the MediaConfiguration isn't valid"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + video: minimalVideoConfiguration, + audio: minimalAudioConfiguration, + })); +}, "Test that encodingInfo rejects if the MediaConfiguration does not have a type"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + })); +}, "Test that encodingInfo rejects if the configuration doesn't have an audio or video field"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: -1, + }, + })); +}, "Test that encodingInfo rejects if the video configuration has a negative framerate"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 0, + }, + })); +}, "Test that encodingInfo rejects if the video configuration has a framerate set to 0"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: Infinity, + }, + })); +}, "Test that encodingInfo rejects if the video configuration has a framerate set to Infinity"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'fgeoa', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + }, + })); +}, "Test that encodingInfo rejects if the video configuration contentType doesn't parse"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'audio/fgeoa', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + }, + })); +}, "Test that encodingInfo rejects if the video configuration contentType isn't of type video"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"; foo="bar"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + }, + })); +}, "Test that encodingInfo rejects if the video configuration contentType has more than one parameter"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; foo="bar"', + width: 800, + height: 600, + bitrate: 3000, + framerate: 24, + }, + })); +}, "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; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '24000/1001', + } + })); +}, "Test that encodingInfo() rejects framerate in the form of x/y"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '24000/0', + } + })); +}, "Test that encodingInfo() rejects framerate in the form of x/0"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '0/10001', + } + })); +}, "Test that encodingInfo() rejects framerate in the form of 0/y"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '-24000/10001', + } + })); +}, "Test that encodingInfo() rejects framerate in the form of -x/y"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '24000/-10001', + } + })); +}, "Test that encodingInfo() rejects framerate in the form of x/-y"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '24000/', + } + })); +}, "Test that encodingInfo() rejects framerate in the form of x/"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: { + contentType: 'video/webm; codecs="vp09.00.10.08"', + width: 800, + height: 600, + bitrate: 3000, + framerate: '1/3x', + } + })); +}, "Test that encodingInfo() rejects framerate with trailing unallowed characters"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + audio: { contentType: 'fgeoa' }, + })); +}, "Test that encodingInfo rejects if the audio configuration contenType doesn't parse"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + audio: { contentType: 'video/fgeoa' }, + })); +}, "Test that encodingInfo rejects if the audio configuration contentType isn't of type audio"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + audio: { contentType: 'audio/webm; codecs="opus"; foo="bar"' }, + })); +}, "Test that encodingInfo rejects if the audio configuration contentType has more than one parameters"); + +promise_test(t => { + return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.encodingInfo({ + type: 'record', + audio: { contentType: 'audio/webm; foo="bar"' }, + })); +}, "Test that encodingInfo rejects if the audio configuration contentType has one parameter that isn't codecs"); + +promise_test(t => { + return navigator.mediaCapabilities.encodingInfo({ + type: 'record', + video: minimalVideoConfiguration, + audio: minimalAudioConfiguration, + }).then(ability => { + assert_equals(typeof ability.supported, "boolean"); + assert_equals(typeof ability.smooth, "boolean"); + assert_equals(typeof ability.powerEfficient, "boolean"); + }); +}, "Test that encodingInfo returns a valid MediaCapabilitiesInfo objects for record type"); + +async_test(t => { + var validTypes = [ 'record', 'webrtc' ]; + var invalidTypes = [ undefined, null, '', 'foobar', 'mse', 'MediaSource', + 'file', 'media-source', ]; + + var validPromises = []; + var invalidCaught = 0; + + validTypes.forEach(type => { + validPromises.push(navigator.mediaCapabilities.encodingInfo({ + type: type, + video: type != "webrtc" ? minimalVideoConfiguration : minimalWebrtcVideoConfiguration, + audio: type != "webrtc" ? minimalAudioConfiguration : minimalWebrtcAudioConfiguration, + })); + }); + + // validTypes are tested via Promise.all(validPromises) because if one of the + // promises fail, Promise.all() will reject. This mechanism can't be used for + // invalid types which will be tested individually and increment invalidCaught + // when rejected until the amount of rejection matches the expectation. + Promise.all(validPromises).then(t.step_func(() => { + for (var i = 0; i < invalidTypes.length; ++i) { + navigator.mediaCapabilities.encodingInfo({ + type: invalidTypes[i], + video: minimalVideoConfiguration, + audio: minimalAudioConfiguration, + }).then(t.unreached_func(), t.step_func(e => { + assert_equals(e.name, 'TypeError'); + ++invalidCaught; + if (invalidCaught == invalidTypes.length) + t.done(); + })); + } + }), t.unreached_func('Promise.all should not reject for valid types')); +}, "Test that encodingInfo rejects if the MediaConfiguration does not have a valid type"); diff --git a/testing/web-platform/tests/media-capabilities/encodingInfo.webrtc.html b/testing/web-platform/tests/media-capabilities/encodingInfo.webrtc.html new file mode 100644 index 0000000000..414b7944f6 --- /dev/null +++ b/testing/web-platform/tests/media-capabilities/encodingInfo.webrtc.html @@ -0,0 +1,217 @@ + +MediaCapabilities.encodingInfo() for webrtc + + + diff --git a/testing/web-platform/tests/media-capabilities/idlharness.any.js b/testing/web-platform/tests/media-capabilities/idlharness.any.js new file mode 100644 index 0000000000..6da5c7d284 --- /dev/null +++ b/testing/web-platform/tests/media-capabilities/idlharness.any.js @@ -0,0 +1,25 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +// https://wicg.github.io/media-capabilities/ + +'use strict'; + +promise_test(async () => { + idl_test( + ['media-capabilities'], + ['html', 'cssom-view'], + idl_array => { + if (self.GLOBAL.isWorker()) { + idl_array.add_objects({ WorkerNavigator: ['navigator'] }); + } else { + idl_array.add_objects({ Navigator: ['navigator'] }); + } + idl_array.add_objects({ + MediaCapabilities: ['navigator.mediaCapabilities'], + Screen: ['screen'], + ScreenLuminance: ['screen.luminance'], + }); + } + ); +}); -- cgit v1.2.3