[iOS] Unset active media capture source when stopped capturing
[WebKit-https.git] / LayoutTests / webrtc / peer-connection-remote-audio-mute.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <meta charset="utf-8">
5     <title>Testing local audio capture playback causes "playing" event to fire</title>
6     <script src="../resources/testharness.js"></script>
7     <script src="../resources/testharnessreport.js"></script>
8 </head>
9 <body>
10     <script src ="routines.js"></script>
11     <script>
12     var context = new webkitAudioContext();
13     promise_test((test) => {
14         if (window.testRunner)
15             testRunner.setUserMediaPermission(true);
16
17         return navigator.mediaDevices.getUserMedia({audio: true}).then((localStream) => {
18             var remoteTrack;
19             var remoteStream;
20             return new Promise((resolve, reject) => {
21                 createConnections((firstConnection) => {
22                     firstConnection.addTrack(localStream.getAudioTracks()[0], localStream);
23                 }, (secondConnection) => {
24                     secondConnection.ontrack = (trackEvent) => {
25                         remoteStream = trackEvent.streams[0];
26                         remoteTrack = remoteStream.getAudioTracks()[0];
27                         resolve();
28                     };
29                 });
30             }).then(() => {
31                 return analyseAudio(remoteStream, 200, context).then((results) => {
32                     assert_true(results.heardHum, "heard hum from remote enabled track");
33                 });
34             }).then(() => {
35                 remoteTrack.enabled = false;
36                 return waitFor(100);
37             }).then(() => {
38                 return analyseAudio(remoteStream, 200, context).then((results) => {
39                     assert_false(results.heardHum, "not heard hum from remote disabled track");
40                 });
41             }).then(() => {
42                 return context.close();
43             });
44         });
45     }, "Muting an incoming audio track");
46     </script>
47 </body>
48 </html>