Title: [260278] trunk
Revision
260278
Author
[email protected]
Date
2020-04-17 13:41:10 -0700 (Fri, 17 Apr 2020)

Log Message

Bring Fullscreen API + alert() behavior from iOS to macOS
https://bugs.webkit.org/show_bug.cgi?id=210662

Reviewed by Eric Carlson.

Source/WebKit:

When a page is showing an alert(), all non-synchronous messages will be blocked until the sync XPC for alert()
ends. And when exiting fullscreen, we block completing the fullscreen exit animation until a repaint XPC completes.
So a page that is showing an alert() will never fully exit element fullscreen mode.

On iOS, we fixed this behavior by exiting fullscreen mode whenever the page shows an alert() or prompt(). We should
bring this behavior to macOS as well.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::runJavaScriptAlert):
(WebKit::WebPageProxy::runJavaScriptConfirm):
(WebKit::WebPageProxy::runJavaScriptPrompt):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/FullscreenAlert.mm: Added.
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (260277 => 260278)


--- trunk/Source/WebKit/ChangeLog	2020-04-17 20:15:01 UTC (rev 260277)
+++ trunk/Source/WebKit/ChangeLog	2020-04-17 20:41:10 UTC (rev 260278)
@@ -1,3 +1,22 @@
+2020-04-17  Jer Noble  <[email protected]>
+
+        Bring Fullscreen API + alert() behavior from iOS to macOS
+        https://bugs.webkit.org/show_bug.cgi?id=210662
+
+        Reviewed by Eric Carlson.
+
+        When a page is showing an alert(), all non-synchronous messages will be blocked until the sync XPC for alert()
+        ends. And when exiting fullscreen, we block completing the fullscreen exit animation until a repaint XPC completes.
+        So a page that is showing an alert() will never fully exit element fullscreen mode.
+
+        On iOS, we fixed this behavior by exiting fullscreen mode whenever the page shows an alert() or prompt(). We should
+        bring this behavior to macOS as well.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::runJavaScriptAlert):
+        (WebKit::WebPageProxy::runJavaScriptConfirm):
+        (WebKit::WebPageProxy::runJavaScriptPrompt):
+
 2020-04-17  Don Olmstead  <[email protected]>
 
         [CMake] Add WebKit::WebCore target

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (260277 => 260278)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-04-17 20:15:01 UTC (rev 260277)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-04-17 20:41:10 UTC (rev 260278)
@@ -5581,9 +5581,7 @@
     WebFrameProxy* frame = m_process->webFrame(frameID);
     MESSAGE_CHECK(m_process, frame);
 
-#if PLATFORM(IOS_FAMILY)
     exitFullscreenImmediately();
-#endif
 
     // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
     m_process->stopResponsivenessTimer();
@@ -5600,9 +5598,7 @@
     WebFrameProxy* frame = m_process->webFrame(frameID);
     MESSAGE_CHECK(m_process, frame);
 
-#if PLATFORM(IOS_FAMILY)
     exitFullscreenImmediately();
-#endif
 
     // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
     m_process->stopResponsivenessTimer();
@@ -5620,9 +5616,8 @@
     WebFrameProxy* frame = m_process->webFrame(frameID);
     MESSAGE_CHECK(m_process, frame);
 
-#if PLATFORM(IOS_FAMILY)
     exitFullscreenImmediately();
-#endif
+
     // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
     m_process->stopResponsivenessTimer();
 

Modified: trunk/Tools/ChangeLog (260277 => 260278)


--- trunk/Tools/ChangeLog	2020-04-17 20:15:01 UTC (rev 260277)
+++ trunk/Tools/ChangeLog	2020-04-17 20:41:10 UTC (rev 260278)
@@ -1,3 +1,14 @@
+2020-04-17  Jer Noble  <[email protected]>
+
+        Bring Fullscreen API + alert() behavior from iOS to macOS
+        https://bugs.webkit.org/show_bug.cgi?id=210662
+
+        Reviewed by Eric Carlson.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/FullscreenAlert.mm: Added.
+        (TestWebKitAPI::TEST):
+
 2020-04-17  Don Olmstead  <[email protected]>
 
         [CMake] Add WebKit::WebCore target

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (260277 => 260278)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-04-17 20:15:01 UTC (rev 260277)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-04-17 20:41:10 UTC (rev 260278)
@@ -977,6 +977,7 @@
 		CDC8E4971BC6F10800594FEC /* video-without-audio.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDC8E48C1BC5C96200594FEC /* video-without-audio.mp4 */; };
 		CDC9442E1EF1FC080059C3C4 /* MediaStreamTrackDetached.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC9442C1EF1FC080059C3C4 /* MediaStreamTrackDetached.mm */; };
 		CDC9442F1EF205D60059C3C4 /* mediastreamtrack-detached.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDC9442B1EF1FBD20059C3C4 /* mediastreamtrack-detached.html */; };
