Enable the mock video presentation mode in related layout tests and fix test failures
authorpeng.liu6@apple.com <peng.liu6@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 May 2020 21:03:24 +0000 (21:03 +0000)
committerpeng.liu6@apple.com <peng.liu6@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 May 2020 21:03:24 +0000 (21:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211645

Reviewed by Darin Adler.

Source/WebCore:

Clean up the internal states of video element regarding video presentation mode
to simplify the task to write reliable layout tests for video fullscreen and
Picture-in-Picture.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::enterFullscreen):
Update the states after we are sure the video element will enter fullscreen.

(WebCore::HTMLMediaElement::exitFullscreen):
Remove the unnecessary "fullscreenModeChanged(VideoFullscreenModeNone)".

* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::waitingToEnterFullscreen):

* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::webkitDisplayingFullscreen):
The function webkitDisplayingFullscreen() will return true after the process
to enter fullscreen is completed.

* html/HTMLVideoElement.h:
Expose didBecomeFullscreenElement() when VIDEO_PRESENTATION_MODE is enabled.

Source/WebKit:

Fix the mistake in VideoFullscreenManager::supportsVideoFullscreen() introduced in r202274.

* WebProcess/cocoa/VideoFullscreenManager.mm:
(WebKit::VideoFullscreenManager::supportsVideoFullscreen const):

Source/WebKitLegacy/mac:

Call HTMLVideoElement::didBecomeFullscreenElement() after a video element enters
fullscreen (to be consistent with WK2).

* WebView/WebVideoFullscreenController.mm:
(-[WebVideoFullscreenController windowDidEnterFullScreen:]):
* WebView/WebView.mm:
(-[WebView _enterVideoFullscreenForVideoElement:mode:]):

LayoutTests:

* http/tests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-live-broadcast-expected.txt:
* http/tests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-live-broadcast.html:
* media/media-fullscreen-inline.html:
* media/media-fullscreen-loop-inline-expected.txt:
* media/media-fullscreen-loop-inline.html:
* media/media-fullscreen-pause-inline-expected.txt:
* media/media-fullscreen-pause-inline.html:
* media/media-fullscreen-return-to-inline-expected.txt:
* media/media-fullscreen-return-to-inline.html:
* media/media-fullscreen.js:
(async beginfullscreen):
(async fullscreenerror):
(addEventListeners):
(beginfullscreen): Deleted.
(fullscreenerror): Deleted.
* media/modern-media-controls/css/webkit-cursor-visibility-auto-hide-expected.txt:
* media/modern-media-controls/css/webkit-cursor-visibility-auto-hide.html:
* media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-expected.txt:
* media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-is-prevented-over-button-expected.txt:
* media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-is-prevented-over-button.html:
* media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag.html:
* media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen-expected.txt:
* media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html:
* media/modern-media-controls/media-controller/media-controller-fullscreen-ltr-expected.txt:
* media/modern-media-controls/media-controller/media-controller-fullscreen-ltr.html:
* media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback-expected.txt:
* media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html:
* media/modern-media-controls/tracks-support/tracks-support-show-panel-fullscreen-expected.txt:
* media/modern-media-controls/tracks-support/tracks-support-show-panel-fullscreen.html:
* media/video-fullscreen-only-playback-expected.txt:
* media/video-fullscreen-only-playback.html:
* platform/ios/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/mac-wk2/TestExpectations:
* platform/mac/TestExpectations:

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

41 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-live-broadcast-expected.txt
LayoutTests/http/tests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-live-broadcast.html
LayoutTests/media/media-fullscreen-inline.html
LayoutTests/media/media-fullscreen-loop-inline-expected.txt
LayoutTests/media/media-fullscreen-loop-inline.html
LayoutTests/media/media-fullscreen-pause-inline-expected.txt
LayoutTests/media/media-fullscreen-pause-inline.html
LayoutTests/media/media-fullscreen-return-to-inline-expected.txt
LayoutTests/media/media-fullscreen-return-to-inline.html
LayoutTests/media/media-fullscreen.js
LayoutTests/media/modern-media-controls/css/webkit-cursor-visibility-auto-hide-expected.txt
LayoutTests/media/modern-media-controls/css/webkit-cursor-visibility-auto-hide.html
LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-expected.txt
LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-is-prevented-over-button-expected.txt
LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-is-prevented-over-button.html
LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag.html
LayoutTests/media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen-expected.txt
LayoutTests/media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html
LayoutTests/media/modern-media-controls/media-controller/media-controller-fullscreen-ltr-expected.txt
LayoutTests/media/modern-media-controls/media-controller/media-controller-fullscreen-ltr.html
LayoutTests/media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback-expected.txt
LayoutTests/media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html
LayoutTests/media/modern-media-controls/tracks-support/tracks-support-show-panel-fullscreen-expected.txt
LayoutTests/media/modern-media-controls/tracks-support/tracks-support-show-panel-fullscreen.html
LayoutTests/media/video-fullscreen-only-playback-expected.txt
LayoutTests/media/video-fullscreen-only-playback.html
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLVideoElement.cpp
Source/WebCore/html/HTMLVideoElement.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebVideoFullscreenController.mm
Source/WebKitLegacy/mac/WebView/WebView.mm

index 8611ab5..6447389 100644 (file)
@@ -1,3 +1,46 @@
+2020-05-11  Peng Liu  <peng.liu6@apple.com>
+
+        Enable the mock video presentation mode in related layout tests and fix test failures
+        https://bugs.webkit.org/show_bug.cgi?id=211645
+
+        Reviewed by Darin Adler.
+
+        * http/tests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-live-broadcast-expected.txt:
+        * http/tests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-live-broadcast.html:
+        * media/media-fullscreen-inline.html:
+        * media/media-fullscreen-loop-inline-expected.txt:
+        * media/media-fullscreen-loop-inline.html:
+        * media/media-fullscreen-pause-inline-expected.txt:
+        * media/media-fullscreen-pause-inline.html:
+        * media/media-fullscreen-return-to-inline-expected.txt:
+        * media/media-fullscreen-return-to-inline.html:
+        * media/media-fullscreen.js:
+        (async beginfullscreen):
+        (async fullscreenerror):
+        (addEventListeners):
+        (beginfullscreen): Deleted.
+        (fullscreenerror): Deleted.
+        * media/modern-media-controls/css/webkit-cursor-visibility-auto-hide-expected.txt:
+        * media/modern-media-controls/css/webkit-cursor-visibility-auto-hide.html:
+        * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-expected.txt:
+        * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-is-prevented-over-button-expected.txt:
+        * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag-is-prevented-over-button.html:
+        * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-drag.html:
+        * media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen-expected.txt:
+        * media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html:
+        * media/modern-media-controls/media-controller/media-controller-fullscreen-ltr-expected.txt:
+        * media/modern-media-controls/media-controller/media-controller-fullscreen-ltr.html:
+        * media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback-expected.txt:
+        * media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html:
+        * media/modern-media-controls/tracks-support/tracks-support-show-panel-fullscreen-expected.txt:
+        * media/modern-media-controls/tracks-support/tracks-support-show-panel-fullscreen.html:
+        * media/video-fullscreen-only-playback-expected.txt:
+        * media/video-fullscreen-only-playback.html:
+        * platform/ios/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/mac-wk2/TestExpectations:
+        * platform/mac/TestExpectations:
+
 2020-05-11  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, reverting r261446.
