Changeset 228825 in webkit


Ignore:
Timestamp:
Feb 20, 2018 10:32:09 AM (6 years ago)
Author:
Wenson Hsieh
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):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r228824 r228825  
     12018-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS 11.3 Beta] Can't copy a URL from Safari and paste it into the Gmail app
     4        https://bugs.webkit.org/show_bug.cgi?id=182952
     5        <rdar://problem/37636190>
     6
     7        Reviewed by Tim Horton.
     8
     9        After r220865 refactored the iOS copy codepaths to use NSItemProviders, we stopped writing the URL as plain text
     10        to the pasteboard. However, this means clients that only check for "text/plain" (or one of its aliases) on the
     11        pasteboard won't read any data on paste.
     12
     13        To fix this, we restore the pre-iOS 11.3 behavior of writing both the URL and plain text to the pasteboard.
     14        Since we're using item providers, we also ensure that the NSURL is at a higher fidelity than the string to make
     15        it clear that the data should be consumed as a URL.
     16
     17        This patch also rebaselines an existing drag and drop test to cover this change, and adds a new API test,
     18        ActionSheetTests.CopyLinkWritesURLAndPlainText, which simulates copying a link using the share sheet and pasting
     19        into a DataTransfer-dumping test harness.
     20
     21        * platform/ios/PlatformPasteboardIOS.mm:
     22        (WebCore::PlatformPasteboard::write):
     23
    1242018-02-20  Eric Carlson  <eric.carlson@apple.com>
    225
  • trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm

    r228531 r228825  
    385385            nsURL._title = url.title;
    386386        [representationsToRegister addRepresentingObject:nsURL];
     387        [representationsToRegister addRepresentingObject:(NSString *)url.url.string()];
    387388    }
    388389
  • trunk/Tools/ChangeLog

    r228818 r228825  
     12018-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS 11.3 Beta] Can't copy a URL from Safari and paste it into the Gmail app
     4        https://bugs.webkit.org/show_bug.cgi?id=182952
     5        <rdar://problem/37636190>
     6
     7        Reviewed by Tim Horton.
     8
     9        Adds a new iOS copy/paste test that copies an anchor element via action sheet, and checks that upon pasting,
     10        both "text/plain" and "text/uri-list" are provided. Additionally tweaks an existing iOS drag and drop test to
     11        check for the same behavior.
     12
     13        * TestWebKitAPI/Tests/ios/ActionSheetTests.mm:
     14        (TestWebKitAPI::TEST):
     15        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
     16        (TestWebKitAPI::TEST):
     17
    1182018-02-20  Philippe Normand  <pnormand@igalia.com>
    219
  • trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm

    r227135 r228825  
    141141}
    142142
    143 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
    144 
    145143static void presentActionSheetAndChooseAction(WKWebView *webView, ActionSheetObserver *observer, CGPoint location, _WKElementActionType actionType)
    146144{
     
    273271}
    274272
    275 #endif // __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     273TEST(ActionSheetTests, CopyLinkWritesURLAndPlainText)
     274{
     275    UIApplicationInitialize();
     276    [UIPasteboard generalPasteboard].items = @[ ];
     277
     278    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     279    auto observer = adoptNS([[ActionSheetObserver alloc] init]);
     280    [webView setUIDelegate:observer.get()];
     281    [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
     282
     283    presentActionSheetAndChooseAction(webView.get(), observer.get(), CGPointMake(100, 100), _WKElementActionTypeCopy);
     284
     285    [webView synchronouslyLoadTestPageNamed:@"DataTransfer"];
     286    [webView paste:nil];
     287
     288    EXPECT_WK_STREQ("text/uri-list, text/plain", [webView stringByEvaluatingJavaScript:@"types.textContent"]);
     289    EXPECT_WK_STREQ("(STRING, text/uri-list), (STRING, text/plain)", [webView stringByEvaluatingJavaScript:@"items.textContent"]);
     290    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"files.textContent"]);
     291    EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"textData.textContent"]);
     292    EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"urlData.textContent"]);
     293    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"htmlData.textContent"]);
     294    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"rawHTMLData.textContent"]);
     295}
    276296
    277297} // namespace TestWebKitAPI
  • trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm

    r228340 r228825  
    15811581    [simulator runFrom:CGPointMake(50, 225) to:CGPointMake(50, 375)];
    15821582    checkJSONWithLogging([webView stringByEvaluatingJavaScript:@"output.value"], @{
    1583         @"dragover": @{ @"text/uri-list" : @"" },
    1584         @"drop": @{ @"text/uri-list" : @"https://www.apple.com/" }
     1583        @"dragover": @{
     1584            @"text/uri-list" : @"",
     1585            @"text/plain" : @""
     1586        },
     1587        @"drop": @{
     1588            @"text/uri-list" : @"https://www.apple.com/",
     1589            @"text/plain" : @"https://www.apple.com/"
     1590        }
    15851591    });
    15861592}
Note: See TracChangeset for help on using the changeset viewer.