Title: [267279] trunk
Revision
267279
Author
commit-qu...@webkit.org
Date
2020-09-18 13:17:10 -0700 (Fri, 18 Sep 2020)

Log Message

WKWebView._tryClose should return whether it succeeded or not
https://bugs.webkit.org/show_bug.cgi?id=216660

Patch by Alex Christensen <achristen...@webkit.org> on 2020-09-18
Reviewed by Tim Horton.

Source/WebKit:

The return value of WKPageTryClose is used by Safari.
In order to migrate to WKWebView _tryClose, we need to expose this return value.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _tryClose]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (267278 => 267279)


--- trunk/Source/WebKit/ChangeLog	2020-09-18 20:15:50 UTC (rev 267278)
+++ trunk/Source/WebKit/ChangeLog	2020-09-18 20:17:10 UTC (rev 267279)
@@ -1,3 +1,17 @@
+2020-09-18  Alex Christensen  <achristen...@webkit.org>
+
+        WKWebView._tryClose should return whether it succeeded or not
+        https://bugs.webkit.org/show_bug.cgi?id=216660
+
+        Reviewed by Tim Horton.
+
+        The return value of WKPageTryClose is used by Safari.
+        In order to migrate to WKWebView _tryClose, we need to expose this return value.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _tryClose]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
 2020-09-18  Sihui Liu  <sihui_...@apple.com>
 
         Webpages flash when getting closed

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (267278 => 267279)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-09-18 20:15:50 UTC (rev 267278)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-09-18 20:17:10 UTC (rev 267279)
@@ -2094,9 +2094,9 @@
     _page->close();
 }
 
-- (void)_tryClose
+- (BOOL)_tryClose
 {
-    _page->tryClose();
+    return _page->tryClose();
 }
 
 - (BOOL)_isClosed

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (267278 => 267279)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2020-09-18 20:15:50 UTC (rev 267278)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2020-09-18 20:17:10 UTC (rev 267279)
@@ -199,7 +199,7 @@
 @property (nonatomic, readonly, getter=_isShowingNavigationGestureSnapshot) BOOL _showingNavigationGestureSnapshot;
 
 - (void)_close;
-- (void)_tryClose WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (BOOL)_tryClose WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (BOOL)_isClosed WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 - (void)_updateWebsitePolicies:(_WKWebsitePolicies *)websitePolicies WK_API_DEPRECATED_WITH_REPLACEMENT("-_updateWebpagePreferences:", macos(10.13, WK_MAC_TBA), ios(11.3, WK_IOS_TBA));

Modified: trunk/Tools/ChangeLog (267278 => 267279)


--- trunk/Tools/ChangeLog	2020-09-18 20:15:50 UTC (rev 267278)
+++ trunk/Tools/ChangeLog	2020-09-18 20:17:10 UTC (rev 267279)
@@ -1,5 +1,15 @@
 2020-09-18  Alex Christensen  <achristen...@webkit.org>
 
+        WKWebView._tryClose should return whether it succeeded or not
+        https://bugs.webkit.org/show_bug.cgi?id=216660
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm:
+        (TEST):
+
+2020-09-18  Alex Christensen  <achristen...@webkit.org>
+
         Make TLSVersion.NetworkSession API test more robust
         https://bugs.webkit.org/show_bug.cgi?id=216704
         <rdar://problem/68643674>

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm (267278 => 267279)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm	2020-09-18 20:15:50 UTC (rev 267278)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm	2020-09-18 20:17:10 UTC (rev 267279)
@@ -26,10 +26,11 @@
 #import "config.h"
 
 #import "PlatformUtilities.h"
+#import "TestWKWebView.h"
 #import <WebKit/WKPreferences.h>
 #import <WebKit/WKUIDelegatePrivate.h>
-#import <WebKit/WKWebView.h>
 #import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/WKWebViewPrivate.h>
 #import <WebKit/WKWindowFeaturesPrivate.h>
 #import <wtf/RetainPtr.h>
 
@@ -339,3 +340,12 @@
     while (![[[webView URL] absoluteString] hasPrefix:@"file:///"])
         TestWebKitAPI::Util::spinRunLoop();
 }
+
+TEST(WebKit, TryClose)
+{
+    auto webView = adoptNS([TestWKWebView new]);
+    [webView synchronouslyLoadHTMLString:@"load something"];
+    EXPECT_TRUE([webView _tryClose]);
+    [webView synchronouslyLoadHTMLString:@"<body _onunload_='runScriptThatDoesNotNeedToExist()'/>"];
+    EXPECT_FALSE([webView _tryClose]);
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to