Bug 1317386 - Add test for overlay element after scroll. r=automatedtester, a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 14 Nov 2016 21:12:00 +0000
changeset 352569 54e23725434ea1aefd120b7d663a9ee16a113140
parent 352568 aa77464b82d3243ce526dcaf3af7101aefbe1d9c
child 352570 229a089df41414b71536dcbfadd93f0afd205f0d
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester, test-only
bugs1317386
milestone52.0a2
Bug 1317386 - Add test for overlay element after scroll. r=automatedtester, a=test-only Add a test that checks that `scrollIntoView({block: "end", inline: "nearest"})` works by placing the element at the bottom of the viewport, where the overlay does not cover it. MozReview-Commit-ID: Gzv9n17240G
testing/marionette/harness/marionette/tests/unit/test_click.py
--- a/testing/marionette/harness/marionette/tests/unit/test_click.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_click.py
@@ -1,20 +1,58 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+import urllib
 from unittest import skip
 
 from marionette_driver.by import By
 from marionette_driver.errors import NoSuchElementException, ElementNotVisibleException
 from marionette_driver.wait import Wait
 from marionette import MarionetteTestCase
 
 
+def inline(doc):
+    return "data:text/html;charset=utf-8,{}".format(urllib.quote(doc))
+
+
+# The <a> element in the following HTML is not interactable because it
+# is hidden by an overlay when scrolled into the top of the viewport.
+# It should be interactable when scrolled in at the bottom of the
+# viewport.
+fixed_overlay = inline("""
+<style>
+* { margin: 0; padding: 0; }
+body { height: 300vh }
+div, a { display: block }
+div {
+  background-color: pink;
+  position: fixed;
+  width: 100%;
+  height: 40px;
+  top: 0;
+}
+a {
+  margin-top: 1000px;
+}
+</style>
+
+<div>overlay</div>
+<a href=#>link</a>
+
+<script>
+window.clicked = false;
+
+let link = document.querySelector("a");
+link.addEventListener("click", () => window.clicked = true);
+</script>
+""")
+
+
 class TestLegacyClick(MarionetteTestCase):
     """Uses legacy Selenium element displayedness checks."""
 
     def setUp(self):
         MarionetteTestCase.setUp(self)
         self.marionette.delete_session()
         self.marionette.start_session()
 
@@ -41,16 +79,22 @@ class TestLegacyClick(MarionetteTestCase
             self.marionette.find_element(By.ID, 'child').click()
 
     def test_clicking_on_a_multiline_link(self):
         test_html = self.marionette.absolute_url("clicks.html")
         self.marionette.navigate(test_html)
         self.marionette.find_element(By.ID, "overflowLink").click()
         self.wait_for_condition(lambda mn: self.marionette.title == "XHTML Test Page")
 
+    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))
+
 
 class TestClick(TestLegacyClick):
     """Uses WebDriver specification compatible element interactability
     checks.
     """
 
     def setUp(self):
         TestLegacyClick.setUp(self)