Bug 1483801 - [wdspec] Create tests for Get Window Handle and Get Window Handles. r=ato
authorHenrik Skupin <mail@hskupin.info>
Thu, 16 Aug 2018 15:37:10 +0200
changeset 431973 e1cfd8ee66d4f1696e922dccd3bcfb9d9dac7a36
parent 431972 3594f4889a4316af5e979631a65d9c7a9bac00d6
child 431974 a84948944042e82007e61cb32f6eb768d037edda
push id34456
push usertoros@mozilla.com
push dateThu, 16 Aug 2018 21:33:21 +0000
treeherdermozilla-central@72442cf86f54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1483801
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1483801 - [wdspec] Create tests for Get Window Handle and Get Window Handles. r=ato
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/webdriver/tests/get_window_handle/__init__.py
testing/web-platform/tests/webdriver/tests/get_window_handle/get.py
testing/web-platform/tests/webdriver/tests/get_window_handle/user_prompts.py
testing/web-platform/tests/webdriver/tests/get_window_handles/__init__.py
testing/web-platform/tests/webdriver/tests/get_window_handles/get.py
testing/web-platform/tests/webdriver/tests/get_window_handles/user_prompts.py
testing/web-platform/tests/webdriver/tests/support/fixtures.py
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -310001,16 +310001,26 @@
      {}
     ]
    ],
    "webdriver/tests/get_title/__init__.py": [
     [
      {}
     ]
    ],
