WebDriver: thrown ObjC exception under -[WKFullScreenWindowController windowDidFailTo...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2018 21:45:14 +0000 (21:45 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2018 21:45:14 +0000 (21:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190098
<rdar://problem/42822671>

Reviewed by Brian Burg.

Source/WebKit:

Forcibly exit fullscreen in resetState(), while the VideoFullscreenManagerProxy is still valid.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetState):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/CloseWebViewAfterEnterFullscreen.mm: Added.
(-[CloseWebViewAfterEnterFullscreenUIDelegate _webViewDidEnterFullscreen:]):
(-[CloseWebViewAfterEnterFullscreenUIDelegate _webViewDidExitFullscreen:]):
(TestWebKitAPI::TEST):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/CloseWebViewAfterEnterFullscreen.mm [new file with mode: 0644]

index 1c99a64..d3c356c 100644 (file)
@@ -1,3 +1,16 @@
+2018-10-09  Jer Noble  <jer.noble@apple.com>
+
+        WebDriver: thrown ObjC exception under -[WKFullScreenWindowController windowDidFailToEnterFullScreen:] when session is terminated
+        https://bugs.webkit.org/show_bug.cgi?id=190098
+        <rdar://problem/42822671>
+
+        Reviewed by Brian Burg.
+
+        Forcibly exit fullscreen in resetState(), while the VideoFullscreenManagerProxy is still valid.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::resetState):
+
 2018-10-09  Daniel Bates  <dabates@apple.com>
 
         [iOS] Ignore some deprecated declarations
index 36b0e1e..108c6fa 100644 (file)
@@ -6111,7 +6111,10 @@ void WebPageProxy::resetState(ResetStateReason resetStateReason)
     }
 
 #if ENABLE(FULLSCREEN_API)
-    m_fullScreenManager = nullptr;
+    if (m_fullScreenManager) {
+        m_fullScreenManager->close();
+        m_fullScreenManager = nullptr;
+    }
 #endif
 
     if (m_openPanelResultListener) {
index fa891ca..662ca2f 100644 (file)
@@ -1,3 +1,17 @@
+2018-10-09  Jer Noble  <jer.noble@apple.com>
+
+        WebDriver: thrown ObjC exception under -[WKFullScreenWindowController windowDidFailToEnterFullScreen:] when session is terminated
+        https://bugs.webkit.org/show_bug.cgi?id=190098
+        <rdar://problem/42822671>
+
+        Reviewed by Brian Burg.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/CloseWebViewAfterEnterFullscreen.mm: Added.
+        (-[CloseWebViewAfterEnterFullscreenUIDelegate _webViewDidEnterFullscreen:]):
+        (-[CloseWebViewAfterEnterFullscreenUIDelegate _webViewDidExitFullscreen:]):
+        (TestWebKitAPI::TEST):
+
 2018-10-09  Jiewen Tan  <jiewen_tan@apple.com>
 
         [WebAuthN] Import CTAP HID message and packet structure from Chromium
index 83fef46..e1eb05f 100644 (file)
                CDC9442F1EF205D60059C3C4 /* mediastreamtrack-detached.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDC9442B1EF1FBD20059C3C4 /* mediastreamtrack-detached.html */; };
                CDCFA7AA1E45183200C2433D /* SampleMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDCFA7A91E45122F00C2433D /* SampleMap.cpp */; };
                CDE195B51CFE0B880053D256 /* FullscreenTopContentInset.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */; };
+               CDF92237216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDF92236216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm */; };
                CE06DF9B1E1851F200E570C9 /* SecurityOrigin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE06DF9A1E1851F200E570C9 /* SecurityOrigin.cpp */; };
                CE0947372063223B003C9BA0 /* SchemeRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE0947362063223B003C9BA0 /* SchemeRegistry.mm */; };
                CE14F1A4181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */; };
                CDCFA7A91E45122F00C2433D /* SampleMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SampleMap.cpp; sourceTree = "<group>"; };
                CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenTopContentInset.html; sourceTree = "<group>"; };
                CDE195B31CFE0ADE0053D256 /* FullscreenTopContentInset.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenTopContentInset.mm; sourceTree = "<group>"; };
+               CDF92236216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CloseWebViewAfterEnterFullscreen.mm; sourceTree = "<group>"; };
                CE06DF9A1E1851F200E570C9 /* SecurityOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecurityOrigin.cpp; sourceTree = "<group>"; };
                CE0947362063223B003C9BA0 /* SchemeRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SchemeRegistry.mm; sourceTree = "<group>"; };
                CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = WillPerformClientRedirectToURLCrash.html; sourceTree = "<group>"; };
                                1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */,
                                1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */,
                                5CB18BA71F5645B200EE23C4 /* ClickAutoFillButton.mm */,
