Bug 1355890 - Infer identity box background-color by computed style draft
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 15 May 2017 19:22:13 +0100
changeset 578801 f1587866656537aee5d427ecb49d0c6578410693
parent 578800 0076e900b4a99c3550e6b3b1b1a3bdf5481ed0cc
child 628841 ce5065a238f947c1cc5e65675b96e3cc442539e6
push id59067
push userbmo:ato@mozilla.com
push dateTue, 16 May 2017 16:07:44 +0000
bugs1355890
milestone55.0a1
Bug 1355890 - Infer identity box background-color by computed style The test for getting a CSS value off a chrome element relied on a hardcoded expectation value. To reduce future maintenance, it is better to get the computed style value and compare it against what Marionette returns. MozReview-Commit-ID: 3FbPHGqNEpK
testing/marionette/harness/marionette_harness/tests/unit/test_chrome_element_css.py
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_chrome_element_css.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_chrome_element_css.py
@@ -4,20 +4,26 @@
 
 from marionette_driver.by import By
 
 from marionette_harness import MarionetteTestCase
 
 
 class TestChromeElementCSS(MarionetteTestCase):
 
-    def test_we_can_get_css_value_on_chrome_element(self):
-        self.marionette.navigate("about:blank")
-        with self.marionette.using_context("chrome"):
-            element = self.marionette.find_element(By.ID, "identity-icon")
-            favicon_image = element.value_of_css_property("list-style-image")
+    def get_element_computed_style(self, element, property):
+        return self.marionette.execute_script("""
+            const [el, prop] = arguments;
+            const elStyle = window.getComputedStyle(el);
+            return elStyle[prop];""",
+            script_args=(element, property),
+            sandbox=None)
 
+    def test_we_can_get_css_value_on_chrome_element(self):
+        with self.marionette.using_context("chrome"):
+            identity_icon = self.marionette.find_element(By.ID, "identity-icon")
+            favicon_image = identity_icon.value_of_css_property("list-style-image")
             self.assertIn("identity-icon.svg", favicon_image)
-
-            element = self.marionette.find_element(By.ID, "identity-box")
-            background_colour = element.value_of_css_property("background-color")
-
-            self.assertEqual("rgba(0, 0, 0, 0)", background_colour)
+            identity_box = self.marionette.find_element(By.ID, "identity-box")
+            expected_bg_colour = self.get_element_computed_style(
+                identity_box, "backgroundColor")
+            actual_bg_colour = identity_box.value_of_css_property("background-color")
+            self.assertEqual(expected_bg_colour, actual_bg_colour)