Update web-platform-tests to revision fb15e14b52049f952612623ee0d7fb7a620a57c9

This commit is contained in:
WPT Sync Bot 2018-11-01 21:34:37 -04:00
parent 200cc8aa6b
commit 4a942c982f
141 changed files with 2563 additions and 1589 deletions

View file

@ -0,0 +1,121 @@
# META: timeout=long
import pytest
from tests.support.asserts import (
assert_error,
assert_same_element,
assert_success,
assert_dialog_handled,
)
from tests.support.inline import inline
def find_element(session, using, value):
return session.transport.send(
"POST", "session/{session_id}/element".format(**vars(session)),
{"using": using, "value": value})
@pytest.fixture
def check_user_prompt_closed_without_exception(session, create_dialog):
def check_user_prompt_closed_without_exception(dialog_type, retval):
session.url = inline("<p>bar</p>")
element = session.find.css("p", all=False)
create_dialog(dialog_type, text=dialog_type)
response = find_element(session, "css selector", "p")
value = assert_success(response)
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert_same_element(session, value, element)
return check_user_prompt_closed_without_exception
@pytest.fixture
def check_user_prompt_closed_with_exception(session, create_dialog):
def check_user_prompt_closed_with_exception(dialog_type, retval):
session.url = inline("<p>bar</p>")
create_dialog(dialog_type, text=dialog_type)
response = find_element(session, "css selector", "p")
assert_error(response, "unexpected alert open")
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
return check_user_prompt_closed_with_exception
@pytest.fixture
def check_user_prompt_not_closed_but_exception(session, create_dialog):
def check_user_prompt_not_closed_but_exception(dialog_type):
session.url = inline("<p>bar</p>")
create_dialog(dialog_type, text=dialog_type)
response = find_element(session, "css selector", "p")
assert_error(response, "unexpected alert open")
assert session.alert.text == dialog_type
session.alert.dismiss()
return check_user_prompt_not_closed_but_exception
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
check_user_prompt_not_closed_but_exception(dialog_type)
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_default(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)

View file

@ -0,0 +1,126 @@
# META: timeout=long
import pytest
from tests.support.asserts import (
assert_error,
assert_same_element,
assert_success,
assert_dialog_handled,
)
from tests.support.inline import inline
def find_element(session, element_id, using, value):
return session.transport.send(
"POST", "session/{session_id}/element/{element_id}/element".format(
session_id=session.session_id,
element_id=element_id),
{"using": using, "value": value})
@pytest.fixture
def check_user_prompt_closed_without_exception(session, create_dialog):
def check_user_prompt_closed_without_exception(dialog_type, retval):
session.url = inline("<div><p>bar</p><div>")
outer_element = session.find.css("div", all=False)
inner_element = session.find.css("p", all=False)
create_dialog(dialog_type, text=dialog_type)
response = find_element(session, outer_element.id, "css selector", "p")
value = assert_success(response)
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert_same_element(session, value, inner_element)
return check_user_prompt_closed_without_exception
@pytest.fixture
def check_user_prompt_closed_with_exception(session, create_dialog):
def check_user_prompt_closed_with_exception(dialog_type, retval):
session.url = inline("<div><p>bar</p><div>")
outer_element = session.find.css("div", all=False)
create_dialog(dialog_type, text=dialog_type)
response = find_element(session, outer_element.id, "css selector", "p")
assert_error(response, "unexpected alert open")
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
return check_user_prompt_closed_with_exception
@pytest.fixture
def check_user_prompt_not_closed_but_exception(session, create_dialog):
def check_user_prompt_not_closed_but_exception(dialog_type):
session.url = inline("<div><p>bar</p><div>")
outer_element = session.find.css("div", all=False)
create_dialog(dialog_type, text=dialog_type)
response = find_element(session, outer_element.id, "css selector", "p")
assert_error(response, "unexpected alert open")
assert session.alert.text == dialog_type
session.alert.dismiss()
return check_user_prompt_not_closed_but_exception
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
check_user_prompt_not_closed_but_exception(dialog_type)
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_default(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)

View file

