Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/media-capabilities/decodingInfo.html

Issue 2807713002: [Media Capabilities] Rename query() to decodingInfo() and MediaDecodingAbility to MediaCapabilities… (Closed)
Patch Set: review comments & rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>MediaCapabilities.query()</title> 2 <title>MediaCapabilities.decodingInfo()</title>
3 <script src=/resources/testharness.js></script> 3 <script src=/resources/testharness.js></script>
4 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testharnessreport.js"></script>
5 <script> 5 <script>
6 6
7 // Minimal VideoConfiguration that will be allowed per spec. All optional 7 // Minimal VideoConfiguration that will be allowed per spec. All optional
8 // properties are missing. 8 // properties are missing.
9 var minimalVideoConfiguration = { 9 var minimalVideoConfiguration = {
10 contentType: 'video/webm; codecs="vp9"', 10 contentType: 'video/webm; codecs="vp9"',
11 width: 800, 11 width: 800,
12 height: 600, 12 height: 600,
13 bitrate: 3000, 13 bitrate: 3000,
14 framerate: 24, 14 framerate: 24,
15 }; 15 };
16 16
17 // Minimal AudioConfiguration that will be allowed per spec. All optional 17 // Minimal AudioConfiguration that will be allowed per spec. All optional
18 // properties are missing. 18 // properties are missing.
19 var minimalAudioConfiguration = { 19 var minimalAudioConfiguration = {
20 contentType: 'audio/webm; codecs="opus"', 20 contentType: 'audio/webm; codecs="opus"',
21 }; 21 };
22 22
23 promise_test(t => { 23 promise_test(t => {
24 return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.query() ); 24 return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodin gInfo());
25 }, "Test that query rejects if it doesn't get a configuration"); 25 }, "Test that decodingInfo rejects if it doesn't get a configuration");
26 26
27 promise_test(t => { 27 promise_test(t => {
28 return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.query({ })); 28 return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodin gInfo({}));
29 }, "Test that query rejects if the MediaConfiguration isn't valid"); 29 }, "Test that decodingInfo rejects if the MediaConfiguration isn't valid");
30 30
31 promise_test(t => { 31 promise_test(t => {
32 return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.query({ 32 return promise_rejects(t, new TypeError(), navigator.mediaCapabilities.decodin gInfo({
33 video: minimalVideoConfiguration, 33 video: minimalVideoConfiguration,
34 audio: minimalAudioConfiguration, 34 audio: minimalAudioConfiguration,
35 })); 35 }));
36 }, "Test that query rejects if the MediaConfiguration does not have a type"); 36 }, "Test that decodingInfo rejects if the MediaConfiguration does not have a typ e");
37 37
38 promise_test(t => { 38 promise_test(t => {
39 return navigator.mediaCapabilities.query({ 39 return navigator.mediaCapabilities.decodingInfo({
40 type: 'file', 40 type: 'file',
41 video: minimalVideoConfiguration, 41 video: minimalVideoConfiguration,
42 audio: minimalAudioConfiguration, 42 audio: minimalAudioConfiguration,
43 }).then(ability => { 43 }).then(ability => {
44 assert_idl_attribute(ability, 'supported'); 44 assert_idl_attribute(ability, 'supported');
45 assert_idl_attribute(ability, 'smooth'); 45 assert_idl_attribute(ability, 'smooth');
46 assert_idl_attribute(ability, 'powerEfficient'); 46 assert_idl_attribute(ability, 'powerEfficient');
47 }); 47 });
48 }, "Test that query returns a valid MediaDecodingAbility objects"); 48 }, "Test that decodingInfo returns a valid MediaCapabilitiesInfo objects");
49 49
50 async_test(t => { 50 async_test(t => {
51 var validTypes = [ 'file', 'media-source' ]; 51 var validTypes = [ 'file', 'media-source' ];
52 var invalidTypes = [ undefined, null, '', 'foobar', 'mse', 'MediaSource' ]; 52 var invalidTypes = [ undefined, null, '', 'foobar', 'mse', 'MediaSource' ];
53 53
54 var validPromises = []; 54 var validPromises = [];
55 var invalidCaught = 0; 55 var invalidCaught = 0;
56 56
57 validTypes.forEach(type => { 57 validTypes.forEach(type => {
58 validPromises.push(navigator.mediaCapabilities.query({ 58 validPromises.push(navigator.mediaCapabilities.decodingInfo({
59 type: type, 59 type: type,
60 video: minimalVideoConfiguration, 60 video: minimalVideoConfiguration,
61 audio: minimalAudioConfiguration, 61 audio: minimalAudioConfiguration,
62 })); 62 }));
63 }); 63 });
64 64
65 // validTypes are tested via Promise.all(validPromises) because if one of the 65 // validTypes are tested via Promise.all(validPromises) because if one of the
66 // promises fail, Promise.all() will reject. This mechanism can't be used for 66 // promises fail, Promise.all() will reject. This mechanism can't be used for
67 // invalid types which will be tested individually and increment invalidCaught 67 // invalid types which will be tested individually and increment invalidCaught
68 // when rejected until the amount of rejection matches the expectation. 68 // when rejected until the amount of rejection matches the expectation.
69 Promise.all(validPromises).then(t.step_func(() => { 69 Promise.all(validPromises).then(t.step_func(() => {
70 for (var i = 0; i < invalidTypes.length; ++i) { 70 for (var i = 0; i < invalidTypes.length; ++i) {
71 navigator.mediaCapabilities.query({ 71 navigator.mediaCapabilities.decodingInfo({
72 type: invalidTypes[i], 72 type: invalidTypes[i],
73 video: minimalVideoConfiguration, 73 video: minimalVideoConfiguration,
74 audio: minimalAudioConfiguration, 74 audio: minimalAudioConfiguration,
75 }).then(t.unreached_func(), t.step_func(e => { 75 }).then(t.unreached_func(), t.step_func(e => {
76 assert_equals(e.name, 'TypeError'); 76 assert_equals(e.name, 'TypeError');
77 ++invalidCaught; 77 ++invalidCaught;
78 if (invalidCaught == invalidTypes.length) 78 if (invalidCaught == invalidTypes.length)
79 t.done(); 79 t.done();
80 })); 80 }));
81 } 81 }
82 }), t.unreached_func('Promise.all should not reject for valid types')); 82 }), t.unreached_func('Promise.all should not reject for valid types'));
83 }, "Test that query rejects if the MediaConfiguration does not have a valid type "); 83 }, "Test that decodingInfo rejects if the MediaConfiguration does not have a val id type");
84 84
85 </script> 85 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698