Title: [249141] trunk
Revision
249141
Author
[email protected]
Date
2019-08-27 08:23:46 -0700 (Tue, 27 Aug 2019)

Log Message

webkitpresentationmodechanged is fired twice when exiting picture in picture
https://bugs.webkit.org/show_bug.cgi?id=193765

Patch by Peng Liu <[email protected]> on 2019-08-27
Reviewed by Jer Noble.

Source/WebCore:

This patch removes the extra "webkitpresentationmodechanged" event when the browser switches from
picture-in-picture or fullscreen to inline.

The bug was introduced by the fix for bug
https://bugs.webkit.org/show_bug.cgi?id=181095
But now we are using modern media controls and the fix is not necessary.
Reverting that fix can fix the issue.

Also, this patch gets rid of the unnecessary try to call a _javascript_ function which is not available
in the modern media controls.

Test: media/presentationmodechanged-fired-once.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::exitFullscreen):
(WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange):

LayoutTests:

* media/presentationmodechanged-fired-once-expected.txt: Added.
* media/presentationmodechanged-fired-once.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (249140 => 249141)


--- trunk/LayoutTests/ChangeLog	2019-08-27 14:59:32 UTC (rev 249140)
+++ trunk/LayoutTests/ChangeLog	2019-08-27 15:23:46 UTC (rev 249141)
@@ -1,3 +1,13 @@
+2019-08-27  Peng Liu  <[email protected]>
+
+        webkitpresentationmodechanged is fired twice when exiting picture in picture
+        https://bugs.webkit.org/show_bug.cgi?id=193765
+
+        Reviewed by Jer Noble.
+
+        * media/presentationmodechanged-fired-once-expected.txt: Added.
+        * media/presentationmodechanged-fired-once.html: Added.
+
 2019-08-27  Carlos Garcia Campos  <[email protected]>
 
         Origin header not included in WebSocket handshake request when using platform WebSocket API

Added: trunk/LayoutTests/media/presentationmodechanged-fired-once-expected.txt (0 => 249141)


--- trunk/LayoutTests/media/presentationmodechanged-fired-once-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/presentationmodechanged-fired-once-expected.txt	2019-08-27 15:23:46 UTC (rev 249141)
@@ -0,0 +1,14 @@
+This tests that the "webkitpresentationmodechanged" event is fired only once when the browser switches back to inline from the picture-in-picture mode.
+
+RUN(internals.settings.setAllowsPictureInPictureMediaPlayback(true))
+RUN(video.src = "" "content/test"))
+EVENT(canplaythrough)
+RUN(video.play())
+RUN(video.webkitSetPresentationMode("picture-in-picture"))
+EVENT(webkitpresentationmodechanged)
+EXPECTED (video.webkitPresentationMode == 'picture-in-picture') OK
+RUN(video.webkitSetPresentationMode("inline"))
+EVENT(webkitpresentationmodechanged)
+EXPECTED (video.webkitPresentationMode == 'inline') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/presentationmodechanged-fired-once.html (0 => 249141)


--- trunk/LayoutTests/media/presentationmodechanged-fired-once.html	                        (rev 0)
+++ trunk/LayoutTests/media/presentationmodechanged-fired-once.html	2019-08-27 15:23:46 UTC (rev 249141)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        var eventCount = 0;
+
+        function go()
+        {
+            findMediaElement();
+            run('internals.settings.setAllowsPictureInPictureMediaPlayback(true)');
+            run('video.src = "" "content/test")');
+            waitForEventOnce('canplaythrough', canPlayThrough);
+        }
+
+        function canPlayThrough()
+        {
+            runWithKeyDown('video.play()');
+            runWithKeyDown('video.webkitSetPresentationMode("picture-in-picture")');
+            waitForEventOnce("webkitpresentationmodechanged", presentationModeChanged1);
+        }
+
+        function presentationModeChanged1()
+        {
+            testExpected("video.webkitPresentationMode", "picture-in-picture");
+            runWithKeyDown('video.webkitSetPresentationMode("inline")');
+            waitForEvent("webkitpresentationmodechanged", presentationModeChanged2);
+        }
+
+        function presentationModeChanged2()
+        {
+            switch (++eventCount)
+            {
+                case 1:
+                    testExpected("video.webkitPresentationMode", "inline");
+                    setTimeout(endTest, 200);
+                    break;
+                default:
+                    failTest("'webkitpresentationmodechanged' event fired again");
+                    break;
+            }
+        }
+    </script>
+</head>
+<body _onload_="go()">
+    <div>This tests that the "webkitpresentationmodechanged" event is fired only once when the browser switches back to inline from the picture-in-picture mode.</div>
+    <video controls></video>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (249140 => 249141)


--- trunk/Source/WebCore/ChangeLog	2019-08-27 14:59:32 UTC (rev 249140)
+++ trunk/Source/WebCore/ChangeLog	2019-08-27 15:23:46 UTC (rev 249141)
@@ -1,3 +1,27 @@
+2019-08-27  Peng Liu  <[email protected]>
+
+        webkitpresentationmodechanged is fired twice when exiting picture in picture
+        https://bugs.webkit.org/show_bug.cgi?id=193765
+
+        Reviewed by Jer Noble.
+
+        This patch removes the extra "webkitpresentationmodechanged" event when the browser switches from
+        picture-in-picture or fullscreen to inline.
+
+        The bug was introduced by the fix for bug
+        https://bugs.webkit.org/show_bug.cgi?id=181095
+        But now we are using modern media controls and the fix is not necessary.
+        Reverting that fix can fix the issue.
+
+        Also, this patch gets rid of the unnecessary try to call a _javascript_ function which is not available
+        in the modern media controls.
+
+        Test: media/presentationmodechanged-fired-once.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::exitFullscreen):
+        (WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange):
+
 2019-08-27  Wenson Hsieh  <[email protected]>
 
         Image pasted from screenshot into Mail compose window via share sheet has the wrong aspect ratio

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (249140 => 249141)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2019-08-27 14:59:32 UTC (rev 249140)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2019-08-27 15:23:46 UTC (rev 249141)
@@ -6121,7 +6121,6 @@
         else
             document().page()->chrome().client().exitVideoFullscreenForVideoElement(downcast<HTMLVideoElement>(*this));
         scheduleEvent(eventNames().webkitendfullscreenEvent);
-        scheduleEvent(eventNames().webkitpresentationmodechangedEvent);
     }
 }
 
@@ -7435,6 +7434,9 @@
     if (!m_mediaControlsHost || document().activeDOMObjectsAreSuspended() || document().activeDOMObjectsAreStopped())
         return;
 
+    if (RuntimeEnabledFeatures::sharedFeatures().modernMediaControlsEnabled())
+        return;
+
     setupAndCallJS([this](JSDOMGlobalObject& globalObject, JSC::ExecState& exec, ScriptController&, DOMWrapperWorld&) {
         auto& vm = globalObject.vm();
         auto scope = DECLARE_THROW_SCOPE(vm);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to