idl test for stream returned from getUserMedia
authorDominique Hazael-Massieux <dom@w3.org>
Thu, 30 May 2013 15:48:54 +0200
changeset 37 bb87c0d0d7e6
parent 36 63793204fc8f
child 38 76c7d79886ac
idl test for stream returned from getUserMedia
submitted/W3C/mediastream-idl.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/mediastream-idl.html	Thu May 30 15:48:54 2013 +0200
@@ -0,0 +1,57 @@
+<!doctype html>
+<html>
+<head>
+<title>getUserMedia({video:true}) creates a stream that matches the interface WebIDL</title>
+<link rel="author" title="Dominique Hazael-Massieux" href="mailto:[email protected]"/>
+<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#navigatorusermedia">
+<link rel='stylesheet' href='/resources/testharness.css' media='all'/>
+</head>
+<body>
+<p>When prompted, accept to share your video stream.</p>
+<h1>Description</h1>
+<p>This test checks that the MediaStream object returned by the success callback in getUserMedia matches what is defined the WebIDL.</p>
+
+<div id='log'></div>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=/resources/webidl2/lib/webidl2.js></script>
+<script src=/resources/idlharness.js></script>
+<script src=featuredetection.js></script>
+<script src=prefix.js></script>
+<script>
+var t = async_test("Tests that a MediaStream that matchest the WebIDL description is returned", {timeout:10000});
+var idl_array = new IdlArray();
+idl_array.add_idls("[Constructor,\
+        Constructor (MediaStream stream),\
+        Constructor (MediaStreamTrackSequence tracks)]\
+interface MediaStream : EventTarget {\
+    readonly    attribute DOMString    id;\
+    sequence<MediaStreamTrack> getAudioTracks ();\
+    sequence<MediaStreamTrack> getVideoTracks ();\
+    MediaStreamTrack?          getTrackById (DOMString trackId);\
+    void                       addTrack (MediaStreamTrack track);\
+    void                       removeTrack (MediaStreamTrack track);\
+    MediaStream                clone ();\
+                attribute boolean      ended;\
+                attribute EventHandler onended;\
+                attribute EventHandler onaddtrack;\
+                attribute EventHandler onremovetrack;\
+};");
+idl_array.add_idls("interface EventTarget {\
+  void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);\
+  void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);\
+  boolean dispatchEvent(Event event);\
+};");
+var idl_stream = null
+
+t.step(function() {
+  navigator.getUserMedia({video: true}, t.step_func(function (stream) {
+    idl_stream = stream;
+    idl_array.add_objects({MediaStream: ["idl_stream"]});
+    idl_array.test();
+    t.done();
+  }), function(error) {});
+});
+</script>
+</body>
+</html>