@ -0,0 +1,123 @@
# META: timeout=long
import pytest
from tests.support.asserts import (
assert_error,
assert_same_element,
assert_success,
assert_dialog_handled,
)
from tests.support.inline import inline
def find_elements(session, using, value):
return session.transport.send(
"POST", "session/{session_id}/elements".format(**vars(session)),
{"using": using, "value": value})
@pytest.fixture
def check_user_prompt_closed_without_exception(session, create_dialog):
def check_user_prompt_closed_without_exception(dialog_type, retval):
session.url = inline("<p>bar</p>")
element = session.find.css("p", all=False)
create_dialog(dialog_type, text=dialog_type)
response = find_elements(session, "css selector", "p")
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 1
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert_same_element(session, value[0], element)
return check_user_prompt_closed_without_exception
@pytest.fixture
def check_user_prompt_closed_with_exception(session, create_dialog):
def check_user_prompt_closed_with_exception(dialog_type, retval):
session.url = inline("<p>bar</p>")
create_dialog(dialog_type, text=dialog_type)
response = find_elements(session, "css selector", "p")
assert_error(response, "unexpected alert open")
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
return check_user_prompt_closed_with_exception
@pytest.fixture
def check_user_prompt_not_closed_but_exception(session, create_dialog):
def check_user_prompt_not_closed_but_exception(dialog_type):
session.url = inline("<p>bar</p>")
create_dialog(dialog_type, text=dialog_type)
response = find_elements(session, "css selector", "p")
assert_error(response, "unexpected alert open")
assert session.alert.text == dialog_type
session.alert.dismiss()
return check_user_prompt_not_closed_but_exception
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
check_user_prompt_not_closed_but_exception(dialog_type)
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_default(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)

View file

@ -0,0 +1,128 @@
# META: timeout=long
import pytest
from tests.support.asserts import (
assert_error,
assert_same_element,
assert_success,
assert_dialog_handled,
)
from tests.support.inline import inline
def find_elements(session, element_id, using, value):
return session.transport.send(
"POST", "session/{session_id}/element/{element_id}/elements".format(
session_id=session.session_id,
element_id=element_id),
{"using": using, "value": value})
@pytest.fixture
def check_user_prompt_closed_without_exception(session, create_dialog):
def check_user_prompt_closed_without_exception(dialog_type, retval):
session.url = inline("<div><p>bar</p><div>")
outer_element = session.find.css("div", all=False)
inner_element = session.find.css("p", all=False)
create_dialog(dialog_type, text=dialog_type)
response = find_elements(session, outer_element.id, "css selector", "p")
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 1
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert_same_element(session, value[0], inner_element)
return check_user_prompt_closed_without_exception
@pytest.fixture
def check_user_prompt_closed_with_exception(session, create_dialog):
def check_user_prompt_closed_with_exception(dialog_type, retval):
session.url = inline("<div><p>bar</p><div>")
outer_element = session.find.css("div", all=False)
create_dialog(dialog_type, text=dialog_type)
response = find_elements(session, outer_element.id, "css selector", "p")
assert_error(response, "unexpected alert open")
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
return check_user_prompt_closed_with_exception
@pytest.fixture
def check_user_prompt_not_closed_but_exception(session, create_dialog):
def check_user_prompt_not_closed_but_exception(dialog_type):
session.url = inline("<div><p>bar</p><div>")
outer_element = session.find.css("div", all=False)
create_dialog(dialog_type, text=dialog_type)
response = find_elements(session, outer_element.id, "css selector", "p")
assert_error(response, "unexpected alert open")
assert session.alert.text == dialog_type
session.alert.dismiss()
return check_user_prompt_not_closed_but_exception
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
check_user_prompt_not_closed_but_exception(dialog_type)
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_default(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)

View file

