Title: [248039] trunk
Revision
248039
Author
wenson_hs...@apple.com
Date
2019-07-31 07:41:16 -0700 (Wed, 31 Jul 2019)

Log Message

[iOS 13] Safari crashes when closing a tab with a focused element if the unified field has focus
https://bugs.webkit.org/show_bug.cgi?id=200291
<rdar://problem/53717946>

Reviewed by Megan Gardner.

Source/WebKit:

Makes -requestAutocorrectionContextWithCompletionHandler: robust in the case where the web page has been closed,
and there is no Connection object to use when waiting for a sync IPC response.

Test: AutocorrectionTests.RequestAutocorrectionContextAfterClosingPage

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):

Tools:

Add an API test to exercise the scenario of synchronously requesting the autocorrection context immediately
after closing the web view, while the web view's content view isn't the first responder.

* TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm:
* TestWebKitAPI/ios/UIKitSPI.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (248038 => 248039)


--- trunk/Source/WebKit/ChangeLog	2019-07-31 14:38:42 UTC (rev 248038)
+++ trunk/Source/WebKit/ChangeLog	2019-07-31 14:41:16 UTC (rev 248039)
@@ -1,3 +1,19 @@
+2019-07-31  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS 13] Safari crashes when closing a tab with a focused element if the unified field has focus
+        https://bugs.webkit.org/show_bug.cgi?id=200291
+        <rdar://problem/53717946>
+
+        Reviewed by Megan Gardner.
+
+        Makes -requestAutocorrectionContextWithCompletionHandler: robust in the case where the web page has been closed,
+        and there is no Connection object to use when waiting for a sync IPC response.
+
+        Test: AutocorrectionTests.RequestAutocorrectionContextAfterClosingPage
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):
+
 2019-07-31  Chris Fleizach  <cfleiz...@apple.com>
 
         AX: com.apple.WebKit.WebContent at com.apple.WebKit: -[WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames]

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248038 => 248039)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-31 14:38:42 UTC (rev 248038)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-31 14:41:16 UTC (rev 248039)
@@ -3890,6 +3890,11 @@
     }
 #endif
 
+    if (!_page->hasRunningProcess()) {
+        completionHandler(WKAutocorrectionContext.emptyAutocorrectionContext);
+        return;
+    }
+
     // FIXME: Remove the synchronous call when <rdar://problem/16207002> is fixed.
     const bool useSyncRequest = true;
 
@@ -3904,7 +3909,6 @@
     if (useSyncRequest) {
         _page->process().connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::HandleAutocorrectionContext>(_page->pageID(), 1_s, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives);
         [self _cancelPendingAutocorrectionContextHandler];
-        return;
     }
 }
 

Modified: trunk/Tools/ChangeLog (248038 => 248039)


--- trunk/Tools/ChangeLog	2019-07-31 14:38:42 UTC (rev 248038)
+++ trunk/Tools/ChangeLog	2019-07-31 14:41:16 UTC (rev 248039)
@@ -1,3 +1,17 @@
+2019-07-31  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS 13] Safari crashes when closing a tab with a focused element if the unified field has focus
+        https://bugs.webkit.org/show_bug.cgi?id=200291
+        <rdar://problem/53717946>
+
+        Reviewed by Megan Gardner.
+
+        Add an API test to exercise the scenario of synchronously requesting the autocorrection context immediately
+        after closing the web view, while the web view's content view isn't the first responder.
+
+        * TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm:
+        * TestWebKitAPI/ios/UIKitSPI.h:
+
 2019-07-31  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Datalist element support for TextFieldInputType

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm (248038 => 248039)


--- trunk/Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm	2019-07-31 14:38:42 UTC (rev 248038)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm	2019-07-31 14:41:16 UTC (rev 248039)
@@ -94,4 +94,20 @@
     EXPECT_EQ(32, fontAfterScaling.pointSize);
 }
 
+TEST(AutocorrectionTests, RequestAutocorrectionContextAfterClosingPage)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] init]);
+    [webView synchronouslyLoadTestPageNamed:@"autofocused-text-input"];
+
+    auto contentView = [webView textInputContentView];
+    [contentView resignFirstResponder];
+    [webView _close];
+
+    bool done = false;
+    [contentView requestAutocorrectionContextWithCompletionHandler:[&] (UIWKAutocorrectionContext *) {
+        done = true;
+    }];
+    TestWebKitAPI::Util::run(&done);
+}
+
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h (248038 => 248039)


--- trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h	2019-07-31 14:38:42 UTC (rev 248038)
+++ trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h	2019-07-31 14:41:16 UTC (rev 248039)
@@ -156,8 +156,12 @@
 @property (nonatomic) CGRect lastRect;
 @end
 
+@interface UIWKAutocorrectionContext : NSObject
+@end
+
 @protocol UIWKInteractionViewProtocol
 - (void)requestAutocorrectionRectsForString:(NSString *)input withCompletionHandler:(void (^)(UIWKAutocorrectionRects *rectsForInput))completionHandler;
+- (void)requestAutocorrectionContextWithCompletionHandler:(void (^)(UIWKAutocorrectionContext *autocorrectionContext))completionHandler;
 @end
 
 IGNORE_WARNINGS_BEGIN("deprecated-implementations")
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to