OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src=../../resources/testharness.js></script> | 2 <script src=../../resources/testharness.js></script> |
3 <script src=../../resources/testharnessreport.js></script> | 3 <script src=../../resources/testharnessreport.js></script> |
4 <script> | 4 <script> |
5 | 5 // Run createStream() on <video>s and <audio>s. |
6 // Run captureStream() on <video>/<audio>s and inspect the generated Stream. | |
7 | 6 |
8 test(function() { | 7 test(function() { |
9 var video = document.createElement('video'); | 8 var video = document.createElement('video'); |
10 assert_throws("NotSupportedError", function () { video.captureStream() }, | 9 assert_throws("NotSupportedError", function () { video.captureStream() }, |
11 "captureStream() cannot be created out of a source-less <video>"
); | 10 "captureStream() cannot be created out of a source-less <video>"
); |
12 }, 'check that captureStream() raises an exception on a <video> with no source.'
); | 11 }, 'check that captureStream() raises an exception on a <video> with no source.'
); |
13 | 12 |
14 test(function() { | 13 test(function() { |
15 var audio = document.createElement('audio'); | 14 var audio = document.createElement('audio'); |
16 assert_throws("NotSupportedError", function () { audio.captureStream() }, | 15 assert_throws("NotSupportedError", function () { audio.captureStream() }, |
17 "captureStream() cannot be created out of a source-less <audio>"
); | 16 "captureStream() cannot be created out of a source-less <audio>"
); |
18 }, 'check that captureStream() raises an exception on an <audio> with no source.
'); | 17 }, 'check that captureStream() raises an exception on an <audio> with no source.
'); |
19 | 18 |
20 var makeAsyncTest = function(filename, num_video_tracks, num_audio_tracks) { | 19 test(function() { |
21 async_test(function() { | 20 var video = document.createElement('video'); |
22 var video = document.createElement('video'); | 21 video.src = "file:///super_duper_videos/amazing_video.webm"; |
23 video.src = "../../http/tests/media/resources/media-source/webm/" + filename
; | 22 video.onloadstart = function() { |
24 video.onerror = this.unreached_func("<video> error"); | 23 var stream = video.captureStream(); |
25 | 24 |
26 video.onloadedmetadata = this.step_func_done(function() { | 25 assert_not_equals(stream, null); |
27 assert_equals(video.audioTracks.length, num_audio_tracks); | 26 assert_equals(1, stream.getVideoTracks().length); |
28 assert_equals(video.videoTracks.length, num_video_tracks); | 27 assert_equals(0, stream.getAudioTracks().length); |
| 28 } |
| 29 }, 'check <video> captureStream().'); |
29 | 30 |
30 var stream = video.captureStream(); | 31 test(function() { |
31 assert_not_equals(stream, null, "error generating stream"); | 32 var audio = document.createElement('audio'); |
| 33 audio.src = "file:///super_duper_videos/amazing_audio_file.webm"; |
| 34 audio.onloadstart = function() { |
| 35 var stream = audio.captureStream(); |
32 | 36 |
33 assert_equals(stream.getAudioTracks().length, num_audio_tracks); | 37 // TODO(mcasas): http://crbug.com/575492, implement <audio>.captureStream(). |
34 assert_equals(stream.getVideoTracks().length, num_video_tracks); | 38 assert_equals(stream, null); |
35 }); | 39 }; |
| 40 }, 'check <audio> captureStream().'); |
36 | 41 |
37 video.load(); | 42 test(function() { |
38 }), "<video>.captureStream()"; | 43 var video = document.createElement('video'); |
39 }; | |
40 | 44 |
41 generate_tests(makeAsyncTest, | 45 const onEncrypted = this.step_func_done(); |
42 [[ "video-only", "test-v-128k-320x240-24fps-8kfr.webm", 1, 0 ], | 46 |
43 [ "audio-only", "test-a-128k-44100Hz-1ch.webm", 0, 1 ], | 47 assert_equals(null, video.error); |
44 [ "video+audio", "test.webm", 1, 1 ]]); | 48 assert_equals(null, video.mediaKeys); |
| 49 video.onencrypted = onEncrypted; |
| 50 |
| 51 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(a
ccess) { |
| 52 return access.createMediaKeys(); |
| 53 }).then(function(mediaKeys) { |
| 54 return video.setMediaKeys(mediaKeys); |
| 55 }).then(function(result) { |
| 56 video.src = "../../media/content/test-encrypted.webm"; |
| 57 assert_throws("NotSupportedError", |
| 58 function() { var stream = video.captureStream(); }, |
| 59 "Cannot create a captureStream() out of a protected <video>"
); |
| 60 }); |
| 61 |
| 62 }, 'check <video> captureStream() fails on an encrypted/protected media'); |
45 | 63 |
46 </script> | 64 </script> |
OLD | NEW |