Title: [219129] trunk

Diff

Modified: trunk/Source/WebCore/ChangeLog (219128 => 219129)


--- trunk/Source/WebCore/ChangeLog	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Source/WebCore/ChangeLog	2017-07-05 16:07:27 UTC (rev 219129)
@@ -1,5 +1,18 @@
 2017-07-05  Matt Lewis  <[email protected]>
 
+        Unreviewed, rolling out r219128.
+
+        Spoke with engineer who originally submitted, Patch for APi
+        test to follow.
+
+        Reverted changeset:
+
+        "Unreviewed, rolling out r219070."
+        https://bugs.webkit.org/show_bug.cgi?id=174082
+        http://trac.webkit.org/changeset/219128
+
+2017-07-05  Matt Lewis  <[email protected]>
+
         Unreviewed, rolling out r219070.
 
         This revision caused consistent failures of the API test

Modified: trunk/Source/WebCore/platform/PlatformPasteboard.h (219128 => 219129)


--- trunk/Source/WebCore/platform/PlatformPasteboard.h	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Source/WebCore/platform/PlatformPasteboard.h	2017-07-05 16:07:27 UTC (rev 219129)
@@ -102,6 +102,7 @@
     WEBCORE_EXPORT void writeObjectRepresentations(const PasteboardImage&);
     WEBCORE_EXPORT void writeObjectRepresentations(const String& pasteboardType, const String& text);
     WEBCORE_EXPORT void writeObjectRepresentations(const PasteboardURL&);
+    bool allowReadingURLAtIndex(const URL&, int index) const;
 #endif
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebCore/platform/ios/AbstractPasteboard.h (219128 => 219129)


--- trunk/Source/WebCore/platform/ios/AbstractPasteboard.h	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Source/WebCore/platform/ios/AbstractPasteboard.h	2017-07-05 16:07:27 UTC (rev 219129)
@@ -34,6 +34,10 @@
 
 @property (readonly, nonatomic) NSInteger numberOfItems;
 
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+@property (nonatomic, copy, nullable) NSArray<__kindof NSItemProvider *> *itemProviders;
+#endif
+
 - (NSArray<NSString *> *)pasteboardTypes;
 - (NSArray *)dataForPasteboardType:(NSString *)pasteboardType inItemSet:(NSIndexSet *)itemSet;
 - (NSArray *)valuesForPasteboardType:(NSString *)pasteboardType inItemSet:(NSIndexSet *)itemSet;

Modified: trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (219128 => 219129)


--- trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2017-07-05 16:07:27 UTC (rev 219129)
@@ -215,6 +215,24 @@
     [itemsToRegister addData:[(NSString *)plainText dataUsingEncoding:NSUTF8StringEncoding] forType:(NSString *)kUTTypeUTF8PlainText];
 }
 
+bool PlatformPasteboard::allowReadingURLAtIndex(const URL& url, int index) const
+{
+    NSItemProvider *itemProvider = (NSUInteger)index < [m_pasteboard itemProviders].count ? [[m_pasteboard itemProviders] objectAtIndex:index] : nil;
+    for (NSString *type in itemProvider.registeredTypeIdentifiers) {
+        if (UTTypeConformsTo((CFStringRef)type, kUTTypeURL))
+            return true;
+    }
+
+    return url.isValid();
+}
+
+#else
+
+bool PlatformPasteboard::allowReadingURLAtIndex(const URL&, int) const
+{
+    return true;
+}
+
 #endif
 
 void PlatformPasteboard::writeObjectRepresentations(const PasteboardWebContent& content)
@@ -426,7 +444,7 @@
             return [(NSAttributedString *)value string];
     } else if (type == String(kUTTypeURL)) {
         ASSERT([value isKindOfClass:[NSURL class]]);
-        if ([value isKindOfClass:[NSURL class]])
+        if ([value isKindOfClass:[NSURL class]] && allowReadingURLAtIndex((NSURL *)value, index))
             return [(NSURL *)value absoluteString];
     }
 
