Test Case: <html> <head> <title>Jasmine Spec Runner</title> <script> function testchangeime() { var q = document.getElementById("username").value; document.getElementById("username").setSelectionRange(0,q.length); var p = q.trim(); document.getElementById("username").value = p; } </script> </head> <body> <input type="text" id="username" oninput="testchangeime()"> </input> </body> </html> When user input "a" "b" "c" "d" continuously,the value of input is "abcd". But i think the value of input should be "d".
Apparently the "document.getElementById("username").value" removes the selection so the next input entry gets appended (instead of replacing the selected content). Chrome behaves like Safari, while Firefox behaves differently (as described as expected behavior)
Created attachment 253887 [details] Patch
Attachment 253887 [details] did not pass style-queue: ERROR: Source/WebCore/ChangeLog:8: You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible. [changelog/nonewtests] [5] Total errors found: 1 in 2 files If any of these errors are false positives, please file a bug against check-webkit-style.
Created attachment 253888 [details] Patch
Comment on attachment 253888 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=253888&action=review r- because this patch is missing a test. I'm also worried that this change is not backwards compatible and may worsen the certain aspects of user interaction. > Source/WebCore/html/TextFieldInputType.cpp:129 > + if (Frame* frame = input->document()->frame()) { > + start = frame->selection()->selection().start().offsetInContainerNode(); > + end = frame->selection()->selection().end().offsetInContainerNode(); > + } This is wrong. containerNode could be a div in the shadow DOM. We should be using element().selectionStart() and element().selectionEnd() instead.
Created attachment 253985 [details] Patch
Comment on attachment 253985 [details] Patch Attachment 253985 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/6746635820335104 New failing tests: fast/frames/take-focus-from-iframe.html platform/mac/editing/input/selection-change-closes-typing.html fast/forms/input-setvalue-selection.html
Created attachment 253986 [details] Archive of layout-test-results from ews104 for mac-mavericks-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-mavericks-wk2 Platform: Mac OS X 10.9.5
Comment on attachment 253985 [details] Patch Again, this patch definitely needs a layout test, and we need to test backwards compatibility of this change.
Created attachment 254052 [details] Patch
Created attachment 254056 [details] Patch
Comment on attachment 254056 [details] Patch The old behavior was intentional, originally to match what other web browsers do. What’s the web compatibility impact of changing this?
It happened with IME of PreEdit . Example : <input type="text" id="username" oninput="testchangeime()"> </input> <script> function testchangeime(){ var q = document.getElementById("username").value; var p = q.trim(); document.getElementById("username").value = p; } </script> When user input 'a' with IME ,the status of 'a' is PreEdit . But if testchangeime() is called , the status of 'a' will become PreEdit to NoPreEdit.
Comment on attachment 254056 [details] Patch This patch has been pending review since 2015 with no recent activity. It seems unlikely that it would even still apply to trunk in its current form. Clearing from the review queue. Feel free to update and resubmit if the patch is still relevant.