| 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 // Run createStream() on <video>s and <audio>s. | 5 |
| 6 // Run captureStream() on <video>/<audio>s and inspect the generated Stream. |
| 6 | 7 |
| 7 test(function() { | 8 test(function() { |
| 8 var video = document.createElement('video'); | 9 var video = document.createElement('video'); |
| 9 assert_throws("NotSupportedError", function () { video.captureStream() }, | 10 assert_throws("NotSupportedError", function () { video.captureStream() }, |
| 10 "captureStream() cannot be created out of a source-less <video>"
); | 11 "captureStream() cannot be created out of a source-less <video>"
); |
| 11 }, 'check that captureStream() raises an exception on a <video> with no source.'
); | 12 }, 'check that captureStream() raises an exception on a <video> with no source.'
); |
| 12 | 13 |
| 13 test(function() { | 14 test(function() { |
| 14 var audio = document.createElement('audio'); | 15 var audio = document.createElement('audio'); |
| 15 assert_throws("NotSupportedError", function () { audio.captureStream() }, | 16 assert_throws("NotSupportedError", function () { audio.captureStream() }, |
| 16 "captureStream() cannot be created out of a source-less <audio>"
); | 17 "captureStream() cannot be created out of a source-less <audio>"
); |
| 17 }, 'check that captureStream() raises an exception on an <audio> with no source.
'); | 18 }, 'check that captureStream() raises an exception on an <audio> with no source.
'); |
| 18 | 19 |
| 19 test(function() { | 20 var makeAsyncTest = function(filename, num_video_tracks, num_audio_tracks) { |
| 20 var video = document.createElement('video'); | 21 async_test(function() { |
| 21 video.src = "file:///super_duper_videos/amazing_video.webm"; | 22 var video = document.createElement('video'); |
| 22 video.onloadstart = function() { | 23 video.src = "../../http/tests/media/resources/media-source/webm/" + filename
; |
| 23 var stream = video.captureStream(); | 24 video.onerror = this.unreached_func("<video> error"); |
| 24 | 25 |
| 25 assert_not_equals(stream, null); | 26 video.onloadedmetadata = this.step_func_done(function() { |
| 26 assert_equals(1, stream.getVideoTracks().length); | 27 assert_equals(video.audioTracks.length, num_audio_tracks); |
| 27 assert_equals(0, stream.getAudioTracks().length); | 28 assert_equals(video.videoTracks.length, num_video_tracks); |
| 28 } | |
| 29 }, 'check <video> captureStream().'); | |
| 30 | 29 |
| 31 test(function() { | 30 var stream = video.captureStream(); |
| 32 var audio = document.createElement('audio'); | 31 assert_not_equals(stream, null, "error generating stream"); |
| 33 audio.src = "file:///super_duper_videos/amazing_audio_file.webm"; | |
| 34 audio.onloadstart = function() { | |
| 35 var stream = audio.captureStream(); | |
| 36 | 32 |
| 37 // TODO(mcasas): http://crbug.com/575492, implement <audio>.captureStream(). | 33 assert_equals(stream.getAudioTracks().length, num_audio_tracks); |
| 38 assert_equals(stream, null); | 34 assert_equals(stream.getVideoTracks().length, num_video_tracks); |
| 39 }; | 35 }); |
| 40 }, 'check <audio> captureStream().'); | |
| 41 | 36 |
| 42 test(function() { | 37 video.load(); |
| 43 var video = document.createElement('video'); | 38 }), "<video>.captureStream()"; |
| 39 }; |
| 44 | 40 |
| 45 const onEncrypted = this.step_func_done(); | 41 generate_tests(makeAsyncTest, |
| 46 | 42 [[ "video-only", "test-v-128k-320x240-24fps-8kfr.webm", 1, 0 ], |
| 47 assert_equals(null, video.error); | 43 [ "audio-only", "test-a-128k-44100Hz-1ch.webm", 0, 1 ], |
| 48 assert_equals(null, video.mediaKeys); | 44 [ "video+audio", "test.webm", 1, 1 ]]); |
| 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'); | |
| 63 | 45 |
| 64 </script> | 46 </script> |
| OLD | NEW |