@@ -447,6 +465,9 @@
     if (![value isKindOfClass:[NSURL class]])
         return URL();
 
+    if (!allowReadingURLAtIndex((NSURL *)value, index))
+        return { };
+
 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     title = [value _title];
 #else

Modified: trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.h (219128 => 219129)


--- trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.h	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.h	2017-07-05 16:07:27 UTC (rev 219129)
@@ -79,7 +79,7 @@
 - (WebItemProviderRegistrationInfoList *)registrationInfoAtIndex:(NSUInteger)index;
 - (UIItemProvider *)itemProviderAtIndex:(NSUInteger)index;
 
-@property (copy, nonatomic, nullable) NSArray<UIItemProvider *> *itemProviders;
+@property (copy, nonatomic, nullable) NSArray<__kindof NSItemProvider *> *itemProviders;
 @property (readonly, nonatomic) NSInteger numberOfItems;
 @property (readonly, nonatomic) NSInteger changeCount;
 

Modified: trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm (219128 => 219129)


--- trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm	2017-07-05 16:07:27 UTC (rev 219129)
@@ -222,12 +222,12 @@
     return _cachedTypeIdentifiers.get();
 }
 
-- (NSArray<UIItemProvider *> *)itemProviders
+- (NSArray<__kindof NSItemProvider *> *)itemProviders
 {
     return _itemProviders.get();
 }
 
-- (void)setItemProviders:(NSArray<UIItemProvider *> *)itemProviders
+- (void)setItemProviders:(NSArray<__kindof NSItemProvider *> *)itemProviders
 {
     itemProviders = itemProviders ?: [NSArray array];
     if (_itemProviders == itemProviders || [_itemProviders isEqualToArray:itemProviders])

Modified: trunk/Source/WebKit2/ChangeLog (219128 => 219129)


--- trunk/Source/WebKit2/ChangeLog	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Source/WebKit2/ChangeLog	2017-07-05 16:07:27 UTC (rev 219129)
@@ -1,5 +1,18 @@
 2017-07-05  Matt Lewis  <[email protected]>
 
+        Unreviewed, rolling out r219128.
+
+        Spoke with engineer who originally submitted, Patch for APi
+        test to follow.
+
+        Reverted changeset:
+
+        "Unreviewed, rolling out r219070."
+        https://bugs.webkit.org/show_bug.cgi?id=174082
+        http://trac.webkit.org/changeset/219128
+
+2017-07-05  Matt Lewis  <[email protected]>
+
         Unreviewed, rolling out r219070.
 
         This revision caused consistent failures of the API test

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.mm (219128 => 219129)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.mm	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.mm	2017-07-05 16:07:27 UTC (rev 219129)
@@ -627,6 +627,16 @@
     return _preferences->_javascript_CanAccessClipboard();
 }
 
+- (void)_setDOMPasteAllowed:(BOOL)domPasteAllowed
+{
+    _preferences->setDOMPasteAllowed(domPasteAllowed);
+}
+
+- (BOOL)_domPasteAllowed
+{
+    return _preferences->domPasteAllowed();
+}
+
 - (void)_setMediaDocumentEntersFullscreenAutomatically:(BOOL)mediaDocumentEntersFullscreenAutomatically
 {
     _preferences->setMediaDocumentEntersFullscreenAutomatically(mediaDocumentEntersFullscreenAutomatically);

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h (219128 => 219129)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2017-07-05 16:07:27 UTC (rev 219129)
@@ -107,6 +107,7 @@
 @property (nonatomic, setter=_setWebRTCLegacyAPIEnabled:) BOOL _webRTCLegacyAPIEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @property (nonatomic, setter=_setJavaScriptCanAccessClipboard:) BOOL _javaScriptCanAccessClipboard WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setDOMPasteAllowed:) BOOL _domPasteAllowed WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @property (nonatomic, setter=_setMediaDocumentEntersFullscreenAutomatically:) BOOL _mediaDocumentEntersFullscreenAutomatically WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 

Modified: trunk/Tools/ChangeLog (219128 => 219129)


