Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Commit

Permalink
Bug 1420431 - Allow WebElement to be returned from GeckoDriver. r=maj…
Browse files Browse the repository at this point in the history
…a_zf

Instead of having to assign resp.body.value explicitly when dealing
with WebElements, this makes it possible to return WebElement
references directly from GeckoDriver command handlers.  This was
not possible in the past because web element representations were
just plain object literals.

MozReview-Commit-ID: EPqXJ2gpNen
  • Loading branch information
andreastt committed Nov 24, 2017
1 parent a85c41c commit 698252c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions testing/marionette/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2171,12 +2171,12 @@ GeckoDriver.prototype.findElements = async function(cmd, resp) {
* @throws {UnexpectedAlertOpenError}
* A modal dialog is open, blocking this operation.
*/
GeckoDriver.prototype.getActiveElement = async function(cmd, resp) {
GeckoDriver.prototype.getActiveElement = async function() {
assert.content(this.context);
assert.window(this.getCurrentWindow());
this._assertAndDismissModal();

resp.body.value = await this.listener.getActiveElement();
return this.listener.getActiveElement();
};

/**
Expand Down
6 changes: 3 additions & 3 deletions testing/marionette/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");

Cu.import("chrome://marionette/content/assert.js");
const {GeckoDriver} = Cu.import("chrome://marionette/content/driver.js", {});
const {WebElement} = Cu.import("chrome://marionette/content/element.js", {});
const {
error,
UnknownCommandError,
Expand All @@ -27,8 +28,7 @@ const {
Message,
Response,
} = Cu.import("chrome://marionette/content/message.js", {});
const {DebuggerTransport} =
Cu.import("chrome://marionette/content/transport.js", {});
const {DebuggerTransport} = Cu.import("chrome://marionette/content/transport.js", {});

XPCOMUtils.defineLazyServiceGetter(
this, "env", "@mozilla.org/process/environment;1", "nsIEnvironment");
Expand Down Expand Up @@ -560,7 +560,7 @@ server.TCPConnection = class {
let rv = await fn.bind(this.driver)(cmd, resp);

if (typeof rv != "undefined") {
if (typeof rv != "object") {
if (rv instanceof WebElement || typeof rv != "object") {
resp.body = {value: rv};
} else {
resp.body = rv;
Expand Down

0 comments on commit 698252c

Please sign in to comment.