Make mDNS ICE Candidate an experimental flag again
[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
13     var context = new webkitAudioContext();
14     var remoteStream;
15     async function checkForSound(expected, message, count)
16     {
17         if (count === undefined)
18             count = 0;
19
20         var results = await analyseAudio(remoteStream, 200, context);
21         if (results.heardHum === expected)
22             return;
23         if (count > 50)
24             return Promise.reject("checkForSound timed out when testing: " + message);
25
26         await waitFor(100);
27         return checkForSound(expected, message, ++count);
28     }
29
30     promise_test((test) => {
31         if (window.testRunner)
32             testRunner.setUserMediaPermission(true);
33
34         return navigator.mediaDevices.getUserMedia({audio: true}).then((localStream) => {
35             var remoteTrack;
36             return new Promise((resolve, reject) => {
37                 createConnections((firstConnection) => {
38                     firstConnection.addTrack(localStream.getAudioTracks()[0], localStream);
39                 }, (secondConnection) => {
40                     secondConnection.ontrack = (trackEvent) => {
41                         remoteStream = trackEvent.streams[0];
42                         remoteTrack = remoteStream.getAudioTracks()[0];
43                         resolve();
44                     };
45                 });
46             }).then(() => {
47                 return checkForSound(true, "should hear hum from remote enabled track");
48             }).then(() => {
49                 remoteTrack.enabled = false;
50                 return waitFor(100);
51             }).then(() => {
52                 return checkForSound(false, "should not hear hum from remote disabled track");
53             }).then(() => {
54                 return context.close();
55             });
56         });
57     }, "Muting an incoming audio track");
58     </script>
59 </body>
60 </html>