Title: [255826] trunk/Tools
- Revision
- 255826
- Author
- [email protected]
- Date
- 2020-02-05 10:08:54 -0800 (Wed, 05 Feb 2020)
Log Message
REGRESSION(r255595): page not closed after beforeunload handler returns true
https://bugs.webkit.org/show_bug.cgi?id=207189
<rdar://problem/59149593>
Reviewed by Youenn Fablet.
Add API test coverage for fix landed in r255677.
* TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm:
(-[SlowBeforeUnloadPromptUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]):
(TEST):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (255825 => 255826)
--- trunk/Tools/ChangeLog 2020-02-05 18:08:03 UTC (rev 255825)
+++ trunk/Tools/ChangeLog 2020-02-05 18:08:54 UTC (rev 255826)
@@ -1,3 +1,17 @@
+2020-02-05 Chris Dumez <[email protected]>
+
+ REGRESSION(r255595): page not closed after beforeunload handler returns true
+ https://bugs.webkit.org/show_bug.cgi?id=207189
+ <rdar://problem/59149593>
+
+ Reviewed by Youenn Fablet.
+
+ Add API test coverage for fix landed in r255677.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm:
+ (-[SlowBeforeUnloadPromptUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]):
+ (TEST):
+
2020-02-05 Jonathan Bedard <[email protected]>
results.webkit.org should disable auto-capitalize over the search field
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm (255825 => 255826)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm 2020-02-05 18:08:03 UTC (rev 255825)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm 2020-02-05 18:08:54 UTC (rev 255826)
@@ -145,7 +145,8 @@
#if PLATFORM(MAC)
-static bool didRejectTryClose = false;
+static bool shouldRejectClosingViaPrompt = false;
+static bool didRespondToPrompt = false;
@interface SlowBeforeUnloadPromptUIDelegate : NSObject <WKUIDelegate>
@end
@@ -155,8 +156,8 @@
- (void)_webView:(WKWebView *)webView runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
- completionHandler(NO);
- didRejectTryClose = true;
+ completionHandler(shouldRejectClosingViaPrompt ? NO : YES);
+ didRespondToPrompt = true;
});
}
@@ -167,7 +168,7 @@
@end
-TEST(WebKit, SlowBeforeUnloadPrompt)
+TEST(WebKit, SlowBeforeUnloadPromptReject)
{
auto slowBeforeUnloadPromptUIDelegate = adoptNS([[SlowBeforeUnloadPromptUIDelegate alloc] init]);
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
@@ -181,9 +182,10 @@
TestWebKitAPI::Util::spinRunLoop(10);
+ shouldRejectClosingViaPrompt = true;
[webView _tryClose];
- TestWebKitAPI::Util::run(&didRejectTryClose);
+ TestWebKitAPI::Util::run(&didRespondToPrompt);
EXPECT_FALSE([webView _isClosed]);
TestWebKitAPI::Util::sleep(0.1);
@@ -190,6 +192,29 @@
EXPECT_FALSE([webView _isClosed]);
}
+TEST(WebKit, SlowBeforeUnloadPromptAllow)
+{
+ auto slowBeforeUnloadPromptUIDelegate = adoptNS([[SlowBeforeUnloadPromptUIDelegate alloc] init]);
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+ [webView setUIDelegate:slowBeforeUnloadPromptUIDelegate.get()];
+ [webView synchronouslyLoadTestPageNamed:@"beforeunload"];
+
+ TestWebKitAPI::Util::spinRunLoop(10);
+
+ // Need a user gesture on the page before being allowed to show the beforeunload prompt.
+ [webView sendClicksAtPoint:NSMakePoint(5, 5) numberOfClicks:1];
+
+ TestWebKitAPI::Util::spinRunLoop(10);
+
+ shouldRejectClosingViaPrompt = false;
+ [webView _tryClose];
+
+ TestWebKitAPI::Util::run(&didRespondToPrompt);
+
+ while (![webView _isClosed])
+ TestWebKitAPI::Util::sleep(0.1);
+}
+
static bool webViewDidCloseCalled = false;
static unsigned viewDidCloseCallCount = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes