Fix flaky test media/click-placeholder-not-pausing.html
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2016 21:04:34 +0000 (21:04 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2016 21:04:34 +0000 (21:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162661

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, wait for the placeholder to become visible before clicking it.

* media/click-placeholder-not-pausing.html:
* platform/mac-wk2/TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/media/click-placeholder-not-pausing.html
LayoutTests/platform/mac-wk2/TestExpectations

index 30abf59..c76f3c7 100644 (file)
@@ -1,3 +1,21 @@
+2016-09-28  Ada Chan  <adachan@apple.com>
+
+        Fix flaky test media/click-placeholder-not-pausing.html
+        https://bugs.webkit.org/show_bug.cgi?id=162661
+
+        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, wait for the placeholder to become visible before clicking it.
+
+        * media/click-placeholder-not-pausing.html:
+        * platform/mac-wk2/TestExpectations:
+
 2016-09-29  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r206483.
index 6f23975..911d338 100644 (file)
@@ -7,6 +7,9 @@
     <script>
         var mediaElement;
         var placeholder;
+        var maxAttemptsToTestPlaceholderVisibility = 10;
+        var attemptsToTestPlaceholderVisibility = 0;
+
 
         if (window.internals)
             window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
         {
             testExpected("mediaElement.webkitPresentationMode", "picture-in-picture");
 
+            pollPIPPlaceholderVisibilityChange();
+        }
+
+        function pollPIPPlaceholderVisibilityChange()
+        {
             placeholder = mediaControlsElement(internals.shadowRoot(mediaElement), '-webkit-media-controls-wireless-playback-status');
+
+            if (placeholder.classList.contains('hidden')) {
+                if (attemptsToTestPlaceholderVisibility > maxAttemptsToTestPlaceholderVisibility) {
+                    failTest("Inline placeholder did not become visible after video enters picture-in-picture.");
+                    endTest();
+                    return;
+                }
+
+                // Use 33 to match PlaceholderPollingDelay in mediaControlsApple.js.
+                setTimeout(pollPIPPlaceholderVisibilityChange, 33);
+                attemptsToTestPlaceholderVisibility++;
+                return;
+            }
+
             testExpected("placeholder.classList.contains('hidden')", false);
 
             if (!window.eventSender) {
index 7927491..e86acba 100644 (file)
@@ -472,8 +472,7 @@ webkit.org/b/158639 [ Release Yosemite ] imported/blink/storage/indexeddb/blob-d
 [ Sierra+ ] media/video-contained-in-fullscreen-element-going-into-pip.html [ Pass ]
 
 # rdar://problem/26885345
-[ Release Sierra+ ] media/click-placeholder-not-pausing.html [ Pass ]
-[ Debug Sierra+ ] media/click-placeholder-not-pausing.html [ Skip ]
+[ Sierra+ ] media/click-placeholder-not-pausing.html [ Pass ]
 
 # RTL Scrollbars are enabled on Sierra WebKit2.
 [ Sierra+ ] fast/scrolling/rtl-scrollbars.html [ Pass ]