Title: [243021] trunk/Tools
Revision
243021
Author
wenson_hs...@apple.com
Date
2019-03-15 16:09:40 -0700 (Fri, 15 Mar 2019)

Log Message

[iOS] Crash under -[TestRunnerWKWebView _didShowMenu] while running layout tests on iOS simulator
https://bugs.webkit.org/show_bug.cgi?id=195810

Reviewed by Tim Horton.

Ensure that the process of resetting web view state between tests doesn't also invoke testing callbacks
registered by the previous layout test. This fixes an occasional crash when hiding the callout menu after
ending certain layout tests.

* WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView dealloc]):
(-[TestRunnerWKWebView resetInteractionCallbacks]):

Pull logic to reset all of TestRunnerWKWebView's callback handler blocks into a separate helper method; use this
helper method when destroying the web view, and when resetting state between tests.

* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::platformResetStateToConsistentValues):

Hide the callout menu *after* clearing out interaction callbacks registered on the web view.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (243020 => 243021)


--- trunk/Tools/ChangeLog	2019-03-15 22:37:24 UTC (rev 243020)
+++ trunk/Tools/ChangeLog	2019-03-15 23:09:40 UTC (rev 243021)
@@ -1,3 +1,27 @@
+2019-03-15  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Crash under -[TestRunnerWKWebView _didShowMenu] while running layout tests on iOS simulator
+        https://bugs.webkit.org/show_bug.cgi?id=195810
+
+        Reviewed by Tim Horton.
+
+        Ensure that the process of resetting web view state between tests doesn't also invoke testing callbacks
+        registered by the previous layout test. This fixes an occasional crash when hiding the callout menu after
+        ending certain layout tests.
+
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+        (-[TestRunnerWKWebView dealloc]):
+        (-[TestRunnerWKWebView resetInteractionCallbacks]):
+
+        Pull logic to reset all of TestRunnerWKWebView's callback handler blocks into a separate helper method; use this
+        helper method when destroying the web view, and when resetting state between tests.
+
+        * WebKitTestRunner/ios/TestControllerIOS.mm:
+        (WTR::TestController::platformResetStateToConsistentValues):
+
+        Hide the callout menu *after* clearing out interaction callbacks registered on the web view.
+
 2019-03-15  Sihui Liu  <sihui_...@apple.com>
 
         [ Mojave WK1 ] Layout Test storage/indexeddb/database-odd-names.html is failing

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h (243020 => 243021)


--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h	2019-03-15 22:37:24 UTC (rev 243020)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h	2019-03-15 23:09:40 UTC (rev 243021)
@@ -47,6 +47,7 @@
 @property (nonatomic, copy) void (^rotationDidEndCallback)(void);
 @property (nonatomic, copy) NSString *accessibilitySpeakSelectionContent;
 
+- (void)resetInteractionCallbacks;
 - (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler;
 - (void)accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:(void (^)(void))completionHandler;
 - (void)_didEndRotation;

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (243020 => 243021)


--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2019-03-15 22:37:24 UTC (rev 243020)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2019-03-15 23:09:40 UTC (rev 243021)
@@ -88,18 +88,7 @@
 {
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 
-    self.didStartFormControlInteractionCallback = nil;
-    self.didEndFormControlInteractionCallback = nil;
-    self.didShowForcePressPreviewCallback = nil;
-    self.didDismissForcePressPreviewCallback = nil;
-    self.willBeginZoomingCallback = nil;
-    self.didEndZoomingCallback = nil;
-    self.didShowKeyboardCallback = nil;
-    self.didHideKeyboardCallback = nil;
-    self.didShowMenuCallback = nil;
-    self.didHideMenuCallback = nil;
-    self.didEndScrollingCallback = nil;
-    self.rotationDidEndCallback = nil;
+    [self resetInteractionCallbacks];
 
     self.zoomToScaleCompletionHandler = nil;
     self.retrieveSpeakSelectionContentCompletionHandler = nil;
@@ -140,6 +129,22 @@
         self.didDismissForcePressPreviewCallback();
 }
 
+- (void)resetInteractionCallbacks
+{
+    self.didStartFormControlInteractionCallback = nil;
+    self.didEndFormControlInteractionCallback = nil;
+    self.didShowForcePressPreviewCallback = nil;
+    self.didDismissForcePressPreviewCallback = nil;
+    self.willBeginZoomingCallback = nil;
+    self.didEndZoomingCallback = nil;
+    self.didShowKeyboardCallback = nil;
+    self.didHideKeyboardCallback = nil;
+    self.didShowMenuCallback = nil;
+    self.didHideMenuCallback = nil;
+    self.didEndScrollingCallback = nil;
+    self.rotationDidEndCallback = nil;
+}
+
 - (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler
 {
     ASSERT(!self.zoomToScaleCompletionHandler);

Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (243020 => 243021)


--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2019-03-15 22:37:24 UTC (rev 243020)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2019-03-15 23:09:40 UTC (rev 243021)
@@ -135,7 +135,6 @@
 {
     cocoaResetStateToConsistentValues(options);
 
-    UIMenuController.sharedMenuController.menuVisible = NO;
     [[UIApplication sharedApplication] _cancelAllTouches];
     [[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait animated:NO];
 
@@ -151,6 +150,7 @@
         webView.overrideSafeAreaInsets = UIEdgeInsetsZero;
         [webView _clearOverrideLayoutParameters];
         [webView _clearInterfaceOrientationOverride];
+        [webView resetInteractionCallbacks];
 
         UIScrollView *scrollView = webView.scrollView;
         [scrollView _removeAllAnimations:YES];
@@ -162,6 +162,8 @@
             shouldRestoreFirstResponder = [webView resignFirstResponder];
     }
 
+    UIMenuController.sharedMenuController.menuVisible = NO;
+
     runUntil(isDoneWaitingForKeyboardToDismiss, m_currentInvocation->shortTimeout());
     runUntil(isDoneWaitingForMenuToDismiss, m_currentInvocation->shortTimeout());
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to