Bug 1405018 - Move Get Active Element test to the tests directory. r=maja_zf
authorAndreas Tolfsen <ato@sny.no>
Mon, 02 Oct 2017 18:45:49 +0100
changeset 432426 fdcd4aa54eae
parent 432425 9a1314063088
child 432427 e287f4cad6d4
push id7953
push userryanvm@gmail.com
push dateThu, 12 Oct 2017 14:05:58 +0000
treeherdermozilla-beta@f4ba99b41183 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1405018
milestone57.0
Bug 1405018 - Move Get Active Element test to the tests directory. r=maja_zf MozReview-Commit-ID: KoblLlmFein
testing/web-platform/meta/MANIFEST.json
testing/web-platform/meta/webdriver/elements/active.py.ini
testing/web-platform/meta/webdriver/tests/element_retrieval/get_active_element.py.ini
testing/web-platform/tests/webdriver/elements/active.py
testing/web-platform/tests/webdriver/tests/element_retrieval/get_active_element.py
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -407151,22 +407151,16 @@
    "css/vendor-imports/mozilla/mozilla-central-reftests/text3/text-align-match-parent-01.html": [
     [
      "/css/vendor-imports/mozilla/mozilla-central-reftests/text3/text-align-match-parent-01.html",
      {}
     ]
    ]
   },
   "wdspec": {
-   "webdriver/elements/active.py": [
-    [
-     "/webdriver/elements/active.py",
-     {}
-    ]
-   ],
    "webdriver/tests/actions/key.py": [
     [
      "/webdriver/tests/actions/key.py",
      {}
     ]
    ],
    "webdriver/tests/actions/mouse.py": [
     [
@@ -407217,16 +407211,22 @@
     ]
    ],
    "webdriver/tests/element_click/select.py": [
     [
      "/webdriver/tests/element_click/select.py",
      {}
     ]
    ],
+   "webdriver/tests/element_retrieval/get_active_element.py": [
+    [
+     "/webdriver/tests/element_retrieval/get_active_element.py",
+     {}
+    ]
+   ],
    "webdriver/tests/fullscreen_window.py": [
     [
      "/webdriver/tests/fullscreen_window.py",
      {
       "timeout": "long"
      }
     ]
    ],
@@ -628398,20 +628398,16 @@
   "webdriver/OWNERS": [
    "cbfd094d14a2be6678df83a7bcd8b022922396dd",
    "support"
   ],
   "webdriver/README.md": [
    "185acb69e9516e0564e16bf7d7f8dc2a4c48d3c7",
    "support"
   ],
-  "webdriver/elements/active.py": [
-   "40ac5fcc5db4d489a802f58bb03dfc78563eafa0",
-   "wdspec"
-  ],
   "webdriver/tests/__init__.py": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
   "webdriver/tests/actions/__init__.py": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
@@ -628474,16 +628470,20 @@
   "webdriver/tests/element_click/__init__.py": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
   "webdriver/tests/element_click/select.py": [
    "5ba51b660c7203bba3ada597c2f56fe094358e1f",
    "wdspec"
   ],
+  "webdriver/tests/element_retrieval/get_active_element.py": [
+   "9080770b60a988cb37e30700efb118d392a896c7",
+   "wdspec"
+  ],
   "webdriver/tests/fullscreen_window.py": [
    "6b1e481aac6856b6e858df17731d037997b99f83",
    "wdspec"
   ],
   "webdriver/tests/get_window_rect.py": [
    "45770411dd6f6468aaf1d59d7f6fe2db63aad79a",
    "wdspec"
   ],
deleted file mode 100644
--- a/testing/web-platform/meta/webdriver/elements/active.py.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[active.py]
-  type: wdspec
-  [active.py::test_handle_prompt_dismiss]
-    expected: FAIL
-
-  [active.py::test_handle_prompt_accept]
-    expected: FAIL
-
-  [active.py::test_handle_prompt_missing_value]
-    expected: FAIL
-
-  [active.py::test_sucess_without_body]
-    expected: FAIL
-
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/webdriver/tests/element_retrieval/get_active_element.py.ini
@@ -0,0 +1,13 @@
+[get_active_element.py]
+  type: wdspec
+  [get_active_element.py::test_handle_prompt_dismiss]
+    expected: FAIL
+
+  [get_active_element.py::test_handle_prompt_accept]
+    expected: FAIL
+
+  [get_active_element.py::test_handle_prompt_missing_value]
+    expected: FAIL
+
+  [get_active_element.py::test_sucess_without_body]
+    expected: FAIL
deleted file mode 100644
--- a/testing/web-platform/tests/webdriver/elements/active.py
+++ /dev/null
@@ -1,252 +0,0 @@
-import pytest
-
-from support.asserts import assert_error, assert_success, assert_dialog_handled, assert_same_element
-from support.fixtures import create_dialog
-from support.inline import inline
-
-def assert_result_is_active_element(session, result):
-    """Ensure that the provided object is a successful WebDriver response
-    describing an element reference and that the referenced element matches the
-    element returned by the `activeElement` attribute of the current browsing
-    context's active document."""
-    assert result.status == 200
-
-    from_js = session.execute_script("return document.activeElement;")
-
-    if result.body["value"] is None:
-        assert from_js == None
-    else:
-        assert_same_element(session, result.body["value"], from_js)
-
-# > 1. If the current browsing context is no longer open, return error with
-# >    error code no such window.
-def test_closed_context(session, create_window):
-    new_window = create_window()
-    session.window_handle = new_window
-    session.close()
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_error(result, "no such window")
-
-# [...]
-# 2. Handle any user prompts and return its value if it is an error.
-# [...]
-# In order to handle any user prompts a remote end must take the following
-# steps:
-# 2. Run the substeps of the first matching user prompt handler:
-#
-#    [...]
-#    - dismiss state
-#      1. Dismiss the current user prompt.
-#    [...]
-#
-# 3. Return success.
-def test_handle_prompt_dismiss(new_session):
-    _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
-    session.url = inline("<body><p>Hello, World!</p></body>")
-
-    create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-    assert_dialog_handled(session, "dismiss #1")
-    assert session.execute_script("return dismiss1;") == None
-
-    create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-    assert_dialog_handled(session, "dismiss #2")
-    assert read_global(session, "dismiss2") == None
-
-    create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-    assert_dialog_handled(session, "dismiss #3")
-    assert read_global(session, "dismiss3") == None
-
-# [...]
-# 2. Handle any user prompts and return its value if it is an error.
-# [...]
-# In order to handle any user prompts a remote end must take the following
-# steps:
-# 2. Run the substeps of the first matching user prompt handler:
-#
-#    [...]
-#    - accept state
-#      1. Accept the current user prompt.
-#    [...]
-#
-# 3. Return success.
-def test_handle_prompt_accept(new_session):
-    _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
-    session.url = inline("<body><p>Hello, World!</p></body>")
-    create_dialog(session)("alert", text="accept #1", result_var="accept1")
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-    assert_dialog_handled(session, "accept #1")
-    assert read_global(session, "accept1") == None
-
-    create_dialog(session)("confirm", text="accept #2", result_var="accept2")
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-    assert_dialog_handled(session, "accept #2")
-    assert read_global(session, "accept2"), True
-
-    create_dialog(session)("prompt", text="accept #3", result_var="accept3")
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-    assert_dialog_handled(session, "accept #3")
-    assert read_global(session, "accept3") == ""
-
-# [...]
-# 2. Handle any user prompts and return its value if it is an error.
-# [...]
-# In order to handle any user prompts a remote end must take the following
-# steps:
-# 2. Run the substeps of the first matching user prompt handler:
-#
-#    [...]
-#    - missing value default state
-#    - not in the table of simple dialogs
-#      1. Dismiss the current user prompt.
-#      2. Return error with error code unexpected alert open.
-def test_handle_prompt_missing_value(session, create_dialog):
-    session.url = inline("<body><p>Hello, World!</p></body>")
-
-    create_dialog("alert", text="dismiss #1", result_var="dismiss1")
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_error(result, "unexpected alert open")
-    assert_dialog_handled(session, "dismiss #1")
-    assert session.execute_script("return accept1;") == None
-
-    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_error(result, "unexpected alert open")
-    assert_dialog_handled(session, "dismiss #2")
-    assert session.execute_script("return dismiss2;") == False
-
-    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")
-
-    result = session.transport.send("GET",
-                                    "session/%s/element/active" % session.session_id)
-
-    assert_error(result, "unexpected alert open")
-    assert_dialog_handled(session, "dismiss #3")
-    assert session.execute_script("return dismiss3;") == None
-
-# > [...]
-# > 3. Let active element be the active element of the current browsing
-# >    context's document element.
-# > 4. Let active web element be the JSON Serialization of active element.
-# > 5. Return success with data active web element.
-def test_success_document(session):
-    session.url = inline("""
-        <body>
-            <h1>Heading</h1>
-            <input />
-            <input />
-            <input style="opacity: 0;" />
-            <p>Another element</p>
-        </body>""")
-    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-
-def test_sucess_input(session):
-    session.url = inline("""
-        <body>
-            <h1>Heading</h1>
-            <input autofocus />
-            <input style="opacity: 0;" />
-            <p>Another element</p>
-        </body>""")
-    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-
-def test_sucess_input_non_interactable(session):
-    session.url = inline("""
-        <body>
-            <h1>Heading</h1>
-            <input />
-            <input style="opacity: 0;" autofocus />
-            <p>Another element</p>
-        </body>""")
-    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-
-def test_success_explicit_focus(session):
-    session.url = inline("""
-        <body>
-            <h1>Heading</h1>
-            <input />
-            <iframe></iframe>
-        </body>""")
-
-    session.execute_script("document.body.getElementsByTagName('h1')[0].focus();")
-    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
-    assert_result_is_active_element(session, result)
-
-    session.execute_script("document.body.getElementsByTagName('input')[0].focus();")
-    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
-    assert_result_is_active_element(session, result)
-
-    session.execute_script("document.body.getElementsByTagName('iframe')[0].focus();")
-    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
-    assert_result_is_active_element(session, result)
-
-    session.execute_script("document.body.getElementsByTagName('iframe')[0].focus();")
-    session.execute_script("document.body.getElementsByTagName('iframe')[0].remove();")
-    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
-    assert_result_is_active_element(session, result)
-
-    session.execute_script("document.body.appendChild(document.createElement('textarea'));")
-    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
-    assert_result_is_active_element(session, result)
-
-def test_success_iframe_content(session):
-    session.url = inline("<body></body>")
-    session.execute_script("""
-        var iframe = document.createElement('iframe');
-        document.body.appendChild(iframe);
-        var input = iframe.contentDocument.createElement('input');
-        iframe.contentDocument.body.appendChild(input);
-        input.focus();""")
-
-    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
-
-    assert_result_is_active_element(session, result)
-
-def test_sucess_without_body(session):
-    session.url = inline("<body></body>")
-    session.execute_script("document.body.remove();")
-
-    result = session.transport.send("GET", "session/%s/element/active"% session.session_id)
-
-    assert_result_is_active_element(session, result)
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webdriver/tests/element_retrieval/get_active_element.py
@@ -0,0 +1,252 @@
+import pytest
+
+from tests.support.asserts import assert_error, assert_success, assert_dialog_handled, assert_same_element
+from tests.support.fixtures import create_dialog
+from tests.support.inline import inline
+
+def assert_result_is_active_element(session, result):
+    """Ensure that the provided object is a successful WebDriver response
+    describing an element reference and that the referenced element matches the
+    element returned by the `activeElement` attribute of the current browsing
+    context's active document."""
+    assert result.status == 200
+
+    from_js = session.execute_script("return document.activeElement;")
+
+    if result.body["value"] is None:
+        assert from_js == None
+    else:
+        assert_same_element(session, result.body["value"], from_js)
+
+# > 1. If the current browsing context is no longer open, return error with
+# >    error code no such window.
+def test_closed_context(session, create_window):
+    new_window = create_window()
+    session.window_handle = new_window
+    session.close()
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_error(result, "no such window")
+
+# [...]
+# 2. Handle any user prompts and return its value if it is an error.
+# [...]
+# In order to handle any user prompts a remote end must take the following
+# steps:
+# 2. Run the substeps of the first matching user prompt handler:
+#
+#    [...]
+#    - dismiss state
+#      1. Dismiss the current user prompt.
+#    [...]
+#
+# 3. Return success.
+def test_handle_prompt_dismiss(new_session):
+    _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
+    session.url = inline("<body><p>Hello, World!</p></body>")
+
+    create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+    assert_dialog_handled(session, "dismiss #1")
+    assert session.execute_script("return dismiss1;") == None
+
+    create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+    assert_dialog_handled(session, "dismiss #2")
+    assert read_global(session, "dismiss2") == None
+
+    create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+    assert_dialog_handled(session, "dismiss #3")
+    assert read_global(session, "dismiss3") == None
+
+# [...]
+# 2. Handle any user prompts and return its value if it is an error.
+# [...]
+# In order to handle any user prompts a remote end must take the following
+# steps:
+# 2. Run the substeps of the first matching user prompt handler:
+#
+#    [...]
+#    - accept state
+#      1. Accept the current user prompt.
+#    [...]
+#
+# 3. Return success.
+def test_handle_prompt_accept(new_session):
+    _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
+    session.url = inline("<body><p>Hello, World!</p></body>")
+    create_dialog(session)("alert", text="accept #1", result_var="accept1")
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+    assert_dialog_handled(session, "accept #1")
+    assert read_global(session, "accept1") == None
+
+    create_dialog(session)("confirm", text="accept #2", result_var="accept2")
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+    assert_dialog_handled(session, "accept #2")
+    assert read_global(session, "accept2"), True
+
+    create_dialog(session)("prompt", text="accept #3", result_var="accept3")
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+    assert_dialog_handled(session, "accept #3")
+    assert read_global(session, "accept3") == ""
+
+# [...]
+# 2. Handle any user prompts and return its value if it is an error.
+# [...]
+# In order to handle any user prompts a remote end must take the following
+# steps:
+# 2. Run the substeps of the first matching user prompt handler:
+#
+#    [...]
+#    - missing value default state
+#    - not in the table of simple dialogs
+#      1. Dismiss the current user prompt.
+#      2. Return error with error code unexpected alert open.
+def test_handle_prompt_missing_value(session, create_dialog):
+    session.url = inline("<body><p>Hello, World!</p></body>")
+
+    create_dialog("alert", text="dismiss #1", result_var="dismiss1")
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_error(result, "unexpected alert open")
+    assert_dialog_handled(session, "dismiss #1")
+    assert session.execute_script("return accept1;") == None
+
+    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_error(result, "unexpected alert open")
+    assert_dialog_handled(session, "dismiss #2")
+    assert session.execute_script("return dismiss2;") == False
+
+    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")
+
+    result = session.transport.send("GET",
+                                    "session/%s/element/active" % session.session_id)
+
+    assert_error(result, "unexpected alert open")
+    assert_dialog_handled(session, "dismiss #3")
+    assert session.execute_script("return dismiss3;") == None
+
+# > [...]
+# > 3. Let active element be the active element of the current browsing
+# >    context's document element.
+# > 4. Let active web element be the JSON Serialization of active element.
+# > 5. Return success with data active web element.
+def test_success_document(session):
+    session.url = inline("""
+        <body>
+            <h1>Heading</h1>
+            <input />
+            <input />
+            <input style="opacity: 0;" />
+            <p>Another element</p>
+        </body>""")
+    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+
+def test_sucess_input(session):
+    session.url = inline("""
+        <body>
+            <h1>Heading</h1>
+            <input autofocus />
+            <input style="opacity: 0;" />
+            <p>Another element</p>
+        </body>""")
+    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+
+def test_sucess_input_non_interactable(session):
+    session.url = inline("""
+        <body>
+            <h1>Heading</h1>
+            <input />
+            <input style="opacity: 0;" autofocus />
+            <p>Another element</p>
+        </body>""")
+    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+
+def test_success_explicit_focus(session):
+    session.url = inline("""
+        <body>
+            <h1>Heading</h1>
+            <input />
+            <iframe></iframe>
+        </body>""")
+
+    session.execute_script("document.body.getElementsByTagName('h1')[0].focus();")
+    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
+    assert_result_is_active_element(session, result)
+
+    session.execute_script("document.body.getElementsByTagName('input')[0].focus();")
+    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
+    assert_result_is_active_element(session, result)
+
+    session.execute_script("document.body.getElementsByTagName('iframe')[0].focus();")
+    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
+    assert_result_is_active_element(session, result)
+
+    session.execute_script("document.body.getElementsByTagName('iframe')[0].focus();")
+    session.execute_script("document.body.getElementsByTagName('iframe')[0].remove();")
+    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
+    assert_result_is_active_element(session, result)
+
+    session.execute_script("document.body.appendChild(document.createElement('textarea'));")
+    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
+    assert_result_is_active_element(session, result)
+
+def test_success_iframe_content(session):
+    session.url = inline("<body></body>")
+    session.execute_script("""
+        var iframe = document.createElement('iframe');
+        document.body.appendChild(iframe);
+        var input = iframe.contentDocument.createElement('input');
+        iframe.contentDocument.body.appendChild(input);
+        input.focus();""")
+
+    result = session.transport.send("GET", "session/%s/element/active" % session.session_id)
+
+    assert_result_is_active_element(session, result)
+
+def test_sucess_without_body(session):
+    session.url = inline("<body></body>")
+    session.execute_script("document.body.remove();")
+
+    result = session.transport.send("GET", "session/%s/element/active"% session.session_id)
+
+    assert_result_is_active_element(session, result)