Skip to content

Commit

Permalink
Bug 1819029 - [wdspec] Enhance tests for execute (async) script for p…
Browse files Browse the repository at this point in the history
…rimitive values. r=webdriver-reviewers,jdescottes

Tests originally written by jugglinmike:
 web-platform-tests/wpt#13880

Differential Revision: https://phabricator.services.mozilla.com/D171234
  • Loading branch information
whimboo committed Feb 28, 2023
1 parent 7dcf557 commit 06ed3db
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ def test_no_browsing_context(session, closed_frame):
assert_error(response, "no such window")


@pytest.mark.parametrize("expression, expected", [
("null", None),
("undefined", None),
("true", True),
("false", False),
("23", 23),
("'foo'", "foo"),
(
# Compute value in the runtime to reduce the potential for
# interference from encoding literal bytes or escape sequences in
# Python and HTTP.
"String.fromCharCode(0)",
"\x00"
)
])
def test_primitive_serialization(session, expression, expected):
response = execute_async_script(session, "arguments[0]({});".format(expression))
value = assert_success(response)
assert value == expected


@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
def test_abort_by_user_prompt(session, dialog_type):
response = execute_async_script(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ def test_no_browsing_context(session, closed_frame):
assert_error(response, "no such window")


@pytest.mark.parametrize("expression, expected", [
("null", None),
("undefined", None),
("true", True),
("false", False),
("23", 23),
("'foo'", "foo"),
(
# Compute value in the runtime to reduce the potential for
# interference from encoding literal bytes or escape sequences in
# Python and HTTP.
"String.fromCharCode(0)",
"\x00"
)
])
def test_primitive_serialization(session, expression, expected):
response = execute_script(session, "return {};".format(expression))
value = assert_success(response)
assert value == expected


def test_opening_new_window_keeps_current_window_handle(session, inline):
original_handle = session.window_handle
original_handles = session.handles
Expand Down

0 comments on commit 06ed3db

Please sign in to comment.