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 1819029] [wdspec] Enhance tests for execute (async) script for primitive values. #38748

Merged
merged 1 commit into from
Mar 1, 2023
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
21 changes: 21 additions & 0 deletions webdriver/tests/execute_async_script/execute_async.py
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
21 changes: 21 additions & 0 deletions webdriver/tests/execute_script/execute.py
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