Title: [233865] trunk
Revision
233865
Author
[email protected]
Date
2018-07-16 13:39:37 -0700 (Mon, 16 Jul 2018)

Log Message

Fullscreen requires active document.
https://bugs.webkit.org/show_bug.cgi?id=186226
rdar://problem/36187413

Patch by Jeremy Jones <[email protected]> on 2018-07-16
Reviewed by Jer Noble.

Source/WebCore:

Test: media/no-fullscreen-when-hidden.html

This change guarantees the document to be visible for both element fullscreen and video fullscreen.

User gesture is not enough to guarantee that the document is visible when fullscreen is initiated
because _javascript_ can spin wait before initiating fullscreen. During that spin the page or window might
be hidden.

Document::hidden() can't be relied upon because it won't update while _javascript_ spins.

This change adds a sync call to the UI process to get the current UI visibility state.

* dom/Document.cpp:
(WebCore::Document::requestFullScreenForElement):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::enterFullscreen):
* page/ChromeClient.h:

Source/WebKit:

This change guarantees the document to be visible for both element fullscreen and video fullscreen.

User gesture is not enough to guarantee that the document is visible when fullscreen is initiated
because _javascript_ can spin wait before initiating fullscreen. During that spin the page or window might
be hidden.

Document::hidden() can't be relied upon because it won't update while _javascript_ spins.

This change adds a sync call to the UI process to get the current UI visibility state.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::getIsViewVisible):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::isViewVisible):
* WebProcess/WebCoreSupport/WebChromeClient.h:

LayoutTests:

This change guarantees the document to be visible for both element fullscreen and video fullscreen.

User gesture is not enough to guarantee that the document is visible when fullscreen is initiated
because _javascript_ can spin wait before initiating fullscreen. During that spin the page or window might
be hidden.

Document::hidden() can't be relied upon because it won't update while _javascript_ spins.

This change adds a sync call to the UI process to get the current UI visibility state.

* media/no-fullscreen-when-hidden.html: Added.
* media/video-test.js:
(eventName.string_appeared_here.thunk):
(runWithKeyDown):
* platform/ios-wk1/TestExpectations:
* platform/mac-wk1/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (233864 => 233865)


--- trunk/LayoutTests/ChangeLog	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/LayoutTests/ChangeLog	2018-07-16 20:39:37 UTC (rev 233865)
@@ -1,3 +1,28 @@
+2018-07-16  Jeremy Jones  <[email protected]>
+
+        Fullscreen requires active document.
+        https://bugs.webkit.org/show_bug.cgi?id=186226
+        rdar://problem/36187413
+
+        Reviewed by Jer Noble.
+
+        This change guarantees the document to be visible for both element fullscreen and video fullscreen.
+
+        User gesture is not enough to guarantee that the document is visible when fullscreen is initiated
+        because _javascript_ can spin wait before initiating fullscreen. During that spin the page or window might
+        be hidden.
+
+        Document::hidden() can't be relied upon because it won't update while _javascript_ spins.
+
+        This change adds a sync call to the UI process to get the current UI visibility state.
+
+        * media/no-fullscreen-when-hidden.html: Added.
+        * media/video-test.js:
+        (eventName.string_appeared_here.thunk):
+        (runWithKeyDown):
+        * platform/ios-wk1/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+
 2018-07-16  Aaron Chu  <[email protected]>
 
         AX: Audit Tab should have an Audit Manager

Added: trunk/LayoutTests/media/no-fullscreen-when-hidden-expected.txt (0 => 233865)


--- trunk/LayoutTests/media/no-fullscreen-when-hidden-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/no-fullscreen-when-hidden-expected.txt	2018-07-16 20:39:37 UTC (rev 233865)
@@ -0,0 +1,7 @@
+Fullscreen should be prevented when page is not visible.
+
+RUN(video.play())
+Attempting to go into Full Screen
+RUN(video.webkitEnterFullscreen())
+END OF TEST
+

