OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>getUserMedia({video:true}) creates a stream with a properly initialized v
ideo track</title> |
| 5 <link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> |
| 6 <link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#id
l-def-MediaStreamTrack"> |
| 7 <link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#li
fe-cycle-and-media-flow"> |
| 8 <link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#wi
dl-MediaStreamTrack-kind"> |
| 9 <link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#wi
dl-MediaStreamTrack-enabled"> |
| 10 <link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#wi
dl-MediaStreamTrack-readyState"> |
| 11 <link rel='stylesheet' href='../../../../../resources/testharness.css' media='al
l'/> |
| 12 </head> |
| 13 <body> |
| 14 <p class="instructions" style="display:none">When prompted, accept to share your
video stream.</p> |
| 15 <h1 class="instructions" style="display:none">Description</h1> |
| 16 <p class="instructions" style="display:none">This test checks that the video tra
ck of MediaStream |
| 17 object returned by the success callback in getUserMedia is correctly initialized
.</p> |
| 18 |
| 19 <div id='log'></div> |
| 20 <script src=../../../../../resources/testharness.js></script> |
| 21 <script src=../../../../../resources/testharnessreport.js></script> |
| 22 <script src=/resources/webidl2/lib/webidl2.js></script> |
| 23 <script src=/resources/idlharness.js></script> |
| 24 <script src="../../../../../resources/vendor-prefix.js" data-prefixed-objects='[
{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> |
| 25 <script> |
| 26 var t = async_test("Tests that the video MediaStreamTrack objects are properly i
nitialized", {timeout:10000}); |
| 27 var track = null |
| 28 var idl_array = new IdlArray(); |
| 29 idl_array.add_idls("interface EventTarget {\ |
| 30 void addEventListener(DOMString type, EventListener? callback, optional boolea
n capture = false);\ |
| 31 void removeEventListener(DOMString type, EventListener? callback, optional boo
lean capture = false);\ |
| 32 boolean dispatchEvent(Event event);\ |
| 33 };"); |
| 34 |
| 35 /*idl_array.add_idls("callback interface EventListener {\ |
| 36 void handleEvent(Event event);\ |
| 37 };");*/ |
| 38 idl_array.add_idls("interface MediaStreamTrack : EventTarget {\ |
| 39 readonly attribute DOMString kind;\ |
| 40 readonly attribute DOMString id;\ |
| 41 readonly attribute DOMString label;\ |
| 42 attribute boolean enabled;\ |
| 43 readonly attribute boolean muted;\ |
| 44 attribute EventHandler onmute;\ |
| 45 attribute EventHandler onunmute;\ |
| 46 readonly attribute boolean _readonly;\ |
| 47 readonly attribute boolean remote;\ |
| 48 readonly attribute MediaStreamTrackState readyState;\ |
| 49 attribute EventHandler onstarted;\ |
| 50 attribute EventHandler onended;\ |
| 51 static sequence<SourceInfo> getSourceInfos ();\ |
| 52 MediaTrackConstraints? constraints ();\ |
| 53 MediaSourceStates states ();\ |
| 54 (AllVideoCapabilities or AllAudioCapabilities) capabilities ();\ |
| 55 void applyConstraints (MediaTrackC
onstraints constraints);\ |
| 56 attribute EventHandler onoverconstrained;\ |
| 57 MediaStreamTrack clone ();\ |
| 58 void stop ();\ |
| 59 };"); |
| 60 |
| 61 t.step(function () { |
| 62 navigator.getUserMedia({video: true}, t.step_func(function (stream) { |
| 63 var videoTracks = stream.getVideoTracks(); |
| 64 assert_equals(videoTracks.length, 1, "There is exactly one video track in th
e media stream"); |
| 65 track = videoTracks[0]; |
| 66 assert_equals(track.readyState, "live", "The track object is in live state")
; |
| 67 assert_equals(track.kind, "video", "The track object is of video kind"); |
| 68 assert_true(track.enabled, "The track object is enabed"); // Not clear that
this is required by the spec, see https://www.w3.org/Bugs/Public/show_bug.cgi?id
=22212 |
| 69 idl_array.add_objects({MediaStreamTrack: ["track"]}); |
| 70 idl_array.test(); |
| 71 |
| 72 t.done(); |
| 73 }), function (error) {}); |
| 74 }); |
| 75 </script> |
| 76 </body> |
| 77 </html> |
OLD | NEW |