+   "webdriver/tests/get_window_handle/__init__.py": [
+    [
+     {}
+    ]
+   ],
+   "webdriver/tests/get_window_handles/__init__.py": [
+    [
+     {}
+    ]
+   ],
    "webdriver/tests/get_window_rect/__init__.py": [
     [
      {}
     ]
    ],
    "webdriver/tests/is_element_selected/__init__.py": [
     [
      {}
@@ -421800,16 +421810,44 @@
    "webdriver/tests/get_title/user_prompts.py": [
     [
      "/webdriver/tests/get_title/user_prompts.py",
      {
       "timeout": "long"
      }
     ]
    ],
+   "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",
      {}
     ]
    ],
    "webdriver/tests/get_window_rect/user_prompts.py": [
     [
@@ -641744,17 +641782,17 @@
    "bd6553fadcb16db177e522a0e60c82e8c55bca03",
    "support"
   ],
   "tools/wptrunner/wptrunner/executors/executorinternetexplorer.py": [
    "898ff144593877c3be33a33be567816e869dcf3e",
    "support"
   ],
   "tools/wptrunner/wptrunner/executors/executormarionette.py": [
-   "b9891c45cd2f8ac70c3e375cf41dceefca1cd2af",
+   "ad71a8fa31c7cf4626c11214a520a2121db897c4",
    "support"
   ],
   "tools/wptrunner/wptrunner/executors/executoropera.py": [
    "55f1f0d59590807452a9ffc201ad8d0f8f972fcd",
    "support"
   ],
   "tools/wptrunner/wptrunner/executors/executorsafari.py": [
    "ed01f4d8341b5497473b6f535ac4a2c04158cd9e",
@@ -646260,17 +646298,17 @@
    "6f844cd255a075d31caf1c19957af3d6ac833778",
    "support"
   ],
   "webdriver/tests/add_cookie/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/add_cookie/add.py": [
-   "49b1d68e7d2baa5086d0b945e9d005c2d86234ea",
+   "48fdf64f2f9523979a7a79ca3f9541603c0e1d60",
    "wdspec"
   ],
   "webdriver/tests/back/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/back/back.py": [
    "0f94ab431ae012b0abc8406f6d372a6fafcf8048",
@@ -646416,33 +646454,33 @@
    "3a809aac6939b54b76cc2badec176abb216dcdd8",
    "wdspec"
   ],
   "webdriver/tests/element_send_keys/scroll_into_view.py": [
    "9ff0a9e25788921eb6d01add0e279c50d7de6134",
    "wdspec"
   ],
   "webdriver/tests/element_send_keys/send_keys.py": [
-   "0d281d7f5cb3c2f3386504aedd66afa6269e65d3",
+   "03cc94850c6c9f65e8a70a931b4816d0bbf2d167",
    "wdspec"
   ],
   "webdriver/tests/element_send_keys/user_prompts.py": [
    "621bdffa6642817684f2a919d3c07103793522dd",
    "wdspec"
   ],
   "webdriver/tests/execute_async_script/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/execute_async_script/collections.py": [
    "8376fdfe061ca615ed12f632d878221ec5cb0e78",
    "wdspec"
   ],
   "webdriver/tests/execute_async_script/execute_async.py": [
-   "2b6e61543176ea1ba15f4c399028ceb24878e3c9",
+   "7c454eaf4ac4f83d7594e58f99dbdb525ef7d687",
    "wdspec"
   ],
   "webdriver/tests/execute_async_script/user_prompts.py": [
    "5c873935519716a3f4933b710828118218f7220c",
    "wdspec"
   ],
   "webdriver/tests/execute_script/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
@@ -646452,57 +646490,57 @@
    "edee1e5532b81f07f19be09b40fc99c2df9ef6f8",
    "wdspec"
   ],
   "webdriver/tests/execute_script/cyclic.py": [
    "16bdcdd1dea5f27753cc525a754dffae3b589005",
    "wdspec"
   ],
   "webdriver/tests/execute_script/execute.py": [
-   "386afe0e1db172c310ff3aefa2bfb0078a79a966",
+   "2af16c1e5e8a3bed01c5703db24a1d399a0e2270",
    "wdspec"
   ],
   "webdriver/tests/execute_script/json_serialize_windowproxy.py": [
    "9864227374e328514d54596f611c474c6f0fe3f3",
    "wdspec"
   ],
   "webdriver/tests/execute_script/user_prompts.py": [
    "ec6895b74f8e110120f2e3067e2c35b94d2a532d",
    "wdspec"
   ],
   "webdriver/tests/find_element/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/find_element/find.py": [
-   "ad25e78e9e47fa7ef45bbd1546eae9c7da78f436",
+   "20cde541d11eebcce70493863fb55fcb1e81a908",
    "wdspec"
   ],
   "webdriver/tests/find_element_from_element/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/find_element_from_element/find.py": [
-   "d44fbb3957bc7b3e0e47e0016ffae3d3bfdf3813",
+   "56e216bb646131bdcc9a0c3c28ea4142c2982897",
    "wdspec"
   ],
   "webdriver/tests/find_elements/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/find_elements/find.py": [
-   "f6856e9ed6ed45fd6f40008ba4ee0309aff0d282",
+   "b31370ee0cd1b7c9cb307541728f4e736117181c",
    "wdspec"
   ],
   "webdriver/tests/find_elements_from_element/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/find_elements_from_element/find.py": [
-   "bcc18642c8fd86285be4ab2520b6d16aeb516f19",
+   "5a48e9c76ef6add6e69952c58a23edbd5e87698d",
    "wdspec"
   ],
   "webdriver/tests/forward/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/forward/conftest.py": [
    "d5fd320a696a507718299c765278edde6205608a",
@@ -646615,16 +646653,40 @@
   "webdriver/tests/get_title/get.py": [
    "ed5b401c564ec7375b3be8ebd9124388f40062a7",
    "wdspec"
   ],
   "webdriver/tests/get_title/user_prompts.py": [
    "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"
   ],
   "webdriver/tests/get_window_rect/get.py": [
    "ee2c9eefd3f4ff81ea1cb8f33be58cc17f332030",
    "wdspec"
   ],
@@ -646672,17 +646734,17 @@
    "1551e3af62668971eeb5681301b6833cf6fb619b",
    "wdspec"
   ],
   "webdriver/tests/navigate_to/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/navigate_to/navigate.py": [
-   "9ac1be00b84eeae73aec8a1facb43b329bae6310",
+   "e478e10b76b0953d854416dffdc7a400087aee95",
    "wdspec"
   ],
   "webdriver/tests/new_session/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/new_session/conftest.py": [
    "bf974ab1c000a1d733664637faf9b39e7303d556",
@@ -646752,33 +646814,33 @@
    "b8ef418e115fcdafa861dcb8f61b01116e9e81f6",
    "wdspec"
   ],
   "webdriver/tests/send_alert_text/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/send_alert_text/send.py": [
-   "9d4532a190c717ad7997a5b9ccb6d8d32a2cb1fc",
+   "edc37d6edb483c232401676f6c11ab7512774605",
    "wdspec"
   ],
   "webdriver/tests/set_timeouts/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/set_timeouts/set.py": [
-   "8dd0344dca561d50df6dd04a0d2507a015649e0c",
+   "e603e217ec7d73bf7bc59f1d2e8687a89c818c47",
    "wdspec"
   ],
   "webdriver/tests/set_window_rect/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/set_window_rect/set.py": [
-   "17210af4f46a25a6f2484ba76a74cd5c54e31d6a",
+   "928fd622efc22f520f4c6a9f783f60ec270146e2",
    "wdspec"
   ],
   "webdriver/tests/set_window_rect/user_prompts.py": [
    "908a9d920f36d0b8664c6b906bc71b0aefba96e6",
    "wdspec"
   ],
   "webdriver/tests/status/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
