test for mediastream.ended / mediastream.onended
authorDominique Hazael-Massieux <dom@w3.org>
Thu, 31 May 2012 11:54:32 +0200
changeset 5 471308e99e8c
parent 4 f80cdb9f4b71
child 6 6583e90151ae
test for mediastream.ended / mediastream.onended
submitted/W3C/stream-ended.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submitted/W3C/stream-ended.html	Thu May 31 11:54:32 2012 +0200
@@ -0,0 +1,38 @@
+<!doctype html>
+<html>
+<head>
+<title>getUserMedia({video:true}) creates a stream with ended set to false</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#navigatorusermedia">
+<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 ended set to false at start, and triggers "onended" when it is set to true.</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 MediaStream handles ended correctly");
+if (window.navigator.getUserMedia) { 
+  navigator.getUserMedia({video:true}, function (stream) {
+    t.step(function () { 
+       assert_true(!stream.ended, "the media stream starts with ended set to false");
+    });
+    stream.addEventListener("ended", function() {
+       t.step(function () {
+           assert_true(stream.ended, "stream.ended now set to true");
+           assert_true(true, "ended event triggered");
+         });
+       t.done();
+       }, false);
+    stream.ended = true;
+  });
+}
+</script>
+</body>
+</html>