Bug 1134872 - Fixing getElementValueOfCssProperty to support chrome elements. r=dburns, a=test-only
authorBarbara Miller <galgeek@me.com>
Fri, 06 Mar 2015 13:45:00 -0800
changeset 248241 13819479b7ab
parent 248240 d9889bdeea07
child 248242 d05ce20c1d77
push id7792
push userryanvm@gmail.com
push dateFri, 20 Mar 2015 15:03:14 +0000
treeherdermozilla-aurora@75b29a50fa63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdburns, test-only
bugs1134872
milestone38.0a2
Bug 1134872 - Fixing getElementValueOfCssProperty to support chrome elements. r=dburns, a=test-only
testing/marionette/client/marionette/tests/unit/test_chrome_element_css.py
testing/marionette/client/marionette/tests/unit/unit-tests.ini
testing/marionette/marionette-server.js
new file mode 100644
--- /dev/null
+++ b/testing/marionette/client/marionette/tests/unit/test_chrome_element_css.py
@@ -0,0 +1,21 @@
+# 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 marionette 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("id", "page-proxy-favicon")
+            favicon_image = element.value_of_css_property("list-style-image")
+
+            self.assertIn("identity-icons-generic.png", favicon_image)
+
+            element = self.marionette.find_element("id", "identity-box")
+            background_colour = element.value_of_css_property("background-color")
+
+            self.assertEqual("transparent", background_colour)
--- a/testing/marionette/client/marionette/tests/unit/unit-tests.ini
+++ b/testing/marionette/client/marionette/tests/unit/unit-tests.ini
@@ -32,16 +32,18 @@ b2g = false
 [test_selected_chrome.py]
 b2g = false
 [test_getattr.py]
 [test_getattr_chrome.py]
 b2g = false
 [test_elementsize.py]
 [test_position.py]
 [test_rendered_element.py]
+[test_chrome_element_css.py]
+b2g = false
 [test_elementState.py]
 [test_elementState_chrome.py]
 b2g = false
 [test_text.py]
 [test_text_chrome.py]
 disabled = "Bug 896046"
 
 [test_clearing.py]
--- a/testing/marionette/marionette-server.js
+++ b/testing/marionette/marionette-server.js
@@ -2180,19 +2180,31 @@ MarionetteServerConnection.prototype = {
    *
    * @param object aRequest
    *               'id' member holds the reference id to
    *               the element that will be checked
    *               'propertyName' is the CSS rule that is being requested
    */
   getElementValueOfCssProperty: function MDA_getElementValueOfCssProperty(aRequest){
     let command_id = this.command_id = this.getCommandId();
-    this.sendAsync("getElementValueOfCssProperty",
-                   {id: aRequest.parameters.id, propertyName: aRequest.parameters.propertyName},
-                   command_id);
+    let curWin = this.getCurrentWindow();
+    if (this.context == "chrome") {
+      try {
+        let el = this.curBrowser.elementManager.getKnownElement(aRequest.parameters.id, curWin);
+        this.sendResponse(curWin.document.defaultView.getComputedStyle(el, null).getPropertyValue(
+          aRequest.parameters.propertyName), command_id);
+      } catch (e) {
+        this.sendError(e.message, e.code, e.stack, command_id);
+      }
+    }
+    else {
+      this.sendAsync("getElementValueOfCssProperty",
+                     {id: aRequest.parameters.id, propertyName: aRequest.parameters.propertyName},
+                     command_id);
+    }
   },
 
   /**
    * Submit a form on a content page by either using form or element in a form
    * @param object aRequest
    *               'id' member holds the reference id to
    *               the element that will be checked
   */