Bug 1277083: Have getElementProperty return element properties in chrome. r?jgriffin draft
authorDavid Burns <dburns@mozilla.com>
Tue, 31 May 2016 23:08:42 +0100
changeset 374023 6225e7dfc279a0b2f1ba2741ef672938cc98fbba
parent 374022 b5cb31afe51c2e53860a0675e97e52d80fc1908f
child 522523 1a0f6dc73fe86c8f6569ef891f1f4044284a8218
push id19899
push userdburns@mozilla.com
push dateWed, 01 Jun 2016 17:09:14 +0000
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")