Skip to content

Commit

Permalink
webdriver: uplift is_fullscreen as helper
Browse files Browse the repository at this point in the history
To be able to reuse is_fullscreen() in other tests, we need to
uplift it to the support.helpers package.

Depends on D8407

Differential Revision: https://phabricator.services.mozilla.com/D8408

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1492499
gecko-commit: cbca19a1e3f4dfa31d45c00d4ef1de1b459cd16a
gecko-integration-branch: autoland
gecko-reviewers: automatedtester
  • Loading branch information
andreastt authored and jgraham committed Nov 1, 2018
1 parent ab0839a commit b0859af
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 55 deletions.
12 changes: 1 addition & 11 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 Down
12 changes: 1 addition & 11 deletions webdriver/tests/fullscreen_window/user_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,14 @@
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):
Expand Down
12 changes: 1 addition & 11 deletions webdriver/tests/maximize_window/maximize.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 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")
Expand Down
12 changes: 1 addition & 11 deletions webdriver/tests/minimize_window/minimize.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 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")

Expand Down
12 changes: 1 addition & 11 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 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
11 changes: 11 additions & 0 deletions webdriver/tests/support/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ def is_element_in_viewport(session, element):
""", args=(element,))


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;
Expand Down

0 comments on commit b0859af

Please sign in to comment.