+                               CDF92236216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm */,
                                1AAD19F51C7CE20300831E47 /* Coding.mm */,
                                7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */,
                                5C4A84941F7EEFD400ACFC54 /* Configuration.mm */,
                                5C0BF88D1DD5964D00B00328 /* MemoryPressureHandler.mm in Sources */,
                                7C83E0B71D0A64B800FEBCF3 /* MenuTypesForMouseEvents.cpp in Sources */,
                                5C0BF8941DD599C900B00328 /* MenuTypesForMouseEvents.mm in Sources */,
+                               CDF92237216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm in Sources */,
                                5165FE04201EE620009F7EC3 /* MessagePortProviders.mm in Sources */,
                                A5B149DE1F5A19EA00C6DAFF /* MIMETypeRegistry.cpp in Sources */,
                                51CD1C6C1B38CE4300142CA5 /* ModalAlerts.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/CloseWebViewAfterEnterFullscreen.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/CloseWebViewAfterEnterFullscreen.mm
new file mode 100644 (file)
index 0000000..b18f4ca
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2018 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 WK_API_ENABLED && PLATFORM(MAC)
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKFullscreenDelegate.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/Seconds.h>
+
+static bool didEnterFullscreen;
+static bool didExitFullscreen;
+
+@interface CloseWebViewAfterEnterFullscreenUIDelegate : NSObject <_WKFullscreenDelegate>
+@end
+
+@implementation CloseWebViewAfterEnterFullscreenUIDelegate
+
+- (void)_webViewDidEnterFullscreen:(WKWebView *)webView
+{
+    didEnterFullscreen = true;
+}
+
+- (void)_webViewDidExitFullscreen:(WKWebView *)webView
+{
+    didExitFullscreen = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(CloseWebViewAfterEnterFullscreen, VideoFullscreen)
+{
+    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [configuration preferences]._fullScreenEnabled = YES;
+    RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
+    RetainPtr<CloseWebViewAfterEnterFullscreenUIDelegate> handler = adoptNS([[CloseWebViewAfterEnterFullscreenUIDelegate alloc] init]);
+    [webView _setFullscreenDelegate:handler.get()];
+
+    [webView synchronouslyLoadHTMLString:@"<video src=\"video-with-audio.mp4\" controls></video>"];
+
+    didEnterFullscreen = false;
+    [webView evaluateJavaScript:@"document.querySelector('video').webkitEnterFullscreen()" completionHandler: nil];
+    TestWebKitAPI::Util::run(&didEnterFullscreen);
+    ASSERT_TRUE(didEnterFullscreen);
+
+    // Should not crash:
+    [webView _close];
+}
+
+
+TEST(CloseWebViewAfterEnterFullscreen, ElementFullscreen)
+{
+    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [configuration preferences]._fullScreenEnabled = YES;
+    RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
+    RetainPtr<CloseWebViewAfterEnterFullscreenUIDelegate> handler = adoptNS([[CloseWebViewAfterEnterFullscreenUIDelegate alloc] init]);
+    [webView _setFullscreenDelegate:handler.get()];
+
+    [webView synchronouslyLoadHTMLString:@"<div style=\"width:100px;height:100px;background-color:red;\"></div>"];
+
+    didEnterFullscreen = false;
+    [webView evaluateJavaScript:@"document.querySelector('div').webkitRequestFullscreen()" completionHandler: nil];
+    TestWebKitAPI::Util::run(&didEnterFullscreen);
+    ASSERT_TRUE(didEnterFullscreen);
+
+    // Should not crash:
+    [webView _close];
+}
+
+} // namespace TestWebKitAPI
+
+#endif