Title: [260541] trunk/Tools
- Revision
- 260541
- Author
- [email protected]
- Date
- 2020-04-22 16:45:39 -0700 (Wed, 22 Apr 2020)
Log Message
Add a test for -focusTextInputContext on a field in detached frame
https://bugs.webkit.org/show_bug.cgi?id=210704
Reviewed by Wenson Hsieh.
Calling -focusTextInputContext on a field in a detached frame should not
cause a focus change. Add a test to ensure this behavior doesn't regress.
* TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (260540 => 260541)
--- trunk/Tools/ChangeLog 2020-04-22 23:45:17 UTC (rev 260540)
+++ trunk/Tools/ChangeLog 2020-04-22 23:45:39 UTC (rev 260541)
@@ -1,3 +1,16 @@
+2020-04-22 Daniel Bates <[email protected]>
+
+ Add a test for -focusTextInputContext on a field in detached frame
+ https://bugs.webkit.org/show_bug.cgi?id=210704
+
+ Reviewed by Wenson Hsieh.
+
+ Calling -focusTextInputContext on a field in a detached frame should not
+ cause a focus change. Add a test to ensure this behavior doesn't regress.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:
+ (TEST):
+
2020-04-22 Don Olmstead <[email protected]>
[CMake] Use WEBKIT_EXECUTABLE in WebKitTestRunner
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm (260540 => 260541)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm 2020-04-22 23:45:17 UTC (rev 260540)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm 2020-04-22 23:45:39 UTC (rev 260541)
@@ -576,6 +576,33 @@
EXPECT_LT([webView scrollView].zoomScale, 2);
}
+TEST(RequestTextInputContext, TextInteraction_FocusElementInDetachedDocument)
+{
+ IPhoneUserInterfaceSwizzler userInterfaceSwizzler;
+
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [configuration _setAllowUniversalAccessFromFileURLs:YES];
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ webViewLoadHTMLStringAndWaitForAllFramesToPaint(webView.get(), applyIframe(@"<input type='text' id='input' style='width: 100px; height: 50px;'>"));
+
+ NSArray<_WKTextInputContext *> *contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
+ EXPECT_EQ(1UL, contexts.count);
+ RetainPtr<_WKTextInputContext> inputElement = contexts[0];
+
+ EXPECT_WK_STREQ("BODY", [webView stringByEvaluatingJavaScript:@"document.querySelector('iframe').contentDocument.activeElement.tagName"]);
+ [webView scrollView].zoomScale = 2;
+
+ // Save a reference to the framed document (to prevent its destruction when its frame is removed)
+ // and remove the frame.
+ [webView stringByEvaluatingJavaScript:@"g_framedDocument = document.querySelector('iframe').contentDocument; document.querySelector('iframe').remove()"];
+ {
+ TextInteractionForScope scope { webView, inputElement };
+ EXPECT_NULL([webView synchronouslyFocusTextInputContext:inputElement.get() placeCaretAt:[inputElement boundingRect].origin]);
+ }
+ EXPECT_WK_STREQ("BODY", [webView stringByEvaluatingJavaScript:@"g_framedDocument.activeElement.tagName"]);
+ EXPECT_EQ(2, [webView scrollView].zoomScale);
+}
+
TEST(RequestTextInputContext, TextInteraction_FocusingElementChangesZoomScale)
{
IPhoneUserInterfaceSwizzler userInterfaceSwizzler;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes