testing end of mediastreamtrack
authorDominique Hazael-Massieux <dom@w3.org>
Thu, 31 May 2012 23:13:28 +0200
changeset 26 de85fe3f590f
parent 25 7652f93149c0
child 27 cebb63d26a31
testing end of mediastreamtrack
submitted/W3C/mediastreamtrack-end.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/mediastreamtrack-end.html	Thu May 31 23:13:28 2012 +0200
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+<head>
+<title>Test that mediastreamtrack are properly ended</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#mediastreamtrack">
+<link rel='stylesheet' href='/resources/testharness.css' media='all'/>
+</head>
+<body>
+<p>When prompted, accept to share your video and audio stream, and then revoke that permission.</p>
+<h1>Description</h1>
+<p>This test checks that the video and audio tracks of LocalMediaStream object returned by the success callback in getUserMedia are correctly set into ended state when permission is revoked.</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 the video MediaStreamTrack objects are properly ended on permission revocation");
+if (window.navigator.getUserMedia) { 
+  navigator.getUserMedia("audio,video", function (stream) {
+    t.step(function () { 
+     for (var i = 0 ; i < stream.videoTracks.length ; i++) {
+        var track = stream.videoTracks[i];
+	assert_equals(track.readyState, track.LIVE, "The video track object #" + i + " is in live state");
+     }
+     for (var i = 0 ; i < stream.audioTracks.length ; i++) {
+        var track = stream.audioTracks[i];
+	assert_equals(track.readyState, track.LIVE, "The audio track object #" + i + " is in live state");
+     }
+    });
+    t.step(function () {
+       stream.audioTracks[0].readyState = stream.audioTracks[0].ENDED;
+       assert_equals(track.readyState, track.LIVE, "The audio track object #0 is in ended state");
+       stream.audioTracks[0].onended = function () { 
+         assert_unreached("The ended event is not supposed to be sent since the track was already in ended state");
+         t.done();
+
+       };
+       stream.videoTracks[0].onended = function () { 
+	 assert_true(true, "Video track #0 has been ended as expected");
+       };
+       for (var i = 0 ; i < stream.videoTracks.length ; i++) {
+         var track = stream.videoTracks[i];
+	 assert_equals(track.readyState, track.ENDED, "The video track object #" + i + " is in ended state");
+       }
+       for (var i = 1 ; i < stream.audioTracks.length ; i++) {
+         var track = stream.audioTracks[i];
+	 assert_equals(track.readyState, track.ENDED, "The audio track object #" + i + " is in ended state");
+       }
+       t.done();
+    });
+});
+}
+</script>
+</body>
+</html>