[iOS WK2] Add a version of DataInteractionTests.ExternalSourceAttributedStringToConte...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Aug 2017 08:46:16 +0000 (08:46 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Aug 2017 08:46:16 +0000 (08:46 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220952 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm

index 78f8e852289eb523acf2eca298aa3f826ee35dd3..00b15626b4e5f16c1af784946485d17a2161b544 100644 (file)
@@ -1,3 +1,24 @@
+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.
index 198b3fe2e528405dc5a450e8285375cd779cce5e..7455dd5b43a514ae7855796d148d2df8b56ef1da 100644 (file)
@@ -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)]);