+		CDCF78A8244A32F700480311 /* FullscreenAlert.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDCF78A7244A2EDB00480311 /* FullscreenAlert.mm */; };
 		CDCFA7AA1E45183200C2433D /* SampleMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDCFA7A91E45122F00C2433D /* SampleMap.cpp */; };
 		CDCFFEC122E26A1500DF4223 /* NoPauseWhenSwitchingTabs.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDCFFEC022E268D500DF4223 /* NoPauseWhenSwitchingTabs.mm */; };
 		CDD68F0D22C18317000CF0AE /* WKWebViewCloseAllMediaPresentations.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDD68F0C22C18317000CF0AE /* WKWebViewCloseAllMediaPresentations.mm */; };
@@ -2583,6 +2584,7 @@
 		CDC8E48C1BC5C96200594FEC /* video-without-audio.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "video-without-audio.mp4"; sourceTree = "<group>"; };
 		CDC9442B1EF1FBD20059C3C4 /* mediastreamtrack-detached.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "mediastreamtrack-detached.html"; sourceTree = "<group>"; };
 		CDC9442C1EF1FC080059C3C4 /* MediaStreamTrackDetached.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaStreamTrackDetached.mm; sourceTree = "<group>"; };
+		CDCF78A7244A2EDB00480311 /* FullscreenAlert.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenAlert.mm; sourceTree = "<group>"; };
 		CDCFA7A91E45122F00C2433D /* SampleMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SampleMap.cpp; sourceTree = "<group>"; };
 		CDCFFEC022E268D500DF4223 /* NoPauseWhenSwitchingTabs.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NoPauseWhenSwitchingTabs.mm; sourceTree = "<group>"; };
 		CDD68F0C22C18317000CF0AE /* WKWebViewCloseAllMediaPresentations.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewCloseAllMediaPresentations.mm; sourceTree = "<group>"; };
@@ -3050,6 +3052,7 @@
 				2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
 				2E92B8F8216490EA005B64F0 /* FontAttributes.mm */,
 				5CB5B3BD1FFC517E00C27BB0 /* FrameHandleSerialization.mm */,
+				CDCF78A7244A2EDB00480311 /* FullscreenAlert.mm */,
 				CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */,
 				3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */,
 				631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */,
@@ -5042,6 +5045,7 @@
 				7C83E0C11D0A652F00FEBCF3 /* ProvisionalURLNotChange.mm in Sources */,
 				5CFACF65226FD2DC0056C7D0 /* Proxy.mm in Sources */,
 				041A1E34216FFDBC00789E0A /* PublicSuffix.cpp in Sources */,
+				CDCF78A8244A32F700480311 /* FullscreenAlert.mm in Sources */,
 				7C83E0C21D0A653500FEBCF3 /* QuickLook.mm in Sources */,
 				6B4E861C2220A5520022F389 /* RegistrableDomain.cpp in Sources */,
 				7CCE7F0D1A411AE600447C4C /* ReloadPageAfterCrash.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenAlert.mm (0 => 260278)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenAlert.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenAlert.mm	2020-04-17 20:41:10 UTC (rev 260278)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if PLATFORM(COCOA)
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static bool isInFullscreen = false;
+static bool isOutOfFullscreen = false;
+
+TEST(Fullscreen, Alert)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
+    [configuration preferences]._fullScreenEnabled = YES;
+
+    auto checkFullscreen = [&] {
+        isInFullscreen = [webView _isInFullscreen];
+        isOutOfFullscreen = !isInFullscreen;
+    };
+
+    [webView performAfterReceivingMessage:@"fullscreenchange" action:checkFullscreen];
+
+    [webView synchronouslyLoadHTMLString:
+        @"<html><head><script>"
+        @"document.addEventListener('webkitfullscreenchange', e => { window.webkit.messageHandlers.testHandler.postMessage(\"fullscreenchange\") });"
+        @"function enterFullscreen() { document.body.webkitRequestFullscreen(); }"
+        @"</script></head><body>some text</body></html>"];
+
+    ASSERT_FALSE([webView _isInFullscreen]);
+
+    [webView evaluateJavaScript:@"enterFullscreen()" completionHandler:nil];
+
+    TestWebKitAPI::Util::run(&isInFullscreen);
+
+    [webView evaluateJavaScript:@"alert()" completionHandler:nil];
+
+    TestWebKitAPI::Util::run(&isOutOfFullscreen);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to