4 <title>Adding a track to a finished MediaStream</title>
5 <link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/>
6 <link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrackList-add-void-MediaStreamTrack-track">
7 <link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrack-stop-void">
8 <link rel='stylesheet' href='../../../../../resources/testharness.css' media='all'/>
11 <p class="instructions" style="display:none">When prompted, accept to share your audio stream, then
12 your video stream.</p>
13 <h1 class="instructions" style="display:none">Description</h1>
14 <p class="instructions" style="display:none">This test checks that adding a track to a finished
15 MediaStream raises an INVALID_STATE_ERR exception.</p>
18 <script src=../../../../../resources/testharness.js></script>
19 <script src=../../../../../resources/testharnessreport.js></script>
20 <script src="../../../../../resources/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script>
22 var t = async_test("Tests that an addition to a finished MediaStream raises an exception", {timeout:20000});
26 navigator.getUserMedia({audio:true}, gotAudio, function() {});
27 function gotAudio(stream) {
29 navigator.getUserMedia({video:true}, gotVideo, function() {});
32 function gotVideo(stream) {
35 audio.getAudioTracks()[0].stop();
36 assert_true(audio.ended, "Audio stream is ended after stopping its only audio track");
37 assert_throws("INVALID_STATE_ERR", function () {
38 video.addTrack(audio.getAudioTracks()[0]);
39 }, "Adding a track from a finished stream raises an INVALID_STATE_ERR exception");
40 assert_throws("INVALID_STATE_ERR", function () {
41 audio.removeTrack(audio.getAudioTracks()[0]);
42 }, "Removing a track from a finished stream raises an INVALID_STATE_ERR exception");