From: wenson_hsieh@apple.com Date: Sat, 19 Aug 2017 08:46:16 +0000 (+0000) Subject: [iOS WK2] Add a version of DataInteractionTests.ExternalSourceAttributedStringToConte... X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=081f891ca0c5bda4f5379af4f3ab04f29f0f768e [iOS WK2] Add a version of DataInteractionTests.ExternalSourceAttributedStringToContentEditable that doesn't hit a debug assertion https://bugs.webkit.org/show_bug.cgi?id=175509 Reviewed by Ryosuke Niwa. Removes ExternalSourceAttributedStringToContentEditable and adds ExternalSourceColoredAttributedStringToContentEditable, which tests dropping an attributed string with colored text instead of a bold attributed string of system font. Due to a recent change in behavior in UIKit, the original test (which this patch renames to ExternalSourceBoldSystemAttributedStringToContentEditable) hits a debug assertion when dropping text of system bold font. Since the original intent of this test was to verify that the attributed string UTI can be accepted in richly contenteditable areas, it suffices to check that some other style attribute, such as color, carries over from the NSAttributedString to the DOM. Also marks ExternalSourceBoldSystemAttributedStringToContentEditable as disabled for the time being. * TestWebKitAPI/Tests/ios/DataInteractionTests.mm: (TestWebKitAPI::TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220952 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 78f8e852289e..00b15626b4e5 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,24 @@ +2017-08-19 Wenson Hsieh + + [iOS WK2] Add a version of DataInteractionTests.ExternalSourceAttributedStringToContentEditable that doesn't hit a debug assertion + https://bugs.webkit.org/show_bug.cgi?id=175509 + + + Reviewed by Ryosuke Niwa. + + Removes ExternalSourceAttributedStringToContentEditable and adds + ExternalSourceColoredAttributedStringToContentEditable, which tests dropping an attributed string with colored + text instead of a bold attributed string of system font. Due to a recent change in behavior in UIKit, the + original test (which this patch renames to ExternalSourceBoldSystemAttributedStringToContentEditable) hits a + debug assertion when dropping text of system bold font. Since the original intent of this test was to verify + that the attributed string UTI can be accepted in richly contenteditable areas, it suffices to check that some + other style attribute, such as color, carries over from the NSAttributedString to the DOM. + + Also marks ExternalSourceBoldSystemAttributedStringToContentEditable as disabled for the time being. + + * TestWebKitAPI/Tests/ios/DataInteractionTests.mm: + (TestWebKitAPI::TEST): + 2017-08-18 Ryan Haddad Unreviewed, rolling out r220938. diff --git a/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm b/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm index 198b3fe2e528..7455dd5b43a5 100644 --- a/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm +++ b/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm @@ -685,7 +685,7 @@ TEST(DataInteractionTests, ExternalSourceHTMLToContentEditable) EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!editor.querySelector('h1')"].boolValue); } -TEST(DataInteractionTests, ExternalSourceAttributedStringToContentEditable) +TEST(DataInteractionTests, DISABLED_ExternalSourceBoldSystemAttributedStringToContentEditable) { auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); [webView synchronouslyLoadTestPageNamed:@"autofocus-contenteditable"]; @@ -701,6 +701,23 @@ TEST(DataInteractionTests, ExternalSourceAttributedStringToContentEditable) EXPECT_WK_STREQ("This is a test", [webView stringByEvaluatingJavaScript:@"editor.textContent"].UTF8String); } +TEST(DataInteractionTests, ExternalSourceColoredAttributedStringToContentEditable) +{ + auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); + [webView synchronouslyLoadTestPageNamed:@"autofocus-contenteditable"]; + [webView stringByEvaluatingJavaScript:@"getSelection().removeAllRanges()"]; + + auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]); + NSDictionary *textAttributes = @{ NSForegroundColorAttributeName: [UIColor redColor] }; + NSAttributedString *richText = [[NSAttributedString alloc] initWithString:@"This is a test" attributes:textAttributes]; + auto itemProvider = adoptNS([[UIItemProvider alloc] initWithObject:richText]); + [dataInteractionSimulator setExternalItemProviders:@[ itemProvider.get() ]]; + [dataInteractionSimulator runFrom:CGPointMake(300, 400) to:CGPointMake(100, 300)]; + + EXPECT_WK_STREQ("rgb(255, 0, 0)", [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.querySelector('p')).color"]); + EXPECT_WK_STREQ("This is a test", [webView stringByEvaluatingJavaScript:@"editor.textContent"].UTF8String); +} + TEST(DataInteractionTests, ExternalSourceMultipleURLsToContentEditable) { auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);