--- trunk/Tools/ChangeLog	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Tools/ChangeLog	2017-07-05 16:07:27 UTC (rev 219129)
@@ -1,5 +1,18 @@
 2017-07-05  Matt Lewis  <[email protected]>
 
+        Unreviewed, rolling out r219128.
+
+        Spoke with engineer who originally submitted, Patch for APi
+        test to follow.
+
+        Reverted changeset:
+
+        "Unreviewed, rolling out r219070."
+        https://bugs.webkit.org/show_bug.cgi?id=174082
+        http://trac.webkit.org/changeset/219128
+
+2017-07-05  Matt Lewis  <[email protected]>
+
         Unreviewed, rolling out r219070.
 
         This revision caused consistent failures of the API test

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm (219128 => 219129)


--- trunk/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm	2017-07-05 15:59:45 UTC (rev 219128)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm	2017-07-05 16:07:27 UTC (rev 219129)
@@ -31,9 +31,13 @@
 #import "TestWKWebView.h"
 #import <MobileCoreServices/MobileCoreServices.h>
 #import <UIKit/UIPasteboard.h>
+#import <WebCore/SoftLinking.h>
 #import <WebKit/WKPreferencesPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>
 
+SOFT_LINK_FRAMEWORK(UIKit)
+SOFT_LINK(UIKit, UIApplicationInitialize, void, (void), ())
+
 namespace TestWebKitAPI {
 
 NSData *dataForPasteboardType(CFStringRef type)
@@ -43,12 +47,17 @@
 
 RetainPtr<TestWKWebView> setUpWebViewForPasteboardTests()
 {
+    // UIPasteboard's type coercion codepaths only take effect when the UIApplication has been initialized.
+    UIApplicationInitialize();
+
     [UIPasteboard generalPasteboard].items = @[];
     EXPECT_TRUE(!dataForPasteboardType(kUTTypeUTF8PlainText).length);
     EXPECT_TRUE(!dataForPasteboardType(kUTTypeUTF16PlainText).length);
 
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
-    [webView configuration].preferences._javaScriptCanAccessClipboard = YES;
+    WKPreferences *preferences = [webView configuration].preferences;
+    preferences._javaScriptCanAccessClipboard = YES;
+    preferences._domPasteAllowed = YES;
     [webView synchronouslyLoadTestPageNamed:@"rich-and-plain-text"];
     return webView;
 }
@@ -77,6 +86,57 @@
     EXPECT_WK_STREQ("Hello world", [utf16Result UTF8String]);
 }
 
+TEST(UIPasteboardTests, DoNotPastePlainTextAsURL)
+{
+    auto webView = setUpWebViewForPasteboardTests();
+
+    NSString *testString = @"[helloworld]";
+    [UIPasteboard generalPasteboard].string = testString;
+
+    [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
+    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"plain.value"]);
+
+    [webView stringByEvaluatingJavaScript:@"selectRichText()"];
+    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"rich.textContent"]);
+    EXPECT_FALSE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
+}
+
+TEST(UIPasteboardTests, PastePlainTextAsURL)
+{
+    auto webView = setUpWebViewForPasteboardTests();
+
+    NSString *testString = @"https://www.apple.com/iphone";
+    [UIPasteboard generalPasteboard].string = testString;
+
+    [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
+    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"plain.value"]);
+
+    [webView stringByEvaluatingJavaScript:@"selectRichText()"];
+    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"rich.textContent"]);
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
+}
+
+TEST(UIPasteboardTests, PasteURLWithPlainTextAsURL)
+{
+    auto webView = setUpWebViewForPasteboardTests();
+
+    NSString *testString = @"thisisdefinitelyaurl";
+    [UIPasteboard generalPasteboard].URL = "" URLWithString:testString];
+
+    [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
+    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"plain.value"]);
+
+    [webView stringByEvaluatingJavaScript:@"selectRichText()"];
+    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"rich.textContent"]);
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
+}
+
 } // namespace TestWebKitAPI
 
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to