diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 0a4c4b5b2add..60d6d3c15132 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -310006,6 +310006,16 @@ {} ] ], + "webdriver/tests/get_window_handle/__init__.py": [ + [ + {} + ] + ], + "webdriver/tests/get_window_handles/__init__.py": [ + [ + {} + ] + ], "webdriver/tests/get_window_rect/__init__.py": [ [ {} @@ -421805,6 +421815,34 @@ } ] ], + "webdriver/tests/get_window_handle/get.py": [ + [ + "/webdriver/tests/get_window_handle/get.py", + {} + ] + ], + "webdriver/tests/get_window_handle/user_prompts.py": [ + [ + "/webdriver/tests/get_window_handle/user_prompts.py", + { + "timeout": "long" + } + ] + ], + "webdriver/tests/get_window_handles/get.py": [ + [ + "/webdriver/tests/get_window_handles/get.py", + {} + ] + ], + "webdriver/tests/get_window_handles/user_prompts.py": [ + [ + "/webdriver/tests/get_window_handles/user_prompts.py", + { + "timeout": "long" + } + ] + ], "webdriver/tests/get_window_rect/get.py": [ [ "/webdriver/tests/get_window_rect/get.py", @@ -641749,7 +641787,7 @@ "support" ], "tools/wptrunner/wptrunner/executors/executormarionette.py": [ - "b9891c45cd2f8ac70c3e375cf41dceefca1cd2af", + "ad71a8fa31c7cf4626c11214a520a2121db897c4", "support" ], "tools/wptrunner/wptrunner/executors/executoropera.py": [ @@ -646265,7 +646303,7 @@ "support" ], "webdriver/tests/add_cookie/add.py": [ - "49b1d68e7d2baa5086d0b945e9d005c2d86234ea", + "48fdf64f2f9523979a7a79ca3f9541603c0e1d60", "wdspec" ], "webdriver/tests/back/__init__.py": [ @@ -646421,7 +646459,7 @@ "wdspec" ], "webdriver/tests/element_send_keys/send_keys.py": [ - "0d281d7f5cb3c2f3386504aedd66afa6269e65d3", + "03cc94850c6c9f65e8a70a931b4816d0bbf2d167", "wdspec" ], "webdriver/tests/element_send_keys/user_prompts.py": [ @@ -646437,7 +646475,7 @@ "wdspec" ], "webdriver/tests/execute_async_script/execute_async.py": [ - "2b6e61543176ea1ba15f4c399028ceb24878e3c9", + "7c454eaf4ac4f83d7594e58f99dbdb525ef7d687", "wdspec" ], "webdriver/tests/execute_async_script/user_prompts.py": [ @@ -646457,7 +646495,7 @@ "wdspec" ], "webdriver/tests/execute_script/execute.py": [ - "386afe0e1db172c310ff3aefa2bfb0078a79a966", + "2af16c1e5e8a3bed01c5703db24a1d399a0e2270", "wdspec" ], "webdriver/tests/execute_script/json_serialize_windowproxy.py": [ @@ -646473,7 +646511,7 @@ "support" ], "webdriver/tests/find_element/find.py": [ - "ad25e78e9e47fa7ef45bbd1546eae9c7da78f436", + "20cde541d11eebcce70493863fb55fcb1e81a908", "wdspec" ], "webdriver/tests/find_element_from_element/__init__.py": [ @@ -646481,7 +646519,7 @@ "support" ], "webdriver/tests/find_element_from_element/find.py": [ - "d44fbb3957bc7b3e0e47e0016ffae3d3bfdf3813", + "56e216bb646131bdcc9a0c3c28ea4142c2982897", "wdspec" ], "webdriver/tests/find_elements/__init__.py": [ @@ -646489,7 +646527,7 @@ "support" ], "webdriver/tests/find_elements/find.py": [ - "f6856e9ed6ed45fd6f40008ba4ee0309aff0d282", + "b31370ee0cd1b7c9cb307541728f4e736117181c", "wdspec" ], "webdriver/tests/find_elements_from_element/__init__.py": [ @@ -646497,7 +646535,7 @@ "support" ], "webdriver/tests/find_elements_from_element/find.py": [ - "bcc18642c8fd86285be4ab2520b6d16aeb516f19", + "5a48e9c76ef6add6e69952c58a23edbd5e87698d", "wdspec" ], "webdriver/tests/forward/__init__.py": [ @@ -646620,6 +646658,30 @@ "76d65c088a0b94e8cefb976e91edf5492a5aae20", "wdspec" ], + "webdriver/tests/get_window_handle/__init__.py": [ + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "support" + ], + "webdriver/tests/get_window_handle/get.py": [ + "c6a90f93c1b693d59df7d0b0b12f5da821e73c7c", + "wdspec" + ], + "webdriver/tests/get_window_handle/user_prompts.py": [ + "0bd660cfa1fb31ba4fc93bb0ecb239fc4a6c136c", + "wdspec" + ], + "webdriver/tests/get_window_handles/__init__.py": [ + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "support" + ], + "webdriver/tests/get_window_handles/get.py": [ + "07ff9d4d26fd3b7cff5620b5295ebe386a226cf2", + "wdspec" + ], + "webdriver/tests/get_window_handles/user_prompts.py": [ + "217e9849b4417d7124e203f937270a9e4823666a", + "wdspec" + ], "webdriver/tests/get_window_rect/__init__.py": [ "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "support" @@ -646677,7 +646739,7 @@ "support" ], "webdriver/tests/navigate_to/navigate.py": [ - "9ac1be00b84eeae73aec8a1facb43b329bae6310", + "e478e10b76b0953d854416dffdc7a400087aee95", "wdspec" ], "webdriver/tests/new_session/__init__.py": [ @@ -646757,7 +646819,7 @@ "support" ], "webdriver/tests/send_alert_text/send.py": [ - "9d4532a190c717ad7997a5b9ccb6d8d32a2cb1fc", + "edc37d6edb483c232401676f6c11ab7512774605", "wdspec" ], "webdriver/tests/set_timeouts/__init__.py": [ @@ -646765,7 +646827,7 @@ "support" ], "webdriver/tests/set_timeouts/set.py": [ - "8dd0344dca561d50df6dd04a0d2507a015649e0c", + "e603e217ec7d73bf7bc59f1d2e8687a89c818c47", "wdspec" ], "webdriver/tests/set_window_rect/__init__.py": [ @@ -646773,7 +646835,7 @@ "support" ], "webdriver/tests/set_window_rect/set.py": [ - "17210af4f46a25a6f2484ba76a74cd5c54e31d6a", + "928fd622efc22f520f4c6a9f783f60ec270146e2", "wdspec" ], "webdriver/tests/set_window_rect/user_prompts.py": [ @@ -646797,11 +646859,11 @@ "support" ], "webdriver/tests/support/fixtures.py": [ - "daeccb70e948b2564f7d78106dbee919b9cd7436", + "64427b4670f72c9ea069d0f008d93ad63a9781c0", "support" ], "webdriver/tests/support/http_request.py": [ - "ae28a6486b1333acc472ab2d37ac3f890249f1a2", + "5e46d97017e14ba009d4d1ed6d62bb5012f48d15", "support" ], "webdriver/tests/support/inline.py": [ @@ -646821,7 +646883,7 @@ "support" ], "webdriver/tests/switch_to_frame/switch.py": [ - "403047958665981f5509e370e38897b8a463e2a7", + "10948102239df61f0fd35fc157fe31b1a3e2968a", "wdspec" ], "webdriver/tests/switch_to_parent_frame/__init__.py": [ @@ -646837,7 +646899,7 @@ "support" ], "webdriver/tests/switch_to_window/switch.py": [ - "17f7c4da328822fb342b7e3f510eb6ed007bce3f", + "907be66a149e8196c87760544140636d9625bbb9", "wdspec" ], "webgl/META.yml": [ diff --git a/testing/web-platform/tests/webdriver/tests/get_window_handle/__init__.py b/testing/web-platform/tests/webdriver/tests/get_window_handle/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/testing/web-platform/tests/webdriver/tests/get_window_handle/get.py b/testing/web-platform/tests/webdriver/tests/get_window_handle/get.py new file mode 100644 index 000000000000..c6a90f93c1b6 --- /dev/null +++ b/testing/web-platform/tests/webdriver/tests/get_window_handle/get.py @@ -0,0 +1,16 @@ +from tests.support.asserts import assert_error, assert_success + + +def get_window_handle(session): + return session.transport.send( + "GET", "session/{session_id}/window".format(**vars(session))) + + +def test_no_browsing_context(session, closed_window): + response = get_window_handle(session) + assert_error(response, "no such window") + + +def test_basic(session): + response = get_window_handle(session) + assert_success(response, session.window_handle) diff --git a/testing/web-platform/tests/webdriver/tests/get_window_handle/user_prompts.py b/testing/web-platform/tests/webdriver/tests/get_window_handle/user_prompts.py new file mode 100644 index 000000000000..0bd660cfa1fb --- /dev/null +++ b/testing/web-platform/tests/webdriver/tests/get_window_handle/user_prompts.py @@ -0,0 +1,61 @@ +# META: timeout=long + +import pytest + +from tests.support.asserts import assert_success + + +def get_window_handle(session): + return session.transport.send( + "GET", "session/{session_id}/window".format(**vars(session))) + + +@pytest.fixture +def check_user_prompt_not_closed_but_exception(session, create_dialog): + def check_user_prompt_not_closed_but_exception(dialog_type): + window_handle = session.window_handle + + create_dialog(dialog_type, text=dialog_type) + + response = get_window_handle(session) + assert_success(response, window_handle) + + assert session.alert.text == dialog_type + session.alert.dismiss() + + return check_user_prompt_not_closed_but_exception + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_accept(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_accept_and_notify(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_dismiss(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_dismiss_and_notify(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_default(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) diff --git a/testing/web-platform/tests/webdriver/tests/get_window_handles/__init__.py b/testing/web-platform/tests/webdriver/tests/get_window_handles/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/testing/web-platform/tests/webdriver/tests/get_window_handles/get.py b/testing/web-platform/tests/webdriver/tests/get_window_handles/get.py new file mode 100644 index 000000000000..07ff9d4d26fd --- /dev/null +++ b/testing/web-platform/tests/webdriver/tests/get_window_handles/get.py @@ -0,0 +1,38 @@ +from tests.support.asserts import assert_success + + +def get_window_handles(session): + return session.transport.send( + "GET", "session/{session_id}/window/handles".format(**vars(session))) + + +def test_no_browsing_context(session, create_window): + window_handles = session.handles + + new_handle = create_window() + session.window_handle = new_handle + session.close() + + response = get_window_handles(session) + assert_success(response, window_handles) + + +def test_single_window(session): + response = get_window_handles(session) + value = assert_success(response) + + assert len(value) == 1 + assert value == session.handles + assert value[0] == session.window_handle + + +def test_multiple_windows(session, create_window): + original_handle = session.window_handle + new_handle = create_window() + + response = get_window_handles(session) + value = assert_success(response) + + assert len(value) == 2 + assert original_handle in value + assert new_handle in value diff --git a/testing/web-platform/tests/webdriver/tests/get_window_handles/user_prompts.py b/testing/web-platform/tests/webdriver/tests/get_window_handles/user_prompts.py new file mode 100644 index 000000000000..217e9849b441 --- /dev/null +++ b/testing/web-platform/tests/webdriver/tests/get_window_handles/user_prompts.py @@ -0,0 +1,61 @@ +# META: timeout=long + +import pytest + +from tests.support.asserts import assert_success + + +def get_window_handles(session): + return session.transport.send( + "GET", "session/{session_id}/window/handles".format(**vars(session))) + + +@pytest.fixture +def check_user_prompt_not_closed_but_exception(session, create_dialog): + def check_user_prompt_not_closed_but_exception(dialog_type): + window_handles = session.handles + + create_dialog(dialog_type, text=dialog_type) + + response = get_window_handles(session) + assert_success(response, window_handles) + + assert session.alert.text == dialog_type + session.alert.dismiss() + + return check_user_prompt_not_closed_but_exception + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_accept(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_accept_and_notify(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_dismiss(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_dismiss_and_notify(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"}) +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) + + +@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"]) +def test_default(check_user_prompt_not_closed_but_exception, dialog_type): + check_user_prompt_not_closed_but_exception(dialog_type) diff --git a/testing/web-platform/tests/webdriver/tests/support/fixtures.py b/testing/web-platform/tests/webdriver/tests/support/fixtures.py index daeccb70e948..64427b4670f7 100644 --- a/testing/web-platform/tests/webdriver/tests/support/fixtures.py +++ b/testing/web-platform/tests/webdriver/tests/support/fixtures.py @@ -294,10 +294,11 @@ def clear_all_cookies(session): def closed_window(session, create_window): - new_handle = create_window() original_handle = session.window_handle + new_handle = create_window() session.window_handle = new_handle + session.close() assert new_handle not in session.handles, "Unable to close window {}".format(new_handle)