Improve debugging ability of some webrtc tests
[WebKit-https.git] / LayoutTests / webrtc / audio-peer-connection-webaudio.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     <script src ="routines.js"></script>
9     <script>
10     var context = new webkitAudioContext();
11     promise_test((test) => {
12         if (window.testRunner)
13             testRunner.setUserMediaPermission(true);
14
15         return navigator.mediaDevices.getUserMedia({audio: true}).then((stream) => {
16             return new Promise((resolve, reject) => {
17                 createConnections((firstConnection) => {
18                     firstConnection.addTrack(stream.getAudioTracks()[0], stream);
19                 }, (secondConnection) => {
20                     secondConnection.ontrack = (event) => { resolve(event.streams[0]); };
21                 });
22                 setTimeout(() => reject("Test timed out"), 5000);
23             });
24         }).then((remoteStream) => {
25             return analyseAudio(remoteStream, 1000, context);
26         }).then((results) => {
27             assert_true(results.heardHum, "heard hum");
28             assert_true(results.heardBip, "heard bip");
29             assert_true(results.heardBop, "heard bop");
30         }).then(() => {
31             return context.close();
32         });
33     }, "Basic audio playback through a peer connection");
34     </script>
35 </head>
36 <body>
37 </body>
38 </html>