Bug 1735858 [wpt PR 31247] - App history: make it mostly nonfunctional for opaque...
[gecko.git] / testing / web-platform / tests / mediacapture-streams / MediaStream-finished-add.https.html
blobfd1a1564ccb506c77af093f40dfaffc09c96271e
1 <!doctype html>
2 <html>
3 <head>
4 <title>Adding a track to an inactive MediaStream</title>
5 <link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/>
6 <link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStream-addTrack-void-MediaStreamTrack-track">
7 <link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStreamTrack-stop-void">
8 </head>
9 <body>
10 <p class="instructions">When prompted, accept to share your audio stream, then
11 your video stream.</p>
12 <h1 class="instructions">Description</h1>
13 <p class="instructions">This test checks that adding a track to an inactive
14 MediaStream is allowed.</p>
16 <div id='log'></div>
17 <script src=/resources/testharness.js></script>
18 <script src=/resources/testharnessreport.js></script>
19 <script>
20 var t = async_test("Tests that adding a track to an inactive MediaStream is allowed");
21 t.step(function () {
22 var audio, video;
24 navigator.mediaDevices.getUserMedia({audio:true}).then(gotAudio);
25 function gotAudio(stream) {
26 audio = stream;
27 navigator.mediaDevices.getUserMedia({video:true}).then(gotVideo);
30 function gotVideo(stream) {
31 video = stream;
32 t.step(function () {
33 audio.getAudioTracks()[0].stop();
34 assert_false(audio.active, "audio stream is inactive after stopping its only audio track");
35 assert_true(video.active, "video stream is active");
36 audio.addTrack(video.getVideoTracks()[0]);
37 audio.removeTrack(audio.getAudioTracks()[0]);
38 });
39 t.done();
41 });
42 </script>
43 </body>
44 </html>