Bug 1277083: Have getElementProperty return element properties in chrome. r=jgriffin
authorDavid Burns <dburns@mozilla.com>
Tue, 31 May 2016 23:08:42 +0100
changeset 324594 c62262afd761e9936348b2e30fb82adf7e1ecc74
parent 324593 2313feadbdaf1e2a6a92ef5f6c0d0e6bd34121b2
child 324595 b83a48d5fab9a296f1522b7e00d31bcb5eb102d4
push id9671
push userraliiev@mozilla.com
push dateMon, 06 Jun 2016 20:27:52 +0000
treeherdermozilla-aurora@cea65ca3d0bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs1277083
milestone49.0a1
Bug 1277083: Have getElementProperty return element properties in chrome. r=jgriffin This removes the UnknowOperationError that was being thrown and returns the property on the element that has been requested. MozReview-Commit-ID: 2WCnBfdmit5
testing/marionette/driver.js
testing/marionette/harness/marionette/tests/unit/test_element_state_chrome.py
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1806,17 +1806,20 @@ GeckoDriver.prototype.getElementAttribut
  * @return {string}
  *     Value of the property.
  */
 GeckoDriver.prototype.getElementProperty = function*(cmd, resp) {
   let {id, name} = cmd.parameters;
 
   switch (this.context) {
     case Context.CHROME:
-      throw new UnsupportedOperationError();
+      let win = this.getCurrentWindow();
+      let el = this.curBrowser.seenEls.get(id, {frame: win});
+      resp.body.value = el[name];
+      break;
 
     case Context.CONTENT:
       return this.listener.getElementProperty(id, name);
   }
 };
 
 /**
  * Get the text of an element, if any.  Includes the text of all child
--- a/testing/marionette/harness/marionette/tests/unit/test_element_state_chrome.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_element_state_chrome.py
@@ -61,8 +61,27 @@ class TestGetElementAttributeChrome(Mari
         self.assertNotEqual(self.win, self.marionette.current_window_handle)
         self.marionette.execute_script("window.close();")
         self.marionette.switch_to_window(self.win)
         MarionetteTestCase.tearDown(self)
 
     def test_get(self):
         el = self.marionette.execute_script("return window.document.getElementById('textInput');")
         self.assertEqual(el.get_attribute("id"), "textInput")
+
+class TestGetElementProperty(MarionetteTestCase):
+    def setUp(self):
+        MarionetteTestCase.setUp(self)
+        self.marionette.set_context("chrome")
+        self.win = self.marionette.current_window_handle
+        self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
+        self.marionette.switch_to_window('foo')
+        self.assertNotEqual(self.win, self.marionette.current_window_handle)
+
+    def tearDown(self):
+        self.assertNotEqual(self.win, self.marionette.current_window_handle)
+        self.marionette.execute_script("window.close();")
+        self.marionette.switch_to_window(self.win)
+        MarionetteTestCase.tearDown(self)
+
+    def test_get(self):
+        el = self.marionette.execute_script("return window.document.getElementById('textInput');")
+        self.assertEqual(el.get_property("id"), "textInput")