ec4f00a5238f7ba53c5ba94dcba31d776d4b77e5
[WebKit-https.git] / LayoutTests / webrtc / peer-connection-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     promise_test((test) => {
13         if (window.testRunner)
14             testRunner.setUserMediaPermission(true);
15
16         var localTrack;
17         return navigator.mediaDevices.getUserMedia({audio: true}).then((localStream) => {
18             localTrack = localStream.getAudioTracks()[0];
19             var remoteStream;
20             return new Promise((resolve, reject) => {
21                 createConnections((firstConnection) => {
22                     firstConnection.addStream(localStream);
23                 }, (secondConnection) => {
24                     secondConnection.onaddstream = (streamEvent) => {
25                         remoteStream = streamEvent.stream;
26                         resolve();
27                     };
28                 });
29             }).then(() => {
30                 return waitFor(500);
31             }).then(() => {
32                 return analyseAudio(remoteStream, 500).then((results) => {
33                     assert_true(results.heardHum, "heard hum from remote enabled track");
34                 });
35             }).then(() => {
36                 localTrack.enabled = false;
37                 return waitFor(500);
38             }).then(() => {
39                 return analyseAudio(remoteStream, 500).then((results) => {
40                     assert_false(results.heardHum, "not heard hum from remote disabled track");
41                 });
42             });
43         });
44     }, "Muting a local audio track and making sure the remote track is silent");
45     </script>
46 </body>
47 </html>