Make captureCanvas-webrtc.html more robust
[WebKit-https.git] / LayoutTests / webrtc / peer-connection-remote-audio-mute2.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <meta charset="utf-8">
5     <title>Testing web audio on peer connection audio tracks</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         return navigator.mediaDevices.getUserMedia({audio: true}).then((localStream) => {
15             var remoteTrack;
16             var remoteStream;
17             return new Promise((resolve, reject) => {
18                 createConnections((firstConnection) => {
19                     firstConnection.addTrack(localStream.getAudioTracks()[0]);
20                 }, (secondConnection) => {
21                     secondConnection.ontrack = (trackEvent) => {
22                         remoteStream = trackEvent.streams[0];
23                         remoteTrack = remoteStream.getAudioTracks()[0];
24                         resolve();
25                     };
26                 });
27             }).then(() => {
28                 return doHumAnalysis(remoteStream, true);
29             }).then((value) => {
30                 assert_true(value, "heard hum from remote enabled track");
31             }).then(() => {
32                 remoteTrack.enabled = false;
33                 return doHumAnalysis(remoteStream, false);
34             }).then((value) => {
35                 assert_true(value, "not heard hum from remote disabled track");
36             }).then(() => {
37                 remoteTrack.enabled = true;
38                 return doHumAnalysis(remoteStream, true);
39             }).then((value) => {
40                 assert_true(value, "heard hum from remote reenabled track");
41             }).then(() => {
42                 return context.close();
43             });
44         });
45     }, "Muting and unmuting an incoming audio track");
46     </script>
47 </body>
48 </html>