Bug 1282331 - Refactor GetActiveFrame to return WebElement
MozReview-Commit-ID: 6LiBOXSEPtz
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1305,20 +1305,17 @@ class Marionette(object):
:param window_id: The id or name of the window to switch to.
"""
self._send_message("switchToWindow", {"name": window_id})
self.window = window_id
def get_active_frame(self):
"""Returns an HTMLElement representing the frame Marionette is
currently acting on."""
- element = self._send_message("getActiveFrame", key="value")
- if element:
- return HTMLElement(self, element)
- return None
+ return self._send_message("getActiveFrame", key="value")
def switch_to_default_content(self):
"""Switch the current context to page's default content."""
return self.switch_to_frame()
def switch_to_parent_frame(self):
"""
Switch to the Parent Frame
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1350,23 +1350,29 @@ GeckoDriver.prototype.switchToWindow = f
};
GeckoDriver.prototype.getActiveFrame = function(cmd, resp) {
switch (this.context) {
case Context.CHROME:
// no frame means top-level
resp.body.value = null;
if (this.curFrame) {
- resp.body.value = this.curBrowser.seenEls
+ let elRef = this.curBrowser.seenEls
.add(this.curFrame.frameElement);
+ let el = element.makeWebElement(elRef);
+ resp.body.value = el;
}
break;
case Context.CONTENT:
- resp.body.value = this.currentFrameElement;
+ resp.body.value = null;
+ if (this.currentFrameElement !== null) {
+ let el = element.makeWebElement(this.currentFrameElement);
+ resp.body.value = el;
+ }
break;
}
};
GeckoDriver.prototype.switchToParentFrame = function*(cmd, resp) {
let res = yield this.listener.switchToParentFrame();
};