Bug 1470098 - [wdspec] Add tests for confirm, and prompt for the Execute (Async) Script commands. draft
authorHenrik Skupin <mail@hskupin.info>
Thu, 05 Jul 2018 13:34:31 +0200
changeset 814482 697db89045e3f61af3236d310d3b4d6b23df1e1b
parent 814481 45292850c03ab9d2af261a03c06f6698c8986830
child 814483 8dd3b325c9d1fddec619d2d662542f6174877816
push id115228
push userbmo:hskupin@gmail.com
push dateThu, 05 Jul 2018 13:36:11 +0000
bugs1470098
milestone63.0a1
Bug 1470098 - [wdspec] Add tests for confirm, and prompt for the Execute (Async) Script commands. MozReview-Commit-ID: 5VNykQGobtx
testing/web-platform/meta/webdriver/tests/execute_async_script/user_prompts.py.ini
testing/web-platform/meta/webdriver/tests/execute_script/user_prompts.py.ini
testing/web-platform/tests/webdriver/tests/execute_async_script/user_prompts.py
testing/web-platform/tests/webdriver/tests/execute_script/user_prompts.py
--- a/testing/web-platform/meta/webdriver/tests/execute_async_script/user_prompts.py.ini
+++ b/testing/web-platform/meta/webdriver/tests/execute_async_script/user_prompts.py.ini
@@ -1,16 +1,41 @@
 [user_prompts.py]
   disabled:
     if webrender: bug 1425588
-  [test_handle_prompt_accept[capabilities0\]]
+  [test_handle_prompt_accept[capabilities0-alert\]]
+    expected: FAIL
+
+  [test_handle_prompt_accept[capabilities0-confirm\]]
+    expected: FAIL
+
+  [test_handle_prompt_accept[capabilities0-prompt\]]
+    expected: FAIL
+
+  [test_handle_prompt_dismiss[capabilities0-alert\]]
     expected: FAIL
 
-  [test_handle_prompt_dismiss[capabilities0\]]
+  [test_handle_prompt_dismiss[capabilities0-confirm\]]
+    expected: FAIL
+
+  [test_handle_prompt_dismiss[capabilities0-prompt\]]
     expected: FAIL
 
-  [test_handle_prompt_ignore[capabilities0\]]
+  [test_handle_prompt_ignore[capabilities0-alert\]]
     expected: FAIL
 
-  [test_handle_prompt_twice[capabilities0\]]
+  [test_handle_prompt_ignore[capabilities0-confirm\]]
+    expected: FAIL
+
+  [test_handle_prompt_ignore[capabilities0-prompt\]]
+    expected: FAIL
+
+  [test_handle_prompt_twice[capabilities0-alert\]]
     expected: FAIL
     disabled: Bug 1459118
 
+  [test_handle_prompt_twice[capabilities0-confirm\]]
+    expected: FAIL
+    disabled: Bug 1459118
+
+  [test_handle_prompt_twice[capabilities0-prompt\]]
+    expected: FAIL
+    disabled: Bug 1459118
--- a/testing/web-platform/meta/webdriver/tests/execute_script/user_prompts.py.ini
+++ b/testing/web-platform/meta/webdriver/tests/execute_script/user_prompts.py.ini
@@ -1,16 +1,41 @@
 [user_prompts.py]
   disabled:
     if webrender: bug 1425588
-  [test_handle_prompt_accept[capabilities0\]]
+  [test_handle_prompt_accept[capabilities0-alert\]]
+    expected: FAIL
+
+  [test_handle_prompt_accept[capabilities0-confirm\]]
+    expected: FAIL
+
+  [test_handle_prompt_accept[capabilities0-prompt\]]
+    expected: FAIL
+
+  [test_handle_prompt_dismiss[capabilities0-alert\]]
     expected: FAIL
 
-  [test_handle_prompt_dismiss[capabilities0\]]
+  [test_handle_prompt_dismiss[capabilities0-confirm\]]
+    expected: FAIL
+
+  [test_handle_prompt_dismiss[capabilities0-prompt\]]
     expected: FAIL
 
-  [test_handle_prompt_ignore[capabilities0\]]
+  [test_handle_prompt_ignore[capabilities0-alert\]]
     expected: FAIL
 
-  [test_handle_prompt_twice[capabilities0\]]
+  [test_handle_prompt_ignore[capabilities0-confirm\]]
+    expected: FAIL
+
+  [test_handle_prompt_ignore[capabilities0-prompt\]]
+    expected: FAIL
+
+  [test_handle_prompt_twice[capabilities0-alert\]]
     expected: FAIL
     disabled: Bug 1459118
 
