--- a/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
@@ -118,16 +118,73 @@ class TestLegacyClick(MarionetteTestCase
self.assertEqual(self.marionette.title, "Marionette Test")
def test_scroll_into_view_near_end(self):
self.marionette.navigate(fixed_overlay)
link = self.marionette.find_element(By.TAG_NAME, "a")
link.click()
self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
+ def test_inclusive_descendant(self):
+ self.marionette.navigate(inline("""
+ <select multiple>
+ <option>first
+ <option>second
+ <option>third
+ </select>"""))
+ select = self.marionette.find_element(By.TAG_NAME, "select")
+
+ # This tests that the pointer-interactability test does not
+ # cause an ElementClickInterceptedException.
+ #
+ # At a <select multiple>'s in-view centre point, you might
+ # find a fully rendered <option>. Marionette should test that
+ # the paint tree at this point _contains_ <option>, not that the
+ # first element of the paint tree is _equal_ to <select>.
+ select.click()
+ self.assertNotEqual(select.get_property("selectedIndex"), -1)
+
+ def test_container_is_select(self):
+ self.marionette.navigate(inline("""
+ <select>
+ <option>foo</option>
+ </select>"""))
+ option = self.marionette.find_element(By.TAG_NAME, "option")
+ option.click()
+ self.assertTrue(option.get_property("selected"))
+
+ def test_container_is_button(self):
+ self.marionette.navigate(inline("""
+ <button onclick="window.clicked = true;">
+ <span><em>foo</em></span>
+ </button>"""))
+ span = self.marionette.find_element(By.TAG_NAME, "span")
+ span.click()
+ self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
+
+ def test_container_element_outside_view(self):
+ self.marionette.navigate(inline("""
+ <select style="margin-top: 100vh">
+ <option>foo</option>
+ </select>"""))
+ option = self.marionette.find_element(By.TAG_NAME, "option")
+ option.click()
+ self.assertTrue(option.get_property("selected"))
+
+ def test_table_tr(self):
+ self.marionette.navigate(inline("""
+ <table>
+ <tr><td onclick="window.clicked = true;">
+ foo
+ </td></tr>
+ </table>"""))
+ tr = self.marionette.find_element(By.TAG_NAME, "tr")
+ tr.click()
+ self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
+
class TestClick(TestLegacyClick):
"""Uses WebDriver specification compatible element interactability
checks.
"""
def setUp(self):
TestLegacyClick.setUp(self)
@@ -154,19 +211,20 @@ class TestClick(TestLegacyClick):
width: 200px;
height: 200px;
/* move centre point off viewport vertically */
top: -105px;
}
</style>
- <div></div>"""))
+ <div onclick="window.clicked = true;"></div>"""))
self.marionette.find_element(By.TAG_NAME, "div").click()
+ self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
def test_centre_outside_viewport_horizontally(self):
self.marionette.navigate(inline("""
<style>
* { margin: 0; padding: 0; }
div {
display: block;
position: absolute;
@@ -174,19 +232,20 @@ class TestClick(TestLegacyClick):
width: 200px;
height: 200px;
/* move centre point off viewport horizontally */
left: -105px;
}
</style>
- <div></div>"""))
+ <div onclick="window.clicked = true;"></div>"""))
self.marionette.find_element(By.TAG_NAME, "div").click()
+ self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
def test_centre_outside_viewport(self):
self.marionette.navigate(inline("""
<style>
* { margin: 0; padding: 0; }
div {
display: block;
position: absolute;
@@ -195,81 +254,45 @@ class TestClick(TestLegacyClick):
height: 200px;
/* move centre point off viewport */
left: -105px;
top: -105px;
}
</style>
- <div></div>"""))
+ <div onclick="window.clicked = true;"></div>"""))
self.marionette.find_element(By.TAG_NAME, "div").click()
+ self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
def test_css_transforms(self):
self.marionette.navigate(inline("""
<style>
* { margin: 0; padding: 0; }
div {
display: block;
background-color: blue;
width: 200px;
height: 200px;
transform: translateX(-105px);
}
</style>
- <div></div>"""))
+ <div onclick="window.clicked = true;"></div>"""))
self.marionette.find_element(By.TAG_NAME, "div").click()
+ self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
def test_input_file(self):
self.marionette.navigate(inline("<input type=file>"))
with self.assertRaises(errors.InvalidArgumentException):
self.marionette.find_element(By.TAG_NAME, "input").click()
- def test_container_for_select(self):
- self.marionette.navigate(inline("""
- <select>
- <option>foo</option>
- </select>"""))
- option = self.marionette.find_element(By.TAG_NAME, "option")
- option.click()
- self.assertTrue(option.get_property("selected"))
-
- def test_container_for_button(self):
- self.marionette.navigate(inline("""
- <button onclick="window.clicked = true;">
- <span><em>foo</em></span>
- </button>"""))
- span = self.marionette.find_element(By.TAG_NAME, "span")
- span.click()
- self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
-
- def test_container_element_outside_view(self):
- self.marionette.navigate(inline("""
- <select style="margin-top: 100vh">
- <option>foo</option>
- </select>"""))
- option = self.marionette.find_element(By.TAG_NAME, "option")
- option.click()
- self.assertTrue(option.get_property("selected"))
-
- def test_table_tr(self):
- self.marionette.navigate(inline("""
- <table>
- <tr><td onclick="window.clicked = true;">
- foo
- </td></tr>
- </table>"""))
- tr = self.marionette.find_element(By.TAG_NAME, "tr")
- tr.click()
- self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
-
def test_obscured_element(self):
self.marionette.navigate(obscured_overlay)
overlay = self.marionette.find_element(By.ID, "overlay")
obscured = self.marionette.find_element(By.ID, "obscured")
overlay.click()
with self.assertRaises(errors.ElementClickInterceptedException):
obscured.click()
@@ -287,33 +310,16 @@ class TestClick(TestLegacyClick):
button = self.marionette.find_element(By.TAG_NAME, "button")
self.assertEqual("none", button.value_of_css_property("pointer-events"))
with self.assertRaisesRegexp(errors.ElementClickInterceptedException,
"does not have pointer events enabled"):
button.click()
self.assertFalse(self.marionette.execute_script("return window.clicked", sandbox=None))
- def test_inclusive_descendant(self):
- self.marionette.navigate(inline("""
- <select multiple>
- <option>first
- <option>second
- <option>third
- </select>"""))
- select = self.marionette.find_element(By.TAG_NAME, "select")
-
- # This tests that the pointer-interactability test does not
- # cause an ElementClickInterceptedException.
- #
- # At a <select multiple>'s in-view centre point, you might
- # find a fully rendered <option>. Marionette should test that
- # the paint tree at this point _contains_ <option>, not that the
- # first element of the paint tree is _equal_ to <select>.
- select.click()
class TestClickNavigation(MarionetteTestCase):
def setUp(self):
super(TestClickNavigation, self).setUp()
self.test_page = self.marionette.absolute_url("clicks.html")