Bug 1434904 - Remove dependency to testSize.html in test_elementsize.py r?whimboo draft
authorMike Yusko <freshjelly12@yahoo.com>
Sat, 17 Feb 2018 14:16:49 +0200
changeset 756654 9f705e006be81a0846ae724542a8ad778075ce79
parent 755180 27fd083ed7ee5782e52a5eaf0286c5ffa8b35a9e
child 756656 66e87feeb722322ccdcb802eb23d2430c2781a16
push id99524
push userbmo:mykhaylo.yusko@gmail.com
push dateSat, 17 Feb 2018 12:18:28 +0000
reviewerswhimboo
bugs1434904
milestone60.0a1
Bug 1434904 - Remove dependency to testSize.html in test_elementsize.py r?whimboo MozReview-Commit-ID: EOteIE2ArhI
testing/marionette/harness/marionette_harness/tests/unit/test_elementsize.py
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_elementsize.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_elementsize.py
@@ -1,19 +1,35 @@
 # 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/.
 
 from __future__ import absolute_import
 
+import urllib
+
 from marionette_driver.by import By
 
 from marionette_harness import MarionetteTestCase
 
 
+TEST_SIZE = """
+    <?xml version="1.0"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <title>Test page for element size</title>
+  </head>
+  <body>
+    <p>Let's get the size of <a href='#' id='linkId'>some really cool link</a></p>
+  </body>
+</html>
+"""
+
+def inline(doc):
+    return "data:text/html;charset=utf-8,{}".format(urllib.quote(doc))
+
 class TestElementSize(MarionetteTestCase):
     def testShouldReturnTheSizeOfALink(self):
-        test_html = self.marionette.absolute_url("testSize.html")
-        self.marionette.navigate(test_html)
+        self.marionette.navigate(inline(TEST_SIZE))
         shrinko = self.marionette.find_element(By.ID, 'linkId')
         size = shrinko.rect
         self.assertTrue(size['width'] > 0)
         self.assertTrue(size['height'] > 0)