- Revision
- 239337
- Author
- wenson_hs...@apple.com
- Date
- 2018-12-18 07:37:10 -0800 (Tue, 18 Dec 2018)
Log Message
Calling setValue() while typing should invoke -textDidChangeInTextField in the injected bundle
https://bugs.webkit.org/show_bug.cgi?id=192785
<rdar://problem/45321184>
Reviewed by Tim Horton.
Source/WebCore:
Makes a minor adjustment in `TextFieldInputType::setValue` to consider value changes as "user editing", if we're
currently processing a keystroke from the user. This is useful for certain private clients, such as Safari, that
need to know when the user is typing in a text form control, but the page is preventing default text insertion
behavior and instead updating values programmatically.
Test: fast/forms/call-text-did-change-in-text-field-when-typing.html
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::setValue):
LayoutTests:
Add a test to verify that:
1. When typing in a focused field, the injected bundle method is invoked.
2. When changing the value of the focused field under non-typing user interaction, the method isn't invoked.
3. When changing the value of the focused field programmatically without user gesture, the method isn't invoked.
* TestExpectations:
* fast/forms/call-text-did-change-in-text-field-when-typing-expected.txt: Added.
* fast/forms/call-text-did-change-in-text-field-when-typing.html: Added.
* platform/wk2/TestExpectations:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (239336 => 239337)
--- trunk/LayoutTests/ChangeLog 2018-12-18 15:30:25 UTC (rev 239336)
+++ trunk/LayoutTests/ChangeLog 2018-12-18 15:37:10 UTC (rev 239337)
@@ -1,3 +1,21 @@
+2018-12-18 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Calling setValue() while typing should invoke -textDidChangeInTextField in the injected bundle
+ https://bugs.webkit.org/show_bug.cgi?id=192785
+ <rdar://problem/45321184>
+
+ Reviewed by Tim Horton.
+
+ Add a test to verify that:
+ 1. When typing in a focused field, the injected bundle method is invoked.
+ 2. When changing the value of the focused field under non-typing user interaction, the method isn't invoked.
+ 3. When changing the value of the focused field programmatically without user gesture, the method isn't invoked.
+
+ * TestExpectations:
+ * fast/forms/call-text-did-change-in-text-field-when-typing-expected.txt: Added.
+ * fast/forms/call-text-did-change-in-text-field-when-typing.html: Added.
+ * platform/wk2/TestExpectations:
+
2018-12-17 Jiewen Tan <jiewen_...@apple.com>
[Mac] Layout Test http/wpt/webauthn/public-key-credential-create-success-hid.https.html and http/wpt/webauthn/public-key-credential-get-success-hid.https.html are flaky
Modified: trunk/LayoutTests/TestExpectations (239336 => 239337)
--- trunk/LayoutTests/TestExpectations 2018-12-18 15:30:25 UTC (rev 239336)
+++ trunk/LayoutTests/TestExpectations 2018-12-18 15:37:10 UTC (rev 239337)
@@ -129,6 +129,7 @@
http/tests/navigation/process-swap-window-open.html [ Skip ]
http/tests/navigation/useragent-reload.php [ Skip ]
storage/indexeddb/modern/opendatabase-after-storage-crash.html [ Skip ]
+fast/forms/call-text-did-change-in-text-field-when-typing.html [ Skip ]
# Only Mac and iOS have an implementation of UIScriptController::doAsyncTask().
fast/harness/uiscriptcontroller [ Skip ]
Added: trunk/LayoutTests/fast/forms/call-text-did-change-in-text-field-when-typing-expected.txt (0 => 239337)
--- trunk/LayoutTests/fast/forms/call-text-did-change-in-text-field-when-typing-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/call-text-did-change-in-text-field-when-typing-expected.txt 2018-12-18 15:37:10 UTC (rev 239337)
@@ -0,0 +1,19 @@
+
+Verifies that programmatically changing text field values with user interaction invokes the -didChangeInTextField injected bundle method. This test requires WebKitTestRunner.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+1. Changing text field value with user typing gesture:
+Text did change in text field.
+The value of the text field is: "a"
+
+2. Changing text field value with non-typing user gesture:
+PASS buttonClicked became true
+The value of the text field is: "ab"
+
+3. Changing text field value without user gesture:
+The value of the text field is: "abc"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/call-text-did-change-in-text-field-when-typing.html (0 => 239337)
--- trunk/LayoutTests/fast/forms/call-text-did-change-in-text-field-when-typing.html (rev 0)
+++ trunk/LayoutTests/fast/forms/call-text-did-change-in-text-field-when-typing.html 2018-12-18 15:37:10 UTC (rev 239337)
@@ -0,0 +1,72 @@
+
+<!DOCTYPE html>
+<html>
+<head>
+ <meta name="viewport" content="width=device-width, user-scalable=no">
+ <script src=""
+ <script src=""
+ <style>
+ body {
+ margin: 0;
+ }
+
+ input, button {
+ width: 100%;
+ height: 100px;
+ display: block;
+ }
+ </style>
+</head>
+<body>
+<input type="text" id="field"></input>
+<button value="Insert text" id="button"></button>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+<script>
+ description("Verifies that programmatically changing text field values with user interaction invokes the -didChangeInTextField"
+ + " injected bundle method. This test requires WebKitTestRunner.");
+
+ buttonClicked = false;
+
+ if (window.testRunner) {
+ jsTestIsAsync = true;
+ testRunner.installTextDidChangeInTextFieldCallback(() => debug("Text did change in text field."));
+ }
+
+ field.addEventListener("keypress", event => {
+ field.value += event.key;
+ event.preventDefault();
+ });
+
+ button.addEventListener("click", event => {
+ field.focus();
+ field.value += "b";
+ buttonClicked = true;
+ });
+
+ addEventListener("load", async () => {
+ if (!window.testRunner)
+ return;
+
+ await UIHelper.activateAndWaitForInputSessionAt(100, 50);
+
+ debug("1. Changing text field value with user typing gesture:");
+ await UIHelper.typeCharacter("a");
+ debug(`The value of the text field is: "${field.value}"`);
+ debug("");
+
+ debug("2. Changing text field value with non-typing user gesture:");
+ UIHelper.activateAt(100, 150);
+ await new Promise(resolve => shouldBecomeEqual("buttonClicked", "true", resolve));
+ debug(`The value of the text field is: "${field.value}"`);
+ debug("");
+
+ debug("3. Changing text field value without user gesture:");
+ field.value += "c";
+ debug(`The value of the text field is: "${field.value}"`);
+
+ finishJSTest();
+ });
+</script>
+</html>
\ No newline at end of file
Modified: trunk/LayoutTests/platform/wk2/TestExpectations (239336 => 239337)
--- trunk/LayoutTests/platform/wk2/TestExpectations 2018-12-18 15:30:25 UTC (rev 239336)
+++ trunk/LayoutTests/platform/wk2/TestExpectations 2018-12-18 15:37:10 UTC (rev 239337)
@@ -742,6 +742,8 @@
http/tests/navigation/useragent-reload.php [ Pass ]
storage/indexeddb/modern/opendatabase-after-storage-crash.html [ Pass ]
+fast/forms/call-text-did-change-in-text-field-when-typing.html [ Pass ]
+
### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
########################################
Modified: trunk/Source/WebCore/ChangeLog (239336 => 239337)
--- trunk/Source/WebCore/ChangeLog 2018-12-18 15:30:25 UTC (rev 239336)
+++ trunk/Source/WebCore/ChangeLog 2018-12-18 15:37:10 UTC (rev 239337)
@@ -1,3 +1,21 @@
+2018-12-18 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Calling setValue() while typing should invoke -textDidChangeInTextField in the injected bundle
+ https://bugs.webkit.org/show_bug.cgi?id=192785
+ <rdar://problem/45321184>
+
+ Reviewed by Tim Horton.
+
+ Makes a minor adjustment in `TextFieldInputType::setValue` to consider value changes as "user editing", if we're
+ currently processing a keystroke from the user. This is useful for certain private clients, such as Safari, that
+ need to know when the user is typing in a text form control, but the page is preventing default text insertion
+ behavior and instead updating values programmatically.
+
+ Test: fast/forms/call-text-did-change-in-text-field-when-typing.html
+
+ * html/TextFieldInputType.cpp:
+ (WebCore::TextFieldInputType::setValue):
+
2018-12-18 Zalan Bujtas <za...@apple.com>
[LFC][BFC][MarginCollapsing] Implement marginBeforeCollapsesWithParentMarginAfter
Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (239336 => 239337)
--- trunk/Source/WebCore/html/TextFieldInputType.cpp 2018-12-18 15:30:25 UTC (rev 239336)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp 2018-12-18 15:37:10 UTC (rev 239337)
@@ -57,6 +57,7 @@
#include "TextEvent.h"
#include "TextIterator.h"
#include "TextNodeTraversal.h"
+#include "UserTypingGestureIndicator.h"
#include "WheelEvent.h"
#if ENABLE(DATALIST_ELEMENT)
@@ -168,6 +169,9 @@
// FIXME: Why do we do this when eventBehavior == DispatchNoEvent
if (!input->focused() || eventBehavior == DispatchNoEvent)
input->setTextAsOfLastFormControlChangeEvent(sanitizedValue);
+
+ if (UserTypingGestureIndicator::processingUserTypingGesture())
+ didSetValueByUserEdit();
}
#if ENABLE(DATALIST_ELEMENT)