blob: 4d537ca25a1f4af5a5f4c1a8417b0efa7502693f [file] [log] [blame]
<!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:dom@w3.org"/>
<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStream-ended">
<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#event-mediastream-ended">
<link rel='stylesheet' href='/resources/testharness.css' media='all'/>
</head>
<body>
<p class="instructions">When prompted, accept to share your video stream.</p>
<h1 class="instructions">Description</h1>
<p class="instructions">This test checks that the MediaStream 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="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script>
<script>
var t = async_test("Tests that a MediaStream handles ended correctly", {timeout:10000});
t.step(function () {
navigator.getUserMedia({video:true}, t.step_func(function (stream) {
assert_true(!stream.ended, "the media stream starts with ended set to false");
stream.addEventListener("ended", t.step_func(function() {
assert_true(stream.ended, "stream.ended now set to true");
t.done();
}), false);
stream.ended = true;
assert_true(!stream.ended, "stream.ended should remain false");
stream.getVideoTracks()[0].stop();
}), function (error) {});
});
</script>
</body>
</html>