+2017-08-19 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ [iOS WK2] Add a version of DataInteractionTests.ExternalSourceAttributedStringToContentEditable that doesn't hit a debug assertion
+ https://bugs.webkit.org/show_bug.cgi?id=175509
+ <rdar://problem/33728169>
+
+ 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 <ryanhaddad@apple.com>
Unreviewed, rolling out r220938.
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"];
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)]);