-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the caret to the end for send_keys
Only if the element isn't already focused. If it is already focused, don't alter the focus. Differential Revision: https://phabricator.services.mozilla.com/D158084 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1791736 gecko-commit: 041c4a14b5ef4b3cd808523379a20c7c43540a8c gecko-reviewers: webdriver-reviewers, jdescottes, whimboo
- Loading branch information
1 parent
92952f8
commit 25fcad4
Showing
4 changed files
with
103 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
from tests.support.asserts import assert_element_has_focus | ||
|
||
|
||
def test_sets_insertion_point_to_end(session, inline): | ||
session.url = inline('<div contenteditable=true>Hello,</div>') | ||
body = session.find.css("body", all=False) | ||
assert_element_has_focus(body) | ||
|
||
input = session.find.css("div", all=False) | ||
input.send_keys(' world!') | ||
text = session.execute_script('return arguments[0].innerText', args=[input]) | ||
text = session.execute_script('return arguments[0].textContent', args=[input]) | ||
assert "Hello, world!" == text.strip() | ||
assert_element_has_focus(input) | ||
|
||
|
||
# 12. Let current text length be the element's length. | ||
# | ||
# 13. Set the text insertion caret using set selection range using current | ||
# text length for both the start and end parameters. | ||
def test_sets_insertion_point_to_after_last_text_node(session, inline): | ||
session.url = inline('<div contenteditable=true>Hel<span>lo</span>,</div>') | ||
input = session.find.css("div", all=False) | ||
input.send_keys(" world!") | ||
text = session.execute_script("return arguments[0].innerText", args=[input]) | ||
text = session.execute_script("return arguments[0].textContent", args=[input]) | ||
assert "Hello, world!" == text.strip() | ||
|
||
|
||
def test_no_move_caret_if_focused(session, inline): | ||
session.url = inline("""<div contenteditable=true>Hel<span>lo</span>,</div> | ||
<script>document.getElementsByTagName("div")[0].focus()</script>""") | ||
input = session.find.css("div", all=False) | ||
input.send_keys("world!") | ||
text = session.execute_script("return arguments[0].textContent", args=[input]) | ||
assert "world!Hello," == text.strip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters