Title: [228825] trunk
Revision
228825
Author
wenson_hs...@apple.com
Date
2018-02-20 10:32:09 -0800 (Tue, 20 Feb 2018)

Log Message

[iOS 11.3 Beta] Can't copy a URL from Safari and paste it into the Gmail app
https://bugs.webkit.org/show_bug.cgi?id=182952
<rdar://problem/37636190>

Reviewed by Tim Horton.

Source/WebCore:

After r220865 refactored the iOS copy codepaths to use NSItemProviders, we stopped writing the URL as plain text
to the pasteboard. However, this means clients that only check for "text/plain" (or one of its aliases) on the
pasteboard won't read any data on paste.

To fix this, we restore the pre-iOS 11.3 behavior of writing both the URL and plain text to the pasteboard.
Since we're using item providers, we also ensure that the NSURL is at a higher fidelity than the string to make
it clear that the data should be consumed as a URL.

This patch also rebaselines an existing drag and drop test to cover this change, and adds a new API test,
ActionSheetTests.CopyLinkWritesURLAndPlainText, which simulates copying a link using the share sheet and pasting
into a DataTransfer-dumping test harness.

* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::write):

Tools:

Adds a new iOS copy/paste test that copies an anchor element via action sheet, and checks that upon pasting,
both "text/plain" and "text/uri-list" are provided. Additionally tweaks an existing iOS drag and drop test to
check for the same behavior.

* TestWebKitAPI/Tests/ios/ActionSheetTests.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228824 => 228825)


--- trunk/Source/WebCore/ChangeLog	2018-02-20 18:29:02 UTC (rev 228824)
+++ trunk/Source/WebCore/ChangeLog	2018-02-20 18:32:09 UTC (rev 228825)
@@ -1,3 +1,26 @@
+2018-02-20  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS 11.3 Beta] Can't copy a URL from Safari and paste it into the Gmail app
+        https://bugs.webkit.org/show_bug.cgi?id=182952
+        <rdar://problem/37636190>
+
+        Reviewed by Tim Horton.
+
+        After r220865 refactored the iOS copy codepaths to use NSItemProviders, we stopped writing the URL as plain text
+        to the pasteboard. However, this means clients that only check for "text/plain" (or one of its aliases) on the
+        pasteboard won't read any data on paste.
+
+        To fix this, we restore the pre-iOS 11.3 behavior of writing both the URL and plain text to the pasteboard.
+        Since we're using item providers, we also ensure that the NSURL is at a higher fidelity than the string to make
+        it clear that the data should be consumed as a URL.
+
+        This patch also rebaselines an existing drag and drop test to cover this change, and adds a new API test,
+        ActionSheetTests.CopyLinkWritesURLAndPlainText, which simulates copying a link using the share sheet and pasting
+        into a DataTransfer-dumping test harness.
+
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::PlatformPasteboard::write):
+
 2018-02-20  Eric Carlson  <eric.carl...@apple.com>
 
         [iOS] Returning from Auto-PiP causes Safari to be unresponsive

Modified: trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (228824 => 228825)


--- trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2018-02-20 18:29:02 UTC (rev 228824)
+++ trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2018-02-20 18:32:09 UTC (rev 228825)
@@ -384,6 +384,7 @@
         if (!url.title.isEmpty())
             nsURL._title = url.title;
         [representationsToRegister addRepresentingObject:nsURL];
+        [representationsToRegister addRepresentingObject:(NSString *)url.url.string()];
     }
 
     registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());

Modified: trunk/Tools/ChangeLog (228824 => 228825)


--- trunk/Tools/ChangeLog	2018-02-20 18:29:02 UTC (rev 228824)
+++ trunk/Tools/ChangeLog	2018-02-20 18:32:09 UTC (rev 228825)
@@ -1,3 +1,20 @@
+2018-02-20  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS 11.3 Beta] Can't copy a URL from Safari and paste it into the Gmail app
+        https://bugs.webkit.org/show_bug.cgi?id=182952
+        <rdar://problem/37636190>
+
+        Reviewed by Tim Horton.
+
+        Adds a new iOS copy/paste test that copies an anchor element via action sheet, and checks that upon pasting,
+        both "text/plain" and "text/uri-list" are provided. Additionally tweaks an existing iOS drag and drop test to
+        check for the same behavior.
+
+        * TestWebKitAPI/Tests/ios/ActionSheetTests.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+        (TestWebKitAPI::TEST):
+
 2018-02-20  Philippe Normand  <pnorm...@igalia.com>
 
         [GStreamer][MiniBrowser] Honor GStreamer command line parameters in MiniBrowser

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm (228824 => 228825)


--- trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm	2018-02-20 18:29:02 UTC (rev 228824)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm	2018-02-20 18:32:09 UTC (rev 228825)
@@ -140,8 +140,6 @@
     EXPECT_TRUE(runTest(@"08080808080"));
 }
 
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
-
 static void presentActionSheetAndChooseAction(WKWebView *webView, ActionSheetObserver *observer, CGPoint location, _WKElementActionType actionType)
 {
     __block RetainPtr<_WKElementAction> copyAction;
@@ -272,8 +270,30 @@
     TestWebKitAPI::Util::run(&done);
 }
 
-#endif // __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+TEST(ActionSheetTests, CopyLinkWritesURLAndPlainText)
+{
+    UIApplicationInitialize();
+    [UIPasteboard generalPasteboard].items = @[ ];
 
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    auto observer = adoptNS([[ActionSheetObserver alloc] init]);
+    [webView setUIDelegate:observer.get()];
+    [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
+
+    presentActionSheetAndChooseAction(webView.get(), observer.get(), CGPointMake(100, 100), _WKElementActionTypeCopy);
+
+    [webView synchronouslyLoadTestPageNamed:@"DataTransfer"];
+    [webView paste:nil];
+
+    EXPECT_WK_STREQ("text/uri-list, text/plain", [webView stringByEvaluatingJavaScript:@"types.textContent"]);
+    EXPECT_WK_STREQ("(STRING, text/uri-list), (STRING, text/plain)", [webView stringByEvaluatingJavaScript:@"items.textContent"]);
+    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"files.textContent"]);
+    EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"textData.textContent"]);
+    EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"urlData.textContent"]);
+    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"htmlData.textContent"]);
+    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"rawHTMLData.textContent"]);
+}
+
 } // namespace TestWebKitAPI
 
 #endif // PLATFORM(IOS)

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (228824 => 228825)


--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm	2018-02-20 18:29:02 UTC (rev 228824)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm	2018-02-20 18:32:09 UTC (rev 228825)
@@ -1580,8 +1580,14 @@
     [webView stringByEvaluatingJavaScript:@"rich.innerHTML = '<a href="" is a link.</a>'"];
     [simulator runFrom:CGPointMake(50, 225) to:CGPointMake(50, 375)];
     checkJSONWithLogging([webView stringByEvaluatingJavaScript:@"output.value"], @{
-        @"dragover": @{ @"text/uri-list" : @"" },
-        @"drop": @{ @"text/uri-list" : @"https://www.apple.com/" }
+        @"dragover": @{
+            @"text/uri-list" : @"",
+            @"text/plain" : @""
+        },
+        @"drop": @{
+            @"text/uri-list" : @"https://www.apple.com/",
+            @"text/plain" : @"https://www.apple.com/"
+        }
     });
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to