Title: [265211] trunk
Revision
265211
Author
[email protected]
Date
2020-08-03 13:29:17 -0700 (Mon, 03 Aug 2020)

Log Message

REGRESSION (r264170): fast/events/touch/ios/long-press-on-image.html times out
https://bugs.webkit.org/show_bug.cgi?id=215075
<rdar://problem/66294637>

Reviewed by Megan Gardner.

Tools:

This test started timing out after r264170, due to the `if (self.showingContextMenu)` early return added inside
`-[TestRunnerWKWebView _didShowContextMenu]`. If this test is run after another test that attempts to show a
context menu but does not dismiss it, we will begin the test in a state where `showingContextMenu` is already
set to `YES`, which means that `didShowContextMenuCallback` will never be invoked.

To address this, force any context menu interactions on `WKContentView` to dismiss between tests. See below for
more details.

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

When resetting state between tests, forcibly dismiss any context menus that were shown while running the
previous test and reset `showingContextMenu` back to `NO`.

(-[TestRunnerWKWebView contentView]):

Drive-by refactoring: add a readonly helper property to grab the WKWebView's content view for testing purposes,
and use this property instead of directly calling `-valueForKeyPath:` in a few places (see below).

* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(WTR::PlatformWebView::windowSnapshotImage):
* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::notifyDone):
(WTR::TestController::platformResetStateToConsistentValues):
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::platformContentView const):
(WTR::UIScriptControllerIOS::calendarType const):

LayoutTests:

Drive-by fix: this helper function had intended to use the `didDismissContextMenuCallback` property to register
callbacks for context menu dismissal, but instead, it sets a new property (`didHideContextMenuCallback`) on
`UIScriptController` that doesn't actually have any effect. The purpose of doing this is to make it safe to
invoke `waitForInputSessionToDismiss()` in the middle of the context menu dismissal animation when dismissing
date pickers on iOS. While it seems that none of our existing tests currently depend on this behavior in order
to pass, it still seems important to fix to avoid timing out when using this helper method in the future.

* resources/ui-helper.js:
(window.UIHelper.waitForInputSessionToDismiss.return.new.Promise.):
(window.UIHelper.waitForInputSessionToDismiss.return.new.Promise):
(window.UIHelper.waitForInputSessionToDismiss):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (265210 => 265211)


--- trunk/LayoutTests/ChangeLog	2020-08-03 19:22:58 UTC (rev 265210)
+++ trunk/LayoutTests/ChangeLog	2020-08-03 20:29:17 UTC (rev 265211)
@@ -1,3 +1,23 @@
+2020-08-03  Wenson Hsieh  <[email protected]>
+
+        REGRESSION (r264170): fast/events/touch/ios/long-press-on-image.html times out
+        https://bugs.webkit.org/show_bug.cgi?id=215075
+        <rdar://problem/66294637>
+
+        Reviewed by Megan Gardner.
+
+        Drive-by fix: this helper function had intended to use the `didDismissContextMenuCallback` property to register
+        callbacks for context menu dismissal, but instead, it sets a new property (`didHideContextMenuCallback`) on
+        `UIScriptController` that doesn't actually have any effect. The purpose of doing this is to make it safe to
+        invoke `waitForInputSessionToDismiss()` in the middle of the context menu dismissal animation when dismissing
+        date pickers on iOS. While it seems that none of our existing tests currently depend on this behavior in order
+        to pass, it still seems important to fix to avoid timing out when using this helper method in the future.
+
+        * resources/ui-helper.js:
+        (window.UIHelper.waitForInputSessionToDismiss.return.new.Promise.):
+        (window.UIHelper.waitForInputSessionToDismiss.return.new.Promise):
+        (window.UIHelper.waitForInputSessionToDismiss):
+
 2020-08-03  Clark Wang  <[email protected]>
 
         Added AudioBuffer Constructor

Modified: trunk/LayoutTests/resources/ui-helper.js (265210 => 265211)