@@ -646792,21 +646854,21 @@
    "e5e43c4e655170d57d3de7a85d4ebb639c31aee0",
    "support"
   ],
   "webdriver/tests/support/asserts.py": [
    "44c76a96b0997100a0201a5ffafd20e9967758ec",
    "support"
   ],
   "webdriver/tests/support/fixtures.py": [
-   "daeccb70e948b2564f7d78106dbee919b9cd7436",
+   "64427b4670f72c9ea069d0f008d93ad63a9781c0",
    "support"
   ],
   "webdriver/tests/support/http_request.py": [
-   "ae28a6486b1333acc472ab2d37ac3f890249f1a2",
+   "5e46d97017e14ba009d4d1ed6d62bb5012f48d15",
    "support"
   ],
   "webdriver/tests/support/inline.py": [
    "2f8fe9b79e3bacf1fb3bd9bcd981c8d8389fcd08",
    "support"
   ],
   "webdriver/tests/support/merge_dictionaries.py": [
    "cf06c9b433cee167c5c98e06d64cc7a2e68faff3",
@@ -646816,33 +646878,33 @@
    "6f439ec61a372bc1202f226a3b4e3f41509d5f60",
    "support"
   ],
   "webdriver/tests/switch_to_frame/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/switch_to_frame/switch.py": [
-   "403047958665981f5509e370e38897b8a463e2a7",
+   "10948102239df61f0fd35fc157fe31b1a3e2968a",
    "wdspec"
   ],
   "webdriver/tests/switch_to_parent_frame/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/switch_to_parent_frame/switch.py": [
    "6b9c90f0cd83e2c916da989a81ed206618fbaf4a",
    "wdspec"
   ],
   "webdriver/tests/switch_to_window/__init__.py": [
    "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
    "support"
   ],
   "webdriver/tests/switch_to_window/switch.py": [
-   "17f7c4da328822fb342b7e3f510eb6ed007bce3f",
+   "907be66a149e8196c87760544140636d9625bbb9",
    "wdspec"
   ],
   "webgl/META.yml": [
    "8e6b680d91c9b81b85e3ce010c5fb9fe338f37bf",
    "support"
   ],
   "webgl/bufferSubData.html": [
    "a97df9062d6ea964e500059e155b29604edc21b6",
new file mode 100644
new file mode 100644
--- /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)
new file mode 100644
--- /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)
new file mode 100644
new file mode 100644
--- /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
new file mode 100644
--- /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)
--- a/testing/web-platform/tests/webdriver/tests/support/fixtures.py
+++ b/testing/web-platform/tests/webdriver/tests/support/fixtures.py
@@ -289,20 +289,21 @@ def create_dialog(session):
 
 
 def clear_all_cookies(session):
     """Removes all cookies associated with the current active document"""
     session.transport.send("DELETE", "session/%s/cookie" % session.session_id)
 
 
 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)
 
     yield new_handle
 
     session.window_handle = original_handle