localmedia stream stop
authorDominique Hazael-Massieux <dom@w3.org>
Thu, 31 May 2012 12:12:25 +0200
changeset 8 5e5ad201ecef
parent 7 1bd16c24b5c2
child 9 87d86cd71219
localmedia stream stop
submitted/W3C/localstream-stop.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/localstream-stop.html	Thu May 31 12:12:25 2012 +0200
@@ -0,0 +1,40 @@
+<!doctype html>
+<html>
+<head>
+<title>getUserMedia({video:true}) creates a local stream with a stop method</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#methods">
+<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 LocalMediaStream object returned by the success callback in getUserMedia has a correct stop() method.</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 LocalMediaStream handles stop() correctly");
+if (window.navigator.getUserMedia) { 
+  navigator.getUserMedia({video:true}, function (stream) {
+    // onended is not supposed to be fired when stop() is invoked
+    stream.onended = function () {
+      assert_unreached("onended is not fired when stop is invoked");
+    };
+
+    stream.stop();
+    t.step(function () { 
+      for (var i = 0; i < stream.videoTracks.length; i++) {
+  	assert_equals(stream.videoTracks[i].readyState, stream.videoTracks[i].ENDED, "Video Track #" + i + " ended");
+      }
+      assert_true(stream.ended);
+    });
+    t.done();
+  });
+}
+</script>
+</body>
+</html>