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
--- 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")