+  [test_handle_prompt_twice[capabilities0-confirm\]]
+    expected: FAIL
+    disabled: Bug 1459118
+
+  [test_handle_prompt_twice[capabilities0-prompt\]]
+    expected: FAIL
+    disabled: Bug 1459118
--- a/testing/web-platform/tests/webdriver/tests/execute_async_script/user_prompts.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_async_script/user_prompts.py
@@ -13,80 +13,88 @@ def execute_async_script(session, script
     body = {"script": script, "args": args}
 
     return session.transport.send(
         "POST", "/session/{session_id}/execute/async".format(**vars(session)),
         body)
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
-def test_handle_prompt_accept(session):
-    response = execute_async_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_accept(session, dialog_type):
+    response = execute_async_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.accept()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
-def test_handle_prompt_accept_and_notify(session):
-    response = execute_async_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_accept_and_notify(session, dialog_type):
+    response = execute_async_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     with pytest.raises(error.UnexpectedAlertOpenException):
         session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.accept()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
-def test_handle_prompt_dismiss(session):
-    response = execute_async_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_dismiss(session, dialog_type):
+    response = execute_async_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
-def test_handle_prompt_dismiss_and_notify(session):
-    response = execute_async_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_dismiss_and_notify(session, dialog_type):
+    response = execute_async_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     with pytest.raises(error.UnexpectedAlertOpenException):
         session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
-def test_handle_prompt_ignore(session):
-    response = execute_async_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_ignore(session, dialog_type):
+    response = execute_async_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     with pytest.raises(error.UnexpectedAlertOpenException):
         session.title
     session.alert.dismiss()
 
 
-def test_handle_prompt_default(session):
-    response = execute_async_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_default(session, dialog_type):
+    response = execute_async_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     with pytest.raises(error.UnexpectedAlertOpenException):
         session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
-def test_handle_prompt_twice(session):
-    response = execute_async_script(session, "window.alert('Hello');window.alert('Bye');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_twice(session, dialog_type):
+    response = execute_async_script(
+        session, "window.{0}('Hello');window.{0}('Bye');".format(dialog_type))
     assert_success(response, None)
 
     session.alert.dismiss()
     # The first alert has been accepted by the user prompt handler, the second one remains.
     # FIXME: this is how browsers currently work, but the spec should clarify if this is the
     #        expected behavior, see https://github.com/w3c/webdriver/issues/1153.
     assert session.alert.text == "Bye"
     session.alert.dismiss()
--- a/testing/web-platform/tests/webdriver/tests/execute_script/user_prompts.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_script/user_prompts.py
@@ -14,80 +14,88 @@ def execute_script(session, script, args
 
     return session.transport.send(
         "POST", "/session/{session_id}/execute/sync".format(
             session_id=session.session_id),
         body)
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
-def test_handle_prompt_accept(session):
-    response = execute_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_accept(session, dialog_type):
+    response = execute_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.accept()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
-def test_handle_prompt_accept_and_notify(session):
-    response = execute_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_accept_and_notify(session, dialog_type):
+    response = execute_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     with pytest.raises(error.UnexpectedAlertOpenException):
         session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.accept()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
-def test_handle_prompt_dismiss(session):
-    response = execute_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_dismiss(session, dialog_type):
+    response = execute_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
-def test_handle_prompt_dismiss_and_notify(session):
-    response = execute_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_dismiss_and_notify(session, dialog_type):
+    response = execute_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     with pytest.raises(error.UnexpectedAlertOpenException):
         session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
-def test_handle_prompt_ignore(session):
-    response = execute_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_ignore(session, dialog_type):
+    response = execute_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     with pytest.raises(error.UnexpectedAlertOpenException):
         session.title
     session.alert.dismiss()
 
 
-def test_handle_prompt_default(session):
-    response = execute_script(session, "window.alert('Hello');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_default(session, dialog_type):
+    response = execute_script(session, "window.{}('Hello');".format(dialog_type))
     assert_success(response, None)
 
     with pytest.raises(error.UnexpectedAlertOpenException):
         session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 @pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
-def test_handle_prompt_twice(session):
-    response = execute_script(session, "window.alert('Hello');window.alert('Bye');")
+@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
+def test_handle_prompt_twice(session, dialog_type):
+    response = execute_script(
+        session, "window.{0}('Hello');window.{0}('Bye');".format(dialog_type))
     assert_success(response, None)
 
     session.alert.dismiss()
     # The first alert has been accepted by the user prompt handler, the second one remains.
     # FIXME: this is how browsers currently work, but the spec should clarify if this is the
     #        expected behavior, see https://github.com/w3c/webdriver/issues/1153.
     assert session.alert.text == "Bye"
     session.alert.dismiss()