more descriptive name
authorDominique Hazael-Massieux <dom@w3.org>
Thu, 31 May 2012 19:43:04 +0200
changeset 13 fd27096ce70c
parent 12 a0e85df6f153
child 14 e9a87cb5182b
more descriptive name
submitted/W3C/mediastreamtracklist-add.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/mediastreamtracklist-add.html	Thu May 31 19:43:04 2012 +0200
@@ -0,0 +1,52 @@
+<!doctype html>
+<html>
+<head>
+<title>Adding a track to a MediaStreamTrackList</title>
+<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/>
+<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 audio stream, then your video stream.</p>
+<h1>Description</h1>
+<p>This test checks that adding a track to a MediaStreamTrackList works 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 an addition to a MediaStreamTrackList works as expected");
+if (window.navigator.getUserMedia) { 
+  var audio, video;
+
+  navigator.getUserMedia({audio:true}, gotAudio);
+  function gotAudio(stream) {
+    audio = stream;
+    navigator.getUserMedia({video:true}, gotVideo);
+  }
+
+  function gotVideo(stream) {
+    video = stream;
+    t.step(function () {
+       assert_equals(video.audioTracks.length, 0, "video mediastream starts with no audio track");
+       video.audioTracks.add(audio.audioTracks[0]);
+       assert_equals(video.audioTracks.length, 1, "video mediastream has now one audio track");
+       video.audioTracks.add(audio.audioTracks[0]);
+       assert_equals(video.audioTracks.length, 1, "video mediastream still has one audio track");
+    });
+    audio.onaddtrack = function () {
+       assert_true(true, "onaddtrack is triggered on adding a track");
+       t.done();
+    };
+    t.step(function () {
+       assert_equals(audio.videoTracks.length, 0, "audio mediastream starts with no video track");
+       audio.videoTracks.add(video.videoTracks[1]);
+       assert_equals(audio.videoTracks.length, 1, "audio mediastream now has one video track");
+    });
+  }
+}
+</script>
+</body>
+</html>