Closed Bug 1203074 Opened 10 years ago Closed 10 years ago

sendKeysToElement should append, not prepend, keys

Categories

(Remote Protocol :: Marionette, defect)

defect
Not set
normal

Tracking

(firefox43 fixed)

RESOLVED FIXED
mozilla43
Tracking Status
firefox43 --- fixed

People

(Reporter: ato, Assigned: ato)

References

(Blocks 1 open bug)

Details

(Keywords: pi-marionette-server)

Attachments

(1 file)

sendKeysToElement prepends input to text fields rather than appending it. This is because element.focus() in https://dxr.mozilla.org/mozilla-central/source/testing/marionette/sendkeys.js?from=marionette%2Fsendkeys.js#131 places the cursor at the beginning of the input field. After focussing the element we should move the cursor to the end before we synthesise the key events. More information about the original reported incident can be found in a wires bug: https://github.com/jgraham/wires/issues/19
A fun fact is that I ran into the same issue years ago when I implemented OperaDriver. The relevant code is here: https://github.com/operasoftware/operaprestodriver/blob/master/src/com/opera/core/systems/OperaWebElement.java#L238
The relevant piece of information is: // When a TEXTAREA element is focused it returns the cursor to the last position was at, or // places it last. INPUT @type="text" (or any other textual input element) places the caret at // the beginning. Because of this we are forced to move the caret to the end of the input // field. We do this by setting the selection range through JavaScript, which should move the // cursor to the end of the field upon the next focus event.
The move caret to end atom: function() { return function() { function a(d) { d.setSelectionRange(d.value.length, d.value.length) } var b = ["_"], c = this; !(b[0] in c) && c.execScript && c.execScript("var " + b[0]); for (var e; b.length && (e = b.shift());) !b.length && void 0 !== a ? c[e] = a : c = c[e] ? c[e] : c[e] = {};; return this._.apply(null, arguments); }.apply({ navigator: typeof window != undefined ? window.navigator : null }, argument + s); }
Bug 1203074: Move caret to end of textual input field before sending keys When a TEXTAREA element is focused it returns the cursor to the last position was at, or places it last. INPUT @type="text" (or any other textual input element) places the caret at the beginning. Because of this we move the caret to the end of the input field. The next time the element is focussed, the cursor should move to the end. r=jgriffin
Attachment #8658723 - Flags: review?(jgriffin)
Assignee: nobody → ato
Status: NEW → ASSIGNED
Comment on attachment 8658723 [details] MozReview Request: Bug 1203074: Move caret to end of textual input field before sending keys https://reviewboard.mozilla.org/r/18681/#review16707 lgtm
Attachment #8658723 - Flags: review?(jgriffin) → review+
This only seems to care about text and text area. Input elements with a control type of text should all handle this. see https://html.spec.whatwg.org/multipage/forms.html#the-input-element.
(In reply to David Burns :automatedtester from comment #8) > This only seems to care about text and text area. Input elements with a > control type of text should all handle this. see > https://html.spec.whatwg.org/multipage/forms.html#the-input-element. It makes sense to default to moving the caret since a textual control is the fallback, and create a blacklist of alternate non-textual control types supported by Firefox where should should not attempt to move it. Filed bug 1203540 fro this.
Flags: needinfo?(ato)
Comment on attachment 8658723 [details] MozReview Request: Bug 1203074: Move caret to end of textual input field before sending keys Bug 1203074: Move caret to end of textual input field before sending keys When a TEXTAREA element is focused it returns the cursor to the last position was at, or places it last. INPUT @type="text" (or any other textual input element) places the caret at the beginning. Because of this we move the caret to the end of the input field. The next time the element is focussed, the cursor should move to the end. The layout touch caret tests relied on the caret being left in its previous position. This patch addresses that by using the advanced user interaction API for these test cases. r=jgriffin
Comment on attachment 8658723 [details] MozReview Request: Bug 1203074: Move caret to end of textual input field before sending keys jgriffin: Mind taking another look? I had to make some changes to the layout/base/tests/marionette/test_touchcaret.py tests.
Flags: needinfo?(ato)
Attachment #8658723 - Flags: review+ → review?(jgriffin)
Comment on attachment 8658723 [details] MozReview Request: Bug 1203074: Move caret to end of textual input field before sending keys https://reviewboard.mozilla.org/r/18681/#review17469
Attachment #8658723 - Flags: review?(jgriffin) → review+
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: