Added changes for bug 1434907 draft
authorRay <paarthurnax@live.ca>
Tue, 27 Feb 2018 14:08:43 -0500
changeset 760507 809364c0cba8e9ad42d33bbbbccf8b089f4ab32d
parent 760506 9a97b323955b57e29ac71808174d20347c64e4b8
child 760508 6e50bf40979bca2246fc686d34d0a299d6b06e55
push id100679
push userbmo:paarthurnax@live.ca
push dateTue, 27 Feb 2018 20:04:41 +0000
bugs1434907
milestone59.0a1
Added changes for bug 1434907 MozReview-Commit-ID: JSlS9cmDoAr
testing/marionette/harness/marionette_harness/tests/unit/test_click.py
testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py
testing/marionette/harness/marionette_harness/tests/unit/test_visibility.py
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
@@ -99,17 +99,17 @@ class TestLegacyClick(MarionetteTestCase
     def test_click_number_link(self):
         test_html = self.marionette.absolute_url("clicks.html")
         self.marionette.navigate(test_html)
         self.marionette.find_element(By.LINK_TEXT, "333333").click()
         self.marionette.find_element(By.ID, "testDiv")
         self.assertEqual(self.marionette.title, "Marionette Test")
 
     def test_clicking_an_element_that_is_not_displayed_raises(self):
-        test_html = self.marionette.absolute_url("hidden.html")
+        test_html = inline("<div id='parent' hidden> <div id='child'>My parent is hidden so you can't see me</div></div>")
         self.marionette.navigate(test_html)
 
         with self.assertRaises(errors.ElementNotInteractableException):
             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)
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py
@@ -29,18 +29,20 @@ class TestMouseAction(MarionetteTestCase
         self.marionette.navigate(test_html)
         link = self.marionette.find_element(By.ID, "mozLink")
         self.action.click(link).perform()
         self.assertEqual("Clicked", self.marionette.execute_script(
             "return document.getElementById('mozLink').innerHTML"))
 
     def test_clicking_element_out_of_view_succeeds(self):
         # The action based click doesn"t check for visibility.
-        test_html = self.marionette.absolute_url("hidden.html")
-        self.marionette.navigate(test_html)
+        self.marionette.navigate(inline("""
+        <div id='parent' hidden>
+            <div id='child'>My parent is hidden so you can't see me</div>
+        </div>"""))
         el = self.marionette.find_element(By.ID, "child")
         self.action.click(el).perform()
 
     def test_double_click_action(self):
         self.marionette.navigate(inline("""
           <div contenteditable>zyxw</div><input type="text"/>
         """))
 
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_visibility.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_visibility.py
@@ -1,16 +1,20 @@
 # 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 marionette_driver.by import By
 
 from marionette_harness import MarionetteTestCase
 
+def inline(doc):
+    return "data:text/html;charset=utf-8,{}".format(urllib.quote(doc))
 
 class TestVisibility(MarionetteTestCase):
 
     def testShouldAllowTheUserToTellIfAnElementIsDisplayedOrNot(self):
         test_html = self.marionette.absolute_url("visibility.html")
         self.marionette.navigate(test_html)
 
         self.assertTrue(self.marionette.find_element(By.ID, "displayed").is_displayed())
@@ -84,24 +88,25 @@ class TestVisibility(MarionetteTestCase)
 
     def testShouldSayElementIsInvisibleWhenOverflowXIsHiddenAndOutOfViewport(self):
         test_html = self.marionette.absolute_url("bug814037.html")
         self.marionette.navigate(test_html)
         overflow_x = self.marionette.find_element(By.ID, "assertMe2")
         self.assertFalse(overflow_x.is_displayed())
 
     def testShouldShowElementNotVisibleWithHiddenAttribute(self):
-        test_html = self.marionette.absolute_url("hidden.html")
-        self.marionette.navigate(test_html)
+        self.marionette.navigate(inline("""<div id='singleHidden' hidden>This will not be visible</div>"""))
         singleHidden = self.marionette.find_element(By.ID, 'singleHidden')
         self.assertFalse(singleHidden.is_displayed())
 
     def testShouldShowElementNotVisibleWhenParentElementHasHiddenAttribute(self):
-        test_html = self.marionette.absolute_url("hidden.html")
-        self.marionette.navigate(test_html)
+        self.marionette.navigate(inline("""
+        <div id='parent' hidden>
+            <div id='child'>My parent is hidden so you can't see me</div>
+        </div>"""))
         child = self.marionette.find_element(By.ID, 'child')
         self.assertFalse(child.is_displayed())
 
     def testShouldClickOnELementPartiallyOffLeft(self):
         test_html = self.marionette.absolute_url("element_left.html")
         self.marionette.navigate(test_html)
         self.marionette.find_element(By.CSS_SELECTOR, '.element').click()