AX: <svg> elements with labels and no accessible contents are exposed as empty AXGroups
[WebKit-https.git] / LayoutTests / webrtc / audio-replace-track.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <meta charset="utf-8">
5     <title>Testing replacing an audio track during a WebRTC call</title>
6     <script src="../resources/testharness.js"></script>
7     <script src="../resources/testharnessreport.js"></script>
8     <script src ="routines.js"></script>
9 </head>
10 <body>
11     <script>
12     var sender;
13     var remoteStream;
14     var secondStream;
15     var receivingConnection;
16     promise_test((test) => {
17         if (window.testRunner)
18             testRunner.setUserMediaPermission(true);
19
20         return navigator.mediaDevices.getUserMedia({ audio: { sampleRate: { exact: 48000 } } }).then((firstStream) => {
21             return new Promise((resolve, reject) => {
22                 createConnections((firstConnection) => {
23                     sender = firstConnection.addTrack(firstStream.getAudioTracks()[0], firstStream);
24                 }, (secondConnection) => {
25                     receivingConnection = secondConnection;
26                     secondConnection.ontrack = (trackEvent) => { resolve(trackEvent.streams[0]); };
27                 });
28                 setTimeout(() => reject("Test timed out"), 5000);
29             });
30         }).then((stream) => {
31             remoteStream = stream;
32          });
33     }, "Starting an audio connection");
34
35     promise_test(() => {
36         if (receivingConnection.connectionState === "connected")
37             return Promise.resolve();
38         return new Promise((resolve, reject) => {
39             receivingConnection.onconnectionstatechange = () => {
40                 if (receivingConnection.connectionState === "connected")
41                     resolve();
42             };
43             setTimeout(() => reject("Test timed out"), 5000);
44         });
45     }, "Ensuring connection state is connected");
46
47     promise_test(() => {
48         return doHumAnalysis(remoteStream, true).then((result) => {
49             assert_true(result, "heard hum 1");
50         });
51     }, "Ensuring mock audio source is received on the remote side");
52
53     promise_test(() => {
54         return navigator.mediaDevices.getUserMedia({ audio: { sampleRate: { exact: 48000 } } }).then((stream) => {
55             secondStream = stream;
56             return sender.replaceTrack(secondStream.getAudioTracks()[0], secondStream);
57         }).then(() => {
58             assert_true(sender.track === secondStream.getAudioTracks()[0]);
59             return waitFor(500);
60         });
61     }, "Using replaceTrack for audio");
62
63     promise_test(() => {
64         return doHumAnalysis(remoteStream, true).then((results) => {
65             assert_true(results, "heard hum 2");
66         });
67     }, "Ensuring remote audio gets the replacing track data");
68     </script>
69 </body>
70 </html>