Changeset 248742 in webkit


Ignore:
Timestamp:
Aug 15, 2019 1:49:52 PM (5 years ago)
Author:
Alan Coon
Message:

Cherry-pick r248717. rdar://problem/54360854

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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248717 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-608-branch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608-branch/Source/WebKit/ChangeLog

    r248725 r248742  
     12019-08-15  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r248717. rdar://problem/54360854
     4
     5    WKUIDelegate's webView:contextMenuDidEndForElement: should be called when context menus end
     6    https://bugs.webkit.org/show_bug.cgi?id=200750
     7    <rdar://problem/54232261> and <rdar://problem/52355829>
     8   
     9    Patch by Alex Christensen <achristensen@webkit.org> on 2019-08-15
     10    Reviewed by Tim Horton.
     11   
     12    Source/WebKit:
     13   
     14    * UIProcess/ios/WKContentViewInteraction.mm:
     15    (-[WKContentView contextMenuInteraction:willEndForConfiguration:animator:]):
     16   
     17    Tools:
     18   
     19    * TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm:
     20    (-[TestContextMenuUIDelegate webView:contextMenuConfigurationForElement:completionHandler:]):
     21    (-[TestContextMenuUIDelegate webView:contextMenuForElement:willCommitWithAnimator:]):
     22    (-[TestContextMenuUIDelegate webView:contextMenuDidEndForElement:]):
     23    (contextMenuWebViewDriver):
     24    (TEST):
     25   
     26    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248717 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     27
     28    2019-08-15  Alex Christensen  <achristensen@webkit.org>
     29
     30            WKUIDelegate's webView:contextMenuDidEndForElement: should be called when context menus end
     31            https://bugs.webkit.org/show_bug.cgi?id=200750
     32            <rdar://problem/54232261> and <rdar://problem/52355829>
     33
     34            Reviewed by Tim Horton.
     35
     36            * UIProcess/ios/WKContentViewInteraction.mm:
     37            (-[WKContentView contextMenuInteraction:willEndForConfiguration:animator:]):
     38
    1392019-08-15  Alan Coon  <alancoon@apple.com>
    240
  • branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r248725 r248742  
    83728372    // FIXME: This delegate is being called more than once by UIKit. <rdar://problem/51550291>
    83738373    // This conditional avoids the WKUIDelegate being called twice too.
    8374     if (!_contextMenuElementInfo) {
     8374    if (_contextMenuElementInfo) {
    83758375        auto uiDelegate = static_cast<id<WKUIDelegatePrivate>>(_webView.UIDelegate);
    83768376        if ([uiDelegate respondsToSelector:@selector(webView:contextMenuDidEndForElement:)])
  • branches/safari-608-branch/Tools/ChangeLog

    r248726 r248742  
     12019-08-15  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r248717. rdar://problem/54360854
     4
     5    WKUIDelegate's webView:contextMenuDidEndForElement: should be called when context menus end
     6    https://bugs.webkit.org/show_bug.cgi?id=200750
     7    <rdar://problem/54232261> and <rdar://problem/52355829>
     8   
     9    Patch by Alex Christensen <achristensen@webkit.org> on 2019-08-15
     10    Reviewed by Tim Horton.
     11   
     12    Source/WebKit:
     13   
     14    * UIProcess/ios/WKContentViewInteraction.mm:
     15    (-[WKContentView contextMenuInteraction:willEndForConfiguration:animator:]):
     16   
     17    Tools:
     18   
     19    * TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm:
     20    (-[TestContextMenuUIDelegate webView:contextMenuConfigurationForElement:completionHandler:]):
     21    (-[TestContextMenuUIDelegate webView:contextMenuForElement:willCommitWithAnimator:]):
     22    (-[TestContextMenuUIDelegate webView:contextMenuDidEndForElement:]):
     23    (contextMenuWebViewDriver):
     24    (TEST):
     25   
     26    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248717 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     27
     28    2019-08-15  Alex Christensen  <achristensen@webkit.org>
     29
     30            WKUIDelegate's webView:contextMenuDidEndForElement: should be called when context menus end
     31            https://bugs.webkit.org/show_bug.cgi?id=200750
     32            <rdar://problem/54232261> and <rdar://problem/52355829>
     33
     34            Reviewed by Tim Horton.
     35
     36            * TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm:
     37            (-[TestContextMenuUIDelegate webView:contextMenuConfigurationForElement:completionHandler:]):
     38            (-[TestContextMenuUIDelegate webView:contextMenuForElement:willCommitWithAnimator:]):
     39            (-[TestContextMenuUIDelegate webView:contextMenuDidEndForElement:]):
     40            (contextMenuWebViewDriver):
     41            (TEST):
     42
    1432019-08-15  Alan Coon  <alancoon@apple.com>
    244
  • branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm

    r248125 r248742  
    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.