Changeset 255595 in webkit


Ignore:
Timestamp:
Feb 3, 2020 2:21:54 PM (4 years ago)
Author:
Chris Dumez
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):

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r255581 r255595  
     12020-02-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r253224) WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView
     4        https://bugs.webkit.org/show_bug.cgi?id=207121
     5        <rdar://problem/58880177>
     6
     7        Reviewed by Alex Christensen.
     8
     9        WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView, in case we time out
     10        while waiting for an answer from the WebProcess but the WebProcess eventually responds.
     11
     12        Change is covered by new API test.
     13
     14        * UIProcess/WebPageProxy.cpp:
     15        (WebKit::WebPageProxy::tryClose):
     16
    1172020-02-03  Eric Carlson  <eric.carlson@apple.com>
    218
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r255532 r255595  
    11301130            return;
    11311131
     1132        // If we timed out, don't ask the client to close again.
     1133        if (!m_tryCloseTimeoutTimer.isActive())
     1134            return;
     1135
    11321136        m_tryCloseTimeoutTimer.stop();
    11331137        if (shouldClose)
  • trunk/Tools/ChangeLog

    r255590 r255595  
     12020-02-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r253224) WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView
     4        https://bugs.webkit.org/show_bug.cgi?id=207121
     5        <rdar://problem/58880177>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/WebKit/beforeunload-slow.html: Added.
     13        * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm:
     14        (-[SlowBeforeUnloadHandlerUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]):
     15        (-[SlowBeforeUnloadHandlerUIDelegate webViewDidClose:]):
     16        (TEST):
     17
    1182020-02-03  Lauro Moura  <lmoura@igalia.com>
    219
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r255322 r255595  
    252252                46EBD8472372320F00223A6E /* RestoreScrollPosition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46EBD846237231E600223A6E /* RestoreScrollPosition.mm */; };
    253253                46FA2FEE23846CA5000CCB0C /* HTTPHeaderMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FA2FED23846C9A000CCB0C /* HTTPHeaderMap.cpp */; };
     254                46FACF7423E8842300A9EBC6 /* beforeunload-slow.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 46FACF7323E883EE00A9EBC6 /* beforeunload-slow.html */; };
    254255                4909EE3A2D09480C88982D56 /* Markable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EC79F168BE454E579E417B05 /* Markable.cpp */; };
    255256                4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
     
    12111212                                F41AB9A01EF4696B0083FA08 /* background-image-link-and-input.html in Copy Resources */,
    12121213                                464C764D230DF85C00AFB020 /* BadServiceWorkerRegistrations-4.sqlite3 in Copy Resources */,
     1214                                46FACF7423E8842300A9EBC6 /* beforeunload-slow.html in Copy Resources */,
    12131215                                46C3AEB323D0E529001B0680 /* beforeunload.html in Copy Resources */,
    12141216                                2DE71B001D49C3ED00904094 /* blinking-div.html in Copy Resources */,
     
    18161818                46EBD846237231E600223A6E /* RestoreScrollPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RestoreScrollPosition.mm; sourceTree = "<group>"; };
    18171819                46FA2FED23846C9A000CCB0C /* HTTPHeaderMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPHeaderMap.cpp; sourceTree = "<group>"; };
     1820                46FACF7323E883EE00A9EBC6 /* beforeunload-slow.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "beforeunload-slow.html"; sourceTree = "<group>"; };
    18181821                4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMedia.cpp; sourceTree = "<group>"; };
    18191822                4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = getUserMedia.html; sourceTree = "<group>"; };
     
    38913894                                C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */,
    38923895                                C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */,
     3896                                46FACF7323E883EE00A9EBC6 /* beforeunload-slow.html */,
    38933897                                46C3AEB223D0E50F001B0680 /* beforeunload.html */,
    38943898                                7C486BA01AA1254B003F6F9B /* bundle-file.html */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm

    r254711 r255595  
    191191}
    192192
    193 #endif
     193static bool webViewDidCloseCalled = false;
     194static unsigned viewDidCloseCallCount = 0;
     195
     196@interface SlowBeforeUnloadHandlerUIDelegate : NSObject <WKUIDelegate>
     197@end
     198
     199@implementation SlowBeforeUnloadHandlerUIDelegate
     200
     201- (void)_webView:(WKWebView *)webView runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler
     202{
     203    completionHandler(YES);
     204}
     205
     206- (void)webViewDidClose:(WKWebView *)webView
     207{
     208    ++viewDidCloseCallCount;
     209    webViewDidCloseCalled = true;
     210}
     211
     212@end
     213
     214TEST(WebKit, SlowBeforeUnloadHandlerSingleClosePageCall)
     215{
     216    auto slowBeforeUnloadHandlerUIDelegate = adoptNS([[SlowBeforeUnloadHandlerUIDelegate alloc] init]);
     217    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     218    [webView setUIDelegate:slowBeforeUnloadHandlerUIDelegate.get()];
     219    [webView synchronouslyLoadTestPageNamed:@"beforeunload-slow"];
     220
     221    TestWebKitAPI::Util::spinRunLoop(10);
     222
     223    // Need a user gesture on the page before being allowed to show the beforeunload prompt.
     224    [webView sendClicksAtPoint:NSMakePoint(5, 5) numberOfClicks:1];
     225
     226    TestWebKitAPI::Util::spinRunLoop(100);
     227
     228    [webView _tryClose];
     229
     230    TestWebKitAPI::Util::run(&webViewDidCloseCalled);
     231    EXPECT_EQ(1U, viewDidCloseCallCount);
     232    EXPECT_FALSE([webView _isClosed]);
     233
     234    TestWebKitAPI::Util::sleep(0.2);
     235
     236    EXPECT_EQ(1U, viewDidCloseCallCount);
     237    EXPECT_FALSE([webView _isClosed]);
     238}
     239
     240#endif
Note: See TracChangeset for help on using the changeset viewer.