AX: <svg> elements with labels and no accessible contents are exposed as empty AXGroups
[WebKit-https.git] / LayoutTests / webrtc / peer-connection-remote-audio-mute.html
index 59456c6..6024c4d 100644 (file)
@@ -9,14 +9,30 @@
 <body>
     <script src ="routines.js"></script>
     <script>
+
     var context = new webkitAudioContext();
+    var remoteStream;
+    async function checkForSound(expected, message, count)
+    {
+        if (count === undefined)
+            count = 0;
+
+        var results = await analyseAudio(remoteStream, 200, context);
+        if (results.heardHum === expected)
+            return;
+        if (count > 50)
+            return Promise.reject("checkForSound timed out when testing: " + message);
+
+        await waitFor(100);
+        return checkForSound(expected, message, ++count);
+    }
+
     promise_test((test) => {
         if (window.testRunner)
             testRunner.setUserMediaPermission(true);
 
         return navigator.mediaDevices.getUserMedia({audio: true}).then((localStream) => {
             var remoteTrack;
-            var remoteStream;
             return new Promise((resolve, reject) => {
                 createConnections((firstConnection) => {
                     firstConnection.addTrack(localStream.getAudioTracks()[0], localStream);
                     };
                 });
             }).then(() => {
-                return analyseAudio(remoteStream, 200, context).then((results) => {
-                    assert_true(results.heardHum, "heard hum from remote enabled track");
-                });
+                return checkForSound(true, "should hear hum from remote enabled track");
             }).then(() => {
                 remoteTrack.enabled = false;
                 return waitFor(100);
             }).then(() => {
-                return analyseAudio(remoteStream, 200, context).then((results) => {
-                    assert_false(results.heardHum, "not heard hum from remote disabled track");
-                });
+                return checkForSound(false, "should not hear hum from remote disabled track");
             }).then(() => {
                 return context.close();
             });