@ -1,4 +1,5 @@
from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import is_fullscreen
def fullscreen(session):
@ -6,17 +7,6 @@ def fullscreen(session):
"POST", "session/{session_id}/window/fullscreen".format(**vars(session)))
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the
# Fullscreen API specification.
#
# Remove the prefixed fallback when
# https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("""
return !!(window.fullScreen || document.webkitIsFullScreen)
""")
def test_no_browsing_context(session, closed_window):
response = fullscreen(session)
assert_error(response, "no such window")
@ -26,7 +16,7 @@ def test_fullscreen(session):
response = fullscreen(session)
assert_success(response)
assert is_fullscreen(session) is True
assert is_fullscreen(session)
def test_payload(session):
@ -47,12 +37,12 @@ def test_payload(session):
def test_fullscreen_twice_is_idempotent(session):
assert is_fullscreen(session) is False
assert not is_fullscreen(session)
first_response = fullscreen(session)
assert_success(first_response)
assert is_fullscreen(session) is True
assert is_fullscreen(session)
second_response = fullscreen(session)
assert_success(second_response)
assert is_fullscreen(session) is True
assert is_fullscreen(session)

View file

@ -3,6 +3,7 @@
import pytest
from tests.support.asserts import assert_dialog_handled, assert_error, assert_success
from tests.support.helpers import is_fullscreen
def fullscreen(session):
@ -10,21 +11,10 @@ def fullscreen(session):
"POST", "session/{session_id}/window/fullscreen".format(**vars(session)))
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the
# Fullscreen API specification.
#
# Remove the prefixed fallback when
# https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("""
return !!(window.fullScreen || document.webkitIsFullScreen)
""")
@pytest.fixture
def check_user_prompt_closed_without_exception(session, create_dialog):
def check_user_prompt_closed_without_exception(dialog_type, retval):
assert is_fullscreen(session) is False
assert not is_fullscreen(session)
create_dialog(dialog_type, text=dialog_type)
@ -32,8 +22,7 @@ def check_user_prompt_closed_without_exception(session, create_dialog):
assert_success(response)
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert is_fullscreen(session) is True
assert is_fullscreen(session)
return check_user_prompt_closed_without_exception
@ -41,7 +30,7 @@ def check_user_prompt_closed_without_exception(session, create_dialog):
@pytest.fixture
def check_user_prompt_closed_with_exception(session, create_dialog):
def check_user_prompt_closed_with_exception(dialog_type, retval):
assert is_fullscreen(session) is False
assert not is_fullscreen(session)
create_dialog(dialog_type, text=dialog_type)
@ -49,8 +38,7 @@ def check_user_prompt_closed_with_exception(session, create_dialog):
assert_error(response, "unexpected alert open")
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert is_fullscreen(session) is False
assert not is_fullscreen(session)
return check_user_prompt_closed_with_exception
@ -58,7 +46,7 @@ def check_user_prompt_closed_with_exception(session, create_dialog):
@pytest.fixture
def check_user_prompt_not_closed_but_exception(session, create_dialog):
def check_user_prompt_not_closed_but_exception(dialog_type):
assert is_fullscreen(session) is False
assert not is_fullscreen(session)
create_dialog(dialog_type, text=dialog_type)
@ -68,7 +56,7 @@ def check_user_prompt_not_closed_but_exception(session, create_dialog):
assert session.alert.text == dialog_type
session.alert.dismiss()
assert is_fullscreen(session) is False
assert not is_fullscreen(session)
return check_user_prompt_not_closed_but_exception

View file

@ -1,4 +1,5 @@
from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import document_hidden, is_fullscreen
def maximize(session):
@ -6,17 +7,6 @@ def maximize(session):
"POST", "session/{session_id}/window/maximize".format(**vars(session)))
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the
# Fullscreen API specification.
#
# Remove the prefixed fallback when
# https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("""
return !!(window.fullScreen || document.webkitIsFullScreen)
""")
def test_no_browsing_context(session, closed_window):
response = maximize(session)
assert_error(response, "no such window")
@ -24,16 +14,16 @@ def test_no_browsing_context(session, closed_window):
def test_fully_exit_fullscreen(session):
session.window.fullscreen()
assert is_fullscreen(session) is True
assert is_fullscreen(session)
response = maximize(session)
assert_success(response)
assert is_fullscreen(session) is False
assert not is_fullscreen(session)
def test_restore_the_window(session):
session.window.minimize()
assert session.execute_script("return document.hidden") is True
assert document_hidden(session)
response = maximize(session)
assert_success(response)

View file

@ -1,4 +1,7 @@
# META: timeout=long
from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import document_hidden, is_fullscreen
def minimize(session):
@ -6,21 +9,6 @@ def minimize(session):
"POST", "session/{session_id}/window/minimize".format(**vars(session)))
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the
# Fullscreen API specification.
#
# Remove the prefixed fallback when
# https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("""
return !!(window.fullScreen || document.webkitIsFullScreen)
""")
def is_minimized(session):
return session.execute_script("return document.hidden")
def test_no_browsing_context(session, closed_window):
response = minimize(session)
assert_error(response, "no such window")
@ -33,19 +21,19 @@ def test_fully_exit_fullscreen(session):
response = minimize(session)
assert_success(response)
assert not is_fullscreen(session)
assert is_minimized(session)
assert document_hidden(session)
def test_minimize(session):
assert not is_minimized(session)
assert not document_hidden(session)
response = minimize(session)
assert_success(response)
assert is_minimized(session)
assert document_hidden(session)
def test_payload(session):
assert not is_minimized(session)
assert not document_hidden(session)
response = minimize(session)
value = assert_success(response)
@ -61,16 +49,16 @@ def test_payload(session):
assert isinstance(value["x"], int)
assert isinstance(value["y"], int)
assert is_minimized(session)
assert document_hidden(session)
def test_minimize_twice_is_idempotent(session):
assert not is_minimized(session)
assert not document_hidden(session)
first_response = minimize(session)
assert_success(first_response)
assert is_minimized(session)
assert document_hidden(session)
second_response = minimize(session)
assert_success(second_response)
assert is_minimized(session)
assert document_hidden(session)

View file

@ -3,6 +3,7 @@
import pytest
from tests.support.asserts import assert_dialog_handled, assert_error, assert_success
from tests.support.helpers import document_hidden
def minimize(session):
@ -10,23 +11,17 @@ def minimize(session):
"POST", "session/{session_id}/window/minimize".format(**vars(session)))
def is_minimized(session):
return session.execute_script("return document.hidden")
@pytest.fixture
def check_user_prompt_closed_without_exception(session, create_dialog):
def check_user_prompt_closed_without_exception(dialog_type, retval):
assert not is_minimized(session)
assert not document_hidden(session)
create_dialog(dialog_type, text=dialog_type)
response = minimize(session)
assert_success(response)
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert is_minimized(session)
assert document_hidden(session)
return check_user_prompt_closed_without_exception
@ -34,16 +29,14 @@ def check_user_prompt_closed_without_exception(session, create_dialog):
@pytest.fixture
def check_user_prompt_closed_with_exception(session, create_dialog):
def check_user_prompt_closed_with_exception(dialog_type, retval):
assert not is_minimized(session)
assert not document_hidden(session)
create_dialog(dialog_type, text=dialog_type)
response = minimize(session)
assert_error(response, "unexpected alert open")
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert not is_minimized(session)
assert not document_hidden(session)
return check_user_prompt_closed_with_exception
@ -51,8 +44,7 @@ def check_user_prompt_closed_with_exception(session, create_dialog):
@pytest.fixture
def check_user_prompt_not_closed_but_exception(session, create_dialog):
def check_user_prompt_not_closed_but_exception(dialog_type):
assert not is_minimized(session)
assert not document_hidden(session)
create_dialog(dialog_type, text=dialog_type)
response = minimize(session)
@ -61,7 +53,7 @@ def check_user_prompt_not_closed_but_exception(session, create_dialog):
assert session.alert.text == dialog_type
session.alert.dismiss()
assert not is_minimized(session)
assert not document_hidden(session)
return check_user_prompt_not_closed_but_exception

View file

@ -5,6 +5,7 @@ import pytest
from webdriver.transport import Response
from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import document_hidden, is_fullscreen
def set_window_rect(session, rect):
@ -13,17 +14,6 @@ def set_window_rect(session, rect):
rect)
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the
# Fullscreen API specification.
#
# Remove the prefixed fallback when
# https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("""
return !!(window.fullScreen || document.webkitIsFullScreen)
""")
def test_null_parameter_value(session, http):
path = "/session/{session_id}/window/rect".format(**vars(session))
with http.post(path, None) as response:
@ -142,26 +132,26 @@ def test_no_change(session, rect):
def test_fully_exit_fullscreen(session):
session.window.fullscreen()
assert is_fullscreen(session) is True
assert is_fullscreen(session)
response = set_window_rect(session, {"width": 400, "height": 400})
value = assert_success(response)
assert value["width"] == 400
assert value["height"] == 400
assert is_fullscreen(session) is False
assert not is_fullscreen(session)
def test_restore_from_minimized(session):
session.window.minimize()
assert session.execute_script("return document.hidden") is True
assert document_hidden(session)
response = set_window_rect(session, {"width": 450, "height": 450})
value = assert_success(response)
assert value["width"] == 450
assert value["height"] == 450
assert session.execute_script("return document.hidden") is False
assert not document_hidden(session)
def test_restore_from_maximized(session):

View file

@ -5,6 +5,8 @@ import sys
import webdriver
from tests.support import defaults
from tests.support.sync import Poll
def ignore_exceptions(f):
def inner(*args, **kwargs):
@ -119,6 +121,24 @@ def is_element_in_viewport(session, element):
""", args=(element,))
def document_hidden(session):
"""Polls for the document to become hidden."""
def hidden(session):
return session.execute_script("return document.hidden")
return Poll(session, timeout=3, raises=None).until(hidden)
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the
# Fullscreen API specification.
#
# Remove the prefixed fallback when
# https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("""
return !!(window.fullScreen || document.webkitIsFullScreen)
""")
def document_dimensions(session):
return tuple(session.execute_script("""
let {devicePixelRatio} = window;