index faf94cd..b32a7c1 100644 (file)
@@ -3,6 +3,7 @@ Testing that we do not show the seeking controls in fullscreen with a live broad
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS media.webkitDisplayingFullscreen became true
 PASS media.duration became Number.POSITIVE_INFINITY
 PASS mediaController.controls.rewindButton.enabled is false
 PASS mediaController.controls.forwardButton.enabled is false
index c63a68d..afbe881 100644 (file)
@@ -15,19 +15,18 @@ const media = document.querySelector("video");
 const mediaController = createControls(shadowRoot, media, null);
 
 media.addEventListener("webkitfullscreenchange", () => {
-    if (!media.webkitDisplayingFullscreen)
-        return;
-
-    shouldBecomeEqual("media.duration", "Number.POSITIVE_INFINITY", () => {
-        shouldBeFalse("mediaController.controls.rewindButton.enabled");
-        shouldBeFalse("mediaController.controls.forwardButton.enabled");
-        shouldBe("mediaController.controls.timeControl.parent", "null");
-        shouldBe("mediaController.controls.statusLabel.parent", "mediaController.controls.bottomControlsBar");
-
-        debug("");
-        media.remove();
-        shadowRoot.host.remove();
-        finishJSTest();
+    shouldBecomeEqual("media.webkitDisplayingFullscreen", "true", () => {
+        shouldBecomeEqual("media.duration", "Number.POSITIVE_INFINITY", () => {
+            shouldBeFalse("mediaController.controls.rewindButton.enabled");
+            shouldBeFalse("mediaController.controls.forwardButton.enabled");
+            shouldBe("mediaController.controls.timeControl.parent", "null");
+            shouldBe("mediaController.controls.statusLabel.parent", "mediaController.controls.bottomControlsBar");
+
+            debug("");
+            media.remove();
+            shadowRoot.host.remove();
+            finishJSTest();
+        });
     });
 });
 
index e95e8d4..e1eb0df 100644 (file)
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <html>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
index 2c1de2a..5a337a3 100644 (file)
@@ -1,19 +1,24 @@
 
-RUN(internals.settings.setAllowsInlineMediaPlayback(false))
-RUN(internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true))
-RUN(internals.settings.setFullScreenEnabled(false))
-RUN(internals.setMediaElementRestrictions(video, "NoRestrictions"))
+Test that a <video> keeps playing and looping after exiting fullscreen when the internal property "allowsInlineMediaPlaybackAfterFullscreen" is true.
+
 RUN(video.loop = true)
 RUN(video.src = findMediaFile("video", "content/test"))
+EVENT(canplaythrough)
 RUN(video.play())
-EVENT(webkitbeginfullscreen)
+Wait to enter fullscreen
+EVENT(webkitpresentationmodechanged)
+EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
+Entered fullscreen
 RUN(video.currentTime = 5)
 RUN(video.webkitExitFullscreen())
-EVENT(webkitendfullscreen)
+Wait to exit fullscreen
+EVENT(webkitpresentationmodechanged)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
+Exited fullscreen
 EXPECTED (video.paused == 'false') OK
 RUN(video.ontimeupdate = timeupdate)
-RUN(video.ontimeupdate = null)
 Looped
+RUN(video.ontimeupdate = null)
 EXPECTED (video.playsInline == 'false') OK
 EXPECTED (video.paused == 'false') OK
 END OF TEST
index fad1cfb..4b8b199 100644 (file)
@@ -1,44 +1,62 @@
 <!DOCTYPE html><!-- webkit-test-runner [ enableModernMediaControls=false ] -->
 <html>
 <head>
-    <title>media-fullscreen-return-to-inline</title>
-
+    <title>media-fullscreen-loop-inline</title>
     <script src="video-test.js"></script>
     <script src="media-file.js"></script>
-
     <script>
     function go()
     {
+        if (!window.internals) {
+            failTest('This test requires window.internals.');
+            return;
+        }
+
         findMediaElement();
-        run('internals.settings.setAllowsInlineMediaPlayback(false)');
-        run('internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true)');
-        run('internals.settings.setFullScreenEnabled(false)');
-        run('internals.setMediaElementRestrictions(video, "NoRestrictions")');
+
+        internals.settings.setAllowsInlineMediaPlayback(false);
+        internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true);
+        // Disable the Fullscreen API (element fullscreen) support
+        internals.settings.setFullScreenEnabled(false);
+        internals.setMockVideoPresentationModeEnabled(true);
+        internals.setMediaElementRestrictions(video, "NoRestrictions");
+
+        waitForEventOnce('canplaythrough', canplaythrough);
         run('video.loop = true');
         run('video.src = findMediaFile("video", "content/test")');
-        waitForEventOnce('webkitbeginfullscreen', beginfullscreen);
+    }
+
+    function canplaythrough()
+    {
+        waitForEventOnce('webkitpresentationmodechanged', beginfullscreen);
         run('video.play()');
+        consoleWrite("Wait to enter fullscreen");
     }
 
-    function beginfullscreen()
+    async function beginfullscreen()
     {
+        await testExpectedEventually('video.webkitDisplayingFullscreen', true);
+        consoleWrite("Entered fullscreen");
         run('video.currentTime = 5');
         run('video.webkitExitFullscreen()');
-        waitForEventOnce('webkitendfullscreen', endfullscreen);
+        waitForEventOnce('webkitpresentationmodechanged', endfullscreen);
+        consoleWrite("Wait to exit fullscreen");
     }
 
