⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 219129 in webkit


Ignore:
Timestamp:
Jul 5, 2017, 9:07:27 AM (9 years ago)
Author:
Matt Lewis
Message:

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

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r219128 r219129  
     12017-07-05  Matt Lewis  <jlewis3@apple.com>
     2
     3        Unreviewed, rolling out r219128.
     4
     5        Spoke with engineer who originally submitted, Patch for APi
     6        test to follow.
     7
     8        Reverted changeset:
     9
     10        "Unreviewed, rolling out r219070."
     11        https://bugs.webkit.org/show_bug.cgi?id=174082
     12        http://trac.webkit.org/changeset/219128
     13
    1142017-07-05  Matt Lewis  <jlewis3@apple.com>
    215
  • trunk/Source/WebCore/platform/PlatformPasteboard.h

    r219128 r219129  
    103103    WEBCORE_EXPORT void writeObjectRepresentations(const String& pasteboardType, const String& text);
    104104    WEBCORE_EXPORT void writeObjectRepresentations(const PasteboardURL&);
     105    bool allowReadingURLAtIndex(const URL&, int index) const;
    105106#endif
    106107
  • trunk/Source/WebCore/platform/ios/AbstractPasteboard.h

    r219128 r219129  
    3535@property (readonly, nonatomic) NSInteger numberOfItems;
    3636
     37#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     38@property (nonatomic, copy, nullable) NSArray<__kindof NSItemProvider *> *itemProviders;
     39#endif
     40
    3741- (NSArray<NSString *> *)pasteboardTypes;
    3842- (NSArray *)dataForPasteboardType:(NSString *)pasteboardType inItemSet:(NSIndexSet *)itemSet;
  • trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm

    r219128 r219129  
    216216}
    217217
     218bool PlatformPasteboard::allowReadingURLAtIndex(const URL& url, int index) const
     219{
     220    NSItemProvider *itemProvider = (NSUInteger)index < [m_pasteboard itemProviders].count ? [[m_pasteboard itemProviders] objectAtIndex:index] : nil;
     221    for (NSString *type in itemProvider.registeredTypeIdentifiers) {
     222        if (UTTypeConformsTo((CFStringRef)type, kUTTypeURL))
     223            return true;
     224    }
     225
     226    return url.isValid();
     227}
     228
     229#else
     230
     231bool PlatformPasteboard::allowReadingURLAtIndex(const URL&, int) const
     232{
     233    return true;
     234}
     235
    218236#endif
    219237
    … …  
    427445    } else if (type == String(kUTTypeURL)) {
    428446        ASSERT([value isKindOfClass:[NSURL class]]);
    429         if ([value isKindOfClass:[NSURL class]])
     447        if ([value isKindOfClass:[NSURL class]] && allowReadingURLAtIndex((NSURL *)value, index))
    430448            return [(NSURL *)value absoluteString];
    431449    }
    … …  
    448466        return URL();
    449467
     468    if (!allowReadingURLAtIndex((NSURL *)value, index))
     469        return { };
     470
    450471#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
    451472    title = [value _title];
  • trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.h

    r219128 r219129  
    8080- (UIItemProvider *)itemProviderAtIndex:(NSUInteger)index;
    8181
    82 @property (copy, nonatomic, nullable) NSArray<UIItemProvider *> *itemProviders;
     82@property (copy, nonatomic, nullable) NSArray<__kindof NSItemProvider *> *itemProviders;
    8383@property (readonly, nonatomic) NSInteger numberOfItems;
    8484@property (readonly, nonatomic) NSInteger changeCount;
  • trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm

    r219128 r219129  
    223223}
    224224
    225 - (NSArray<UIItemProvider *> *)itemProviders
     225- (NSArray<__kindof NSItemProvider *> *)itemProviders
    226226{
    227227    return _itemProviders.get();
    228228}
    229229
    230 - (void)setItemProviders:(NSArray<UIItemProvider *> *)itemProviders
     230- (void)setItemProviders:(NSArray<__kindof NSItemProvider *> *)itemProviders
    231231{
    232232    itemProviders = itemProviders ?: [NSArray array];
  • trunk/Source/WebKit2/ChangeLog

    r219128 r219129  
     12017-07-05  Matt Lewis  <jlewis3@apple.com>
     2
     3        Unreviewed, rolling out r219128.
     4
     5        Spoke with engineer who originally submitted, Patch for APi
     6        test to follow.
     7
     8        Reverted changeset:
     9
     10        "Unreviewed, rolling out r219070."
     11        https://bugs.webkit.org/show_bug.cgi?id=174082
     12        http://trac.webkit.org/changeset/219128
     13
    1142017-07-05  Matt Lewis  <jlewis3@apple.com>
    215
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.mm

    r219128 r219129  
    628628}
    629629
     630- (void)_setDOMPasteAllowed:(BOOL)domPasteAllowed
     631{
     632    _preferences->setDOMPasteAllowed(domPasteAllowed);
     633}
     634
     635- (BOOL)_domPasteAllowed
     636{
     637    return _preferences->domPasteAllowed();
     638}
     639
    630640- (void)_setMediaDocumentEntersFullscreenAutomatically:(BOOL)mediaDocumentEntersFullscreenAutomatically
    631641{
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h

    r219128 r219129  
    108108
    109109@property (nonatomic, setter=_setJavaScriptCanAccessClipboard:) BOOL _javaScriptCanAccessClipboard WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     110@property (nonatomic, setter=_setDOMPasteAllowed:) BOOL _domPasteAllowed WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    110111
    111112@property (nonatomic, setter=_setMediaDocumentEntersFullscreenAutomatically:) BOOL _mediaDocumentEntersFullscreenAutomatically WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
  • trunk/Tools/ChangeLog

    r219128 r219129  
     12017-07-05  Matt Lewis  <jlewis3@apple.com>
     2
     3        Unreviewed, rolling out r219128.
     4
     5        Spoke with engineer who originally submitted, Patch for APi
     6        test to follow.
     7
     8        Reverted changeset:
     9
     10        "Unreviewed, rolling out r219070."
     11        https://bugs.webkit.org/show_bug.cgi?id=174082
     12        http://trac.webkit.org/changeset/219128
     13
    1142017-07-05  Matt Lewis  <jlewis3@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm

    r219128 r219129  
    3232#import <MobileCoreServices/MobileCoreServices.h>
    3333#import <UIKit/UIPasteboard.h>
     34#import <WebCore/SoftLinking.h>
    3435#import <WebKit/WKPreferencesPrivate.h>
    3536#import <WebKit/WKWebViewPrivate.h>
     37
     38SOFT_LINK_FRAMEWORK(UIKit)
     39SOFT_LINK(UIKit, UIApplicationInitialize, void, (void), ())
    3640
    3741namespace TestWebKitAPI {
    … …  
    4448RetainPtr<TestWKWebView> setUpWebViewForPasteboardTests()
    4549{
     50    // UIPasteboard's type coercion codepaths only take effect when the UIApplication has been initialized.
     51    UIApplicationInitialize();
     52
    4653    [UIPasteboard generalPasteboard].items = @[];
    4754    EXPECT_TRUE(!dataForPasteboardType(kUTTypeUTF8PlainText).length);
    … …  
    4956
    5057    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
    51     [webView configuration].preferences._javaScriptCanAccessClipboard = YES;
     58    WKPreferences *preferences = [webView configuration].preferences;
     59    preferences._javaScriptCanAccessClipboard = YES;
     60    preferences._domPasteAllowed = YES;
    5261    [webView synchronouslyLoadTestPageNamed:@"rich-and-plain-text"];
    5362    return webView;
    … …  
    7887}
    7988
     89TEST(UIPasteboardTests, DoNotPastePlainTextAsURL)
     90{
     91    auto webView = setUpWebViewForPasteboardTests();
     92
     93    NSString *testString = @"[helloworld]";
     94    [UIPasteboard generalPasteboard].string = testString;
     95
     96    [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
     97    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
     98    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"plain.value"]);
     99
     100    [webView stringByEvaluatingJavaScript:@"selectRichText()"];
     101    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
     102    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"rich.textContent"]);
     103    EXPECT_FALSE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
     104}
     105
     106TEST(UIPasteboardTests, PastePlainTextAsURL)
     107{
     108    auto webView = setUpWebViewForPasteboardTests();
     109
     110    NSString *testString = @"https://www.apple.com/iphone";
     111    [UIPasteboard generalPasteboard].string = testString;
     112
     113    [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
     114    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
     115    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"plain.value"]);
     116
     117    [webView stringByEvaluatingJavaScript:@"selectRichText()"];
     118    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
     119    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"rich.textContent"]);
     120    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
     121}
     122
     123TEST(UIPasteboardTests, PasteURLWithPlainTextAsURL)
     124{
     125    auto webView = setUpWebViewForPasteboardTests();
     126
     127    NSString *testString = @"thisisdefinitelyaurl";
     128    [UIPasteboard generalPasteboard].URL = [NSURL URLWithString:testString];
     129
     130    [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
     131    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
     132    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"plain.value"]);
     133
     134    [webView stringByEvaluatingJavaScript:@"selectRichText()"];
     135    [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
     136    EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"rich.textContent"]);
     137    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
     138}
     139
    80140} // namespace TestWebKitAPI
    81141
Note: See TracChangeset for help on using the changeset viewer.