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 339118 c62262afd761e9936348b2e30fb82adf7e1ecc74
parent 339117 2313feadbdaf1e2a6a92ef5f6c0d0e6bd34121b2
child 339119 b83a48d5fab9a296f1522b7e00d31bcb5eb102d4
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs1277083
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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")