--- trunk/LayoutTests/resources/ui-helper.js	2020-08-03 19:22:58 UTC (rev 265210)
+++ trunk/LayoutTests/resources/ui-helper.js	2020-08-03 20:29:17 UTC (rev 265211)
@@ -481,13 +481,13 @@
                     function clearCallbacksAndScriptComplete() {
                         uiController.didHideKeyboardCallback = null;
                         uiController.didDismissPopoverCallback = null;
-                        uiController.didHideContextMenuCallback = null;
+                        uiController.didDismissContextMenuCallback = null;
                         uiController.uiScriptComplete();
                     }
 
                     uiController.didHideKeyboardCallback = clearCallbacksAndScriptComplete;
                     uiController.didDismissPopoverCallback = clearCallbacksAndScriptComplete;
-                    uiController.didHideContextMenuCallback = clearCallbacksAndScriptComplete;
+                    uiController.didDismissContextMenuCallback = clearCallbacksAndScriptComplete;
                 })()`, resolve);
         });
     }

Modified: trunk/Tools/ChangeLog (265210 => 265211)


--- trunk/Tools/ChangeLog	2020-08-03 19:22:58 UTC (rev 265210)
+++ trunk/Tools/ChangeLog	2020-08-03 20:29:17 UTC (rev 265211)
@@ -1,3 +1,40 @@
+2020-08-03  Wenson Hsieh  <[email protected]>
+
+        REGRESSION (r264170): fast/events/touch/ios/long-press-on-image.html times out
+        https://bugs.webkit.org/show_bug.cgi?id=215075
+        <rdar://problem/66294637>
+
+        Reviewed by Megan Gardner.
+
+        This test started timing out after r264170, due to the `if (self.showingContextMenu)` early return added inside
+        `-[TestRunnerWKWebView _didShowContextMenu]`. If this test is run after another test that attempts to show a
+        context menu but does not dismiss it, we will begin the test in a state where `showingContextMenu` is already
+        set to `YES`, which means that `didShowContextMenuCallback` will never be invoked.
+
+        To address this, force any context menu interactions on `WKContentView` to dismiss between tests. See below for
+        more details.
+
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+        (-[TestRunnerWKWebView immediatelyDismissContextMenuIfNeeded]):
+
+        When resetting state between tests, forcibly dismiss any context menus that were shown while running the
+        previous test and reset `showingContextMenu` back to `NO`.
+
+        (-[TestRunnerWKWebView contentView]):
+
+        Drive-by refactoring: add a readonly helper property to grab the WKWebView's content view for testing purposes,
+        and use this property instead of directly calling `-valueForKeyPath:` in a few places (see below).
+
+        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
+        (WTR::PlatformWebView::windowSnapshotImage):
+        * WebKitTestRunner/ios/TestControllerIOS.mm:
+        (WTR::TestController::notifyDone):
+        (WTR::TestController::platformResetStateToConsistentValues):
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptControllerIOS::platformContentView const):
+        (WTR::UIScriptControllerIOS::calendarType const):
+
 2020-08-03  Devin Rousso  <[email protected]>
 
         should be able to request an editing context for a given region of a given input

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h (265210 => 265211)


--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h	2020-08-03 19:22:58 UTC (rev 265210)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h	2020-08-03 20:29:17 UTC (rev 265211)
@@ -51,6 +51,7 @@
 - (void)setAllowedMenuActions:(NSArray<NSString *> *)actions;
 
 - (void)resetCustomMenuAction;
+- (void)immediatelyDismissContextMenuIfNeeded;
 - (void)installCustomMenuAction:(NSString *)name dismissesAutomatically:(BOOL)dismissesAutomatically callback:(dispatch_block_t)callback;
 
 - (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler;
@@ -59,6 +60,7 @@
 
 @property (nonatomic, assign) UIEdgeInsets overrideSafeAreaInsets;
 
+@property (nonatomic, readonly) UIView *contentView;
 @property (nonatomic, readonly, getter=isShowingKeyboard) BOOL showingKeyboard;
 @property (nonatomic, readonly, getter=isDismissingMenu) BOOL dismissingMenu;
 @property (nonatomic, readonly, getter=isShowingPopover) BOOL showingPopover;

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (265210 => 265211)


--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2020-08-03 19:22:58 UTC (rev 265210)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2020-08-03 20:29:17 UTC (rev 265211)
@@ -216,6 +216,21 @@
     return _isInteractingWithFormControl;
 }
 
+- (void)immediatelyDismissContextMenuIfNeeded
+{
+    if (!self.showingContextMenu)
+        return;
+
+    self.showingContextMenu = NO;
+
+#if PLATFORM(IOS)
+    for (id <UIInteraction> interaction in self.contentView.interactions) {
+        if ([interaction isKindOfClass:UIContextMenuInteraction.class])
+            [(UIContextMenuInteraction *)interaction dismissMenu];
+    }
+#endif
+}
+
 - (void)_didShowContextMenu
 {
     if (self.showingContextMenu)
@@ -502,6 +517,11 @@
     return _overrideSafeAreaInsets;
 }
 
+- (UIView *)contentView
+{
+    return [self valueForKeyPath:@"_currentContentView"];
+}
+
 #pragma mark - WKUIDelegatePrivate
 
 // In extra zoom mode, fullscreen form control UI takes on the same role as keyboards and input view controllers

Modified: trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm (265210 => 265211)


--- trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2020-08-03 19:22:58 UTC (rev 265210)
+++ trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2020-08-03 20:29:17 UTC (rev 265211)
@@ -334,7 +334,7 @@
     RELEASE_ASSERT(viewSize.width);
     RELEASE_ASSERT(viewSize.height);
 
-    UIView *selectionView = [platformView() valueForKeyPath:@"_currentContentView.interactionAssistant.selectionView"];
+    UIView *selectionView = [platformView().contentView valueForKeyPath:@"interactionAssistant.selectionView"];
     UIView *startGrabberView = [selectionView valueForKeyPath:@"rangeView.startGrabber"];
     UIView *endGrabberView = [selectionView valueForKeyPath:@"rangeView.endGrabber"];
     Vector<WeakObjCPtr<UIView>, 3> viewsToUnhide;

Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (265210 => 265211)


--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2020-08-03 19:22:58 UTC (rev 265210)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2020-08-03 20:29:17 UTC (rev 265211)
@@ -92,7 +92,7 @@
 
 void TestController::notifyDone()
 {
-    UIView *contentView = [mainWebView()->platformView() valueForKeyPath:@"_currentContentView"];
+    UIView *contentView = mainWebView()->platformView().contentView;
     UIView *selectionView = [contentView valueForKeyPath:@"interactionAssistant.selectionView"];
     [selectionView _removeAllAnimations:YES];
 }
@@ -217,6 +217,8 @@
 
         if (webView.interactingWithFormControl)
             shouldRestoreFirstResponder = [webView resignFirstResponder];
+
+        [webView immediatelyDismissContextMenuIfNeeded];
     }
 
     UIMenuController.sharedMenuController.menuVisible = NO;

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (265210 => 265211)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2020-08-03 19:22:58 UTC (rev 265210)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2020-08-03 20:29:17 UTC (rev 265211)
@@ -1235,12 +1235,12 @@
 
 UIView *UIScriptControllerIOS::platformContentView() const
 {
-    return [webView() valueForKeyPath:@"_currentContentView"];
+    return webView().contentView;
 }
 
 JSObjectRef UIScriptControllerIOS::calendarType() const
 {
-    UIView *contentView = [webView() valueForKeyPath:@"_currentContentView"];
+    UIView *contentView = webView().contentView;
     NSString *calendarTypeString = [contentView valueForKeyPath:@"dateTimeInputControl.dateTimePickerCalendarType"];
     auto jsContext = m_context->jsContext();
     return JSValueToObject(jsContext, [JSValue valueWithObject:calendarTypeString inContext:[JSContext contextWithJSGlobalContextRef:jsContext]].JSValueRef, nullptr);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to