Added: trunk/LayoutTests/media/no-fullscreen-when-hidden.html (0 => 233865)


--- trunk/LayoutTests/media/no-fullscreen-when-hidden.html	                        (rev 0)
+++ trunk/LayoutTests/media/no-fullscreen-when-hidden.html	2018-07-16 20:39:37 UTC (rev 233865)
@@ -0,0 +1,60 @@
+<html>
+<head>
+    <title>Test fullscreen video going into pip should exit fullscreen</title>
+    <script src=""
+    <script src=""
+    <script>
+
+        var divElement
+
+        function init()
+        {
+            if (!window.testRunner || !testRunner.runUIScript) {
+                consoleWrite("This test requires testRunner.runUIScript()");
+                return;
+            }
+
+            findMediaElement();
+            video.src = "" 'content/test');
+            divElement = document.getElementById("divElement");
+            video.addEventListener('playing', onplaying);
+            run('video.play()');
+        }
+
+        function getUIScript()
+        {
+            return `
+            (function() {
+                uiController.removeViewFromWindow(function() {
+                    uiController.uiScriptComplete('');
+                });
+            })();`
+        }
+
+        function onplaying()
+        {
+            waitForEventAndFail('webkitpresentationmodechanged');
+            waitForEventAndFail('webkitbeginfullscreen');
+            waitForEventAndFail('webkitfullscreenchange');
+
+            testRunner.runUIScript(getUIScript(), function(result) {
+                runWithKeyDown(function(){ 
+                    consoleWrite("Attempting to go into Full Screen");
+                    if (video.webkitRequestFullscreen)
+                    	video.webkitRequestFullscreen(); 
+                    run('video.webkitEnterFullscreen()');
+                    if (divElement.webkitRequestFullscreen)
+                    	divElement.webkitRequestFullscreen();
+                    endTestLater()
+                });
+            });
+        }
+    </script>
+</head>
+<body _onload_="init()">
+    Fullscreen should be prevented when page is not visible.<br>
+    <div id="divElement"></div>
+    <video controls></video>
+</body>
+</html>
+

Modified: trunk/LayoutTests/media/video-test.js (233864 => 233865)


