- Revision
- 255595
- Author
- [email protected]
- Date
- 2020-02-03 14:21:54 -0800 (Mon, 03 Feb 2020)
Log Message
Regression(r253224) WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView
https://bugs.webkit.org/show_bug.cgi?id=207121
<rdar://problem/58880177>
Reviewed by Alex Christensen.
Source/WebKit:
WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView, in case we time out
while waiting for an answer from the WebProcess but the WebProcess eventually responds.
Change is covered by new API test.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::tryClose):
Tools:
Add API test coverage.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/beforeunload-slow.html: Added.
* TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm:
(-[SlowBeforeUnloadHandlerUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]):
(-[SlowBeforeUnloadHandlerUIDelegate webViewDidClose:]):
(TEST):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (255594 => 255595)
--- trunk/Source/WebKit/ChangeLog 2020-02-03 22:19:31 UTC (rev 255594)
+++ trunk/Source/WebKit/ChangeLog 2020-02-03 22:21:54 UTC (rev 255595)
@@ -1,3 +1,19 @@
+2020-02-03 Chris Dumez <[email protected]>
+
+ Regression(r253224) WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView
+ https://bugs.webkit.org/show_bug.cgi?id=207121
+ <rdar://problem/58880177>
+
+ Reviewed by Alex Christensen.
+
+ WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView, in case we time out
+ while waiting for an answer from the WebProcess but the WebProcess eventually responds.
+
+ Change is covered by new API test.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::tryClose):
+
2020-02-03 Eric Carlson <[email protected]>
[macOS] AirPlay sometimes stops after 60 minutes of playback
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (255594 => 255595)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-02-03 22:19:31 UTC (rev 255594)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-02-03 22:21:54 UTC (rev 255595)
@@ -1129,6 +1129,10 @@
if (!weakThis)
return;
+ // If we timed out, don't ask the client to close again.
+ if (!m_tryCloseTimeoutTimer.isActive())
+ return;
+
m_tryCloseTimeoutTimer.stop();
if (shouldClose)
closePage();
Modified: trunk/Tools/ChangeLog (255594 => 255595)
--- trunk/Tools/ChangeLog 2020-02-03 22:19:31 UTC (rev 255594)
+++ trunk/Tools/ChangeLog 2020-02-03 22:21:54 UTC (rev 255595)
@@ -1,3 +1,20 @@
+2020-02-03 Chris Dumez <[email protected]>
+
+ Regression(r253224) WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView
+ https://bugs.webkit.org/show_bug.cgi?id=207121
+ <rdar://problem/58880177>
+
+ Reviewed by Alex Christensen.
+
+ Add API test coverage.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit/beforeunload-slow.html: Added.
+ * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm:
+ (-[SlowBeforeUnloadHandlerUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]):
+ (-[SlowBeforeUnloadHandlerUIDelegate webViewDidClose:]):
+ (TEST):
+
2020-02-03 Lauro Moura <[email protected]>
[WebKitTestRunner] setOpenPanelFiles support in non-local tests
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (255594 => 255595)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-02-03 22:19:31 UTC (rev 255594)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-02-03 22:21:54 UTC (rev 255595)
@@ -251,6 +251,7 @@
46E816F81E79E29C00375ADC /* RestoreStateAfterTermination.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46E816F71E79E29100375ADC /* RestoreStateAfterTermination.mm */; };
46EBD8472372320F00223A6E /* RestoreScrollPosition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46EBD846237231E600223A6E /* RestoreScrollPosition.mm */; };
46FA2FEE23846CA5000CCB0C /* HTTPHeaderMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FA2FED23846C9A000CCB0C /* HTTPHeaderMap.cpp */; };
+ 46FACF7423E8842300A9EBC6 /* beforeunload-slow.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 46FACF7323E883EE00A9EBC6 /* beforeunload-slow.html */; };
4909EE3A2D09480C88982D56 /* Markable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EC79F168BE454E579E417B05 /* Markable.cpp */; };
4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
510477721D298DDD009747EB /* IDBDeleteRecovery.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5104776F1D298D85009747EB /* IDBDeleteRecovery.sqlite3 */; };
@@ -1210,6 +1211,7 @@
2E14A5291D3FE96B0010F35B /* autoplaying-video-with-audio.html in Copy Resources */,
F41AB9A01EF4696B0083FA08 /* background-image-link-and-input.html in Copy Resources */,
464C764D230DF85C00AFB020 /* BadServiceWorkerRegistrations-4.sqlite3 in Copy Resources */,
+ 46FACF7423E8842300A9EBC6 /* beforeunload-slow.html in Copy Resources */,
46C3AEB323D0E529001B0680 /* beforeunload.html in Copy Resources */,
2DE71B001D49C3ED00904094 /* blinking-div.html in Copy Resources */,
7C486BA11AA12567003F6F9B /* bundle-file.html in Copy Resources */,
@@ -1815,6 +1817,7 @@
46E816F71E79E29100375ADC /* RestoreStateAfterTermination.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RestoreStateAfterTermination.mm; sourceTree = "<group>"; };
46EBD846237231E600223A6E /* RestoreScrollPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RestoreScrollPosition.mm; sourceTree = "<group>"; };
46FA2FED23846C9A000CCB0C /* HTTPHeaderMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPHeaderMap.cpp; sourceTree = "<group>"; };
+ 46FACF7323E883EE00A9EBC6 /* beforeunload-slow.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "beforeunload-slow.html"; sourceTree = "<group>"; };
4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMedia.cpp; sourceTree = "<group>"; };
4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = getUserMedia.html; sourceTree = "<group>"; };
4A410F4D19AF7BEF002EBAB6 /* ondevicechange.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ondevicechange.html; sourceTree = "<group>"; };
@@ -3890,6 +3893,7 @@
C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */,
C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */,
C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */,
+ 46FACF7323E883EE00A9EBC6 /* beforeunload-slow.html */,
46C3AEB223D0E50F001B0680 /* beforeunload.html */,
7C486BA01AA1254B003F6F9B /* bundle-file.html */,
9BD4239B1E04BFD000200395 /* chinese-character-with-image.html */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/beforeunload-slow.html (0 => 255595)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/beforeunload-slow.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/beforeunload-slow.html 2020-02-03 22:21:54 UTC (rev 255595)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function sleep(millisecondsToWait) {
+ var now = new Date().getTime();
+ while (new Date().getTime() < now + millisecondsToWait) { }
+}
+
+_onbeforeunload_ = (ev) => {
+ sleep(70);
+}
+</script>
+</head>
+</html>
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm (255594 => 255595)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm 2020-02-03 22:19:31 UTC (rev 255594)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm 2020-02-03 22:21:54 UTC (rev 255595)
@@ -190,4 +190,51 @@
EXPECT_FALSE([webView _isClosed]);
}
+static bool webViewDidCloseCalled = false;
+static unsigned viewDidCloseCallCount = 0;
+
+@interface SlowBeforeUnloadHandlerUIDelegate : NSObject <WKUIDelegate>
+@end
+
+@implementation SlowBeforeUnloadHandlerUIDelegate
+
+- (void)_webView:(WKWebView *)webView runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler
+{
+ completionHandler(YES);
+}
+
+- (void)webViewDidClose:(WKWebView *)webView
+{
+ ++viewDidCloseCallCount;
+ webViewDidCloseCalled = true;
+}
+
+@end
+
+TEST(WebKit, SlowBeforeUnloadHandlerSingleClosePageCall)
+{
+ auto slowBeforeUnloadHandlerUIDelegate = adoptNS([[SlowBeforeUnloadHandlerUIDelegate alloc] init]);
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+ [webView setUIDelegate:slowBeforeUnloadHandlerUIDelegate.get()];
+ [webView synchronouslyLoadTestPageNamed:@"beforeunload-slow"];
+
+ 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(100);
+
+ [webView _tryClose];
+
+ TestWebKitAPI::Util::run(&webViewDidCloseCalled);
+ EXPECT_EQ(1U, viewDidCloseCallCount);
+ EXPECT_FALSE([webView _isClosed]);
+
+ TestWebKitAPI::Util::sleep(0.2);
+
+ EXPECT_EQ(1U, viewDidCloseCallCount);
+ EXPECT_FALSE([webView _isClosed]);
+}
+
#endif