-    function endfullscreen()
+    async function endfullscreen()
     {
+        await testExpectedEventually('video.webkitDisplayingFullscreen', false);
+        consoleWrite("Exited fullscreen");
         testExpected('video.paused', false);
         run('video.ontimeupdate = timeupdate');
-        waitForEventAndFail('webkitbeginfullscreen');
+        waitForEventAndFail('webkitpresentationmodechanged');
     }
 
     function timeupdate()
     {
         if (video.currentTime == 0) {
-            run('video.ontimeupdate = null');
             consoleWrite("Looped");
+            run('video.ontimeupdate = null');
             testExpected('video.playsInline', false);
             setTimeout(function loopCompleted() {
                testExpected('video.paused', false);
             }, 0);
         }
     }
-
     </script>
-
 </head>
-
 <body onload="go()">
     <video controls></video>
+    <p>Test that a &lt;video&gt; keeps playing and looping after exiting fullscreen when the internal property "allowsInlineMediaPlaybackAfterFullscreen" is true.</p>
 </body>
 </html>
index 3e2ca6d..3abc9e2 100644 (file)
@@ -1,13 +1,13 @@
 
-RUN(internals.settings.setAllowsInlineMediaPlayback(false))
-RUN(internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true))
-RUN(internals.settings.setFullScreenEnabled(false))
-RUN(internals.setMediaElementRestrictions(video, "NoRestrictions"))
+Test that a <video> keeps playing after exiting fullscreen when the internal property "allowsInlineMediaPlaybackAfterFullscreen" is true.
+
 RUN(video.src = findMediaFile("video", "content/test"))
+EVENT(canplaythrough)
 RUN(video.play().then(playing);)
 EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
 RUN(video.webkitExitFullscreen())
-EVENT(webkitendfullscreen)
+EVENT(webkitpresentationmodechanged)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
 EXPECTED (video.paused == 'false') OK
 RUN(video.pause())
 EVENT(pause)
index 858e8f1..6ea103e 100644 (file)
@@ -1,55 +1,66 @@
 <!DOCTYPE html><!-- webkit-test-runner [ enableModernMediaControls=false ] -->
 <html>
 <head>
-    <title>media-fullscreen-return-to-inline</title>
-
+    <title>media-fullscreen-pause-inline</title>
     <script src="video-test.js"></script>
     <script src="media-file.js"></script>
 
     <script>
     function go()
     {
+        if (!window.internals) {
+            failTest('This test requires window.internals.');
+            return;
+        }
+
         findMediaElement();
-        run('internals.settings.setAllowsInlineMediaPlayback(false)');
-        run('internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true)');
-        run('internals.settings.setFullScreenEnabled(false)');
-        run('internals.setMediaElementRestrictions(video, "NoRestrictions")');
+
+        internals.settings.setAllowsInlineMediaPlayback(false);
+        internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true);
+        // Disable the Fullscreen API (element fullscreen) support
+        internals.settings.setFullScreenEnabled(false);
+        internals.setMockVideoPresentationModeEnabled(true);
+        internals.setMediaElementRestrictions(video, "NoRestrictions");
+
+        waitForEventOnce('canplaythrough', canplaythrough);
         run('video.src = findMediaFile("video", "content/test")');
+    }
+
+    function canplaythrough()
+    {
         run('video.play().then(playing);');
     }
 
-    function playing()
+    async function playing()
     {
-        testExpected('video.webkitDisplayingFullscreen', true);
-        waitForEventOnce('webkitendfullscreen', endfullscreen);
+        await testExpectedEventually('video.webkitDisplayingFullscreen', true);
+        waitForEventOnce('webkitpresentationmodechanged', endfullscreen);
         run('video.webkitExitFullscreen()');
     }
 
-    function endfullscreen()
+    async function endfullscreen()
     {
+        await testExpectedEventually('video.webkitDisplayingFullscreen', false);
         testExpected('video.paused', false);
-        run('video.pause()');
         waitForEventOnce('pause', paused);
+        run('video.pause()');
     }
 
     function paused()
     {
         testExpected('video.paused', true);
-        setTimeout(function(){ run('video.play().then(playingAgain)');}, 0)
+        setTimeout(function(){ run('video.play().then(playingAgain)'); }, 0);
     }
 
-    function playingAgain()
+    async function playingAgain()
     {
-
-        testExpected('video.webkitDisplayingFullscreen', true);
+        await testExpectedEventually('video.webkitDisplayingFullscreen', true);
         endTest();
     }
-
     </script>
-
 </head>
-
 <body onload="go()">
     <video controls></video>
+    <p>Test that a &lt;video&gt; keeps playing after exiting fullscreen when the internal property "allowsInlineMediaPlaybackAfterFullscreen" is true.</p>
 </body>
-</html>
+</html>
\ No newline at end of file
index 3f56795..ae8729c 100644 (file)
@@ -1,17 +1,21 @@
 
-RUN(internals.settings.setAllowsInlineMediaPlayback(false))
-RUN(internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(false))
+Test that a <video> pauses after exiting fullscreen when the internal property "allowsInlineMediaPlaybackAfterFullscreen" is false.
+
 RUN(video.src = findMediaFile("video", "content/test"))
 EVENT(canplaythrough)
 RUN(video.play())
-EVENT(webkitfullscreenchange)
+EVENT(webkitpresentationmodechanged)
+EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
 RUN(video.webkitExitFullscreen())
 EVENT(pause)
-RUN(internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true))
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
+EXPECTED (video.paused == 'true') OK
 RUN(video.play())
-EVENT(webkitfullscreenchange)
+EVENT(webkitpresentationmodechanged)
+EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
 RUN(video.webkitExitFullscreen())
-EVENT(webkitfullscreenchange)
+EVENT(webkitpresentationmodechanged)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
 EXPECTED (video.paused == 'false') OK
 END OF TEST
 
index c5b6762..93220ed 100644 (file)
@@ -9,48 +9,65 @@
     <script>
     function go()
     {
+        if (!window.internals) {
+            failTest('This test requires window.internals.');
+            return;
+        }
+
         findMediaElement();
-        run('internals.settings.setAllowsInlineMediaPlayback(false)');
-        run('internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(false)');
-        run('video.src = findMediaFile("video", "content/test")');
+
+        internals.settings.setAllowsInlineMediaPlayback(false);
+        internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(false);
+        // Disable the Fullscreen API (element fullscreen) support
+        internals.settings.setFullScreenEnabled(false);
+        internals.setMockVideoPresentationModeEnabled(true);
+
         waitForEventOnce('canplaythrough', canplaythrough);
+        run('video.src = findMediaFile("video", "content/test")');
     }
 
     function canplaythrough()
     {
+        waitForEventOnce('webkitpresentationmodechanged', beginfullscreen1);
         runWithKeyDown('video.play()');
-        waitForEventOnce('webkitfullscreenchange', beginfullscreen1);
     }
 
