Changeset 215598 in webkit


Ignore:
Timestamp:
Apr 20, 2017 6:02:47 PM (7 years ago)
Author:
beidson@apple.com
Message:

WebContent process becomes unresponsive after returning nil from async version of -webView:createWebViewWithConfiguration:...
<rdar://problem/31739023> and https://bugs.webkit.org/show_bug.cgi?id=171090

Reviewed by Andy Estes.

Source/WebKit2:

  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::UIClient::createNewPageCommon): Handle the perfectly valid "nil webView" case correctly.

Tools:

  • TestWebKitAPI/Tests/WebKit2/open-and-close-window.html:
  • TestWebKitAPI/Tests/WebKit2Cocoa/OpenAndCloseWindow.mm:

(resetToConsistentState):
(-[OpenAndCloseWindowUIDelegate webViewDidClose:]):
(-[OpenAndCloseWindowUIDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
(TEST):
(-[OpenAndCloseWindowUIDelegateAsync _webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:completionHandler:]):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r215589 r215598  
     12017-04-20  Brady Eidson  <beidson@apple.com>
     2
     3        WebContent process becomes unresponsive after returning nil from async version of -webView:createWebViewWithConfiguration:...
     4        <rdar://problem/31739023> and https://bugs.webkit.org/show_bug.cgi?id=171090
     5
     6        Reviewed by Andy Estes.
     7
     8        * UIProcess/Cocoa/UIDelegate.mm:
     9        (WebKit::UIDelegate::UIClient::createNewPageCommon): Handle the perfectly valid "nil webView" case correctly.
     10
    1112017-04-20  Dan Bernstein  <mitz@apple.com>
    212
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm

    r215577 r215598  
    195195            checker->didCallCompletionHandler();
    196196
    197             if (!webView)
     197            if (!webView) {
     198                completionHandler(nullptr);
    198199                return;
     200            }
    199201
    200202            if ([webView->_configuration _relatedWebView] != relatedWebView.get())
     
    202204
    203205            completionHandler(webView->_page.get());
    204 
    205206        }).get()];
    206207
  • trunk/Tools/ChangeLog

    r215594 r215598  
     12017-04-20  Brady Eidson  <beidson@apple.com>
     2
     3        WebContent process becomes unresponsive after returning nil from async version of -webView:createWebViewWithConfiguration:...
     4        <rdar://problem/31739023> and https://bugs.webkit.org/show_bug.cgi?id=171090
     5
     6        Reviewed by Andy Estes.
     7
     8        * TestWebKitAPI/Tests/WebKit2/open-and-close-window.html:
     9        * TestWebKitAPI/Tests/WebKit2Cocoa/OpenAndCloseWindow.mm:
     10        (resetToConsistentState):
     11        (-[OpenAndCloseWindowUIDelegate webViewDidClose:]):
     12        (-[OpenAndCloseWindowUIDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
     13        (TEST):
     14        (-[OpenAndCloseWindowUIDelegateAsync _webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:completionHandler:]):
     15
    1162017-04-20  Wenson Hsieh  <wenson_hsieh@apple.com>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2/open-and-close-window.html

    r173851 r215598  
    55if (document.location.search === "?close-window")
    66    window.close();
    7 else
    8     window.open("open-and-close-window.html?close-window");
     7else {
     8    if (!window.open("open-and-close-window.html?close-window"))
     9        window.close();
     10}
    911</script>
    1012</head>
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/OpenAndCloseWindow.mm

    r215586 r215598  
    4343static RetainPtr<OpenAndCloseWindowUIDelegateAsync> sharedUIDelegateAsync;
    4444
     45static void resetToConsistentState()
     46{
     47    isDone = false;
     48    openedWebView = nil;
     49    sharedUIDelegate = nil;
     50    sharedUIDelegateAsync = nil;
     51}
     52
    4553@interface OpenAndCloseWindowUIDelegate : NSObject <WKUIDelegate>
     54@property (nonatomic, assign) WKWebView *expectedClosingView;
    4655@end
    4756
     
    5059- (void)webViewDidClose:(WKWebView *)webView
    5160{
    52     EXPECT_EQ(openedWebView, webView);
     61    EXPECT_EQ(_expectedClosingView, webView);
    5362    isDone = true;
    5463}
     
    5867    openedWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
    5968    [openedWebView setUIDelegate:sharedUIDelegate.get()];
     69    _expectedClosingView = openedWebView.get();
    6070    return openedWebView.get();
    6171}
     
    6575TEST(WebKit2, OpenAndCloseWindow)
    6676{
    67     openedWebView = nullptr;
    68     isDone = false;
     77    resetToConsistentState();
    6978
    7079    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     
    8493@property (nonatomic) BOOL shouldCallback;
    8594@property (nonatomic, assign) id savedCompletionHandler;
    86 
     95@property (nonatomic) BOOL shouldCallbackWithNil;
    8796@end
    8897
     
    104113{
    105114    if (_shouldCallback) {
    106         dispatch_async(dispatch_get_main_queue(), ^ {
    107             openedWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
    108             [openedWebView setUIDelegate:sharedUIDelegateAsync.get()];
    109             completionHandler(openedWebView.get());
    110         });
     115        if (!_shouldCallbackWithNil) {
     116            dispatch_async(dispatch_get_main_queue(), ^ {
     117                openedWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
     118                [openedWebView setUIDelegate:sharedUIDelegateAsync.get()];
     119                self.expectedClosingView = openedWebView.get();
     120                completionHandler(openedWebView.get());
     121            });
     122        } else {
     123            dispatch_async(dispatch_get_main_queue(), ^ {
     124                self.expectedClosingView = webView;
     125                completionHandler(nil);
     126            });
     127        }
    111128        return;
    112129    }
     
    120137TEST(WebKit2, OpenAndCloseWindowAsync)
    121138{
    122     openedWebView = nullptr;
    123     isDone = false;
     139    resetToConsistentState();
    124140
    125141    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     
    137153}
    138154
     155TEST(WebKit2, OpenAsyncWithNil)
     156{
     157    resetToConsistentState();
     158
     159    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     160
     161    sharedUIDelegateAsync = adoptNS([[OpenAndCloseWindowUIDelegateAsync alloc] init]);
     162    sharedUIDelegateAsync.get().shouldCallback = YES;
     163    sharedUIDelegateAsync.get().shouldCallbackWithNil = YES;
     164    [webView setUIDelegate:sharedUIDelegateAsync.get()];
     165
     166    [webView configuration].preferences.javaScriptCanOpenWindowsAutomatically = YES;
     167
     168    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"open-and-close-window" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
     169    [webView loadRequest:request];
     170
     171    TestWebKitAPI::Util::run(&isDone);
     172}
     173
    139174// https://bugs.webkit.org/show_bug.cgi?id=171083 - Try to figure out why this fails for some configs but not others, and resolve.
    140175//TEST(WebKit2, OpenAndCloseWindowAsyncCallbackException)
    141176//{
    142 //    openedWebView = nullptr;
    143 //    isDone = false;
     177//    resetToConsistentState();
    144178//
    145179//    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
Note: See TracChangeset for help on using the changeset viewer.