Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gecko Bug 1492499] webdriver: fix is_fullscreen assertions #13804

Merged
merged 3 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions webdriver/tests/fullscreen_window/fullscreen.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import is_fullscreen


def fullscreen(session):
return session.transport.send(
"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")
Expand All @@ -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):
Expand All @@ -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)
26 changes: 7 additions & 19 deletions webdriver/tests/fullscreen_window/user_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,50 @@
import pytest

from tests.support.asserts import assert_dialog_handled, assert_error, assert_success
from tests.support.helpers import is_fullscreen


def fullscreen(session):
return session.transport.send(
"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)

response = fullscreen(session)
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


@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)

response = fullscreen(session)
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


@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)

Expand All @@ -68,7 +56,7 @@ def check_user_prompt_not_closed_but_exception(dialog_type):
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

Expand Down
18 changes: 4 additions & 14 deletions webdriver/tests/maximize_window/maximize.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import document_hidden, is_fullscreen


def maximize(session):
return session.transport.send(
"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")


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)
Expand Down
34 changes: 11 additions & 23 deletions webdriver/tests/minimize_window/minimize.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
# META: timeout=long

from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import document_hidden, is_fullscreen


def minimize(session):
return session.transport.send(
"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")
Expand All @@ -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)
Expand All @@ -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)
22 changes: 7 additions & 15 deletions webdriver/tests/minimize_window/user_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,48 @@
import pytest

from tests.support.asserts import assert_dialog_handled, assert_error, assert_success
from tests.support.helpers import document_hidden


def minimize(session):
return session.transport.send(
"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


@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


@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)
Expand All @@ -61,7 +53,7 @@ def check_user_prompt_not_closed_but_exception(dialog_type):
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

Expand Down
20 changes: 5 additions & 15 deletions webdriver/tests/set_window_rect/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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):
Expand All @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
Loading