test for MediaStream.getTrackById
authorDominique Hazael-Massieux <dom@w3.org>
Tue, 04 Jun 2013 17:25:02 +0200
changeset 72 b404b9f202e8
parent 71 4d1bc08dc2eb
child 73 e3113bce02ba
test for MediaStream.getTrackById
submitted/W3C/mediastream-gettrackid.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/mediastream-gettrackid.html	Tue Jun 04 17:25:02 2013 +0200
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+<head>
+<title>Retrieving a track from a MediaStream</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#widl-MediaStreamTrackList-add-void-MediaStreamTrack-track">
+<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 MediaStream.getTrackById behaves as expected</p>
+
+<div id='log'></div>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=featuredetection.js></script>
+<script src=prefix.js></script>
+<script>
+var t = async_test("Tests that MediaStream.getTrackById works as expected", {timeout: 10000});
+t.step(function () {
+  navigator.getUserMedia({video: true}, t.step_func(gotVideo), function(error) {});
+  function gotVideo(stream) {
+    var track = stream.getVideoTracks()[0];
+    assert_equals(track, stream.getTrackById(track.id), "getTrackById returns track of given id");
+    assert_equals(stream.getTrackById(track.id + "foo"), null, "getTrackById of inexistant id  returns null");
+    t.done();
+  }
+});
+</script>
+</body>
+</html>