LayoutTest webrtc/video-mute.html is a flaky failure
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Apr 2017 22:04:56 +0000 (22:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Apr 2017 22:04:56 +0000 (22:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170704

Patch by Youenn Fablet <youenn@apple.com> on 2017-04-17
Reviewed by Eric Carlson.

* webrtc/video-mute.html: Another try at making the test not flaky.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215434 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webrtc/video-mute.html

index 2da13c3..9316218 100644 (file)
@@ -1,3 +1,12 @@
+2017-04-17  Youenn Fablet  <youenn@apple.com>
+
+        LayoutTest webrtc/video-mute.html is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=170704
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/video-mute.html: Another try at making the test not flaky.
+
 2017-04-17  Tim Horton  <timothy_horton@apple.com>
 
         Provide a viewport parameter to disable clipping to the safe area
index 3128f23..d7c22f3 100644 (file)
@@ -7,7 +7,7 @@
         <script src="../resources/testharnessreport.js"></script>
     </head>
     <body>
-        <video id="video" autoplay=""></video>
+        <video id="video" autoplay width="640" height="480"></video>
         <canvas id="canvas" width="640" height="480"></canvas>
         <script src ="routines.js"></script>
         <script>
@@ -30,12 +30,28 @@ function isVideoBlack()
     return true;
 }
 
+function pollVideoBlackCheck(expected, resolve)
+{
+    if (isVideoBlack() === expected)
+         resolve();
+
+    setTimeout(() => pollVideoBlackCheck(expected, resolve), 50);
+}
+
+function checkVideoBlack(expected, message)
+{
+    return new Promise((resolve, reject) => {
+       pollVideoBlackCheck(expected, resolve);
+        setTimeout(() => reject(message), 5000);
+    });
+}
+
 var track;
 promise_test((test) => {
     if (window.testRunner)
         testRunner.setUserMediaPermission(true);
 
-    return navigator.mediaDevices.getUserMedia({ video: true}).then((localStream) => {
+    return navigator.mediaDevices.getUserMedia({ video: {width: 640, height: 480}}).then((localStream) => {
         return new Promise((resolve, reject) => {
             track = localStream.getVideoTracks()[0];
 
@@ -50,18 +66,13 @@ promise_test((test) => {
         video.srcObject = remoteStream;
         return video.play();
     }).then(() => {
-        return waitFor(100);
-    }).then(() => {
-         assert_false(isVideoBlack(), "track is enabled, video is not black");
+        return checkVideoBlack(false, "track is enabled, video should not be black");
     }).then(() => {
         track.enabled = false;
-        return waitFor(500);
+        return checkVideoBlack(true, "track is disabled, video should be black");
     }).then(() => {
-        assert_true(isVideoBlack(), "track is disabled, video is black");
         track.enabled = true;
-        return waitFor(500);
-    }).then(() => {
-        assert_false(isVideoBlack(), "track is reenabled, video is not black");
+        return checkVideoBlack(false, "track is reenabled, video should not be black");
     });
 }, "Outgoing muted/unmuted video track");
         </script>