Title: [248742] branches/safari-608-branch
Revision
248742
Author
alanc...@apple.com
Date
2019-08-15 13:49:52 -0700 (Thu, 15 Aug 2019)

Log 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 <achristen...@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

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (248741 => 248742)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-15 20:21:05 UTC (rev 248741)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-15 20:49:52 UTC (rev 248742)
@@ -1,5 +1,43 @@
 2019-08-15  Alan Coon  <alanc...@apple.com>
 
+        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 <achristen...@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
+
+    2019-08-15  Alex Christensen  <achristen...@webkit.org>
+
+            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>
+
+            Reviewed by Tim Horton.
+
+            * UIProcess/ios/WKContentViewInteraction.mm:
+            (-[WKContentView contextMenuInteraction:willEndForConfiguration:animator:]):
+
+2019-08-15  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r248690. rdar://problem/54333950
 
     v3: CrashTracer: Regression : MobileSafari at UIKitCore: -[UITargetedPreview initWithView:parameters:]

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248741 => 248742)


--- branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-15 20:21:05 UTC (rev 248741)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-15 20:49:52 UTC (rev 248742)
@@ -8371,7 +8371,7 @@
 
     // FIXME: This delegate is being called more than once by UIKit. <rdar://problem/51550291>
     // This conditional avoids the WKUIDelegate being called twice too.
-    if (!_contextMenuElementInfo) {
+    if (_contextMenuElementInfo) {
         auto uiDelegate = static_cast<id<WKUIDelegatePrivate>>(_webView.UIDelegate);
         if ([uiDelegate respondsToSelector:@selector(webView:contextMenuDidEndForElement:)])
             [uiDelegate webView:_webView contextMenuDidEndForElement:_contextMenuElementInfo.get()];

Modified: branches/safari-608-branch/Tools/ChangeLog (248741 => 248742)


--- branches/safari-608-branch/Tools/ChangeLog	2019-08-15 20:21:05 UTC (rev 248741)
+++ branches/safari-608-branch/Tools/ChangeLog	2019-08-15 20:49:52 UTC (rev 248742)
@@ -1,5 +1,47 @@
 2019-08-15  Alan Coon  <alanc...@apple.com>
 
+        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 <achristen...@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
+
+    2019-08-15  Alex Christensen  <achristen...@webkit.org>
+
+            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>
+
+            Reviewed by Tim Horton.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm:
+            (-[TestContextMenuUIDelegate webView:contextMenuConfigurationForElement:completionHandler:]):
+            (-[TestContextMenuUIDelegate webView:contextMenuForElement:willCommitWithAnimator:]):
+            (-[TestContextMenuUIDelegate webView:contextMenuDidEndForElement:]):
+            (contextMenuWebViewDriver):
+            (TEST):
+
+2019-08-15  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r248701. rdar://problem/54333796
 
     [iOS](REGRESSION: r200487): WebKit.RequestActivatedElementInfoForRotatedImage fails on iOS 13

Modified: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm (248741 => 248742)


--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm	2019-08-15 20:21:05 UTC (rev 248741)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm	2019-08-15 20:49:52 UTC (rev 248742)
@@ -34,8 +34,10 @@
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WebKit.h>
 
+static bool contextMenuRequested;
 static bool willPresentCalled;
-static bool contextMenuRequested;
+static bool willCommitCalled;
+static bool didEndCalled;
 static RetainPtr<NSURL> simpleURL;
 
 @interface TestContextMenuUIDelegate : NSObject <WKUIDelegate>
@@ -47,7 +49,15 @@
 {
     EXPECT_TRUE([elementInfo.linkURL.absoluteString isEqualToString:[simpleURL absoluteString]]);
     contextMenuRequested = true;
-    completionHandler([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:nil actionProvider:nil]);
+    UIContextMenuContentPreviewProvider previewProvider = ^UIViewController * ()
+    {
+        return [UIViewController new];
+    };
+    UIContextMenuActionProvider actionProvider = ^UIMenu *(NSArray<UIMenuElement *> *suggestedActions)
+    {
+        return [UIMenu menuWithTitle:@"" children:suggestedActions];
+    };
+    completionHandler([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:previewProvider actionProvider:actionProvider]);
 }
 
 - (void)webView:(WKWebView *)webView contextMenuWillPresentForElement:(WKContextMenuElementInfo *)elementInfo
@@ -57,36 +67,58 @@
 
 - (void)webView:(WKWebView *)webView contextMenuForElement:(WKContextMenuElementInfo *)elementInfo willCommitWithAnimator:(id<UIContextMenuInteractionCommitAnimating>)animator
 {
+    willCommitCalled = true;
 }
 
 - (void)webView:(WKWebView *)webView contextMenuDidEndForElement:(WKContextMenuElementInfo *)elementInfo
 {
+    didEndCalled = true;
 }
 
 @end
 
-TEST(WebKit, DISABLED_ContextMenuBasic)
+static RetainPtr<TestContextMenuDriver> contextMenuWebViewDriver()
 {
-    auto window = adoptNS([[UIWindow alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
-    auto driver = adoptNS([TestContextMenuDriver new]);
-    auto uiDelegate = adoptNS([TestContextMenuUIDelegate new]);
-    auto configuration = adoptNS([WKWebViewConfiguration new]);
+    static auto window = adoptNS([[UIWindow alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+    static auto driver = adoptNS([TestContextMenuDriver new]);
+    static auto uiDelegate = adoptNS([TestContextMenuUIDelegate new]);
+    static auto configuration = adoptNS([WKWebViewConfiguration new]);
     [configuration _setClickInteractionDriverForTesting:(id<_UIClickInteractionDriving>)driver.get()];
-    auto webViewController = adoptNS([[TestWKWebViewController alloc] initWithFrame:CGRectMake(0, 0, 200, 200) configuration:configuration.get()]);
+    static auto webViewController = adoptNS([[TestWKWebViewController alloc] initWithFrame:CGRectMake(0, 0, 200, 200) configuration:configuration.get()]);
     TestWKWebView *webView = [webViewController webView];
     [window addSubview:webView];
     [webView setUIDelegate:uiDelegate.get()];
-
     simpleURL = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     [webView synchronouslyLoadHTMLString:[NSString stringWithFormat:@"<a href=''>This is a link</a>", simpleURL.get()]];
+    return driver;
+}
+
+TEST(WebKit, ContextMenuClick)
+{
+    auto driver = contextMenuWebViewDriver();
     [driver begin:^(BOOL result) {
-        if (result) {
-            [driver clickDown];
-            [driver clickUp];
-            [driver end];
-        }
+        EXPECT_TRUE(result);
+        [driver clickDown];
+        [driver clickUp];
     }];
     TestWebKitAPI::Util::run(&willPresentCalled);
+    EXPECT_TRUE(contextMenuRequested);
+    EXPECT_TRUE(willPresentCalled);
+    EXPECT_FALSE(willCommitCalled);
+    EXPECT_FALSE(didEndCalled);
 }
 
+TEST(WebKit, ContextMenuEnd)
+{
+    auto driver = contextMenuWebViewDriver();
+    [driver begin:^(BOOL result) {
+        EXPECT_TRUE(result);
+        [driver end];
+    }];
+    TestWebKitAPI::Util::run(&didEndCalled);
+    EXPECT_TRUE(contextMenuRequested);
+    EXPECT_FALSE(willPresentCalled);
+    EXPECT_FALSE(willCommitCalled);
+    EXPECT_TRUE(didEndCalled);
+}
 #endif // PLATFORM(IOS) && USE(UICONTEXTMENU)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to