Skip to content

Commit

Permalink
[wdspec] Add test case with an empty string as defaultValue.
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D191328

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1851761
gecko-commit: bd7f4ef21a69d45b5cd22238c93c03a3315adaed
gecko-reviewers: webdriver-reviewers, whimboo
  • Loading branch information
moz-wptsync-bot committed Oct 24, 2023
1 parent 4945ce4 commit c1f15ed
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,40 @@ async def test_prompt_type(
}


@pytest.mark.parametrize(
"default", [None, "", "default"], ids=["null", "empty string", "non empty string"]
)
async def test_prompt_default_value(
bidi_session, inline, new_tab, subscribe_events, wait_for_event
bidi_session, inline, new_tab, subscribe_events, wait_for_event, default
):
await subscribe_events(events=[USER_PROMPT_OPENED_EVENT])
on_entry = wait_for_event(USER_PROMPT_OPENED_EVENT)

text = "test"
default = "default"

if default is None:
script = f"<script>window.prompt('{text}', null)</script>"
else:
script = f"<script>window.prompt('{text}', '{default}')</script>"

await bidi_session.browsing_context.navigate(
context=new_tab["context"],
url=inline(f"<script>window.prompt('{text}', '{default}')</script>"),
url=inline(script),
)

event = await on_entry

assert event == {
expected_event = {
"context": new_tab["context"],
"type": "prompt",
"message": text,
"defaultValue": default,
}

if default is not None:
expected_event["defaultValue"] = default

assert event == expected_event


@pytest.mark.parametrize("type_hint", ["tab", "window"])
async def test_subscribe_to_one_context(
Expand Down

0 comments on commit c1f15ed

Please sign in to comment.