зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1659550 [wpt PR 25051] - WebCodecs: Evaluate decoder config codec strings, a=testonly
Automatic update from web-platform-tests WebCodecs: Evaluate decoder config codec strings Updates Audio/Video Decoder to reject invalid codecs passed to configure(). A TypeError should be thrown. Additionally, if the config is valid but unsupported, throw a NotSupportedError. Adds wpt test to verify the behavior for validity. Support behavior is difficult to wpt test (varies by build/platform) - tested manually. Bug: 1113824 Change-Id: I647c476fa32e684d57816222e1787aeb8f723c25 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2360312 Reviewed-by: Thomas Guilbert <tguilbert@chromium.org> Commit-Queue: Chrome Cunningham <chcunningham@chromium.org> Auto-Submit: Chrome Cunningham <chcunningham@chromium.org> Cr-Commit-Position: refs/heads/master@{#799271} -- wpt-commits: 0299abc230efc4994083cba80b09d836fd2bed64 wpt-pr: 25051
This commit is contained in:
Родитель
373666b2a3
Коммит
0efbf4b923
|
@ -0,0 +1,60 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<title>Test the AudioDecoder API.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
// Calls done after giving async output/error callbacks a final chance to run.
|
||||
async function asyncDone(test) {
|
||||
test.step_timeout(test.step_func_done(), 0);
|
||||
}
|
||||
|
||||
async_test(async (t) => {
|
||||
// AudioDecoderInit lacks required fields.
|
||||
assert_throws_js(TypeError, () => { new AudioDecoder({}); });
|
||||
|
||||
// AudioDecoderInit has required fields.
|
||||
let decoder = new AudioDecoder({
|
||||
output(chunk) { t.unreached_func("Unexpected output").call(); },
|
||||
error(error) { t.unreached_func("Unexpected error:" + error).call(); },
|
||||
});
|
||||
|
||||
asyncDone(t);
|
||||
}, 'Test AudioDecoder construction');
|
||||
|
||||
async_test(async (t) => {
|
||||
let decoder = new AudioDecoder({
|
||||
output(chunk) { t.unreached_func("Unexpected output").call(); },
|
||||
error(error) { t.unreached_func("Unexpected error:" + error).call(); },
|
||||
});
|
||||
|
||||
let config = {
|
||||
sampleRate: 48000,
|
||||
numberOfChannels: 2
|
||||
}
|
||||
|
||||
// Empty codec rejected.
|
||||
config.codec = '';
|
||||
assert_throws_js(TypeError, () => { decoder.configure(config); });
|
||||
|
||||
// Invalid codec rejected.
|
||||
config.codec = 'bogus';
|
||||
assert_throws_js(TypeError, () => { decoder.configure(config); });
|
||||
|
||||
// Video codec rejected.
|
||||
config.codec = 'vp8';
|
||||
assert_throws_js(TypeError, () => { decoder.configure(config); });
|
||||
|
||||
// Codec with mime type rejected.
|
||||
config.codec = 'audio/webm; codecs="opus"';
|
||||
assert_throws_js(TypeError, () => { decoder.configure(config); });
|
||||
|
||||
// Valid audio codec accepted.
|
||||
config.codec = 'opus';
|
||||
decoder.configure(config);
|
||||
|
||||
asyncDone(t);
|
||||
}, 'Test AudioDecoder.configure() codec validity');
|
||||
</script>
|
||||
</html>
|
|
@ -0,0 +1,58 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<title>Test the VideoDecoder API.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
// Calls done after giving async output/error callbacks a final chance to run.
|
||||
async function asyncDone(test) {
|
||||
test.step_timeout(test.step_func_done(), 0);
|
||||
}
|
||||
|
||||
async_test(async (t) => {
|
||||
// VideoDecoderInit lacks required fields.
|
||||
assert_throws_js(TypeError, () => { new VideoDecoder({}); });
|
||||
|
||||
// VideoDecoderInit has required fields.
|
||||
let decoder = new VideoDecoder({
|
||||
output(chunk) { t.unreached_func("Unexpected output").call(); },
|
||||
error(error) { t.unreached_func("Unexpected error:" + error).call(); },
|
||||
});
|
||||
|
||||
asyncDone(t);
|
||||
}, 'Test VideoDecoder construction');
|
||||
|
||||
async_test(async (t) => {
|
||||
let decoder = new VideoDecoder({
|
||||
output(chunk) { t.unreached_func("Unexpected output").call(); },
|
||||
error(error) { t.unreached_func("Unexpected error:" + error).call(); },
|
||||
});
|
||||
|
||||
|
||||
let config = {};
|
||||
|
||||
// Bogus codec rejected.
|
||||
config.codec = 'bogus';
|
||||
assert_throws_js(TypeError, () => { decoder.configure(config); });
|
||||
|
||||
// Audio codec rejected.
|
||||
config.codec = 'vorbis';
|
||||
assert_throws_js(TypeError, () => { decoder.configure(config); });
|
||||
|
||||
// Ambiguous codec rejected.
|
||||
config.codec = 'vp9';
|
||||
assert_throws_js(TypeError, () => { decoder.configure(config); });
|
||||
|
||||
// Codec with mime type rejected.
|
||||
config.codec = 'video/webm; codecs="vp9"';
|
||||
assert_throws_js(TypeError, () => { decoder.configure(config); });
|
||||
|
||||
// Valid unambiguous codec accepted.
|
||||
config.codec = 'vp09.00.10.08';
|
||||
decoder.configure(config);
|
||||
|
||||
asyncDone(t);
|
||||
}, 'Test VideoDecoder.configure() codec validity');
|
||||
</script>
|
||||
</html>
|
|
@ -62,8 +62,6 @@ async_test(async (t) => {
|
|||
// Configure should pass once incrementalConfig meets all requirements.
|
||||
encoder.configure(incrementalConfig);
|
||||
|
||||
encoder.configure(incrementalConfig);
|
||||
|
||||
encoder.close();
|
||||
|
||||
asyncDone(t);
|
||||
|
|
Загрузка…
Ссылка в новой задаче