-    function beginfullscreen1()
+    async function beginfullscreen1()
     {
-        run('video.webkitExitFullscreen()');
+        await testExpectedEventually('video.webkitDisplayingFullscreen', true);
         waitForEventOnce('pause', pause);
+        run('video.webkitExitFullscreen()');
     }
 
-    function pause()
+    async function pause()
     {
-        run('internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true)');
+        await testExpectedEventually('video.webkitDisplayingFullscreen', false);
+        testExpected('video.paused', true);
+
+        internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true);
+
+        waitForEventOnce('webkitpresentationmodechanged', beginfullscreen2);
         runWithKeyDown('video.play()');
-        waitForEventOnce('webkitfullscreenchange', beginfullscreen2);
     }
 
-    function beginfullscreen2()
+    async function beginfullscreen2()
     {
+        await testExpectedEventually('video.webkitDisplayingFullscreen', true);
+        waitForEventOnce('webkitpresentationmodechanged', endfullscreen);
         run('video.webkitExitFullscreen()');
-        waitForEventOnce('webkitfullscreenchange', endfullscreen);
     }
 
-    function endfullscreen()
+    async function endfullscreen()
     {
+        await testExpectedEventually('video.webkitDisplayingFullscreen', false);
         testExpected('video.paused', false);
         endTest();
     }
     </script>
-
 </head>
 
 <body onload="go()">
-    <video controls></video>
+    <video controls loop></video>
+    <p>Test that a &lt;video&gt; pauses after exiting fullscreen when the internal property "allowsInlineMediaPlaybackAfterFullscreen" is false.</p>
 </body>
 </html>
index d339ca0..664eb65 100644 (file)
@@ -38,9 +38,9 @@ function fullscreenchange()
         endfullscreen();
 }
 
-function beginfullscreen()
+async function beginfullscreen()
 {
-    testExpected("mediaElement.webkitDisplayingFullscreen", true);
+    await testExpectedEventually("mediaElement.webkitDisplayingFullscreen", true);
     run("mediaElement.webkitExitFullScreen()");
 }
 
@@ -49,13 +49,13 @@ function endfullscreen()
     setTimeout(openNextMovie, 10);
 }
 
-function fullscreenerror()
+async function fullscreenerror()
 {
     var movie = movieInfo.movies[movieInfo.current];
     if (movie.inline) {
         failTest("Unexpected fullscreenerror event");
     } else {
-        testExpected("mediaElement.webkitDisplayingFullscreen", false);
+        await testExpectedEventually("mediaElement.webkitDisplayingFullscreen", false);
         openNextMovie();
     }
 }
@@ -138,4 +138,3 @@ function addEventListeners(elem)
     waitForEvent('webkitfullscreenchange', fullscreenchange);
     waitForEvent('webkitfullscreenerror', fullscreenerror);
 }
-
index f21098a..c5f0aec 100644 (file)
@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS media.webkitDisplayingFullscreen is false
 PASS getComputedStyle(window.internals.shadowRoot(media).querySelector('.media-controls-container')).webkitCursorVisibility is "auto"
 
-PASS media.webkitDisplayingFullscreen is true
+PASS media.webkitDisplayingFullscreen became true
 PASS getComputedStyle(window.internals.shadowRoot(media).querySelector('.media-controls-container')).webkitCursorVisibility is "auto-hide"
 
 PASS successfullyParsed is true
