[macOS Sierra] Fix flaky test: media/controls/picture-in-picture.html
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2016 21:54:58 +0000 (21:54 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2016 21:54:58 +0000 (21:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160707

Reviewed by Eric Carlson.

This test became flaky after r201474 when we started to delay showing
the inline placeholder until we are sure the video layer has been moved
into the video fullscreen layer. This means we can't guarantee that the
placeholder is visible right away after the video's presentation mode
changes to "picture-in-picture".

To fix this, we'll update the test so that we'll wait until the placeholder
becomes visible before testing its visibility without the "controls" attribute.

* media/controls/picture-in-picture.html:
* platform/mac-wk2/TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/media/controls/picture-in-picture.html
LayoutTests/platform/mac-wk2/TestExpectations

index 7088c84..1a5253d 100644 (file)
@@ -1,3 +1,22 @@
+2016-08-09  Ada Chan  <adachan@apple.com>
+
+        [macOS Sierra] Fix flaky test: media/controls/picture-in-picture.html
+        https://bugs.webkit.org/show_bug.cgi?id=160707
+
+        Reviewed by Eric Carlson.
+
+        This test became flaky after r201474 when we started to delay showing
+        the inline placeholder until we are sure the video layer has been moved
+        into the video fullscreen layer. This means we can't guarantee that the
+        placeholder is visible right away after the video's presentation mode
+        changes to "picture-in-picture".
+
+        To fix this, we'll update the test so that we'll wait until the placeholder
+        becomes visible before testing its visibility without the "controls" attribute.
+
+        * media/controls/picture-in-picture.html:
+        * platform/mac-wk2/TestExpectations:
+
 2016-08-09  Chris Dumez  <cdumez@apple.com>
 
         It should be possible to re-initialize a CustomEvent after it's been dispatched
index ef8c763..d9d0e0a 100644 (file)
@@ -4,6 +4,9 @@
         <script src="../media-file.js"></script>
         <script src="controls-test-helpers.js"></script>
         <script>
+            var maxAttemptsToTestPlaceholderVisibility = 10;
+            var attemptsToTestPlaceholderVisibility = 0;
+
             if (window.internals)
                 window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
 
                     .value(tester.media.webkitPresentationMode)
                     .isEqualTo("picture-in-picture");
 
+                pollPIPPlaceholderVisibilityChange();
+            }
+
+            function pollPIPPlaceholderVisibilityChange()
+            {
                 const stateForPlaceholder = tester.stateForControlsElement("Inline playback placeholder", true);
+                if (stateForPlaceholder.className.indexOf("hidden") >= 0) {
+                    if (attemptsToTestPlaceholderVisibility > maxAttemptsToTestPlaceholderVisibility) {
+                        tester.logFailure("Inline placeholder did not become visible after video enters picture-in-picture.");
+                        tester.end();
+                        return;
+                    }
+
+                    // Use 33 to match PlaceholderPollingDelay in mediaControlsApple.js.
+                    setTimeout(pollPIPPlaceholderVisibilityChange, 33);
+                    attemptsToTestPlaceholderVisibility++;
+                    return;
+                }
+
                 tester.test("Inline placeholder should be visible at this point")
                     .value(stateForPlaceholder.className)
                     .doesNotContain("hidden");
index e1deaeb..821edb2 100644 (file)
@@ -472,7 +472,7 @@ webkit.org/b/158639 [ Release Yosemite ] imported/blink/storage/indexeddb/blob-d
 
 # PiP tests are only enabled for Sierra WebKit2.
 # rdar://problem/27574303
-[ Sierra+ ] media/controls/picture-in-picture.html [ Pass Failure ]
+[ Sierra+ ] media/controls/picture-in-picture.html [ Pass ]
 [ Sierra+ ] media/element-containing-pip-video-going-into-fullscreen.html [ Pass ]
 [ Sierra+ ] media/fullscreen-api-enabled-media-with-presentation-mode.html [ Pass ]
 [ Sierra+ ] media/fullscreen-video-going-into-pip.html [ Pass ]