Title: [262926] trunk/Tools
Revision
262926
Author
[email protected]
Date
2020-06-11 15:11:53 -0700 (Thu, 11 Jun 2020)

Log Message

REGRESSION (r262879): 3 TestWebKitAPI.TextManipulation tests are failing
https://bugs.webkit.org/show_bug.cgi?id=213079
<rdar://problem/64256870>

Reviewed by Wenson Hsieh.

Update a few tests after behavior change in r262879. From r262879, we no longer use visible positions of element
to calculate range to observe. Instead, we use the first and end position in the element to decide the range. In
previous implementation, the range can be extended to outside of the element, like some visible positon before
or after the element.

TextManipulation.StartTextManipulationFindNewlyDisplayedParagraph: Different elements would make separate ranges
because we create range with the boundaries of element. We can consider merging adjacent ranges later.
TextManipulation.StartTextManipulationFindSameParagraphWithNewContent: The newly observing range only includes
the newly inserted element now.
TextManipulation.InsertingContentIntoAlreadyManipulatedContentDoesNotCreateTextManipulationItem: The p element
is not manipulated as it is the common ancestor of manipulated elements. And we want to make sure the newly
inserted element is child of a manipulated element.

* TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (262925 => 262926)


--- trunk/Tools/ChangeLog	2020-06-11 21:05:39 UTC (rev 262925)
+++ trunk/Tools/ChangeLog	2020-06-11 22:11:53 UTC (rev 262926)
@@ -1,3 +1,27 @@
+2020-06-11  Sihui Liu  <[email protected]>
+
+        REGRESSION (r262879): 3 TestWebKitAPI.TextManipulation tests are failing
+        https://bugs.webkit.org/show_bug.cgi?id=213079
+        <rdar://problem/64256870>
+
+        Reviewed by Wenson Hsieh.
+
+        Update a few tests after behavior change in r262879. From r262879, we no longer use visible positions of element
+        to calculate range to observe. Instead, we use the first and end position in the element to decide the range. In
+        previous implementation, the range can be extended to outside of the element, like some visible positon before 
+        or after the element.
+
+        TextManipulation.StartTextManipulationFindNewlyDisplayedParagraph: Different elements would make separate ranges 
+        because we create range with the boundaries of element. We can consider merging adjacent ranges later.
+        TextManipulation.StartTextManipulationFindSameParagraphWithNewContent: The newly observing range only includes
+        the newly inserted element now.
+        TextManipulation.InsertingContentIntoAlreadyManipulatedContentDoesNotCreateTextManipulationItem: The p element
+        is not manipulated as it is the common ancestor of manipulated elements. And we want to make sure the newly
+        inserted element is child of a manipulated element.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
+        (TestWebKitAPI::TEST):
+
 2020-06-11  Andy Estes  <[email protected]>
 
         [iOS] nullptr deref in FileInputType::iconLoaded when the input's type attribute is modified by a change event listener

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm (262925 => 262926)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm	2020-06-11 21:05:39 UTC (rev 262925)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm	2020-06-11 22:11:53 UTC (rev 262926)
@@ -314,7 +314,13 @@
 
     [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><html><body>"
         "<style> .hidden { display: none; } </style>"
-        "<p>hello</p><div><span class='hidden'>Web</span><span class='hidden'>Kit</span></div><div class='hidden'>hey</div></body></html>"];
+        "<p>hello</p>"
+        "<div>"
+            "<span class='hidden'>Web</span>"
+            "<span class='hidden'>Kit</span>"
+        "</div>"
+        "<div class='hidden'>hey</div>"
+        "</body></html>"];
 
     done = false;
     [webView _startTextManipulationsWithConfiguration:nil completion:^{
@@ -329,29 +335,31 @@
 
     done = false;
     delegate.get().itemCallback = ^(_WKTextManipulationItem *item) {
-        if (items.count == 2)
+        if (items.count == 3)
             done = true;
     };
     [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('span.hidden').forEach((span) => span.classList.remove('hidden'));"];
     TestWebKitAPI::Util::run(&done);
 
-    EXPECT_EQ(items.count, 2UL);
-    EXPECT_EQ(items[1].tokens.count, 2UL);
-    EXPECT_STREQ("Web", items[1].tokens[0].content.UTF8String);
-    EXPECT_STREQ("Kit", items[1].tokens[1].content.UTF8String);
+    EXPECT_EQ(items.count, 3UL);
+    EXPECT_EQ(items[1].tokens.count, 1UL);
+    EXPECT_EQ(items[2].tokens.count, 1UL);
+    RetainPtr<NSSet> tokens = adoptNS([[NSSet alloc] initWithObjects:items[1].tokens[0].content, items[2].tokens[0].content, nil]);
+    EXPECT_TRUE([tokens.get() containsObject:@"Web"]);
+    EXPECT_TRUE([tokens.get() containsObject:@"Kit"]);
 
     // This has to happen separately in order to have a deterministic ordering.
     done = false;
     delegate.get().itemCallback = ^(_WKTextManipulationItem *item) {
-        if (items.count == 3)
+        if (items.count == 4)
             done = true;
     };
     [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('div.hidden').forEach((div) => div.classList.remove('hidden'));"];
     TestWebKitAPI::Util::run(&done);
 
-    EXPECT_EQ(items.count, 3UL);
-    EXPECT_EQ(items[2].tokens.count, 1UL);
-    EXPECT_STREQ("hey", items[2].tokens[0].content.UTF8String);
+    EXPECT_EQ(items.count, 4UL);
+    EXPECT_EQ(items[3].tokens.count, 1UL);
+    EXPECT_STREQ("hey", items[3].tokens[0].content.UTF8String);
 }
 
 TEST(TextManipulation, StartTextManipulationFindSameParagraphWithNewContent)
@@ -385,9 +393,8 @@
     TestWebKitAPI::Util::run(&done);
 
     EXPECT_EQ(items.count, 2UL);
-    EXPECT_EQ(items[1].tokens.count, 2UL);
-    EXPECT_STREQ("hello", items[1].tokens[0].content.UTF8String);
-    EXPECT_STREQ(" world", items[1].tokens[1].content.UTF8String);
+    EXPECT_EQ(items[1].tokens.count, 1UL);
+    EXPECT_STREQ(" world", items[1].tokens[0].content.UTF8String);
 }
 
 TEST(TextManipulation, StartTextManipulationApplySingleExcluionRuleForElement)
@@ -2399,7 +2406,7 @@
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
     [webView _setTextManipulationDelegate:delegate.get()];
 
-    [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><html><body><p><b>hey</b> dude</p></body></html>"];
+    [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><html><body><p><i><b>hey</b></i> dude</p></body></html>"];
 
     auto configuration = adoptNS([[_WKTextManipulationConfiguration alloc] init]);
 
@@ -2436,7 +2443,7 @@
     [webView waitForNextPresentationUpdate];
 
     EXPECT_FALSE(foundNewItemAfterCompletingTextManipulation);
-    EXPECT_WK_STREQ("<p><b>hello,</b><span> WebKit!</span> world</p>", [webView stringByEvaluatingJavaScript:@"document.body.innerHTML"]);
+    EXPECT_WK_STREQ("<p><i><b>hello,</b><span> WebKit!</span></i> world</p>", [webView stringByEvaluatingJavaScript:@"document.body.innerHTML"]);
 }
 
 TEST(TextManipulation, CompleteTextManipulationInButtonsAndTextFields)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to