- Revision
- 280288
- Author
- [email protected]
- Date
- 2021-07-25 12:40:36 -0700 (Sun, 25 Jul 2021)
Log Message
[iOS] Unified field is unselected after focusing URL bar if text was selected in a fixed position container
https://bugs.webkit.org/show_bug.cgi?id=228269
rdar://80556392
Reviewed by Tim Horton.
Source/WebKit:
In Safari on iOS 15, if the selection (either ranged or caret) is inside a fixed position container when the
user taps on the unified field, we'll immediately clear the text selection inside the unified field upon
bringing up the keyboard. This happens because the tab pill in iOS 15 is lowered as the URL bar is focused,
which causes the web view to scroll slightly. This, in turn, induces a brief unstable scrolling tree state,
which then causes us to temporarily hide and show selection views while scrolling in unstable state (see
r209931) by calling `-deactivateSelection` and then `-activateSelection` on the text interaction assistant.
Calling `-[UIWKTextInteractionAssistant activateSelection]` then causes UIKit to dispatch a
UITextSelectionViewActivatedNotification; In the unified field, which is a UITextField subclass, UIKit code then
listens for this notification and responds to it by clearing the selection if the newly activated selection's
host view (WKContentView) is different than itself, thereby causing the bug.
To fix this, we simply make two (minor) adjustments to the logic for temporarily hiding and showing the
selection while performing an unstable scroll. See below for more details.
Test: editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field.html
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView shouldHideSelectionWhenScrolling]):
Only hide and (later) restore the selection in non-editable text if the selection is ranged. This is because
caret selections in non-editable content are not user-visible anyways, so there's no need to temporarily
suppress the selection.
(-[WKContentView _updateChangedSelection:]):
Only attempt to show the selection views again if doing so doesn't cause us to steal first responder status away
from the existing first responder; otherwise, we'll wait until we `-becomeFirstResponder` to `-activateSelection`.
(-[WKContentView selectionInteractionAssistant]): Deleted.
Tools:
We already have some very basic support for installing and removing native text fields in the view hierarchy,
through `TestRunner::(add|remove)ChromeInputField()`. In order to support the new layout test, we additionally
implement the ability to:
- Set text inside the native chrome input field that was installed using `addChromeInputField()`.
- Select all text inside the chrome input field.
- Query the chrome input field for the currently selected text.
We only support iOS for the time being, with stubs on other platforms, since the new test that uses this
functionality is iOS-specific; if needed in the future for a similar test on other platforms, we can implement
the stubbed testing hooks on TestRunner and PlatformWebView as well.
* DumpRenderTree/TestRunner.h:
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setTextInChromeInputField):
(TestRunner::selectChromeInputField):
(TestRunner::getSelectedTextInChromeInputField):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::setTextInChromeInputField):
(TestRunner::selectChromeInputField):
(TestRunner::getSelectedTextInChromeInputField):
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
(WTR::InjectedBundle::postSetTextInChromeInputField):
(WTR::InjectedBundle::postSelectChromeInputField):
(WTR::InjectedBundle::postGetSelectedTextInChromeInputField):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setTextInChromeInputField):
(WTR::TestRunner::selectChromeInputField):
(WTR::TestRunner::getSelectedTextInChromeInputField):
(WTR::TestRunner::callSetTextInChromeInputFieldCallback):
(WTR::TestRunner::callSelectChromeInputFieldCallback):
(WTR::TestRunner::callGetSelectedTextInChromeInputFieldCallback):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/PlatformWebView.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
(WTR::PlatformWebView::setTextInChromeInputField):
(WTR::PlatformWebView::selectChromeInputField):
(WTR::PlatformWebView::getSelectedTextInChromeInputField):
* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(WTR::chromeInputField):
Additionally do some light refactoring by pulling out logic for grabbing the chrome input field (i.e. a view
with a tag of 1 under the window) out into a separate helper method. Use this helper in a few places below.
(WTR::PlatformWebView::addChromeInputField):
(WTR::PlatformWebView::setTextInChromeInputField):
(WTR::PlatformWebView::selectChromeInputField):
(WTR::PlatformWebView::getSelectedTextInChromeInputField):
(WTR::PlatformWebView::removeChromeInputField):
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::setTextInChromeInputField):
(WTR::PlatformWebView::selectChromeInputField):
(WTR::PlatformWebView::getSelectedTextInChromeInputField):
* WebKitTestRunner/win/PlatformWebViewWin.cpp:
(WTR::PlatformWebView::setTextInChromeInputField):
(WTR::PlatformWebView::selectChromeInputField):
(WTR::PlatformWebView::getSelectedTextInChromeInputField):
* WebKitTestRunner/wpe/PlatformWebViewWPE.cpp:
(WTR::PlatformWebView::setTextInChromeInputField):
(WTR::PlatformWebView::selectChromeInputField):
(WTR::PlatformWebView::getSelectedTextInChromeInputField):
LayoutTests:
Add a new layout test that installs, focuses, and selects text inside a native UITextField (simulating Safari's
URL field) while the DOM selection is inside a fixed position container, and then scrolls the web view a bit to
temporarily induce an unstable scrolling tree state. After this, we verify that the text selection inside the
native text field has not been cleared.
See Tools/ changes for more details.
* editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field-expected.txt: Added.
* editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field.html: Added.
* resources/ui-helper.js:
(window.UIHelper.addChromeInputField):
(window.UIHelper.removeChromeInputField):
(window.UIHelper.setTextInChromeInputField):
(window.UIHelper.selectChromeInputField):
(window.UIHelper.getSelectedTextInChromeInputField):
(window.UIHelper):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (280287 => 280288)
--- trunk/LayoutTests/ChangeLog 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/LayoutTests/ChangeLog 2021-07-25 19:40:36 UTC (rev 280288)
@@ -1,3 +1,28 @@
+2021-07-25 Wenson Hsieh <[email protected]>
+
+ [iOS] Unified field is unselected after focusing URL bar if text was selected in a fixed position container
+ https://bugs.webkit.org/show_bug.cgi?id=228269
+ rdar://80556392
+
+ Reviewed by Tim Horton.
+
+ Add a new layout test that installs, focuses, and selects text inside a native UITextField (simulating Safari's
+ URL field) while the DOM selection is inside a fixed position container, and then scrolls the web view a bit to
+ temporarily induce an unstable scrolling tree state. After this, we verify that the text selection inside the
+ native text field has not been cleared.
+
+ See Tools/ changes for more details.
+
+ * editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field-expected.txt: Added.
+ * editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field.html: Added.
+ * resources/ui-helper.js:
+ (window.UIHelper.addChromeInputField):
+ (window.UIHelper.removeChromeInputField):
+ (window.UIHelper.setTextInChromeInputField):
+ (window.UIHelper.selectChromeInputField):
+ (window.UIHelper.getSelectedTextInChromeInputField):
+ (window.UIHelper):
+
2021-07-24 Devin Rousso <[email protected]>
[Apple Pay] Do not add coupon code `ApplePayErrorCode` values for systems that do not support it
Added: trunk/LayoutTests/editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field-expected.txt (0 => 280288)
--- trunk/LayoutTests/editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field-expected.txt 2021-07-25 19:40:36 UTC (rev 280288)
@@ -0,0 +1,10 @@
+This test verifies that scrolling while there is a selection in a fixed position container does not unselect text in a focused native text field. This test requires WebKitTestRunner.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS selectedTextInInputField is "Foo bar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Hello
Added: trunk/LayoutTests/editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field.html (0 => 280288)
--- trunk/LayoutTests/editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field.html (rev 0)
+++ trunk/LayoutTests/editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field.html 2021-07-25 19:40:36 UTC (rev 280288)
@@ -0,0 +1,58 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<script src=""
+<script src=""
+<style>
+body, html {
+ width: 100%;
+ height: 1000vh;
+}
+
+.fixed {
+ position: fixed;
+ width: 100%;
+ height: 100px;
+ bottom: 0;
+ left: 0;
+ background-color: tomato;
+ text-align: center;
+ font-size: 100px;
+}
+</style>
+<script>
+jsTestIsAsync = true;
+
+addEventListener("load", async () => {
+ description("This test verifies that scrolling while there is a selection in a fixed position container does not unselect text in a focused native text field. This test requires WebKitTestRunner.");
+ if (!window.testRunner)
+ return;
+
+ getSelection().selectAllChildren(document.querySelector(".fixed"));
+
+ await UIHelper.addChromeInputField();
+ await UIHelper.setTextInChromeInputField("Foo bar");
+ await UIHelper.selectChromeInputField();
+ await UIHelper.sendEventStream(new UIHelper.EventStreamBuilder()
+ .begin(150, 350)
+ .move(150, 100, 0.25)
+ .move(150, 350, 0.25)
+ .end()
+ .takeResult());
+
+ await UIHelper.ensureStablePresentationUpdate();
+
+ selectedTextInInputField = await UIHelper.getSelectedTextInChromeInputField();
+ shouldBeEqualToString("selectedTextInInputField", "Foo bar");
+
+ await UIHelper.removeChromeInputField();
+ await UIHelper.becomeFirstResponder();
+ finishJSTest();
+});
+</script>
+</head>
+<body>
+<div class="fixed">Hello</div>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/LayoutTests/resources/ui-helper.js (280287 => 280288)
--- trunk/LayoutTests/resources/ui-helper.js 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/LayoutTests/resources/ui-helper.js 2021-07-25 19:40:36 UTC (rev 280288)
@@ -1592,6 +1592,31 @@
const script = `(() => uiController.dismissContactPickerWithContacts(${JSON.stringify(contacts)}))()`;
return new Promise(resolve => testRunner.runUIScript(script, resolve));
}
+
+ static addChromeInputField()
+ {
+ return new Promise(resolve => testRunner.addChromeInputField(resolve));
+ }
+
+ static removeChromeInputField()
+ {
+ return new Promise(resolve => testRunner.removeChromeInputField(resolve));
+ }
+
+ static setTextInChromeInputField(text)
+ {
+ return new Promise(resolve => testRunner.setTextInChromeInputField(text, resolve));
+ }
+
+ static selectChromeInputField()
+ {
+ return new Promise(resolve => testRunner.selectChromeInputField(resolve));
+ }
+
+ static getSelectedTextInChromeInputField()
+ {
+ return new Promise(resolve => testRunner.getSelectedTextInChromeInputField(resolve));
+ }
}
UIHelper.EventStreamBuilder = class {
Modified: trunk/Source/WebKit/ChangeLog (280287 => 280288)
--- trunk/Source/WebKit/ChangeLog 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Source/WebKit/ChangeLog 2021-07-25 19:40:36 UTC (rev 280288)
@@ -1,3 +1,41 @@
+2021-07-25 Wenson Hsieh <[email protected]>
+
+ [iOS] Unified field is unselected after focusing URL bar if text was selected in a fixed position container
+ https://bugs.webkit.org/show_bug.cgi?id=228269
+ rdar://80556392
+
+ Reviewed by Tim Horton.
+
+ In Safari on iOS 15, if the selection (either ranged or caret) is inside a fixed position container when the
+ user taps on the unified field, we'll immediately clear the text selection inside the unified field upon
+ bringing up the keyboard. This happens because the tab pill in iOS 15 is lowered as the URL bar is focused,
+ which causes the web view to scroll slightly. This, in turn, induces a brief unstable scrolling tree state,
+ which then causes us to temporarily hide and show selection views while scrolling in unstable state (see
+ r209931) by calling `-deactivateSelection` and then `-activateSelection` on the text interaction assistant.
+ Calling `-[UIWKTextInteractionAssistant activateSelection]` then causes UIKit to dispatch a
+ UITextSelectionViewActivatedNotification; In the unified field, which is a UITextField subclass, UIKit code then
+ listens for this notification and responds to it by clearing the selection if the newly activated selection's
+ host view (WKContentView) is different than itself, thereby causing the bug.
+
+ To fix this, we simply make two (minor) adjustments to the logic for temporarily hiding and showing the
+ selection while performing an unstable scroll. See below for more details.
+
+ Test: editing/selection/ios/scrolling-with-fixed-selection-does-not-unselect-native-text-field.html
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView shouldHideSelectionWhenScrolling]):
+
+ Only hide and (later) restore the selection in non-editable text if the selection is ranged. This is because
+ caret selections in non-editable content are not user-visible anyways, so there's no need to temporarily
+ suppress the selection.
+
+ (-[WKContentView _updateChangedSelection:]):
+
+ Only attempt to show the selection views again if doing so doesn't cause us to steal first responder status away
+ from the existing first responder; otherwise, we'll wait until we `-becomeFirstResponder` to `-activateSelection`.
+
+ (-[WKContentView selectionInteractionAssistant]): Deleted.
+
2021-07-24 Devin Rousso <[email protected]>
[Apple Pay] Do not add coupon code `ApplePayErrorCode` values for systems that do not support it
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (280287 => 280288)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-07-25 19:40:36 UTC (rev 280288)
@@ -1424,7 +1424,7 @@
return _focusedElementInformation.insideFixedPosition;
auto& editorState = _page->editorState();
- return !editorState.isMissingPostLayoutData && editorState.postLayoutData().insideFixedPosition;
+ return !editorState.isMissingPostLayoutData && editorState.selectionIsRange && editorState.postLayoutData().insideFixedPosition;
}
- (BOOL)isEditable
@@ -5616,11 +5616,6 @@
return _textInteractionAssistant.get();
}
-- (id<UISelectionInteractionAssistant>)selectionInteractionAssistant
-{
- return nil;
-}
-
// NSRange support. Would like to deprecate to the extent possible, although some support
// (i.e. selectionRange) has shipped as API.
- (NSRange)selectionRange
@@ -7269,9 +7264,8 @@
}
if (postLayoutData.isStableStateUpdate && _needsDeferredEndScrollingSelectionUpdate && _page->inStableState()) {
- [[self selectionInteractionAssistant] showSelectionCommands];
-
- if (!_suppressSelectionAssistantReasons)
+ auto firstResponder = self.firstResponder;
+ if ((!firstResponder || self == firstResponder) && !_suppressSelectionAssistantReasons)
[_textInteractionAssistant activateSelection];
[_textInteractionAssistant didEndScrollingOverflow];
Modified: trunk/Tools/ChangeLog (280287 => 280288)
--- trunk/Tools/ChangeLog 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/ChangeLog 2021-07-25 19:40:36 UTC (rev 280288)
@@ -1,3 +1,78 @@
+2021-07-25 Wenson Hsieh <[email protected]>
+
+ [iOS] Unified field is unselected after focusing URL bar if text was selected in a fixed position container
+ https://bugs.webkit.org/show_bug.cgi?id=228269
+ rdar://80556392
+
+ Reviewed by Tim Horton.
+
+ We already have some very basic support for installing and removing native text fields in the view hierarchy,
+ through `TestRunner::(add|remove)ChromeInputField()`. In order to support the new layout test, we additionally
+ implement the ability to:
+
+ - Set text inside the native chrome input field that was installed using `addChromeInputField()`.
+ - Select all text inside the chrome input field.
+ - Query the chrome input field for the currently selected text.
+
+ We only support iOS for the time being, with stubs on other platforms, since the new test that uses this
+ functionality is iOS-specific; if needed in the future for a similar test on other platforms, we can implement
+ the stubbed testing hooks on TestRunner and PlatformWebView as well.
+
+ * DumpRenderTree/TestRunner.h:
+ * DumpRenderTree/mac/TestRunnerMac.mm:
+ (TestRunner::setTextInChromeInputField):
+ (TestRunner::selectChromeInputField):
+ (TestRunner::getSelectedTextInChromeInputField):
+ * DumpRenderTree/win/TestRunnerWin.cpp:
+ (TestRunner::setTextInChromeInputField):
+ (TestRunner::selectChromeInputField):
+ (TestRunner::getSelectedTextInChromeInputField):
+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+ (WTR::InjectedBundle::didReceiveMessageToPage):
+ (WTR::InjectedBundle::postSetTextInChromeInputField):
+ (WTR::InjectedBundle::postSelectChromeInputField):
+ (WTR::InjectedBundle::postGetSelectedTextInChromeInputField):
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::setTextInChromeInputField):
+ (WTR::TestRunner::selectChromeInputField):
+ (WTR::TestRunner::getSelectedTextInChromeInputField):
+ (WTR::TestRunner::callSetTextInChromeInputFieldCallback):
+ (WTR::TestRunner::callSelectChromeInputFieldCallback):
+ (WTR::TestRunner::callGetSelectedTextInChromeInputFieldCallback):
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/PlatformWebView.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+ * WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
+ (WTR::PlatformWebView::setTextInChromeInputField):
+ (WTR::PlatformWebView::selectChromeInputField):
+ (WTR::PlatformWebView::getSelectedTextInChromeInputField):
+ * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
+ (WTR::chromeInputField):
+
+ Additionally do some light refactoring by pulling out logic for grabbing the chrome input field (i.e. a view
+ with a tag of 1 under the window) out into a separate helper method. Use this helper in a few places below.
+
+ (WTR::PlatformWebView::addChromeInputField):
+ (WTR::PlatformWebView::setTextInChromeInputField):
+ (WTR::PlatformWebView::selectChromeInputField):
+ (WTR::PlatformWebView::getSelectedTextInChromeInputField):
+ (WTR::PlatformWebView::removeChromeInputField):
+ * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+ (WTR::PlatformWebView::setTextInChromeInputField):
+ (WTR::PlatformWebView::selectChromeInputField):
+ (WTR::PlatformWebView::getSelectedTextInChromeInputField):
+ * WebKitTestRunner/win/PlatformWebViewWin.cpp:
+ (WTR::PlatformWebView::setTextInChromeInputField):
+ (WTR::PlatformWebView::selectChromeInputField):
+ (WTR::PlatformWebView::getSelectedTextInChromeInputField):
+ * WebKitTestRunner/wpe/PlatformWebViewWPE.cpp:
+ (WTR::PlatformWebView::setTextInChromeInputField):
+ (WTR::PlatformWebView::selectChromeInputField):
+ (WTR::PlatformWebView::getSelectedTextInChromeInputField):
+
2021-07-24 Devin Rousso <[email protected]>
[iOS] REGRESSION(r277505): `-[WKWebView underPageBackgroundColor]` also changes the scroll bar color
Modified: trunk/Tools/DumpRenderTree/TestRunner.h (280287 => 280288)
--- trunk/Tools/DumpRenderTree/TestRunner.h 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/DumpRenderTree/TestRunner.h 2021-07-25 19:40:36 UTC (rev 280288)
@@ -36,6 +36,7 @@
#include <string>
#include <vector>
#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
extern FILE* testResult;
@@ -327,6 +328,10 @@
void removeChromeInputField();
void focusWebView();
+ void setTextInChromeInputField(const String&);
+ void selectChromeInputField();
+ String getSelectedTextInChromeInputField();
+
void setBackingScaleFactor(double);
void setPOSIXLocale(JSStringRef);
Modified: trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm (280287 => 280288)
--- trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm 2021-07-25 19:40:36 UTC (rev 280288)
@@ -1084,6 +1084,19 @@
#endif
}
+void TestRunner::setTextInChromeInputField(const String&)
+{
+}
+
+void TestRunner::selectChromeInputField()
+{
+}
+
+String TestRunner::getSelectedTextInChromeInputField()
+{
+ return { };
+}
+
void TestRunner::focusWebView()
{
#if !PLATFORM(IOS_FAMILY)
Modified: trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp (280287 => 280288)
--- trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp 2021-07-25 19:40:36 UTC (rev 280288)
@@ -1150,6 +1150,22 @@
fprintf(testResult, "ERROR: TestRunner::removeChromeInputField() not implemented\n");
}
+void TestRunner::setTextInChromeInputField(const String&)
+{
+ fprintf(testResult, "ERROR: TestRunner::setTextInChromeInputField() not implemented\n");
+}
+
+void TestRunner::selectChromeInputField()
+{
+ fprintf(testResult, "ERROR: TestRunner::selectChromeInputField() not implemented\n");
+}
+
+String TestRunner::getSelectedTextInChromeInputField()
+{
+ fprintf(testResult, "ERROR: TestRunner::getSelectedTextInChromeInputField() not implemented\n");
+ return { };
+}
+
void TestRunner::focusWebView()
{
fprintf(testResult, "ERROR: TestRunner::focusWebView() not implemented\n");
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2021-07-25 19:40:36 UTC (rev 280288)
@@ -179,6 +179,9 @@
undefined addChromeInputField(object callback);
undefined removeChromeInputField(object callback);
undefined focusWebView(object callback);
+ undefined setTextInChromeInputField(DOMString text, object callback);
+ undefined getSelectedTextInChromeInputField(object callback);
+ undefined selectChromeInputField(object callback);
// Window/view state
undefined setBackingScaleFactor(double backingScaleFactor, object callback);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp 2021-07-25 19:40:36 UTC (rev 280288)
@@ -255,6 +255,24 @@
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "CallSetTextInChromeInputFieldCallback")) {
+ m_testRunner->callSetTextInChromeInputFieldCallback();
+ return;
+ }
+
+ if (WKStringIsEqualToUTF8CString(messageName, "CallSelectChromeInputFieldCallback")) {
+ m_testRunner->callSelectChromeInputFieldCallback();
+ return;
+ }
+
+ if (WKStringIsEqualToUTF8CString(messageName, "CallGetSelectedTextInChromeInputFieldCallback")) {
+ ASSERT(messageBody);
+ ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
+ auto jsString = toJS(static_cast<WKStringRef>(messageBody));
+ m_testRunner->callGetSelectedTextInChromeInputFieldCallback(jsString.get());
+ return;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "CallFocusWebViewCallback")) {
m_testRunner->callFocusWebViewCallback();
return;
@@ -607,6 +625,22 @@
postPageMessage("RemoveChromeInputField");
}
+void InjectedBundle::postSetTextInChromeInputField(const String& text)
+{
+ auto wkText = toWK(text);
+ postPageMessage("SetTextInChromeInputField", wkText.get());
+}
+
+void InjectedBundle::postSelectChromeInputField()
+{
+ postPageMessage("SelectChromeInputField");
+}
+
+void InjectedBundle::postGetSelectedTextInChromeInputField()
+{
+ postPageMessage("GetSelectedTextInChromeInputField");
+}
+
void InjectedBundle::postFocusWebView()
{
postPageMessage("FocusWebView");
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h 2021-07-25 19:40:36 UTC (rev 280288)
@@ -87,6 +87,9 @@
void postNewBeforeUnloadReturnValue(bool);
void postAddChromeInputField();
void postRemoveChromeInputField();
+ void postSetTextInChromeInputField(const String&);
+ void postSelectChromeInputField();
+ void postGetSelectedTextInChromeInputField();
void postFocusWebView();
void postSetBackingScaleFactor(double);
void postSetWindowIsKey(bool);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2021-07-25 19:40:36 UTC (rev 280288)
@@ -608,6 +608,9 @@
enum {
AddChromeInputFieldCallbackID = 1,
RemoveChromeInputFieldCallbackID,
+ SetTextInChromeInputFieldCallbackID,
+ SelectChromeInputFieldCallbackID,
+ GetSelectedTextInChromeInputFieldCallbackID,
FocusWebViewCallbackID,
SetBackingScaleFactorCallbackID,
DidBeginSwipeCallbackID,
@@ -700,6 +703,24 @@
InjectedBundle::singleton().postRemoveChromeInputField();
}
+void TestRunner::setTextInChromeInputField(JSStringRef text, JSValueRef callback)
+{
+ cacheTestRunnerCallback(SetTextInChromeInputFieldCallbackID, callback);
+ InjectedBundle::singleton().postSetTextInChromeInputField(toWTFString(text));
+}
+
+void TestRunner::selectChromeInputField(JSValueRef callback)
+{
+ cacheTestRunnerCallback(SelectChromeInputFieldCallbackID, callback);
+ InjectedBundle::singleton().postSelectChromeInputField();
+}
+
+void TestRunner::getSelectedTextInChromeInputField(JSValueRef callback)
+{
+ cacheTestRunnerCallback(GetSelectedTextInChromeInputFieldCallbackID, callback);
+ InjectedBundle::singleton().postGetSelectedTextInChromeInputField();
+}
+
void TestRunner::focusWebView(JSValueRef callback)
{
cacheTestRunnerCallback(FocusWebViewCallbackID, callback);
@@ -732,6 +753,22 @@
callTestRunnerCallback(RemoveChromeInputFieldCallbackID);
}
+void TestRunner::callSetTextInChromeInputFieldCallback()
+{
+ callTestRunnerCallback(SetTextInChromeInputFieldCallbackID);
+}
+
+void TestRunner::callSelectChromeInputFieldCallback()
+{
+ callTestRunnerCallback(SelectChromeInputFieldCallbackID);
+}
+
+void TestRunner::callGetSelectedTextInChromeInputFieldCallback(JSStringRef text)
+{
+ auto textValue = JSValueMakeString(mainFrameJSContext(), text);
+ callTestRunnerCallback(GetSelectedTextInChromeInputFieldCallbackID, 1, &textValue);
+}
+
void TestRunner::callFocusWebViewCallback()
{
callTestRunnerCallback(FocusWebViewCallbackID);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2021-07-25 19:40:36 UTC (rev 280288)
@@ -257,6 +257,11 @@
void addChromeInputField(JSValueRef);
void removeChromeInputField(JSValueRef);
void focusWebView(JSValueRef);
+
+ void setTextInChromeInputField(JSStringRef text, JSValueRef callback);
+ void selectChromeInputField(JSValueRef callback);
+ void getSelectedTextInChromeInputField(JSValueRef callback);
+
void setBackingScaleFactor(double, JSValueRef);
void setWindowIsKey(bool);
@@ -268,6 +273,10 @@
void callFocusWebViewCallback();
void callSetBackingScaleFactorCallback();
+ void callSetTextInChromeInputFieldCallback();
+ void callSelectChromeInputFieldCallback();
+ void callGetSelectedTextInChromeInputFieldCallback(JSStringRef);
+
static void overridePreference(JSStringRef preference, JSStringRef value);
// Cookies testing
Modified: trunk/Tools/WebKitTestRunner/PlatformWebView.h (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/PlatformWebView.h 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/PlatformWebView.h 2021-07-25 19:40:36 UTC (rev 280288)
@@ -27,6 +27,7 @@
#include "TestOptions.h"
#include <wtf/FastMalloc.h>
+#include <wtf/text/WTFString.h>
#if PLATFORM(COCOA) && !defined(BUILDING_GTK__)
#include <WebKit/WKFoundation.h>
@@ -107,6 +108,10 @@
void setWindowIsKey(bool);
bool windowIsKey() const { return m_windowIsKey; }
+ void setTextInChromeInputField(const String&);
+ void selectChromeInputField();
+ String getSelectedTextInChromeInputField();
+
bool drawsBackground() const;
void setDrawsBackground(bool);
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2021-07-25 19:40:36 UTC (rev 280288)
@@ -357,7 +357,25 @@
postPageMessage("CallRemoveChromeInputFieldCallback");
return;
}
-
+
+ if (WKStringIsEqualToUTF8CString(messageName, "SetTextInChromeInputField")) {
+ TestController::singleton().mainWebView()->setTextInChromeInputField(toWTFString(stringValue(messageBody)));
+ postPageMessage("CallSetTextInChromeInputFieldCallback");
+ return;
+ }
+
+ if (WKStringIsEqualToUTF8CString(messageName, "SelectChromeInputField")) {
+ TestController::singleton().mainWebView()->selectChromeInputField();
+ postPageMessage("CallSelectChromeInputFieldCallback");
+ return;
+ }
+
+ if (WKStringIsEqualToUTF8CString(messageName, "GetSelectedTextInChromeInputField")) {
+ auto selectedText = TestController::singleton().mainWebView()->getSelectedTextInChromeInputField();
+ postPageMessage("CallGetSelectedTextInChromeInputFieldCallback", toWK(selectedText));
+ return;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "FocusWebView")) {
TestController::singleton().mainWebView()->makeWebViewFirstResponder();
postPageMessage("CallFocusWebViewCallback");
Modified: trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp 2021-07-25 19:40:36 UTC (rev 280288)
@@ -36,6 +36,7 @@
#include <gtk/gtk.h>
#include <wtf/Assertions.h>
#include <wtf/glib/GRefPtr.h>
+#include <wtf/text/WTFString.h>
namespace WTR {
@@ -169,6 +170,19 @@
{
}
+void PlatformWebView::setTextInChromeInputField(const String&)
+{
+}
+
+void PlatformWebView::selectChromeInputField()
+{
+}
+
+String PlatformWebView::getSelectedTextInChromeInputField()
+{
+ return { };
+}
+
void PlatformWebView::addToWindow()
{
#if USE(GTK4)
Modified: trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm 2021-07-25 19:40:36 UTC (rev 280288)
@@ -321,17 +321,39 @@
setWindowFrame(wkFrame);
}
+static UITextField *chromeInputField(UIWindow *window)
+{
+ return (UITextField *)[window viewWithTag:1];
+}
+
void PlatformWebView::addChromeInputField()
{
- auto textField = adoptNS([[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 20)]);
+ auto textField = adoptNS([[UITextField alloc] initWithFrame:CGRectMake(0, 0, 320, 64)]);
[textField setTag:1];
[m_window addSubview:textField.get()];
}
+void PlatformWebView::setTextInChromeInputField(const String& text)
+{
+ chromeInputField(m_window).text = text;
+}
+
+void PlatformWebView::selectChromeInputField()
+{
+ auto textField = chromeInputField(m_window);
+ [textField becomeFirstResponder];
+ [textField selectAll:nil];
+}
+
+String PlatformWebView::getSelectedTextInChromeInputField()
+{
+ auto textField = chromeInputField(m_window);
+ return [textField textInRange:textField.selectedTextRange];
+}
+
void PlatformWebView::removeChromeInputField()
{
- UITextField* textField = (UITextField*)[m_window viewWithTag:1];
- if (textField) {
+ if (auto textField = chromeInputField(m_window)) {
[textField removeFromSuperview];
makeWebViewFirstResponder();
}
Modified: trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm 2021-07-25 19:40:36 UTC (rev 280288)
@@ -35,6 +35,7 @@
#import <WebKit/WKWebViewConfiguration.h>
#import <WebKit/WKWebViewPrivate.h>
#import <wtf/RetainPtr.h>
+#import <wtf/text/WTFString.h>
@interface WKWebView ()
- (WKPageRef)_pageForTesting;
@@ -167,6 +168,19 @@
}
}
+void PlatformWebView::setTextInChromeInputField(const String&)
+{
+}
+
+void PlatformWebView::selectChromeInputField()
+{
+}
+
+String PlatformWebView::getSelectedTextInChromeInputField()
+{
+ return { };
+}
+
void PlatformWebView::addToWindow()
{
[[m_window contentView] addSubview:m_view];
Modified: trunk/Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp 2021-07-25 19:40:36 UTC (rev 280288)
@@ -168,6 +168,19 @@
{
}
+void PlatformWebView::setTextInChromeInputField(const String&)
+{
+}
+
+void PlatformWebView::selectChromeInputField()
+{
+}
+
+String PlatformWebView::getSelectedTextInChromeInputField()
+{
+ return { };
+}
+
void PlatformWebView::addToWindow()
{
}
Modified: trunk/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp (280287 => 280288)
--- trunk/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp 2021-07-25 18:29:26 UTC (rev 280287)
+++ trunk/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp 2021-07-25 19:40:36 UTC (rev 280288)
@@ -32,6 +32,7 @@
#include <cstdio>
#include <glib.h>
#include <wtf/RunLoop.h>
+#include <wtf/text/WTFString.h>
namespace WTR {
@@ -82,6 +83,19 @@
{
}
+void PlatformWebView::setTextInChromeInputField(const String&)
+{
+}
+
+void PlatformWebView::selectChromeInputField()
+{
+}
+
+String PlatformWebView::getSelectedTextInChromeInputField()
+{
+ return { };
+}
+
void PlatformWebView::addToWindow()
{
m_window->addActivityState(wpe_view_activity_state_in_window);