| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <script src=../../resources/testharness.js></script> | |
| 3 <script src=../../resources/testharnessreport.js></script> | |
| 4 <script src=../../resources/testharness-helpers.js></script> | |
| 5 <script> | |
| 6 | |
| 7 // This test verifies that ImageCapture can be created (or not) with different | |
| 8 // Media Stream Track types (audio, video). The simplest API method grabFrame() | |
| 9 // is also exercised here. | |
| 10 | |
| 11 var test = async_test('exercises the ImageCapture API creation and grabFrame().'
); | |
| 12 | |
| 13 gotStream = test.step_func(function(stream) { | |
| 14 assert_equals(stream.getAudioTracks().length, 1); | |
| 15 assert_equals(stream.getVideoTracks().length, 1); | |
| 16 assert_throws("NotSupportedError", | |
| 17 function() { | |
| 18 capturer = new ImageCapture(stream.getAudioTracks()[0]); | |
| 19 }, | |
| 20 'an ImageCapturer can only be created from a video track'); | |
| 21 | |
| 22 assert_equals(stream.getVideoTracks()[0].readyState, 'live'); | |
| 23 assert_true(stream.getVideoTracks()[0].enabled); | |
| 24 assert_false(stream.getVideoTracks()[0].muted); | |
| 25 capturer = new ImageCapture(stream.getVideoTracks()[0]); | |
| 26 | |
| 27 assert_equals(capturer.videoStreamTrack, stream.getVideoTracks()[0]); | |
| 28 | |
| 29 // TODO(mcasas): Remove this assert after the method is implemented, and | |
| 30 // substitute with something more relevant. | |
| 31 stream.getVideoTracks()[0].enabled = true; | |
| 32 assert_promise_rejects(capturer.grabFrame(), | |
| 33 'NotSupportedError', | |
| 34 'ImageCapturer grabFrame() is not implemented'); | |
| 35 | |
| 36 // Assert that grabFrame() is rejected if the associated video track is | |
| 37 // disabled, or ended. grabFrame() would also reject if the video Track is | |
| 38 // muted but that's a read-only property. | |
| 39 stream.getVideoTracks()[0].enabled = false; | |
| 40 assert_promise_rejects(capturer.grabFrame(), | |
| 41 'InvalidStateError', | |
| 42 'ImageCapturer cannot grabFrame() of a disabled Track
'); | |
| 43 | |
| 44 stream.getVideoTracks()[0].stop(); | |
| 45 assert_equals(stream.getVideoTracks()[0].readyState, 'ended'); | |
| 46 assert_promise_rejects(capturer.grabFrame(), | |
| 47 'InvalidStateError', | |
| 48 'ImageCapturer cannot grabFrame() of a non-live Track
'); | |
| 49 | |
| 50 test.done(); | |
| 51 }); | |
| 52 | |
| 53 onError = test.step_func(function() { | |
| 54 assert_unreached('Error creating MediaStream'); | |
| 55 }); | |
| 56 | |
| 57 navigator.webkitGetUserMedia({video:true, audio:true}, gotStream, onError); | |
| 58 | |
| 59 </script> | |
| OLD | NEW |