--- trunk/LayoutTests/media/video-test.js	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/LayoutTests/media/video-test.js	2018-07-16 20:39:37 UTC (rev 233865)
@@ -441,12 +441,9 @@
 
 function runWithKeyDown(fn, preventDefault) 
 {
-    // FIXME: WKTR does not yet support the keyDown() message.  Do a mouseDown here
-    // instead until keyDown support is added.
-    var eventName = !window.testRunner || eventSender.keyDown ? 'keypress' : 'mousedown'
-
+    var eventName = 'keypress'
     function thunk(event) {
-        if (preventDefault)
+        if (preventDefault && event !== undefined)
             event.preventDefault();
 
         document.removeEventListener(eventName, thunk, false);
@@ -457,12 +454,8 @@
     }
     document.addEventListener(eventName, thunk, false);
 
-    if (window.testRunner) {
-        if (eventSender.keyDown)
-            eventSender.keyDown("a", []);
-        else
-            eventSender.mouseDown();
-    }
+    if (window.internals)
+        internals.withUserGesture(thunk);
 }
 
 function shouldResolve(promise) {

Modified: trunk/LayoutTests/platform/ios-wk1/TestExpectations (233864 => 233865)


--- trunk/LayoutTests/platform/ios-wk1/TestExpectations	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/LayoutTests/platform/ios-wk1/TestExpectations	2018-07-16 20:39:37 UTC (rev 233865)
@@ -21,6 +21,9 @@
 webrtc [ Skip ]
 fast/events/constructors/media-stream-event-constructor.html
 
+# Not supported on WK1
+media/no-fullscreen-when-hidden.html [ Skip ]
+
 # <rdar://problem/6501130> LayoutTests: Enable editing tests after we support editing
 editing/deleting/4922367.html
 editing/deleting/5126166.html

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (233864 => 233865)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2018-07-16 20:39:37 UTC (rev 233865)
@@ -320,6 +320,9 @@
 webkit.org/b/156069 imported/w3c/web-platform-tests/html/semantics/text-level-semantics/the-a-element/a-download-click.html [ Skip ]
 webkit.org/b/156069 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-area-element/area-download-click.html [ Skip ]
 
+# Not supported on WK1
+media/no-fullscreen-when-hidden.html [ Skip ]
+
 webkit.org/b/169523 [ Debug ] imported/w3c/web-platform-tests/html/dom/interfaces.worker.html [ Failure ]
 
 imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_no_argument.html [ Pass Failure ]

Modified: trunk/Source/WebCore/ChangeLog (233864 => 233865)


--- trunk/Source/WebCore/ChangeLog	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebCore/ChangeLog	2018-07-16 20:39:37 UTC (rev 233865)
@@ -1,3 +1,29 @@
+2018-07-16  Jeremy Jones  <[email protected]>
+
+        Fullscreen requires active document.
+        https://bugs.webkit.org/show_bug.cgi?id=186226
+        rdar://problem/36187413
+
+        Reviewed by Jer Noble.
+
+        Test: media/no-fullscreen-when-hidden.html
+
+        This change guarantees the document to be visible for both element fullscreen and video fullscreen.
+
+        User gesture is not enough to guarantee that the document is visible when fullscreen is initiated
+        because _javascript_ can spin wait before initiating fullscreen. During that spin the page or window might
+        be hidden.
+
+        Document::hidden() can't be relied upon because it won't update while _javascript_ spins.
+
+        This change adds a sync call to the UI process to get the current UI visibility state.
+
+        * dom/Document.cpp:
+        (WebCore::Document::requestFullScreenForElement):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::enterFullscreen):
+        * page/ChromeClient.h:
+
 2018-07-16  Alex Christensen  <[email protected]>
 
         Reduce size of NetworkLoadMetrics and therefore ResourceResponse

Modified: trunk/Source/WebCore/dom/Document.cpp (233864 => 233865)


--- trunk/Source/WebCore/dom/Document.cpp	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebCore/dom/Document.cpp	2018-07-16 20:39:37 UTC (rev 233865)
@@ -6019,6 +6019,10 @@
         // an event named fullscreenerror with its bubbles attribute set to true on the context object's 
         // node document:
 
+        // Don't allow fullscreen if document is hidden.
+        if (!page() || !page()->chrome().client().isViewVisible())
+            break;
+
         // The context object is not in a document.
         if (!element->isConnected())
             break;

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (233864 => 233865)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2018-07-16 20:39:37 UTC (rev 233865)
@@ -5910,6 +5910,11 @@
     if (m_videoFullscreenMode == mode)
         return;
 
+    if (!document().page() || !document().page()->chrome().client().isViewVisible()) {
+        ALWAYS_LOG(LOGIDENTIFIER, "  returning because document is hidden");
+        return;
+    }
+
     m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
     m_waitingToEnterFullscreen = true;
 
@@ -5936,7 +5941,7 @@
     configureMediaControls();
     if (hasMediaControls())
         mediaControls()->enteredFullscreen();
