Skip to content
Permalink
Browse files
REGRESSION (r258092): fast/forms/ios/file-upload-panel.html fails whe…
…n HAVE(UICONTEXTMENU_LOCATION)

https://bugs.webkit.org/show_bug.cgi?id=213314
<rdar://problem/60339129>

Reviewed by Maciej Stachowiak.

fast/forms/ios/file-upload-panel.html sets the shouldHandleRunOpenPanel and
shouldPresentPopovers test options to false so that WKTR will (a) not register a
runOpenPanel UI delegate callback, causing WebKit to create a WKFileUploadPanel instead, and
(b) swizzle two UIKit view controller presentation methods to prevent the document picker
menu from being presented. The test merely wants the WKFileUploadPanel instance to exist in
order to query its available actions, not for it to show UI.

In r258092, WKFileUploadPanel now sometimes uses a UIContextMenuInteraction instance to
present the document picker menu, but -[UIContextMenuInteraction _presentMenuAtLocation:]
fails due to WKTR's above-mentioned swizzling. When this failure occurs,
UIContextMenuInteraction calls -contextMenuInteraction:willEndForConfiguration:animator: on
its delegate (the WKFileUploadPanel), which dismisses the open panel before the test has had
a chance to query the available actions.

Fixed this by swizzling -[UIContextMenuInteraction _presentMenuAtLocation:] when the
shouldPresentPopovers test option is false.

* WebKitTestRunner/ios/TestControllerIOS.mm:
(overridePresentMenuOrPopoverOrViewController): Renamed from
overridePresentViewControllerOrPopover.
(WTR::TestController::platformResetStateToConsistentValues): Swizzled
-[UIContextMenuInteraction _presentMenuAtLocation:] with
overridePresentMenuOrPopoverOrViewController when the shouldPresentPopovers test option is
false.
(overridePresentViewControllerOrPopover): Renamed to
overridePresentMenuOrPopoverOrViewController.


Canonical link: https://commits.webkit.org/226116@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263194 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aestes committed Jun 18, 2020
1 parent 756c5ca commit cebbe629489a4a13e6d197ba9121c48caff86577
Showing 2 changed files with 40 additions and 4 deletions.
@@ -1,3 +1,38 @@
2020-06-17 Andy Estes <aestes@apple.com>

REGRESSION (r258092): fast/forms/ios/file-upload-panel.html fails when HAVE(UICONTEXTMENU_LOCATION)
https://bugs.webkit.org/show_bug.cgi?id=213314
<rdar://problem/60339129>

Reviewed by Maciej Stachowiak.

fast/forms/ios/file-upload-panel.html sets the shouldHandleRunOpenPanel and
shouldPresentPopovers test options to false so that WKTR will (a) not register a
runOpenPanel UI delegate callback, causing WebKit to create a WKFileUploadPanel instead, and
(b) swizzle two UIKit view controller presentation methods to prevent the document picker
menu from being presented. The test merely wants the WKFileUploadPanel instance to exist in
order to query its available actions, not for it to show UI.

In r258092, WKFileUploadPanel now sometimes uses a UIContextMenuInteraction instance to
present the document picker menu, but -[UIContextMenuInteraction _presentMenuAtLocation:]
fails due to WKTR's above-mentioned swizzling. When this failure occurs,
UIContextMenuInteraction calls -contextMenuInteraction:willEndForConfiguration:animator: on
its delegate (the WKFileUploadPanel), which dismisses the open panel before the test has had
a chance to query the available actions.

Fixed this by swizzling -[UIContextMenuInteraction _presentMenuAtLocation:] when the
shouldPresentPopovers test option is false.

* WebKitTestRunner/ios/TestControllerIOS.mm:
(overridePresentMenuOrPopoverOrViewController): Renamed from
overridePresentViewControllerOrPopover.
(WTR::TestController::platformResetStateToConsistentValues): Swizzled
-[UIContextMenuInteraction _presentMenuAtLocation:] with
overridePresentMenuOrPopoverOrViewController when the shouldPresentPopovers test option is
false.
(overridePresentViewControllerOrPopover): Renamed to
overridePresentMenuOrPopoverOrViewController.

2020-06-17 Sihui Liu <sihui_liu@apple.com>

REGRESSION (r263044): [macOS] TestWebKitAPI.TextManipulation.InsertingContentIntoAlreadyManipulatedContentCreatesTextManipulationItem is a flaky failure
@@ -52,7 +52,7 @@ static BOOL overrideIsInHardwareKeyboardMode()
return NO;
}

static void overridePresentViewControllerOrPopover()
static void overridePresentMenuOrPopoverOrViewController()
{
}

@@ -177,10 +177,11 @@ static void handleMenuDidHideNotification(CFNotificationCenterRef, void*, CFStri

m_presentPopoverSwizzlers.clear();
if (!options.shouldPresentPopovers) {
m_presentPopoverSwizzlers.append(makeUnique<InstanceMethodSwizzler>([UIViewController class], @selector(presentViewController:animated:completion:), reinterpret_cast<IMP>(overridePresentViewControllerOrPopover)));
m_presentPopoverSwizzlers.append(makeUnique<InstanceMethodSwizzler>([UIPopoverController class], @selector(presentPopoverFromRect:inView:permittedArrowDirections:animated:), reinterpret_cast<IMP>(overridePresentViewControllerOrPopover)));
m_presentPopoverSwizzlers.append(makeUnique<InstanceMethodSwizzler>([UIContextMenuInteraction class], @selector(_presentMenuAtLocation:), reinterpret_cast<IMP>(overridePresentMenuOrPopoverOrViewController)));
m_presentPopoverSwizzlers.append(makeUnique<InstanceMethodSwizzler>([UIPopoverController class], @selector(presentPopoverFromRect:inView:permittedArrowDirections:animated:), reinterpret_cast<IMP>(overridePresentMenuOrPopoverOrViewController)));
m_presentPopoverSwizzlers.append(makeUnique<InstanceMethodSwizzler>([UIViewController class], @selector(presentViewController:animated:completion:), reinterpret_cast<IMP>(overridePresentMenuOrPopoverOrViewController)));
}

BOOL shouldRestoreFirstResponder = NO;
if (PlatformWebView* platformWebView = mainWebView()) {
TestRunnerWKWebView *webView = platformWebView->platformView();

0 comments on commit cebbe62

Please sign in to comment.