Bug 1410796 - Test element retrieval from XHTML namespace. r=maja_zf
authorAndreas Tolfsen <ato@sny.no>
Tue, 31 Oct 2017 20:01:53 +0000
changeset 440370 3617d7a46b5806cd5c498686e7a57e41e2fc1795
parent 440369 cefff31e8739bf321fc366470c7583f2973b9e43
child 440371 c34d538776d5d0c23f816b00646ed9c031156b8c
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1410796
milestone58.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 1410796 - Test element retrieval from XHTML namespace. r=maja_zf Finding elements in the XHTML namespace will fail unless element.isDOMElement is fixed so that it does not look at a particular namespaceURI. It is worth noting that, generally, the WPT element retrieval tests are pretty awful and the new tests don't exactly match the style of the preceding tests. This intended, because the other tests are bad. This should be addessed individually. MozReview-Commit-ID: 8I3VwhJirSb
testing/web-platform/tests/webdriver/tests/retrieval/find_element.py
testing/web-platform/tests/webdriver/tests/retrieval/find_element_from_element.py
testing/web-platform/tests/webdriver/tests/retrieval/find_element_from_elements.py
testing/web-platform/tests/webdriver/tests/retrieval/find_elements.py
--- a/testing/web-platform/tests/webdriver/tests/retrieval/find_element.py
+++ b/testing/web-platform/tests/webdriver/tests/retrieval/find_element.py
@@ -1,12 +1,11 @@
 import pytest
 
-
-from tests.support.asserts import assert_error, assert_success
+from tests.support.asserts import assert_error, assert_same_element, assert_success
 from tests.support.inline import inline
 
 
 def find_element(session, using, value):
     return session.transport.send("POST",
                                   "session/%s/element" % session.session_id,
                                   {"using": using, "value": value})
 
@@ -52,8 +51,23 @@ def test_find_element(session, using, va
     assert_success(response)
 
 
 @pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
 def test_no_element(session, using, value):
     # Step 8 - 9
     response = find_element(session, using, value)
     assert_error(response, "no such element")
+
+
+@pytest.mark.parametrize("using,value",
+                         [("css selector", "#linkText"),
+                          ("link text", "full link text"),
+                          ("partial link text", "link text"),
+                          ("tag name", "a"),
+                          ("xpath", "//*[name()='a']")])
+def test_xhtml_namespace(session, using, value):
+    session.url = inline("""<a href="#" id="linkText">full link text</a>""", doctype="xhtml")
+    expected = session.execute_script("return document.links[0]")
+
+    response = find_element(session, using, value)
+    value = assert_success(response)
+    assert_same_element(session, value, expected)
--- a/testing/web-platform/tests/webdriver/tests/retrieval/find_element_from_element.py
+++ b/testing/web-platform/tests/webdriver/tests/retrieval/find_element_from_element.py
@@ -1,12 +1,11 @@
 import pytest
 
-
-from tests.support.asserts import assert_error, assert_success
+from tests.support.asserts import assert_error, assert_same_element, assert_success
 from tests.support.inline import inline
 
 
 def find_element(session, element, using, value):
     return session.transport.send("POST",
                                   "session/%s/element/%s/element" % (session.session_id, element),
                                   {"using": using, "value": value})
 
@@ -52,8 +51,24 @@ def test_find_element(session, using, va
 
 @pytest.mark.parametrize("using,value",[("css selector", "#wontExist")])
 def test_no_element(session, using, value):
     # Step 8 - 9
     session.url = inline("<div></div>")
     element = session.find.css("div", all=False)
     response = find_element(session, element.id, using, value)
     assert_error(response, "no such element")
+
+
+@pytest.mark.parametrize("using,value",
+                         [("css selector", "#linkText"),
+                          ("link text", "full link text"),
+                          ("partial link text", "link text"),
+                          ("tag name", "a"),
+                          ("xpath", "//*[name()='a']")])
+def test_xhtml_namespace(session, using, value):
+    session.url = inline("""<p><a href="#" id="linkText">full link text</a></p>""", doctype="xhtml")
+    from_element = session.execute_script("""return document.querySelector("p")""")
+    expected = session.execute_script("return document.links[0]")
+
+    response = find_element(session, from_element.id, using, value)
+    value = assert_success(response)
+    assert_same_element(session, value, expected)
--- a/testing/web-platform/tests/webdriver/tests/retrieval/find_element_from_elements.py
+++ b/testing/web-platform/tests/webdriver/tests/retrieval/find_element_from_elements.py
@@ -1,12 +1,11 @@
 import pytest
 
-
-from tests.support.asserts import assert_error, assert_success
+from tests.support.asserts import assert_error, assert_same_element, assert_success
 from tests.support.inline import inline
 
 
 def find_elements(session, element, using, value):
     return session.transport.send("POST",
                                   "session/%s/element/%s/elements" % (session.session_id, element),
                                   {"using": using, "value": value})
 
@@ -51,8 +50,28 @@ def test_find_elements(session, using, v
 
 @pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
 def test_no_element(session, using, value):
     # Step 8 - 9
     session.url = inline("<div></div>")
     element = session.find.css("div", all=False)
     response = find_elements(session, element.id, using, value)
     assert response.body["value"] == []
+
+
+@pytest.mark.parametrize("using,value",
+                         [("css selector", "#linkText"),
+                          ("link text", "full link text"),
+                          ("partial link text", "link text"),
+                          ("tag name", "a"),
+                          ("xpath", "//*[name()='a']")])
+def test_xhtml_namespace(session, using, value):
+    session.url = inline("""<p><a href="#" id="linkText">full link text</a></p>""", doctype="xhtml")
+    from_element = session.execute_script("""return document.querySelector("p")""")
+    expected = session.execute_script("return document.links[0]")
+
+    response = find_elements(session, from_element.id, using, value)
+    value = assert_success(response)
+    assert isinstance(value, list)
+    assert len(value) == 1
+
+    found_element = value[0]
+    assert_same_element(session, found_element, expected)
--- a/testing/web-platform/tests/webdriver/tests/retrieval/find_elements.py
+++ b/testing/web-platform/tests/webdriver/tests/retrieval/find_elements.py
@@ -1,11 +1,11 @@
 import pytest
 
-from tests.support.asserts import assert_error, assert_success
+from tests.support.asserts import assert_error, assert_same_element, assert_success
 from tests.support.inline import inline
 
 
 def find_elements(session, using, value):
     return session.transport.send("POST",
                                   "session/%s/elements" % session.session_id,
                                   {"using": using, "value": value})
 
@@ -53,8 +53,27 @@ def test_find_elements(session, using, v
 
 
 @pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
 def test_no_element(session, using, value):
     # Step 8 - 9
     response = find_elements(session, using, value)
     assert_success(response)
     assert response.body["value"] == []
+
+
+@pytest.mark.parametrize("using,value",
+                         [("css selector", "#linkText"),
+                          ("link text", "full link text"),
+                          ("partial link text", "link text"),
+                          ("tag name", "a"),
+                          ("xpath", "//*[name()='a']")])
+def test_xhtml_namespace(session, using, value):
+    session.url = inline("""<p><a href="#" id="linkText">full link text</a></p>""", doctype="xhtml")
+    expected = session.execute_script("return document.links[0]")
+
+    response = find_elements(session, using, value)
+    value = assert_success(response)
+    assert isinstance(value, list)
+    assert len(value) == 1
+
+    found_element = value[0]
+    assert_same_element(session, found_element, expected)