mediastreamtracklist.remove
authorDominique Hazael-Massieux <dom@w3.org>
Thu, 31 May 2012 20:37:43 +0200
changeset 15 56b84464e644
parent 14 e9a87cb5182b
child 16 2430b7357ae4
mediastreamtracklist.remove
submitted/W3C/mediastreamtracklist-remove.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/mediastreamtracklist-remove.html	Thu May 31 20:37:43 2012 +0200
@@ -0,0 +1,42 @@
+<!doctype html>
+<html>
+<head>
+<title>Removing a track from 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 removinging a track from 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 a removal from a MediaStreamTrackList works as expected");
+if (window.navigator.getUserMedia) { 
+  var video;
+
+  navigator.getUserMedia({video:true}, gotVideo);
+
+  function gotVideo(stream) {
+    video = stream;
+    t.step(function () {
+       assert_equals(video.videoTracks.length, 1, "video mediastream starts with one video track");
+       video.videoTracks.remove(video.videoTracks[0]);
+       assert_equals(video.videoTracks.length, 0, "video mediastream has now one audio track");
+       // TODO: add a test that removing a non existent track is a no-op
+    });
+    audio.onremovetrack = function () {
+       assert_true(true, "onremovetrack is triggered on removal of a track");
+       t.done();
+    };
+  }
+}
+</script>
+</body>
+</html>