Title: [257854] trunk/Tools
Revision
257854
Author
dba...@webkit.org
Date
2020-03-04 10:07:46 -0800 (Wed, 04 Mar 2020)

Log Message

Should use -bounds instead of -frame in RequestTextInputContext.mm tests
https://bugs.webkit.org/show_bug.cgi?id=208565

Reviewed by Wenson Hsieh.

Pass the bounds of the web view to -synchronouslyRequestTextInputContextsInRect: instead
of its frame as a means to find all the editable elements in the visible content area
of the web view.

Coincidentally this makes no difference to the test results right now because the web view
happens to be located at the origin (0, 0) in the window. However if in the future the
web view would be located at some other point then the tests may fail because the rectangle
passed to -synchronouslyRequestTextInputContextsInRect: would no longer represent the
rectangle for the visible content area.

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

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (257853 => 257854)


--- trunk/Tools/ChangeLog	2020-03-04 18:06:58 UTC (rev 257853)
+++ trunk/Tools/ChangeLog	2020-03-04 18:07:46 UTC (rev 257854)
@@ -1,5 +1,25 @@
 2020-03-04  Daniel Bates  <daba...@apple.com>
 
+        Should use -bounds instead of -frame in RequestTextInputContext.mm tests
+        https://bugs.webkit.org/show_bug.cgi?id=208565
+
+        Reviewed by Wenson Hsieh.
+
+        Pass the bounds of the web view to -synchronouslyRequestTextInputContextsInRect: instead
+        of its frame as a means to find all the editable elements in the visible content area
+        of the web view.
+
+        Coincidentally this makes no difference to the test results right now because the web view
+        happens to be located at the origin (0, 0) in the window. However if in the future the
+        web view would be located at some other point then the tests may fail because the rectangle
+        passed to -synchronouslyRequestTextInputContextsInRect: would no longer represent the
+        rectangle for the visible content area.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:
+        (TEST):
+
+2020-03-04  Daniel Bates  <daba...@apple.com>
+
         Organize tests in RequestTextInputContext.mm tests under test name RequestTextInputContext
         https://bugs.webkit.org/show_bug.cgi?id=208564
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm (257853 => 257854)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm	2020-03-04 18:06:58 UTC (rev 257853)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm	2020-03-04 18:07:46 UTC (rev 257854)
@@ -83,17 +83,17 @@
     // Basic inputs.
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<input type='text' style='width: 50px; height: 50px;'>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     EXPECT_EQ(CGRectMake(0, 0, 50, 50), contexts[0].boundingRect);
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<textarea style='width: 100px; height: 100px;'></textarea>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     EXPECT_EQ(CGRectMake(0, 0, 100, 100), contexts[0].boundingRect);
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<div contenteditable style='width: 100px; height: 100px;'></div>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     EXPECT_EQ(CGRectMake(0, 0, 100, 100), contexts[0].boundingRect);
 
@@ -100,17 +100,17 @@
     // Basic inputs inside subframe.
 
     [webView synchronouslyLoadHTMLString:applyIframe(@"<input type='text' style='width: 50px; height: 50px;'>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     EXPECT_EQ(CGRectMake(0, 200, 50, 50), contexts[0].boundingRect);
 
     [webView synchronouslyLoadHTMLString:applyIframe(@"<textarea style='width: 100px; height: 100px;'></textarea>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     EXPECT_EQ(CGRectMake(0, 200, 100, 100), contexts[0].boundingRect);
 
     [webView synchronouslyLoadHTMLString:applyIframe(@"<div contenteditable style='width: 100px; height: 100px;'></div>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     EXPECT_EQ(CGRectMake(0, 200, 100, 100), contexts[0].boundingRect);
 
@@ -117,11 +117,11 @@
     // Read only inputs; should not be included.
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<input type='text' style='width: 50px; height: 50px;' readonly>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(0UL, contexts.count);
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<textarea style='width: 100px; height: 100px;' readonly>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(0UL, contexts.count);
 
     // Inputs outside the requested rect; should not be included.
@@ -136,7 +136,7 @@
     [webView stringByEvaluatingJavaScript:@"window.scrollTo(0, 5000)"];
     [webView waitForNextPresentationUpdate];
     EXPECT_EQ(5000, [[webView objectByEvaluatingJavaScript:@"pageYOffset"] floatValue]);
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(0UL, contexts.count);
 
     // Inputs scrolled into the requested rect.
@@ -145,7 +145,7 @@
     [webView stringByEvaluatingJavaScript:@"window.scrollTo(0, 5000)"];
     [webView waitForNextPresentationUpdate];
     EXPECT_EQ(5000, [[webView objectByEvaluatingJavaScript:@"pageYOffset"] floatValue]);
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     EXPECT_EQ(CGRectMake(0, 0, 50, 50), contexts[0].boundingRect);
 
@@ -152,7 +152,7 @@
     // Multiple inputs.
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<input type='text' style='width: 50px; height: 50px;'><br/><input type='text' style='width: 50px; height: 50px;'><br/><input type='text' style='width: 50px; height: 50px;'>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(3UL, contexts.count);
     EXPECT_EQ(CGRectMake(0, 100, 50, 50), contexts[0].boundingRect);
     EXPECT_EQ(CGRectMake(0, 50, 50, 50), contexts[1].boundingRect);
@@ -161,7 +161,7 @@
     // Nested <input>-inside-contenteditable.
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<div contenteditable style='width: 100px; height: 100px;'><input type='text' style='width: 50px; height: 50px;'></div>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(2UL, contexts.count);
     EXPECT_EQ(CGRectMake(0, 0, 50, 50), contexts[0].boundingRect);
     EXPECT_EQ(CGRectMake(0, 0, 100, 100), contexts[1].boundingRect);
@@ -176,7 +176,7 @@
     NSArray<_WKTextInputContext *> *contexts;
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<input id='test' type='text' style='width: 50px; height: 50px;'>")];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     RetainPtr<_WKTextInputContext> originalInput = contexts[0];
     EXPECT_TRUE([webView synchronouslyFocusTextInputContext:originalInput.get()]);
@@ -183,13 +183,13 @@
     EXPECT_WK_STREQ("test", [webView objectByEvaluatingJavaScript:@"document.activeElement.id"]);
 
     // The _WKTextInputContext should still work even after another request.
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_TRUE([contexts[0] isEqual:originalInput.get()]);
     EXPECT_TRUE([webView synchronouslyFocusTextInputContext:originalInput.get()]);
 
     // Replace the <input> with a <textarea> with script; the <input> should no longer be focusable.
     [webView objectByEvaluatingJavaScript:@"document.body.innerHTML = '<textarea id=\"area\">';"];
-    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     RetainPtr<_WKTextInputContext> textArea = contexts[0];
     EXPECT_FALSE([textArea isEqual:originalInput.get()]);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to