index 02aa2ce..2572e85 100644 (file)
@@ -17,12 +17,13 @@ media.addEventListener("play", () => {
     debug("");
 
     media.addEventListener("webkitfullscreenchange", () => {
-        shouldBeTrue("media.webkitDisplayingFullscreen");
-        shouldBeEqualToString("getComputedStyle(window.internals.shadowRoot(media).querySelector('.media-controls-container')).webkitCursorVisibility", "auto-hide");
-        debug("");
-        button.remove();
-        media.remove();
-        finishJSTest();
+        shouldBecomeEqual("media.webkitDisplayingFullscreen", "true", () => {
+            shouldBeEqualToString("getComputedStyle(window.internals.shadowRoot(media).querySelector('.media-controls-container')).webkitCursorVisibility", "auto-hide");
+            debug("");
+            button.remove();
+            media.remove();
+            finishJSTest();
+        });
     });
 
     const button = document.body.appendChild(document.createElement("div"));
index fa2a50e..bb97785 100644 (file)
@@ -3,6 +3,7 @@ This test pauses the video, presses the fullscreen button, and drags the control
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS media.webkitDisplayingFullscreen became true
 PASS !!mediaControls.querySelector('.buttons-container.left') became true
 PASS mediaControls.querySelector('.buttons-container.left').style.width became "118px"
 PASS mediaControls.querySelector('.controls-bar').style.transform is "translate(-50px, -100px)"
index d6fc7e2..b08eaa2 100644 (file)
@@ -3,6 +3,7 @@ This test pauses the video, presses the fullscreen button, and drags the control
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS media.webkitDisplayingFullscreen became true
 PASS !!mediaControls.querySelector('.buttons-container.left') became true
 PASS mediaControls.querySelector('.buttons-container.left').style.width became "118px"
 PASS mediaControls.querySelector('.controls-bar').style.transform is ""
index ca7afdb..56ae7af 100644 (file)
@@ -17,7 +17,7 @@ media.addEventListener("webkitbeginfullscreen", () => {
 });
 
 media.addEventListener("webkitfullscreenchange", () => {
-    if (media.webkitDisplayingFullscreen) {
+    shouldBecomeEqual("media.webkitDisplayingFullscreen", "true", () => {
         mediaControls = shadowRoot.lastChild;
         shouldBecomeEqual("!!mediaControls.querySelector('.buttons-container.left')", "true", () => {
             shouldBecomeEqualToString("mediaControls.querySelector('.buttons-container.left').style.width", "118px", () => {
@@ -33,7 +33,7 @@ media.addEventListener("webkitfullscreenchange", () => {
                 });
             });
         });
-    }
+    });
 });
 
 media.addEventListener("play", () => {
index 58d1ed8..e643d0b 100644 (file)
@@ -17,7 +17,7 @@ media.addEventListener("webkitbeginfullscreen", () => {
 });
 
 media.addEventListener("webkitfullscreenchange", () => {
-    if (media.webkitDisplayingFullscreen) {
+    shouldBecomeEqual("media.webkitDisplayingFullscreen", "true", () => {
         mediaControls = shadowRoot.lastChild;
         shouldBecomeEqual("!!mediaControls.querySelector('.buttons-container.left')", "true", () => {
             shouldBecomeEqualToString("mediaControls.querySelector('.buttons-container.left').style.width", "118px", () => {
@@ -33,7 +33,7 @@ media.addEventListener("webkitfullscreenchange", () => {
                 });
             });
         });
-    }
+    });
 });
 
 media.addEventListener("play", () => {
index ccd677f..2064d7d 100644 (file)
@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS mediaControls.querySelector('button.fullscreen') instanceof HTMLButtonElement became true
 
 Entering fullscreen
-PASS media.webkitDisplayingFullscreen is true
+PASS media.webkitDisplayingFullscreen became true
 PASS media.paused is false
 
 Clicking on video background
index 8cf5ee7..b5c4832 100644 (file)
@@ -22,21 +22,22 @@ media.addEventListener("play", () => {
 
 
 media.addEventListener("webkitfullscreenchange", () => {
-    shouldBeTrue("media.webkitDisplayingFullscreen");
-    shouldBeFalse("media.paused");
+    shouldBecomeEqual("media.webkitDisplayingFullscreen", "true", () => {
+        shouldBeFalse("media.paused");
 
-    const bounds = media.getBoundingClientRect();
-    debug("");
-    debug("Clicking on video background");
-    eventSender.mouseMoveTo(bounds.left + 5, bounds.top + 5);
-    eventSender.mouseDown();
-    eventSender.mouseUp();
+        const bounds = media.getBoundingClientRect();
+        debug("");
+        debug("Clicking on video background");
+        eventSender.mouseMoveTo(bounds.left + 5, bounds.top + 5);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
 
-    shouldBeTrue("media.paused");
+        shouldBeTrue("media.paused");
 
-    debug("");
-    media.remove();
-    finishJSTest();
+        debug("");
+        media.remove();
+        finishJSTest();
+    });
 });
 
 </script>
index c711f51..a58f8fb 100644 (file)
@@ -3,6 +3,7 @@ Testing ltr is set correctly when entering fullscreen.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS media.webkitDisplayingFullscreen became true
 Media entered fullscreen
 PASS mediaControlsElement.classList.contains('uses-ltr-user-interface-layout-direction') is true
 PASS document.defaultView.getComputedStyle(volumeSliderElement).transform is "none"
index 6879f0e..26449da 100644 (file)
@@ -15,7 +15,7 @@ let shadowRoot = window.internals.shadowRoot(media);
 let mediaControlsElement, volumeSliderElement;
 
 media.addEventListener("webkitfullscreenchange", function() {
-    if (media.webkitDisplayingFullscreen) {
+    shouldBecomeEqual("media.webkitDisplayingFullscreen", "true", () => {
         window.requestAnimationFrame(() => {
             window.requestAnimationFrame(() => {
                 debug("Media entered fullscreen");
@@ -44,7 +44,7 @@ media.addEventListener("webkitfullscreenchange", function() {
                 finishJSTest();
             });
         });
-    }
+    });
 });
 
 media.addEventListener("loadedmetadata", () => {
index ca1a3dc..9fa8635 100644 (file)
@@ -9,7 +9,7 @@ Obtained a 'play' event.
 Entering fullscreen.
 
 Obtained a 'webkitfullscreenchange' event.
-media.webkitDisplayingFullscreen = true.
+PASS media.webkitDisplayingFullscreen became true
 PASS media.paused is false
 
 Pressing the space bar.
@@ -21,7 +21,6 @@ Pressing the space bar.
 Obtained a 'play' event.
 
 Obtained a 'webkitfullscreenchange' event.
-media.webkitDisplayingFullscreen = false.
 
 PASS successfullyParsed is true
 
index f305f1e..0934403 100644 (file)
@@ -16,11 +16,12 @@ button.textContent = "Enter Fullscreen";
 media.addEventListener("webkitfullscreenchange", () => {
     debug("");
     debug("Obtained a 'webkitfullscreenchange' event.");
-    debug(`media.webkitDisplayingFullscreen = ${media.webkitDisplayingFullscreen}.`);
 
-    if (media.webkitDisplayingFullscreen) {
-        shouldBeFalse("media.paused");
-        pressSpace();
+    if (playCount == 1) {
+        shouldBecomeEqual('media.webkitDisplayingFullscreen', 'true', () => {
+            shouldBeFalse("media.paused");
+            pressSpace();
+        });
     } else
         endTest();
 });
@@ -46,7 +47,6 @@ media.addEventListener("pause", () => {
     pressSpace();
 });
 
-
 function enterFullscreen() {
     debug("");
     debug("Entering fullscreen.");
index a331093..7515255 100644 (file)
@@ -5,6 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 PASS internals.shadowRoot(media).querySelector("button.fullscreen") became different from null
 PASS internals.shadowRoot(media).querySelector("button.fullscreen").getBoundingClientRect().width became different from 0
+PASS media.webkitDisplayingFullscreen became true
 PASS internals.shadowRoot(media).querySelector("button.tracks") became different from null
 PASS internals.shadowRoot(media).querySelector("button.tracks").getBoundingClientRect().width became different from 0
 PASS internals.shadowRoot(media).querySelector("button.tracks").getBoundingClientRect().right became 582
index 3e12d42..42fadaf 100644 (file)
@@ -12,19 +12,18 @@ description("Showing the tracks panel in fullscreen.");
 const media = document.querySelector("video");
 
 media.addEventListener("webkitfullscreenchange", () => {
-    if (!media.webkitDisplayingFullscreen)
-        return;
-
-    shouldBecomeDifferent(`internals.shadowRoot(media).querySelector("button.tracks")`, "null", () => {
-        shouldBecomeDifferent(`internals.shadowRoot(media).querySelector("button.tracks").getBoundingClientRect().width`, "0", () => {
-            shouldBecomeEqual(`internals.shadowRoot(media).querySelector("button.tracks").getBoundingClientRect().right`, "582", () => {
-                pressOnElement(internals.shadowRoot(media).querySelector("button.tracks"));
-                shouldBecomeDifferent(`internals.shadowRoot(media).querySelector('.tracks-panel')`, "null", () => {
-                    shouldBeEqualToString("internals.shadowRoot(media).querySelector('.tracks-panel').style.right", "218px");
-                    shouldBeEqualToString("internals.shadowRoot(media).querySelector('.tracks-panel').style.bottom", "101px");
-                    debug("");
-                    media.remove();
-                    finishJSTest();
+    shouldBecomeEqual("media.webkitDisplayingFullscreen", "true", () => {
+        shouldBecomeDifferent(`internals.shadowRoot(media).querySelector("button.tracks")`, "null", () => {
+            shouldBecomeDifferent(`internals.shadowRoot(media).querySelector("button.tracks").getBoundingClientRect().width`, "0", () => {
+                shouldBecomeEqual(`internals.shadowRoot(media).querySelector("button.tracks").getBoundingClientRect().right`, "582", () => {
+                    pressOnElement(internals.shadowRoot(media).querySelector("button.tracks"));
+                    shouldBecomeDifferent(`internals.shadowRoot(media).querySelector('.tracks-panel')`, "null", () => {
+                        shouldBeEqualToString("internals.shadowRoot(media).querySelector('.tracks-panel').style.right", "218px");
+                        shouldBeEqualToString("internals.shadowRoot(media).querySelector('.tracks-panel').style.bottom", "101px");
+                        debug("");
+                        media.remove();
+                        finishJSTest();
+                    });
                 });
             });
         });
index 33724f0..c172b52 100644 (file)
@@ -1,18 +1,18 @@
 
-Test play() when <video> playback requires fullscreen.
+Test the play() function of <video> when fullscreen is required.
 
-RUN(internals.settings.setAllowsInlineMediaPlayback(false))
 
 EVENT(canplaythrough)
 EXPECTED (video.webkitSupportsFullscreen == 'true') OK
 EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
-
-** Clicking 'play' button...
+RUN(video.play())
 EVENT(playing)
+EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
 
 ** Entered fullscreen
-EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
 RUN(video.webkitExitFullScreen())
+EVENT(webkitpresentationmodechanged)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
 
 ** Exited fullscreen
 END OF TEST
index f6f9d6b..f324599 100644 (file)
@@ -1,28 +1,28 @@
-<!-- webkit-test-runner [ enableModernMediaControls=false ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ enableModernMediaControls=false ] -->
 <html>
     <head>
         <script src=media-file.js></script>
         <script src=video-test.js></script>
         <script src=media-controls.js></script>
         <script>
-
-            function fullscreenchange()
+            function start()
             {
-                if (!document.webkitIsFullScreen)
-                    endfullscreen();
-            }
+                if (!window.internals) {
+                    failTest('This test requires window.internals.');
+                    return;
+                }
 
-            function playing()
-            {
-                consoleWrite("<br>** Entered fullscreen");
-                testExpected("video.webkitDisplayingFullscreen", true);
-                run("video.webkitExitFullScreen()");
-            }
+                video = document.getElementsByTagName('video')[0];
+                waitForEvent("canplaythrough", canplaythrough);
+                waitForEvent('playing', playing);
+                video.src = findMediaFile("video", "content/test");
 
-            function endfullscreen()
-            {
-                consoleWrite("<br>** Exited fullscreen");
-                endTest();
+                internals.settings.setAllowsInlineMediaPlayback(false);
+                // Disable the Fullscreen API (element fullscreen) support
+                internals.settings.setFullScreenEnabled(false);
+                internals.setMockVideoPresentationModeEnabled(true);
+
+                consoleWrite("");
             }
 
             function canplaythrough()
                 testExpected("video.webkitSupportsFullscreen", true);
                 testExpected("video.webkitDisplayingFullscreen", false);
 
-                consoleWrite("<br>** Clicking \'play\' button...");
-
                 try {
-                    clickPlayButton(video);
+                    runWithKeyDown("video.play()");
                 } catch (exception) {
                     failTest(exception.description);
                     return;
                 }
             }
 
-
-            function start()
+            async function playing()
             {
-                if (!window.internals) {
-                    failTest('This test requires window.internals.');
-                    return;
-                }
-
-                video = document.getElementsByTagName('video')[0];
-                waitForEvent("canplaythrough", canplaythrough);
-                waitForEvent('playing', playing);
-
-                video.addEventListener('webkitendfullscreen', endfullscreen, true);
-                video.addEventListener('webkitfullscreenchange', fullscreenchange, true);
-
-                video.src = findMediaFile("video", "content/test");
+                await testExpectedEventually("video.webkitDisplayingFullscreen", true);
+                consoleWrite("<br>** Entered fullscreen");
+                waitForEvent('webkitpresentationmodechanged', endfullscreen);
+                run("video.webkitExitFullScreen()");
+            }
 
-                run("internals.settings.setAllowsInlineMediaPlayback(false)");
-                consoleWrite("");
+            async function endfullscreen()
+            {
+                await testExpectedEventually("video.webkitDisplayingFullscreen", false);
+                consoleWrite("<br>** Exited fullscreen");
+                endTest();
             }
         </script>
     </head>
 
     <body onload="start()">
         <video controls></video>
-        <p>Test play() when &lt;video&gt; playback requires fullscreen.</p>
+        <p>Test the play() function of &lt;video&gt; when fullscreen is required.</p>
     </body>
 </html>
index 125764e..500e49e 100644 (file)
@@ -2430,7 +2430,6 @@ media/media-fullscreen-inline.html
 webkit.org/b/136708 media/media-fullscreen-not-in-document.html
 
 media/media-controls-accessibility.html [ Timeout ]
-media/media-fullscreen-return-to-inline.html
 media/no-autoplay-with-user-gesture-requirement.html
 media/video-controls-drag.html
 media/video-controls-fullscreen-volume.html
@@ -2567,7 +2566,6 @@ webkit.org/b/162647 http/tests/xmlhttprequest/onabort-response-getters.html [ Pa
 webkit.org/b/163291 media/require-user-gesture-to-load-video.html
 webkit.org/b/163291 media/video-controls-transformed.html [ Failure ]
 webkit.org/b/163291 media/video-controls-visible-audio-only.html [ Failure ]
-webkit.org/b/163291 media/video-fullscreen-only-playback.html [ Failure ]
 webkit.org/b/163291 media/video-play-audio-require-user-gesture.html [ Failure ]
 webkit.org/b/163291 media/video-play-require-user-gesture.html
 
@@ -3156,11 +3154,6 @@ fast/gradients/conic-two-hints.html [ Pass ]
 # <rdar://problem/36455339> LayoutTest compositing/ios/overflow-scroll-touch-tiles.html is a flaky failure
 compositing/ios/overflow-scroll-touch-tiles.html [ Pass Failure ]
 
-# <rdar://problem/41546970> REGRESSION: LayoutTest media/media-fullscreen-loop-inline.html is a flaky timeout
-media/media-fullscreen-loop-inline.html [ Pass Timeout ]
-
-webkit.org/b/187618 [ Release ] media/media-fullscreen-pause-inline.html [ Pass Failure ]
-
 # Disabled globally.
 http/tests/xmlhttprequest/gzip-content-type-no-content-encoding.html [ Pass ]
 
index 080624f..989ae59 100644 (file)
@@ -616,7 +616,6 @@ webkit.org/b/172807 imported/w3c/web-platform-tests/css/selectors/focus-display-
 webkit.org/b/172807 imported/w3c/web-platform-tests/css/selectors/focus-within-display-none-001.html [ Pass Failure ]
 
 webkit.org/b/168409 media/modern-media-controls/airplay-button/airplay-button.html [ Pass Timeout ]
-webkit.org/b/175195 media/modern-media-controls/css/webkit-cursor-visibility-auto-hide.html [ Pass Failure ]
 webkit.org/b/168265 media/modern-media-controls/forward-button/forward-button.html [ Pass Timeout ]
 
 
index b13c3b6..0dcabff 100644 (file)
@@ -341,10 +341,6 @@ webkit.org/b/150542 fast/forms/state-restore-per-form.html [ Pass Timeout ]
 
 webkit.org/b/151709 [ Release ] http/tests/xmlhttprequest/workers/methods.html [ Pass Timeout ]
 
-# Video fullscreen is not implemented for mac wk2 in webkittestrunner
-media/media-fullscreen-loop-inline.html [ Skip ]
-media/media-fullscreen-pause-inline.html [ Skip ]
-
 ### END OF (1) Classified failures with bug reports
 ########################################
 
index 2a0e20e..bdb7391 100644 (file)
@@ -759,7 +759,6 @@ webkit.org/b/133686 media/track/w3c/interfaces/TextTrackCue/align.html [ Pass Fa
 webkit.org/b/135071 media/video-seek-with-negative-playback.html [ Pass Timeout ]
 webkit.org/b/135160 media/track/track-in-band-subtitles-too-large.html [ Failure ]
 webkit.org/b/135160 media/track/track-long-word-container-sizing.html [ Failure ]
-webkit.org/b/137311 media/video-fullscreen-only-playback.html [ Pass Timeout Crash ]
 webkit.org/b/139789 media/media-controls-timeline-updates.html [ Pass Failure ]
 webkit.org/b/139825 media/video-seek-past-end-paused.html [ Pass Timeout ]
 webkit.org/b/141084 http/tests/media/video-preload.html [ Pass Timeout ]
@@ -1641,8 +1640,6 @@ webkit.org/b/189680 platform/mac/media/audio-session-category-video-paused.html
 webkit.org/b/195466 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ready-states/autoplay.html [ Pass Failure ]
 webkit.org/b/195466 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/error-codes/error.html [ Pass Failure ]
 
-webkit.org/b/193399 media/media-fullscreen-return-to-inline.html [ Pass Timeout ]
-
 http/tests/websocket/tests/hybi/handshake-ok-with-legacy-sec-websocket-response-headers.html [ Pass Failure ]
 
 webkit.org/b/195466 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-width-1000px.html [ Pass Failure ]
@@ -1948,8 +1945,6 @@ webkit.org/b/209908 svg/custom/animate-initial-pause-unpause.html [ Pass Timeout
 
 webkit.org/b/210046 [ Release ] storage/indexeddb/value-cursor-cycle.html [ Pass Failure ]
 
-webkit.org/b/182571 [ Debug ] media/modern-media-controls/tracks-support/tracks-support-show-panel-fullscreen.html [ Pass Timeout ]
-
 webkit.org/b/207160 css2.1/20110323/replaced-intrinsic-ratio-001.htm [ Pass Failure ]
 
 webkit.org/b/210351 scrollingcoordinator/mac/latching/horizontal-overflow-back-swipe.html [ Pass Timeout ]
index f7639d7..56149a1 100644 (file)
@@ -1,3 +1,32 @@
+2020-05-11  Peng Liu  <peng.liu6@apple.com>
+
+        Enable the mock video presentation mode in related layout tests and fix test failures
+        https://bugs.webkit.org/show_bug.cgi?id=211645
+
+        Reviewed by Darin Adler.
+
+        Clean up the internal states of video element regarding video presentation mode
+        to simplify the task to write reliable layout tests for video fullscreen and
+        Picture-in-Picture.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::enterFullscreen):
+        Update the states after we are sure the video element will enter fullscreen.
+
+        (WebCore::HTMLMediaElement::exitFullscreen):
+        Remove the unnecessary "fullscreenModeChanged(VideoFullscreenModeNone)".
+
+        * html/HTMLMediaElement.h:
+        (WebCore::HTMLMediaElement::waitingToEnterFullscreen):
+
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::webkitDisplayingFullscreen):
+        The function webkitDisplayingFullscreen() will return true after the process
+        to enter fullscreen is completed.
+
+        * html/HTMLVideoElement.h:
+        Expose didBecomeFullscreenElement() when VIDEO_PRESENTATION_MODE is enabled.
+
 2020-05-11  Antoine Quint  <graouts@apple.com>
 
         [Web Animations] Document.getAnimations() should only consider document connection and not timeline association
index a9555cd..ef9fbd7 100644 (file)
@@ -5989,11 +5989,10 @@ void HTMLMediaElement::enterFullscreen(VideoFullscreenMode mode)
     if (m_videoFullscreenMode == mode)
         return;
 
-    m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
-    m_waitingToEnterFullscreen = true;
-
 #if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO_USES_ELEMENT_FULLSCREEN)
     if (document().settings().fullScreenEnabled() && mode == VideoFullscreenModeStandard) {
+        m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
+        m_waitingToEnterFullscreen = true;
         document().fullscreenManager().requestFullscreenForElement(this, FullscreenManager::ExemptIFrameAllowFullscreenRequirement);
         return;
     }
@@ -6005,12 +6004,16 @@ void HTMLMediaElement::enterFullscreen(VideoFullscreenMode mode)
             return;
         }
 
-        fullscreenModeChanged(mode);
-        configureMediaControls();
         if (is<HTMLVideoElement>(*this)) {
             HTMLVideoElement& asVideo = downcast<HTMLVideoElement>(*this);
-            if (document().page()->chrome().client().supportsVideoFullscreen(m_videoFullscreenMode)) {
-                INFO_LOG(LOGIDENTIFIER, "Entering fullscreen mode ", m_videoFullscreenMode, ", m_videoFullscreenStandby = ", m_videoFullscreenStandby);
+            if (document().page()->chrome().client().supportsVideoFullscreen(mode)) {
+                INFO_LOG(LOGIDENTIFIER, "Entering fullscreen mode ", mode, ", m_videoFullscreenStandby = ", m_videoFullscreenStandby);
+
+                m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
+                m_waitingToEnterFullscreen = true;
+                fullscreenModeChanged(mode);
+                configureMediaControls();
+
                 document().page()->chrome().client().enterVideoFullscreenForVideoElement(asVideo, m_videoFullscreenMode, m_videoFullscreenStandby);
                 scheduleEvent(eventNames().webkitbeginfullscreenEvent);
             }
@@ -6041,7 +6044,6 @@ void HTMLMediaElement::exitFullscreen()
 
     ASSERT(m_videoFullscreenMode != VideoFullscreenModeNone);
     VideoFullscreenMode oldVideoFullscreenMode = m_videoFullscreenMode;
-    fullscreenModeChanged(VideoFullscreenModeNone);
     Ref<HTMLMediaElement> protectedThis(*this); // updateMediaControlsAfterPresentationModeChange calls methods that can trigger arbitrary DOM mutations.
     updateMediaControlsAfterPresentationModeChange();
 
index 2764aa3..2b68de8 100644 (file)
@@ -614,6 +614,7 @@ protected:
     void updateMediaControlsAfterPresentationModeChange();
 
     void scheduleEvent(const AtomString&);
+    bool waitingToEnterFullscreen() { return m_waitingToEnterFullscreen; }
 
 private:
     void createMediaPlayer();
index 1b64fb2..0c936c6 100644 (file)
@@ -346,7 +346,7 @@ bool HTMLVideoElement::webkitSupportsFullscreen()
 
 bool HTMLVideoElement::webkitDisplayingFullscreen()
 {
-    return isFullscreen();
+    return isFullscreen() && !waitingToEnterFullscreen();
 }
 
 void HTMLVideoElement::ancestorWillEnterFullscreen()
@@ -523,7 +523,6 @@ void HTMLVideoElement::fullscreenModeChanged(VideoFullscreenMode mode)
     HTMLMediaElement::fullscreenModeChanged(mode);
 }
 
-#if ENABLE(PICTURE_IN_PICTURE_API)
 void HTMLVideoElement::didBecomeFullscreenElement()
 {
     m_isFullscreen = true;
@@ -531,6 +530,7 @@ void HTMLVideoElement::didBecomeFullscreenElement()
     HTMLMediaElement::didBecomeFullscreenElement();
 }
 
+#if ENABLE(PICTURE_IN_PICTURE_API)
 void HTMLVideoElement::setPictureInPictureObserver(PictureInPictureObserver* observer)
 {
     m_pictureInPictureObserver = observer;
index ed92183..f5447c0 100644 (file)
@@ -88,9 +88,9 @@ public:
     VideoPresentationMode webkitPresentationMode() const;
     void setFullscreenMode(VideoFullscreenMode);
     void fullscreenModeChanged(VideoFullscreenMode) final;
+    WEBCORE_EXPORT void didBecomeFullscreenElement() final;
 
 #if ENABLE(PICTURE_IN_PICTURE_API)
-    WEBCORE_EXPORT void didBecomeFullscreenElement() final;
     void setPictureInPictureObserver(PictureInPictureObserver*);
     WEBCORE_EXPORT void setPictureInPictureAPITestEnabled(bool);
 #endif
index 87cd764..f50317b 100644 (file)
@@ -1,3 +1,15 @@
+2020-05-11  Peng Liu  <peng.liu6@apple.com>
+
+        Enable the mock video presentation mode in related layout tests and fix test failures
+        https://bugs.webkit.org/show_bug.cgi?id=211645
+
+        Reviewed by Darin Adler.
+
+        Fix the mistake in VideoFullscreenManager::supportsVideoFullscreen() introduced in r202274.
+
+        * WebProcess/cocoa/VideoFullscreenManager.mm:
+        (WebKit::VideoFullscreenManager::supportsVideoFullscreen const):
+
 2020-05-11  Per Arne Vollan  <pvollan@apple.com>
 
         [iOS] Update message filtering rules in the WebContent process' sandbox
index fbdd4e9..e026f5e 100644 (file)
@@ -223,7 +223,7 @@ bool VideoFullscreenManager::supportsVideoFullscreen(WebCore::HTMLMediaElementEn
     UNUSED_PARAM(mode);
     return DeprecatedGlobalSettings::avKitEnabled();
 #else
-    return mode == HTMLMediaElementEnums::VideoFullscreenModePictureInPicture && supportsPictureInPicture();
+    return mode == HTMLMediaElementEnums::VideoFullscreenModeStandard || (mode == HTMLMediaElementEnums::VideoFullscreenModePictureInPicture && supportsPictureInPicture());
 #endif
 }
 
index f609d03..5da5310 100644 (file)
@@ -1,3 +1,18 @@
+2020-05-11  Peng Liu  <peng.liu6@apple.com>
+
+        Enable the mock video presentation mode in related layout tests and fix test failures
+        https://bugs.webkit.org/show_bug.cgi?id=211645
+
+        Reviewed by Darin Adler.
+
+        Call HTMLVideoElement::didBecomeFullscreenElement() after a video element enters
+        fullscreen (to be consistent with WK2).
+
+        * WebView/WebVideoFullscreenController.mm:
+        (-[WebVideoFullscreenController windowDidEnterFullScreen:]):
+        * WebView/WebView.mm:
+        (-[WebView _enterVideoFullscreenForVideoElement:mode:]):
+
 2020-05-07  Darin Adler  <darin@apple.com>
 
         Remove USE(INSERTION_UNDO_GROUPING) checks in macOS platform code
index e735627..2944c03 100644 (file)
@@ -312,6 +312,8 @@ static WebAVPlayerView *allocWebAVPlayerViewInstance()
     [_playerView willChangeValueForKey:@"isFullScreen"];
     _isFullScreen = YES;
     [_playerView didChangeValueForKey:@"isFullScreen"];
+    if (_videoElement)
+        _videoElement->didBecomeFullscreenElement();
 }
 
 - (void)windowWillExitFullScreen:(NSNotification *)notification
index 83d0525..ad9bfdd 100644 (file)
@@ -9269,8 +9269,10 @@ bool LayerFlushController::flushLayers()
 
 - (void)_enterVideoFullscreenForVideoElement:(NakedPtr<WebCore::HTMLVideoElement>)videoElement mode:(WebCore::HTMLMediaElementEnums::VideoFullscreenMode)mode
 {
-    if (_private->mockVideoPresentationModeEnabled)
+    if (_private->mockVideoPresentationModeEnabled) {
+        videoElement->didBecomeFullscreenElement();
         return;
+    }
 
     if (_private->fullscreenController) {
         if ([_private->fullscreenController videoElement] == videoElement) {