Bug 1455282 - [wdspec] Add tests for Close Window command. r=ato
authorHenrik Skupin <mail@hskupin.info>
Fri, 20 Apr 2018 10:50:14 +0200
changeset 468798 2ec2ee71cc277daf81db6ae6bb21db9495c229b3
parent 468797 90908c3a6f9ede9a0c541dedecbd74a4a34807e3
child 468799 1513e4d8668757d4be6bb4b81ed4e167c028a54d
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1455282
milestone61.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 1455282 - [wdspec] Add tests for Close Window command. r=ato MozReview-Commit-ID: 13j69lZhr1G
testing/web-platform/meta/MANIFEST.json
testing/web-platform/meta/webdriver/tests/close_window/user_prompts.py.ini
testing/web-platform/tests/webdriver/tests/close_window/close.py
testing/web-platform/tests/webdriver/tests/close_window/user_prompts.py
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -393704,16 +393704,28 @@
    "webdriver/tests/actions/special_keys.py": [
     [
      "/webdriver/tests/actions/special_keys.py",
      {
       "timeout": "long"
      }
     ]
    ],
+   "webdriver/tests/close_window/close.py": [
+    [
+     "/webdriver/tests/close_window/close.py",
+     {}
+    ]
+   ],
+   "webdriver/tests/close_window/user_prompts.py": [
+    [
+     "/webdriver/tests/close_window/user_prompts.py",
+     {}
+    ]
+   ],
    "webdriver/tests/contexts/json_serialize_windowproxy.py": [
     [
      "/webdriver/tests/contexts/json_serialize_windowproxy.py",
      {
       "timeout": "long"
      }
     ]
    ],
@@ -606307,16 +606319,24 @@
   "webdriver/tests/actions/support/refine.py": [
    "0d244bffe67ef57be68aad99f1cbc7440ff80e27",
    "support"
   ],
   "webdriver/tests/actions/support/test_actions_wdspec.html": [
    "95203777fcc012ab64465287737a89a4ba2c31dc",
    "support"
   ],
+  "webdriver/tests/close_window/close.py": [
+   "4138394adbccb06712b22a2f982e8638aa03629a",
+   "wdspec"
+  ],
+  "webdriver/tests/close_window/user_prompts.py": [
+   "6151fb105fafcfb462a580fc725b207eae725f6c",
+   "wdspec"
+  ],
   "webdriver/tests/conftest.py": [
    "c812269d034c9ca1b8c4f136dd5d0cea52f4d0f0",
    "support"
   ],
   "webdriver/tests/contexts/json_serialize_windowproxy.py": [
    "d29c82c48b3bd1e2b07c40798a774eb77d6178a5",
    "wdspec"
   ],
@@ -606540,17 +606560,17 @@
    "5a31a3917a5157516c10951a3b3d5ffb43b992d9",
    "support"
   ],
   "webdriver/tests/support/asserts.py": [
    "1b839404daaca1d059cba98377edb91691ef7e82",
    "support"
   ],
   "webdriver/tests/support/fixtures.py": [
-   "e787c0ef06fcdfc86f337be5af61e492be08ec9c",
+   "126e82c42568c9ecb240e735a2b1361882ecd9ba",
    "support"
   ],
   "webdriver/tests/support/http_request.py": [
    "cb40c781fea2280b98135522def5e6a116d7b946",
    "support"
   ],
   "webdriver/tests/support/inline.py": [
    "ffabd6a12d6e7928176fa00702214e0c8e0a25d7",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/webdriver/tests/close_window/user_prompts.py.ini
@@ -0,0 +1,3 @@
+[user_prompts.py]
+  [test_handle_prompt_accept]
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webdriver/tests/close_window/close.py
@@ -0,0 +1,38 @@
+from tests.support.asserts import assert_error, assert_success
+
+
+def close(session):
+    return session.transport.send("DELETE", "session/%s/window" % session.session_id)
+
+
+def test_no_browsing_context(session, create_window):
+    new_handle = create_window()
+
+    session.window_handle = new_handle
+    session.close()
+    assert new_handle not in session.handles
+
+    response = close(session)
+    assert_error(response, "no such window")
+
+
+def test_close_browsing_context(session, create_window):
+    handles = session.handles
+
+    new_handle = create_window()
+    session.window_handle = new_handle
+
+    response = close(session)
+    value = assert_success(response, handles)
+    assert session.handles == handles
+    assert new_handle not in value
+
+
+def test_close_last_browsing_context(session):
+    assert len(session.handles) == 1
+    response = close(session)
+
+    assert_success(response, [])
+
+    # With no more open top-level browsing contexts, the session is closed.
+    session.session_id = None
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webdriver/tests/close_window/user_prompts.py
@@ -0,0 +1,66 @@
+from tests.support.asserts import assert_error, assert_dialog_handled
+from tests.support.fixtures import create_dialog, create_window
+from tests.support.inline import inline
+
+
+def close(session):
+    return session.transport.send("DELETE", "session/%s/window" % session.session_id)
+
+
+def test_handle_prompt_dismiss_and_notify():
+    """TODO"""
+
+
+def test_handle_prompt_accept_and_notify():
+    """TODO"""
+
+
+def test_handle_prompt_ignore():
+    """TODO"""
+
+
+def test_handle_prompt_accept(new_session, add_browser_capabilites):
+    _, session = new_session({"capabilities": {
+        "alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
+    session.window_handle = create_window(session)()
+
+    session.url = inline("<title>WD doc title</title>")
+
+    create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
+    response = close(session)
+    assert response.status == 200
+    assert_dialog_handled(session, "dismiss #1")
+
+    create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
+    response = close(session)
+    assert response.status == 200
+    assert_dialog_handled(session, "dismiss #2")
+
+    create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
+    response = close(session)
+    assert response.status == 200
+    assert_dialog_handled(session, "dismiss #3")
+
+
+def test_handle_prompt_missing_value(session, create_dialog, create_window):
+    session.window_handle = create_window()
+
+    session.url = inline("<title>WD doc title</title>")
+    create_dialog("alert", text="dismiss #1", result_var="dismiss1")
+
+    response = close(session)
+
+    assert_error(response, "unexpected alert open")
+    assert_dialog_handled(session, "dismiss #1")
+
+    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")
+
+    response = close(session)
+    assert_error(response, "unexpected alert open")
+    assert_dialog_handled(session, "dismiss #2")
+
+    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")
+
+    response = close(session)
+    assert_error(response, "unexpected alert open")
+    assert_dialog_handled(session, "dismiss #3")