Unreviewed. Update W3C WebDriver imported tests.
[WebKit-https.git] / WebDriverTests / imported / w3c / webdriver / tests / element_send_keys / scroll_into_view.py
1 from tests.support.asserts import assert_success
2 from tests.support.fixtures import is_element_in_viewport
3 from tests.support.inline import inline
4
5
6 def element_send_keys(session, element, text):
7     return session.transport.send(
8         "POST", "/session/{session_id}/element/{element_id}/value".format(
9             session_id=session.session_id,
10             element_id=element.id),
11         {"text": text})
12
13
14 def test_element_outside_of_not_scrollable_viewport(session):
15     session.url = inline("<input style=\"position: relative; left: -9999px;\">")
16     element = session.find.css("input", all=False)
17
18     response = element_send_keys(session, element, "foo")
19     assert_success(response)
20
21     assert not is_element_in_viewport(session, element)
22
23
24 def test_element_outside_of_scrollable_viewport(session):
25     session.url = inline("<input style=\"margin-top: 102vh;\">")
26     element = session.find.css("input", all=False)
27
28     response = element_send_keys(session, element, "foo")
29     assert_success(response)
30
31     assert is_element_in_viewport(session, element)
32
33
34 def test_option_select_container_outside_of_scrollable_viewport(session):
35     session.url = inline("""
36         <select style="margin-top: 102vh;">
37           <option value="foo">foo</option>
38           <option value="bar" id="bar">bar</option>
39         </select>
40     """)
41     element = session.find.css("option#bar", all=False)
42     select = session.find.css("select", all=False)
43
44     response = element_send_keys(session, element, "bar")
45     assert_success(response)
46
47     assert is_element_in_viewport(session, select)
48     assert is_element_in_viewport(session, element)
49
50
51 def test_option_stays_outside_of_scrollable_viewport(session):
52     session.url = inline("""
53         <select multiple style="height: 105vh; margin-top: 100vh;">
54           <option value="foo" id="foo" style="height: 100vh;">foo</option>
55           <option value="bar" id="bar" style="background-color: yellow;">bar</option>
56         </select>
57     """)
58     select = session.find.css("select", all=False)
59     option_foo = session.find.css("option#foo", all=False)
60     option_bar = session.find.css("option#bar", all=False)
61
62     response = element_send_keys(session, option_bar, "bar")
63     assert_success(response)
64
65     assert is_element_in_viewport(session, select)
66     assert is_element_in_viewport(session, option_foo)
67     assert not is_element_in_viewport(session, option_bar)
68
69
70 def test_contenteditable_element_outside_of_scrollable_viewport(session):
71     session.url = inline("<div contenteditable style=\"margin-top: 102vh;\"></div>")
72     element = session.find.css("div", all=False)
73
74     response = element_send_keys(session, element, "foo")
75     assert_success(response)
76
77     assert is_element_in_viewport(session, element)