-    if (document().page() && is<HTMLVideoElement>(*this)) {
+    if (is<HTMLVideoElement>(*this)) {
         HTMLVideoElement& asVideo = downcast<HTMLVideoElement>(*this);
         if (document().page()->chrome().client().supportsVideoFullscreen(m_videoFullscreenMode)) {
             document().page()->chrome().client().enterVideoFullscreenForVideoElement(asVideo, m_videoFullscreenMode, m_videoFullscreenStandby);

Modified: trunk/Source/WebCore/page/ChromeClient.h (233864 => 233865)


--- trunk/Source/WebCore/page/ChromeClient.h	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebCore/page/ChromeClient.h	2018-07-16 20:39:37 UTC (rev 233865)
@@ -487,6 +487,8 @@
 
     virtual String signedPublicKeyAndChallengeString(unsigned, const String&, const URL&) const { return emptyString(); }
 
+    virtual bool isViewVisible() { return true; }
+
 protected:
     virtual ~ChromeClient() = default;
 };

Modified: trunk/Source/WebKit/ChangeLog (233864 => 233865)


--- trunk/Source/WebKit/ChangeLog	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebKit/ChangeLog	2018-07-16 20:39:37 UTC (rev 233865)
@@ -1,3 +1,29 @@
+2018-07-16  Jeremy Jones  <[email protected]>
+
+        Fullscreen requires active document.
+        https://bugs.webkit.org/show_bug.cgi?id=186226
+        rdar://problem/36187413
+
+        Reviewed by Jer Noble.
+
+        This change guarantees the document to be visible for both element fullscreen and video fullscreen.
+
+        User gesture is not enough to guarantee that the document is visible when fullscreen is initiated
+        because _javascript_ can spin wait before initiating fullscreen. During that spin the page or window might
+        be hidden.
+
+        Document::hidden() can't be relied upon because it won't update while _javascript_ spins.
+
+        This change adds a sync call to the UI process to get the current UI visibility state.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::getIsViewVisible):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::isViewVisible):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+
 2018-07-16  Tim Horton  <[email protected]>
 
         REGRESSION (r233502): Camera in <input type=file> becomes unresponsive after attempting to dismiss it

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (233864 => 233865)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-07-16 20:39:37 UTC (rev 233865)
@@ -7829,4 +7829,9 @@
     m_process->send(Messages::WebPage::SetDefersLoading(defersLoading), m_pageID);
 }
 
+void WebPageProxy::getIsViewVisible(bool& result)
+{
+    result = isViewVisible();
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (233864 => 233865)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-07-16 20:39:37 UTC (rev 233865)
@@ -1452,6 +1452,7 @@
     void getMenuBarIsVisible(Messages::WebPageProxy::GetMenuBarIsVisible::DelayedReply&&);
     void setStatusBarIsVisible(bool statusBarIsVisible);
     void getStatusBarIsVisible(Messages::WebPageProxy::GetStatusBarIsVisible::DelayedReply&&);
+    void getIsViewVisible(bool&);
     void setIsResizable(bool isResizable);
     void screenToRootView(const WebCore::IntPoint& screenPoint, Messages::WebPageProxy::ScreenToRootView::DelayedReply&&);
     void rootViewToScreen(const WebCore::IntRect& viewRect, Messages::WebPageProxy::RootViewToScreen::DelayedReply&&);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (233864 => 233865)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2018-07-16 20:39:37 UTC (rev 233865)
@@ -61,6 +61,7 @@
     GetWindowFrame() -> (WebCore::FloatRect windowFrame) Delayed
     ScreenToRootView(WebCore::IntPoint screenPoint) -> (WebCore::IntPoint windowPoint) Delayed
     RootViewToScreen(WebCore::IntRect rect) -> (WebCore::IntRect screenFrame) Delayed
+    GetIsViewVisible() -> (bool result)
 
 #if PLATFORM(COCOA)
     ShowValidationMessage(WebCore::IntRect anchorRect, String message)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (233864 => 233865)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2018-07-16 20:39:37 UTC (rev 233865)
@@ -1311,4 +1311,11 @@
 }
 #endif
 
+bool WebChromeClient::isViewVisible()
+{
+    bool isVisible = false;
+    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::GetIsViewVisible(), Messages::WebPageProxy::GetIsViewVisible::Reply(isVisible), m_page.pageID());
+    return isVisible;
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (233864 => 233865)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2018-07-16 20:32:07 UTC (rev 233864)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2018-07-16 20:39:37 UTC (rev 233865)
@@ -367,6 +367,8 @@
     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
 #endif
 
+    bool isViewVisible() final;
+
     String m_cachedToolTip;
     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
     mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to