Changeset 248717 in webkit


Ignore:
Timestamp:
Aug 15, 2019 9:34:00 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

WKUIDelegate's webView:contextMenuDidEndForElement: should be called when context menus end
https://bugs.webkit.org/show_bug.cgi?id=200750
<rdar://problem/54232261> and <rdar://problem/52355829>

Patch by Alex Christensen <achristensen@webkit.org> on 2019-08-15
Reviewed by Tim Horton.

Source/WebKit:

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView contextMenuInteraction:willEndForConfiguration:animator:]):

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm:

(-[TestContextMenuUIDelegate webView:contextMenuConfigurationForElement:completionHandler:]):
(-[TestContextMenuUIDelegate webView:contextMenuForElement:willCommitWithAnimator:]):
(-[TestContextMenuUIDelegate webView:contextMenuDidEndForElement:]):
(contextMenuWebViewDriver):
(TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r248715 r248717  
     12019-08-15  Alex Christensen  <achristensen@webkit.org>
     2
     3        WKUIDelegate's webView:contextMenuDidEndForElement: should be called when context menus end
     4        https://bugs.webkit.org/show_bug.cgi?id=200750
     5        <rdar://problem/54232261> and <rdar://problem/52355829>
     6
     7        Reviewed by Tim Horton.
     8
     9        * UIProcess/ios/WKContentViewInteraction.mm:
     10        (-[WKContentView contextMenuInteraction:willEndForConfiguration:animator:]):
     11
    1122019-08-14  Brian Burg  <bburg@apple.com>
    213
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r248690 r248717  
    83708370    // FIXME: This delegate is being called more than once by UIKit. <rdar://problem/51550291>
    83718371    // This conditional avoids the WKUIDelegate being called twice too.
    8372     if (!_contextMenuElementInfo) {
     8372    if (_contextMenuElementInfo) {
    83738373        auto uiDelegate = static_cast<id<WKUIDelegatePrivate>>(_webView.UIDelegate);
    83748374        if ([uiDelegate respondsToSelector:@selector(webView:contextMenuDidEndForElement:)])
  • trunk/Tools/ChangeLog

    r248701 r248717  
     12019-08-15  Alex Christensen  <achristensen@webkit.org>
     2
     3        WKUIDelegate's webView:contextMenuDidEndForElement: should be called when context menus end
     4        https://bugs.webkit.org/show_bug.cgi?id=200750
     5        <rdar://problem/54232261> and <rdar://problem/52355829>
     6
     7        Reviewed by Tim Horton.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm:
     10        (-[TestContextMenuUIDelegate webView:contextMenuConfigurationForElement:completionHandler:]):
     11        (-[TestContextMenuUIDelegate webView:contextMenuForElement:willCommitWithAnimator:]):
     12        (-[TestContextMenuUIDelegate webView:contextMenuDidEndForElement:]):
     13        (contextMenuWebViewDriver):
     14        (TEST):
     15
    1162019-08-14  Said Abou-Hallawa  <sabouhallawa@apple.com>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm

    r248072 r248717  
    3535#import <WebKit/WebKit.h>
    3636
     37static bool contextMenuRequested;
    3738static bool willPresentCalled;
    38 static bool contextMenuRequested;
     39static bool willCommitCalled;
     40static bool didEndCalled;
    3941static RetainPtr<NSURL> simpleURL;
    4042
     
    4850    EXPECT_TRUE([elementInfo.linkURL.absoluteString isEqualToString:[simpleURL absoluteString]]);
    4951    contextMenuRequested = true;
    50     completionHandler([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:nil actionProvider:nil]);
     52    UIContextMenuContentPreviewProvider previewProvider = ^UIViewController * ()
     53    {
     54        return [UIViewController new];
     55    };
     56    UIContextMenuActionProvider actionProvider = ^UIMenu *(NSArray<UIMenuElement *> *suggestedActions)
     57    {
     58        return [UIMenu menuWithTitle:@"" children:suggestedActions];
     59    };
     60    completionHandler([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:previewProvider actionProvider:actionProvider]);
    5161}
    5262
     
    5868- (void)webView:(WKWebView *)webView contextMenuForElement:(WKContextMenuElementInfo *)elementInfo willCommitWithAnimator:(id<UIContextMenuInteractionCommitAnimating>)animator
    5969{
     70    willCommitCalled = true;
    6071}
    6172
    6273- (void)webView:(WKWebView *)webView contextMenuDidEndForElement:(WKContextMenuElementInfo *)elementInfo
    6374{
     75    didEndCalled = true;
    6476}
    6577
    6678@end
    6779
    68 TEST(WebKit, DISABLED_ContextMenuBasic)
     80static RetainPtr<TestContextMenuDriver> contextMenuWebViewDriver()
    6981{
    70     auto window = adoptNS([[UIWindow alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
    71     auto driver = adoptNS([TestContextMenuDriver new]);
    72     auto uiDelegate = adoptNS([TestContextMenuUIDelegate new]);
    73     auto configuration = adoptNS([WKWebViewConfiguration new]);
     82    static auto window = adoptNS([[UIWindow alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     83    static auto driver = adoptNS([TestContextMenuDriver new]);
     84    static auto uiDelegate = adoptNS([TestContextMenuUIDelegate new]);
     85    static auto configuration = adoptNS([WKWebViewConfiguration new]);
    7486    [configuration _setClickInteractionDriverForTesting:(id<_UIClickInteractionDriving>)driver.get()];
    75     auto webViewController = adoptNS([[TestWKWebViewController alloc] initWithFrame:CGRectMake(0, 0, 200, 200) configuration:configuration.get()]);
     87    static auto webViewController = adoptNS([[TestWKWebViewController alloc] initWithFrame:CGRectMake(0, 0, 200, 200) configuration:configuration.get()]);
    7688    TestWKWebView *webView = [webViewController webView];
    7789    [window addSubview:webView];
    7890    [webView setUIDelegate:uiDelegate.get()];
    79 
    8091    simpleURL = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
    8192    [webView synchronouslyLoadHTMLString:[NSString stringWithFormat:@"<a href='%@'>This is a link</a>", simpleURL.get()]];
     93    return driver;
     94}
     95
     96TEST(WebKit, ContextMenuClick)
     97{
     98    auto driver = contextMenuWebViewDriver();
    8299    [driver begin:^(BOOL result) {
    83         if (result) {
    84             [driver clickDown];
    85             [driver clickUp];
    86             [driver end];
    87         }
     100        EXPECT_TRUE(result);
     101        [driver clickDown];
     102        [driver clickUp];
    88103    }];
    89104    TestWebKitAPI::Util::run(&willPresentCalled);
     105    EXPECT_TRUE(contextMenuRequested);
     106    EXPECT_TRUE(willPresentCalled);
     107    EXPECT_FALSE(willCommitCalled);
     108    EXPECT_FALSE(didEndCalled);
    90109}
    91110
     111TEST(WebKit, ContextMenuEnd)
     112{
     113    auto driver = contextMenuWebViewDriver();
     114    [driver begin:^(BOOL result) {
     115        EXPECT_TRUE(result);
     116        [driver end];
     117    }];
     118    TestWebKitAPI::Util::run(&didEndCalled);
     119    EXPECT_TRUE(contextMenuRequested);
     120    EXPECT_FALSE(willPresentCalled);
     121    EXPECT_FALSE(willCommitCalled);
     122    EXPECT_TRUE(didEndCalled);
     123}
    92124#endif // PLATFORM(IOS) && USE(UICONTEXTMENU)
Note: See TracChangeset for help on using the changeset viewer.