Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/external/wpt/media-capabilities/query.html |
| diff --git a/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/query.html b/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/query.html |
| index 809fbc66ec5c46b69d6bd656c6860a6dcc0de99d..3a04ebe3a52380d0965f3f0ac2512bbfe978d904 100644 |
| --- a/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/query.html |
| +++ b/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/query.html |
| @@ -4,6 +4,22 @@ |
| <script src="/resources/testharnessreport.js"></script> |
| <script> |
| +// Minimal VideoConfiguration that will be allowed per spec. All optional |
| +// properties are missing. |
| +var minimalVideoConfiguration = { |
| + contentType: 'video/webm', |
|
chcunningham
2017/02/20 18:03:30
When we have real plumbing, this content type wont
|
| + 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', |
|
chcunningham
2017/02/20 18:03:30
Ditto. Instead, do 'audio/webm; codecs="opus"'
|
| +}; |
| + |
| promise_test(t => { |
| return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.query()); |
| }, "Test that query rejects if it doesn't get a configuration"); |
| @@ -13,18 +29,17 @@ promise_test(t => { |
| }, "Test that query rejects if the MediaConfiguration isn't valid"); |
| promise_test(t => { |
| + return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.query({ |
| + video: minimalVideoConfiguration, |
| + audio: minimalAudioConfiguration, |
| + })); |
| +}, "Test that query rejects if the MediaConfiguration does not have a type"); |
| + |
| +promise_test(t => { |
| return navigator.mediaCapabilities.query({ |
| type: 'file', |
| - video: { |
| - type: 'video/webm', |
| - width: 800, |
| - height: 600, |
| - bitrate: 3000, |
| - framerate: 24, |
| - }, |
| - audio: { |
| - type: 'audio/webm', |
| - }, |
| + video: minimalVideoConfiguration, |
| + audio: minimalAudioConfiguration, |
| }).then(ability => { |
| assert_idl_attribute(ability, 'supported'); |
| assert_idl_attribute(ability, 'smooth'); |
| @@ -32,4 +47,39 @@ promise_test(t => { |
| }); |
| }, "Test that query returns a valid MediaDecodingAbility objects"); |
| +async_test(t => { |
| + var validTypes = [ 'file', 'media-source' ]; |
| + var invalidTypes = [ undefined, null, '', 'foobar', 'mse', 'MediaSource' ]; |
| + |
| + var validPromises = []; |
| + var invalidCaught = 0; |
| + |
| + validTypes.forEach(type => { |
| + validPromises.push(navigator.mediaCapabilities.query({ |
| + 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.query({ |
| + 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 query rejects if the MediaConfiguration does not have a valid type"); |
| + |
| </script> |