WebKit Bugzilla
Attachment 372531 Details for
Bug 199043
: Add unit test for UIContextMenuConfiguration API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199043-20190619221921.patch (text/plain), 29.46 KB, created by
Alex Christensen
on 2019-06-19 22:19:22 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2019-06-19 22:19:22 PDT
Size:
29.46 KB
patch
obsolete
>Subversion Revision: 246630 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 59b8c976aeb838cc490016581e876f64931b77f3..6544c1a1bd70dfa3197e736969f764aa3e098c6a 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,21 @@ >+2019-06-19 Alex Christensen <achristensen@webkit.org> >+ >+ Add unit test for UIContextMenuConfiguration API >+ https://bugs.webkit.org/show_bug.cgi?id=199043 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UIProcess/API/APIPageConfiguration.cpp: >+ (API::PageConfiguration::copy const): >+ * UIProcess/API/APIPageConfiguration.h: >+ (API::PageConfiguration::clickInteractionDriverForTesting const): >+ (API::PageConfiguration::setClickInteractionDriverForTesting): >+ * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: >+ (-[WKWebViewConfiguration _setClickInteractionDriverForTesting:]): >+ (-[WKWebViewConfiguration _clickInteractionDriverForTesting]): >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView _registerPreview]): >+ > 2019-06-19 Dean Jackson <dino@apple.com> > > No menu pop-up when long pressing on a link in Firefox app >diff --git a/Source/WebKit/Platform/spi/ios/UIKitSPI.h b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >index e14db14ed5596c93a2a38c5928775f60c12a5699..f43f200c3f7757ed487b47e444c6c83ba6aa0483 100644 >--- a/Source/WebKit/Platform/spi/ios/UIKitSPI.h >+++ b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >@@ -1190,6 +1190,30 @@ static inline bool currentUserInterfaceIdiomIsPad() > @property (nonatomic, copy) UIContextMenuContentPreviewProvider previewProvider; > @property (nonatomic, copy) UIContextMenuActionProvider actionProvider; > @end >+ >+@protocol _UIClickInteractionDriverDelegate; >+@protocol _UIClickInteractionDriving <NSObject> >+@property (nonatomic, weak) id<_UIClickInteractionDriverDelegate> delegate; >+@end >+ >+@class _UIClickPresentationInteraction; >+@interface UIContextMenuInteraction (Radar51288435) >+@property (nonatomic, strong) _UIClickPresentationInteraction *presentationInteraction; >+@end >+ >+@interface _UIClickInteraction : NSObject <UIInteraction> >+@end >+ >+@interface _UIClickPresentationInteraction : NSObject <UIInteraction> >+@end >+@interface _UIClickPresentationInteraction (NeededUntil51288435Fixed) >+@property (nonatomic, strong) _UIClickInteraction *previewClickInteraction; >+@end >+ >+@interface _UIClickInteraction (Radar51288435) >+@property (nonatomic, strong) id<_UIClickInteractionDriving> driver; >+@end >+ > #endif > > WTF_EXTERN_C_BEGIN >diff --git a/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp b/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp >index eb9f13e50aa4bde086836e3c89509c348719d7dc..065121c00c44cb5ef4fa1f9d355ed29c54f2f048 100644 >--- a/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp >+++ b/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp >@@ -73,6 +73,7 @@ Ref<PageConfiguration> PageConfiguration::copy() const > #if PLATFORM(IOS_FAMILY) > copy->m_alwaysRunsAtForegroundPriority = this->m_alwaysRunsAtForegroundPriority; > copy->m_canShowWhileLocked = this->m_canShowWhileLocked; >+ copy->m_clickInteractionDriverForTesting = this->m_clickInteractionDriverForTesting; > #endif > copy->m_initialCapitalizationEnabled = this->m_initialCapitalizationEnabled; > copy->m_waitsForPaintAfterViewDidMoveToWindow = this->m_waitsForPaintAfterViewDidMoveToWindow; >diff --git a/Source/WebKit/UIProcess/API/APIPageConfiguration.h b/Source/WebKit/UIProcess/API/APIPageConfiguration.h >index 0c51afdc005f9fa8656e62fe7340d80829ce7e28..02759131e47098a90fd60ca90dcec088af27dd5e 100644 >--- a/Source/WebKit/UIProcess/API/APIPageConfiguration.h >+++ b/Source/WebKit/UIProcess/API/APIPageConfiguration.h >@@ -31,6 +31,11 @@ > #include <wtf/Forward.h> > #include <wtf/GetPtr.h> > >+#if PLATFORM(IOS_FAMILY) >+OBJC_PROTOCOL(_UIClickInteractionDriving); >+#include <wtf/RetainPtr.h> >+#endif >+ > namespace WebKit { > class VisitedLinkStore; > class WebPageGroup; >@@ -98,6 +103,9 @@ public: > > bool canShowWhileLocked() const { return m_canShowWhileLocked; } > void setCanShowWhileLocked(bool canShowWhileLocked) { m_canShowWhileLocked = canShowWhileLocked; } >+ >+ const RetainPtr<_UIClickInteractionDriving>& clickInteractionDriverForTesting() const { return m_clickInteractionDriverForTesting; } >+ void setClickInteractionDriverForTesting(RetainPtr<_UIClickInteractionDriving>&& driver) { m_clickInteractionDriverForTesting = WTFMove(driver); } > #endif > bool initialCapitalizationEnabled() { return m_initialCapitalizationEnabled; } > void setInitialCapitalizationEnabled(bool initialCapitalizationEnabled) { m_initialCapitalizationEnabled = initialCapitalizationEnabled; } >@@ -151,6 +159,7 @@ private: > #if PLATFORM(IOS_FAMILY) > bool m_alwaysRunsAtForegroundPriority { false }; > bool m_canShowWhileLocked { false }; >+ RetainPtr<_UIClickInteractionDriving> m_clickInteractionDriverForTesting; > #endif > bool m_initialCapitalizationEnabled { true }; > bool m_waitsForPaintAfterViewDidMoveToWindow { true }; >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm >index 4151021c051dbfd29103bf00e14f3b223fe8bfd5..bee52f6380a52d196b10cb587b02d9c0b6d74632 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm >@@ -791,6 +791,16 @@ ALLOW_DEPRECATED_DECLARATIONS_END > return _pageConfiguration->canShowWhileLocked(); > } > >+- (void)_setClickInteractionDriverForTesting:(id<_UIClickInteractionDriving>)driver >+{ >+ _pageConfiguration->setClickInteractionDriverForTesting((NSObject<_UIClickInteractionDriving> *)driver); >+} >+ >+- (id<_UIClickInteractionDriving>)_clickInteractionDriverForTesting >+{ >+ return _pageConfiguration->clickInteractionDriverForTesting().get(); >+} >+ > #endif // PLATFORM(IOS_FAMILY) > > - (BOOL)_invisibleAutoplayNotPermitted >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h >index 60ae06e4951e292e5d2a68de4eee0187a0c34acf..9f716ff7a55911e6f2be96aeb32b264b499a413e 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h >@@ -33,6 +33,8 @@ typedef NS_ENUM(NSUInteger, _WKDragLiftDelay) { > _WKDragLiftDelayMedium, > _WKDragLiftDelayLong > } WK_API_AVAILABLE(ios(11.0)); >+ >+@protocol _UIClickInteractionDriving; > #endif > > @class WKWebView; >@@ -84,6 +86,7 @@ typedef NS_ENUM(NSUInteger, _WKDragLiftDelay) { > @property (nonatomic, setter=_setSystemPreviewEnabled:) BOOL _systemPreviewEnabled WK_API_AVAILABLE(ios(12.0)); > @property (nonatomic, setter=_setShouldDecidePolicyBeforeLoadingQuickLookPreview:) BOOL _shouldDecidePolicyBeforeLoadingQuickLookPreview WK_API_AVAILABLE(ios(WK_IOS_TBA)); > @property (nonatomic, setter=_setCanShowWhileLocked:) BOOL _canShowWhileLocked WK_API_AVAILABLE(ios(WK_IOS_TBA)); >+@property (nonatomic, setter=_setClickInteractionDriverForTesting:) id<_UIClickInteractionDriving> _clickInteractionDriverForTesting WK_API_AVAILABLE(ios(WK_IOS_TBA)); > #else > @property (nonatomic, setter=_setShowsURLsInToolTips:) BOOL _showsURLsInToolTips WK_API_AVAILABLE(macos(10.12)); > @property (nonatomic, setter=_setServiceControlsEnabled:) BOOL _serviceControlsEnabled WK_API_AVAILABLE(macos(10.12)); >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 3111a48d127a8669b6cee3b2d608771bcbba7c8e..ac335fe31329c3f4c9dd79d3eb3af1d2d434d796 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -7434,6 +7434,12 @@ static NSString *previewIdentifierForElementAction(_WKElementAction *action) > _contextMenuHasRequestedLegacyData = NO; > [self addInteraction:_contextMenuInteraction.get()]; > >+ if (id<_UIClickInteractionDriving> driver = _webView.configuration._clickInteractionDriverForTesting) { >+ _UIClickInteraction *previewClickInteraction = [[_contextMenuInteraction presentationInteraction] previewClickInteraction]; >+ [previewClickInteraction setDriver:driver]; >+ [driver setDelegate:(id<_UIClickInteractionDriverDelegate>)previewClickInteraction]; >+ } >+ > [self _showLinkPreviewsPreferenceChanged:nil]; > > [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_showLinkPreviewsPreferenceChanged:) name:webkitShowLinkPreviewsPreferenceChangedNotification object:nil]; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index bf9b4d538dd417fee9934ac93efa39c0021b1b43..050c4f64b471259d22085cbf667b41be874d4222 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,37 @@ >+2019-06-19 Alex Christensen <achristensen@webkit.org> >+ >+ Add unit test for UIContextMenuConfiguration API >+ https://bugs.webkit.org/show_bug.cgi?id=199043 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm: Added. >+ (-[TestContextMenuUIDelegate webView:contextMenuConfigurationForElement:completionHandler:]): >+ (-[TestContextMenuUIDelegate webView:contextMenuWillPresentForElement:]): >+ (-[TestContextMenuUIDelegate webView:contextMenuForElement:willCommitWithAnimator:]): >+ (-[TestContextMenuUIDelegate webView:contextMenuDidEndForElement:]): >+ (TEST): >+ * TestWebKitAPI/cocoa/TestContextMenuDriver.h: Added. >+ * TestWebKitAPI/cocoa/TestContextMenuDriver.mm: Added. >+ (-[TestContextMenuDriver delegate]): >+ (-[TestContextMenuDriver setDelegate:]): >+ (-[TestContextMenuDriver view]): >+ (-[TestContextMenuDriver setView:]): >+ (-[TestContextMenuDriver allowableMovement]): >+ (-[TestContextMenuDriver setAllowableMovement:]): >+ (-[TestContextMenuDriver primaryGestureRecognizer]): >+ (-[TestContextMenuDriver setPrimaryGestureRecognizer:]): >+ (-[TestContextMenuDriver touchDuration]): >+ (-[TestContextMenuDriver setTouchDuration:]): >+ (-[TestContextMenuDriver locationInCoordinateSpace:]): >+ (-[TestContextMenuDriver cancelInteraction]): >+ (-[TestContextMenuDriver begin:]): >+ (-[TestContextMenuDriver clickDown]): >+ (-[TestContextMenuDriver clickUp]): >+ (-[TestContextMenuDriver end]): >+ * TestWebKitAPI/ios/UIKitSPI.h: >+ > 2019-06-19 Yusuke Suzuki <ysuzuki@apple.com> > > [bmalloc] IsoHeap's initialization is racy with IsoHeap::isInitialized >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index cbc013587058a196b096bf76faade32982e2fd0a..fc28c57c27af085e36bd467210c93e67aca211d7 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -319,6 +319,7 @@ > 5C23DF0B2246015800F454B6 /* Challenge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C23DF0A2245C9D700F454B6 /* Challenge.mm */; }; > 5C2936931D5BF70D00DEAB1E /* CookieAcceptPolicy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */; }; > 5C2936961D5C00ED00DEAB1E /* CookieMessage.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C2936941D5BFD1900DEAB1E /* CookieMessage.html */; }; >+ 5C3B1D2622A74F6700BCF4D0 /* ContextMenus.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C3B1D2522A74EA400BCF4D0 /* ContextMenus.mm */; }; > 5C4259462266A68A0039AA7A /* BasicProposedCredentialPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C42594422669E9B0039AA7A /* BasicProposedCredentialPlugIn.mm */; }; > 5C4A84951F7EEFFC00ACFC54 /* Configuration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C4A84941F7EEFD400ACFC54 /* Configuration.mm */; }; > 5C69BDD51F82A7EF000F4F4B /* JavaScriptDuringNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C69BDD41F82A7EB000F4F4B /* JavaScriptDuringNavigation.mm */; }; >@@ -349,6 +350,7 @@ > 5CCB10E3213457D800AC5AF0 /* RestoreSessionStateWithoutNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CCB10DE2134579D00AC5AF0 /* RestoreSessionStateWithoutNavigation.mm */; }; > 5CCB10E4213457E000AC5AF0 /* ShouldGoToBackForwardListItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CCB10DF2134579D00AC5AF0 /* ShouldGoToBackForwardListItem.mm */; }; > 5CE354D91E70DA5C00BEFE3B /* WKContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */; }; >+ 5CE7594922A883D200C12409 /* TestContextMenuDriver.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE7594722A883A500C12409 /* TestContextMenuDriver.mm */; }; > 5CEAB5E11FA939F400A77FAA /* _WKInputDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */; }; > 5CF540E92257E67C00E6BC0E /* DownloadThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CF540E82257E64B00E6BC0E /* DownloadThread.mm */; }; > 5CFACF63226F73C60056C7D0 /* libboringssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CFACF62226F73C60056C7D0 /* libboringssl.a */; }; >@@ -1767,6 +1769,7 @@ > 5C23DF0A2245C9D700F454B6 /* Challenge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Challenge.mm; sourceTree = "<group>"; }; > 5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieAcceptPolicy.mm; sourceTree = "<group>"; }; > 5C2936941D5BFD1900DEAB1E /* CookieMessage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = CookieMessage.html; sourceTree = "<group>"; }; >+ 5C3B1D2522A74EA400BCF4D0 /* ContextMenus.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenus.mm; sourceTree = "<group>"; }; > 5C42594422669E9B0039AA7A /* BasicProposedCredentialPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BasicProposedCredentialPlugIn.mm; sourceTree = "<group>"; }; > 5C4A84941F7EEFD400ACFC54 /* Configuration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Configuration.mm; sourceTree = "<group>"; }; > 5C5E633D1D0B67940085A025 /* UniqueRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueRef.cpp; sourceTree = "<group>"; }; >@@ -1798,6 +1801,8 @@ > 5CCB10DF2134579D00AC5AF0 /* ShouldGoToBackForwardListItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShouldGoToBackForwardListItem.mm; sourceTree = "<group>"; }; > 5CCB10E02134579D00AC5AF0 /* ResponsivenessTimer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResponsivenessTimer.mm; sourceTree = "<group>"; }; > 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentExtensionStore.mm; sourceTree = "<group>"; }; >+ 5CE7594722A883A500C12409 /* TestContextMenuDriver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestContextMenuDriver.mm; path = cocoa/TestContextMenuDriver.mm; sourceTree = "<group>"; }; >+ 5CE7594822A883A500C12409 /* TestContextMenuDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestContextMenuDriver.h; path = cocoa/TestContextMenuDriver.h; sourceTree = "<group>"; }; > 5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInputDelegate.mm; sourceTree = "<group>"; }; > 5CF540E82257E64B00E6BC0E /* DownloadThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DownloadThread.mm; sourceTree = "<group>"; }; > 5CFACF62226F73C60056C7D0 /* libboringssl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libboringssl.a; sourceTree = BUILT_PRODUCTS_DIR; }; >@@ -2539,6 +2544,8 @@ > F44A530D21B8976900DBB99C /* InstanceMethodSwizzler.h */, > F44A531021B8976900DBB99C /* InstanceMethodSwizzler.mm */, > 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */, >+ 5CE7594822A883A500C12409 /* TestContextMenuDriver.h */, >+ 5CE7594722A883A500C12409 /* TestContextMenuDriver.mm */, > 2D1C04A51D76298B000A6816 /* TestNavigationDelegate.h */, > 2D1C04A61D76298B000A6816 /* TestNavigationDelegate.mm */, > A14FC58D1B8AE36500D107EB /* TestProtocol.h */, >@@ -2615,6 +2622,7 @@ > A14FC5861B8991B600D107EB /* ContentFiltering.mm */, > A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */, > 5CA1DED81F74A87100E71BD3 /* ContentRuleListNotification.mm */, >+ 5C3B1D2522A74EA400BCF4D0 /* ContextMenus.mm */, > 5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */, > 5C19A5231FD0F32600EEA323 /* CookiePrivateBrowsing.mm */, > 9B1056411F9045C700D5583F /* CopyHTML.mm */, >@@ -4170,6 +4178,7 @@ > 37FB72971DB2E82F00E41BE4 /* ContextMenuDefaultItemsHaveTags.mm in Sources */, > 8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */, > CD0BD0A61F79924D001AB2CF /* ContextMenuImgWithVideo.mm in Sources */, >+ 5C3B1D2622A74F6700BCF4D0 /* ContextMenus.mm in Sources */, > 5C2936931D5BF70D00DEAB1E /* CookieAcceptPolicy.mm in Sources */, > 51D1249B1E785425002B2820 /* CookieManager.cpp in Sources */, > 5C19A5241FD0F60100EEA323 /* CookiePrivateBrowsing.mm in Sources */, >@@ -4473,6 +4482,7 @@ > 5C9B548E223C4CBE00B150C4 /* TCPServer.cpp in Sources */, > 7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */, > 7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */, >+ 5CE7594922A883D200C12409 /* TestContextMenuDriver.mm in Sources */, > F46128CB211D475100D9FADB /* TestDraggingInfo.mm in Sources */, > F4E0A2B82122847400AF7C7F /* TestFilePromiseReceiver.mm in Sources */, > F4F5BB5221667BAA002D06B9 /* TestFontOptions.mm in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..34b0195c7c52b37d1fa342bb65d4428ab2358327 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm >@@ -0,0 +1,94 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+ >+#if PLATFORM(IOS) >+ >+#import "TestContextMenuDriver.h" >+#import "TestWKWebView.h" >+#import "TestWKWebViewController.h" >+#import "Utilities.h" >+#import <WebKit/WKWebViewConfigurationPrivate.h> >+#import <WebKit/WebKit.h> >+ >+static bool willPresentCalled; >+static bool contextMenuRequested; >+static RetainPtr<NSURL> simpleURL; >+ >+@interface TestContextMenuUIDelegate : NSObject <WKUIDelegate> >+@end >+ >+@implementation TestContextMenuUIDelegate >+ >+- (void)webView:(WKWebView *)webView contextMenuConfigurationForElement:(WKContextMenuElementInfo *)elementInfo completionHandler:(void(^)(UIContextMenuConfiguration * _Nullable))completionHandler >+{ >+ EXPECT_TRUE([elementInfo.linkURL.absoluteString isEqualToString:[simpleURL absoluteString]]); >+ contextMenuRequested = true; >+ completionHandler([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:nil actionProvider:nil]); >+} >+ >+- (void)webView:(WKWebView *)webView contextMenuWillPresentForElement:(WKContextMenuElementInfo *)elementInfo >+{ >+ willPresentCalled = true; >+} >+ >+- (void)webView:(WKWebView *)webView contextMenuForElement:(WKContextMenuElementInfo *)elementInfo willCommitWithAnimator:(id<UIContextMenuInteractionCommitAnimating>)animator >+{ >+} >+ >+- (void)webView:(WKWebView *)webView contextMenuDidEndForElement:(WKContextMenuElementInfo *)elementInfo >+{ >+} >+ >+@end >+ >+#if USE(UICONTEXTMENU) >+TEST(WebKit, ContextMenuBasic) >+{ >+ 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]); >+ [configuration _setClickInteractionDriverForTesting:(id<_UIClickInteractionDriving>)driver.get()]; >+ 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()]]; >+ [driver begin:^(BOOL result) { >+ if (result) { >+ [driver clickDown]; >+ [driver clickUp]; >+ [driver end]; >+ } >+ }]; >+ TestWebKitAPI::Util::run(&willPresentCalled); >+} >+#endif // USE(UICONTEXTMENU) >+ >+#endif // PLATFORM(IOS) >diff --git a/Tools/TestWebKitAPI/cocoa/TestContextMenuDriver.h b/Tools/TestWebKitAPI/cocoa/TestContextMenuDriver.h >new file mode 100644 >index 0000000000000000000000000000000000000000..841f623c90a3ebb0754c3828f6fa15759bec0094 >--- /dev/null >+++ b/Tools/TestWebKitAPI/cocoa/TestContextMenuDriver.h >@@ -0,0 +1,44 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#import <wtf/WeakObjCPtr.h> >+ >+@protocol _UIClickInteractionDriverDelegate; >+@protocol _UIClickInteractionDriving; >+ >+@interface TestContextMenuDriver : NSObject { >+ WeakObjCPtr<id<_UIClickInteractionDriverDelegate>> _delegate; >+ WeakObjCPtr<UIView> _view; >+ CGFloat _allowableMovement; >+ RetainPtr<UIGestureRecognizer> _primaryGestureRecognizer; >+ NSTimeInterval _touchDuration; >+} >+- (void)begin:(void(^)(BOOL))completionHandler; >+- (void)clickDown; >+- (void)clickUp; >+- (void)end; >+@end >diff --git a/Tools/TestWebKitAPI/cocoa/TestContextMenuDriver.mm b/Tools/TestWebKitAPI/cocoa/TestContextMenuDriver.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..cad61b2ab429449fc8aa91881b9433e605670a22 >--- /dev/null >+++ b/Tools/TestWebKitAPI/cocoa/TestContextMenuDriver.mm >@@ -0,0 +1,117 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "TestContextMenuDriver.h" >+ >+#import "UIKitSPI.h" >+#import <wtf/BlockPtr.h> >+ >+@implementation TestContextMenuDriver >+ >+- (id<_UIClickInteractionDriverDelegate>)delegate >+{ >+ return _delegate.get().get(); >+} >+ >+- (void)setDelegate:(id<_UIClickInteractionDriverDelegate>)delegate >+{ >+ _delegate = delegate; >+} >+ >+- (UIView *)view >+{ >+ return _view.get().get(); >+} >+ >+- (void)setView:(UIView *)view >+{ >+ _view = view; >+} >+ >+- (CGFloat)allowableMovement >+{ >+ return _allowableMovement; >+} >+ >+- (void)setAllowableMovement:(CGFloat)allowableMovement >+{ >+ _allowableMovement = allowableMovement; >+} >+ >+- (UIGestureRecognizer *)primaryGestureRecognizer >+{ >+ return _primaryGestureRecognizer.get(); >+} >+ >+- (void)setPrimaryGestureRecognizer:(UIGestureRecognizer *)primaryGestureRecognizer >+{ >+ _primaryGestureRecognizer = primaryGestureRecognizer; >+} >+ >+- (NSTimeInterval)touchDuration >+{ >+ return _touchDuration; >+} >+ >+- (void)setTouchDuration:(NSTimeInterval)touchDuration >+{ >+ _touchDuration = touchDuration; >+} >+ >+- (CGPoint)locationInCoordinateSpace:(id <UICoordinateSpace>)coordinateSpace >+{ >+ return CGPointZero; >+} >+ >+- (void)cancelInteraction >+{ >+} >+ >+- (void)begin:(void(^)(BOOL))completionHandler >+{ >+ auto completionBlock = makeBlockPtr(completionHandler); >+ [self.delegate clickDriver:(id<_UIClickInteractionDriving>)self shouldBegin:^(BOOL result) { >+ [self.delegate clickDriver:(id<_UIClickInteractionDriving>)self didPerformEvent:_UIClickInteractionEventBegan]; >+ completionBlock(result); >+ }]; >+} >+ >+- (void)clickDown >+{ >+ [self.delegate clickDriver:(id<_UIClickInteractionDriving>)self didPerformEvent:_UIClickInteractionEventClickedDown]; >+} >+ >+- (void)clickUp >+{ >+ [self.delegate clickDriver:(id<_UIClickInteractionDriving>)self didPerformEvent:_UIClickInteractionEventClickedUp]; >+} >+ >+- (void)end >+{ >+ [self.delegate clickDriver:(id<_UIClickInteractionDriving>)self didPerformEvent:_UIClickInteractionEventEnded]; >+} >+ >+@end >diff --git a/Tools/TestWebKitAPI/ios/UIKitSPI.h b/Tools/TestWebKitAPI/ios/UIKitSPI.h >index d930ae4e373a0bac6f8aa758b47521eee0d537a8..5726bdb35dabada075c1f9fb08e95760fede0a30 100644 >--- a/Tools/TestWebKitAPI/ios/UIKitSPI.h >+++ b/Tools/TestWebKitAPI/ios/UIKitSPI.h >@@ -199,6 +199,24 @@ typedef NS_OPTIONS(NSInteger, UIWKDocumentRequestFlags) { > - (void)_dropInteraction:(UIDropInteraction *)interaction delayedPreviewProviderForDroppingItem:(UIDragItem *)item previewProvider:(void(^)(UITargetedDragPreview *preview))previewProvider; > @end > >+typedef NS_ENUM(NSUInteger, _UIClickInteractionEvent) { >+ _UIClickInteractionEventBegan = 0, >+ _UIClickInteractionEventClickedDown, >+ _UIClickInteractionEventClickedUp, >+ _UIClickInteractionEventEnded, >+ >+ _UIClickInteractionEventCount >+}; >+ >+@protocol _UIClickInteractionDriving; >+@protocol _UIClickInteractionDriverDelegate <NSObject> >+- (void)clickDriver:(id<_UIClickInteractionDriving>)driver shouldBegin:(void(^)(BOOL))completion; >+- (void)clickDriver:(id<_UIClickInteractionDriving>)driver didPerformEvent:(_UIClickInteractionEvent)event; >+@optional >+- (void)clickDriver:(id<_UIClickInteractionDriving>)driver didUpdateHighlightProgress:(CGFloat)progress; >+- (BOOL)clickDriver:(id<_UIClickInteractionDriving>)driver shouldDelayGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer; >+@end >+ > #endif // PLATFORM(IOS) > > #endif // PLATFORM(IOS_FAMILY)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199043
:
372502
|
372516
|
372531
|
372564
|
372565
|
372580