--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -351,17 +351,17 @@ GeckoDriver.prototype.switchToGlobalMess
GeckoDriver.prototype.sendAsync = function(name, data, commandID) {
name = "Marionette:" + name;
let payload = copy(data);
// TODO(ato): When proxy.AsyncMessageChannel
// is used for all chrome <-> content communication
// this can be removed.
if (commandID) {
- payload.command_id = commandID;
+ payload.commandID = commandID;
}
if (!this.curBrowser.frameManager.currentRemoteFrame) {
this.broadcastDelayedAsyncMessage_(name, payload);
} else {
this.sendTargettedAsyncMessage_(name, payload);
}
};
@@ -1113,17 +1113,17 @@ GeckoDriver.prototype.get = async functi
let get = this.listener.get({url, pageTimeout: this.timeouts.pageLoad});
// If a reload of the frame script interrupts our page load, this will
// never return. We need to re-issue this request to correctly poll for
// readyState and send errors.
this.curBrowser.pendingCommands.push(() => {
let parameters = {
// TODO(ato): Bug 1242595
- command_id: this.listener.activeMessageId,
+ commandID: this.listener.activeMessageId,
pageTimeout: this.timeouts.pageLoad,
startTime: new Date().getTime(),
};
this.mm.broadcastAsyncMessage(
"Marionette:waitForPageLoaded" + this.curBrowser.curFrameId,
parameters);
});
@@ -1232,17 +1232,17 @@ GeckoDriver.prototype.goBack = async fun
let goBack = this.listener.goBack({pageTimeout: this.timeouts.pageLoad});
// If a reload of the frame script interrupts our page load, this will
// never return. We need to re-issue this request to correctly poll for
// readyState and send errors.
this.curBrowser.pendingCommands.push(() => {
let parameters = {
// TODO(ato): Bug 1242595
- command_id: this.listener.activeMessageId,
+ commandID: this.listener.activeMessageId,
lastSeenURL: lastURL.toString(),
pageTimeout: this.timeouts.pageLoad,
startTime: new Date().getTime(),
};
this.mm.broadcastAsyncMessage(
"Marionette:waitForPageLoaded" + this.curBrowser.curFrameId,
parameters);
});
@@ -1276,17 +1276,17 @@ GeckoDriver.prototype.goForward = async
{pageTimeout: this.timeouts.pageLoad});
// If a reload of the frame script interrupts our page load, this will
// never return. We need to re-issue this request to correctly poll for
// readyState and send errors.
this.curBrowser.pendingCommands.push(() => {
let parameters = {
// TODO(ato): Bug 1242595
- command_id: this.listener.activeMessageId,
+ commandID: this.listener.activeMessageId,
lastSeenURL: lastURL.toString(),
pageTimeout: this.timeouts.pageLoad,
startTime: new Date().getTime(),
};
this.mm.broadcastAsyncMessage(
"Marionette:waitForPageLoaded" + this.curBrowser.curFrameId,
parameters);
});
@@ -1314,17 +1314,17 @@ GeckoDriver.prototype.refresh = async fu
{pageTimeout: this.timeouts.pageLoad});
// If a reload of the frame script interrupts our page load, this will
// never return. We need to re-issue this request to correctly poll for
// readyState and send errors.
this.curBrowser.pendingCommands.push(() => {
let parameters = {
// TODO(ato): Bug 1242595
- command_id: this.listener.activeMessageId,
+ commandID: this.listener.activeMessageId,
pageTimeout: this.timeouts.pageLoad,
startTime: new Date().getTime(),
};
this.mm.broadcastAsyncMessage(
"Marionette:waitForPageLoaded" + this.curBrowser.curFrameId,
parameters);
});
@@ -1899,17 +1899,17 @@ GeckoDriver.prototype.switchToFrame = as
this.curBrowser.frameManager.currentRemoteFrame !== null) {
// We're currently using a ChromeMessageSender for a remote frame,
// so this request indicates we need to switch back to the top-level
// (parent) frame. We'll first switch to the parent's (global)
// ChromeMessageBroadcaster, so we send the message to the right
// listener.
this.switchToGlobalMessageManager();
}
- cmd.command_id = cmd.id;
+ cmd.commandID = cmd.id;
let res = await this.listener.switchToFrame(cmd.parameters);
if (res) {
let {win: winId, frame: frameId} = res;
this.mm = this.curBrowser.frameManager.getFrameMM(winId, frameId);
let registerBrowsers = this.registerPromise();
let browserListening = this.listeningPromise();
@@ -2223,17 +2223,17 @@ GeckoDriver.prototype.clickElement = asy
{id, pageTimeout: this.timeouts.pageLoad});
// If a reload of the frame script interrupts our page load, this will
// never return. We need to re-issue this request to correctly poll for
// readyState and send errors.
this.curBrowser.pendingCommands.push(() => {
let parameters = {
// TODO(ato): Bug 1242595
- command_id: this.listener.activeMessageId,
+ commandID: this.listener.activeMessageId,
pageTimeout: this.timeouts.pageLoad,
startTime: new Date().getTime(),
};
this.mm.broadcastAsyncMessage(
"Marionette:waitForPageLoaded" + this.curBrowser.curFrameId,
parameters);
});
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -116,40 +116,40 @@ var sandboxName = "default";
/**
* The load listener singleton helps to keep track of active page load
* activities, and can be used by any command which might cause a navigation
* to happen. In the specific case of a reload of the frame script it allows
* to continue observing the current page load.
*/
var loadListener = {
- command_id: null,
+ commandID: null,
seenBeforeUnload: false,
seenUnload: false,
timeout: null,
timerPageLoad: null,
timerPageUnload: null,
/**
* Start listening for page unload/load events.
*
- * @param {number} command_id
+ * @param {number} commandID
* ID of the currently handled message between the driver and
* listener.
* @param {number} timeout
* Timeout in seconds the method has to wait for the page being
* finished loading.
* @param {number} startTime
* Unix timestap when the navitation request got triggered.
* @param {boolean=} waitForUnloaded
* If true wait for page unload events, otherwise only for page
* load events.
*/
- start(command_id, timeout, startTime, waitForUnloaded = true) {
- this.command_id = command_id;
+ start(commandID, timeout, startTime, waitForUnloaded = true) {
+ this.commandID = commandID;
this.timeout = timeout;
this.seenBeforeUnload = false;
this.seenUnload = false;
this.timerPageLoad = Cc["@mozilla.org/timer;1"]
.createInstance(Ci.nsITimer);
this.timerPageUnload = null;
@@ -267,17 +267,17 @@ var loadListener = {
// Now wait until the target page has been loaded
addEventListener("DOMContentLoaded", this, false);
addEventListener("pageshow", this, false);
break;
case "hashchange":
case "popstate":
this.stop();
- sendOk(this.command_id);
+ sendOk(this.commandID);
break;
case "DOMContentLoaded":
case "pageshow":
this.handleReadyState(event.target.readyState,
event.target.documentURI);
break;
}
@@ -299,45 +299,45 @@ var loadListener = {
*/
handleReadyState(readyState, documentURI) {
let finished = false;
switch (readyState) {
case "interactive":
if (documentURI.startsWith("about:certerror")) {
this.stop();
- sendError(new InsecureCertificateError(), this.command_id);
+ sendError(new InsecureCertificateError(), this.commandID);
finished = true;
} else if (/about:.*(error)\?/.exec(documentURI)) {
this.stop();
sendError(new UnknownError(`Reached error page: ${documentURI}`),
- this.command_id);
+ this.commandID);
finished = true;
// Return early with a page load strategy of eager, and also
// special-case about:blocked pages which should be treated as
// non-error pages but do not raise a pageshow event. about:blank
// is also treaded specifically here, because it gets temporary
// loaded for new content processes, and we only want to rely on
// complete loads for it.
} else if ((capabilities.get("pageLoadStrategy") ===
session.PageLoadStrategy.Eager &&
documentURI != "about:blank") ||
/about:blocked\?/.exec(documentURI)) {
this.stop();
- sendOk(this.command_id);
+ sendOk(this.commandID);
finished = true;
}
break;
case "complete":
this.stop();
- sendOk(this.command_id);
+ sendOk(this.commandID);
finished = true;
break;
}
return finished;
},
@@ -361,25 +361,25 @@ var loadListener = {
this, 5000, Ci.nsITimer.TYPE_ONE_SHOT);
// If no page unload has been detected, ensure to properly stop
// the load listener, and return from the currently active command.
} else if (!this.seenUnload) {
logger.debug("Canceled page load listener because no navigation " +
"has been detected");
this.stop();
- sendOk(this.command_id);
+ sendOk(this.commandID);
}
break;
case this.timerPageLoad:
this.stop();
sendError(
new TimeoutError(`Timeout loading page after ${this.timeout}ms`),
- this.command_id);
+ this.commandID);
break;
}
},
observe(subject, topic, data) {
const win = curContainer.frame;
const winID = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
const curWinID = win.QueryInterface(Ci.nsIInterfaceRequestor)
@@ -388,92 +388,92 @@ var loadListener = {
logger.debug(`Received observer notification "${topic}" for "${winID}"`);
switch (topic) {
// In the case when the currently selected frame is closed,
// there will be no further load events. Stop listening immediately.
case "outer-window-destroyed":
if (curWinID === winID) {
this.stop();
- sendOk(this.command_id);
+ sendOk(this.commandID);
}
break;
}
},
/**
* Continue to listen for page load events after the frame script has been
* reloaded.
*
- * @param {number} command_id
+ * @param {number} commandID
* ID of the currently handled message between the driver and
* listener.
* @param {number} timeout
* Timeout in milliseconds the method has to wait for the page
* being finished loading.
* @param {number} startTime
* Unix timestap when the navitation request got triggered.
*/
- waitForLoadAfterFramescriptReload(command_id, timeout, startTime) {
- this.start(command_id, timeout, startTime, false);
+ waitForLoadAfterFramescriptReload(commandID, timeout, startTime) {
+ this.start(commandID, timeout, startTime, false);
},
/**
* Use a trigger callback to initiate a page load, and attach listeners if
* a page load is expected.
*
* @param {function} trigger
* Callback that triggers the page load.
- * @param {number} command_id
+ * @param {number} commandID
* ID of the currently handled message between the driver and listener.
* @param {number} pageTimeout
* Timeout in milliseconds the method has to wait for the page
* finished loading.
* @param {boolean=} loadEventExpected
* Optional flag, which indicates that navigate has to wait for the page
* finished loading.
* @param {string=} url
* Optional URL, which is used to check if a page load is expected.
*/
- navigate(trigger, command_id, timeout, loadEventExpected = true,
+ navigate(trigger, commandID, timeout, loadEventExpected = true,
useUnloadTimer = false) {
// Only wait if the page load strategy is not `none`
loadEventExpected = loadEventExpected &&
(capabilities.get("pageLoadStrategy") !==
session.PageLoadStrategy.None);
if (loadEventExpected) {
let startTime = new Date().getTime();
- this.start(command_id, timeout, startTime, true);
+ this.start(commandID, timeout, startTime, true);
}
return (async () => {
await trigger();
})().then(val => {
if (!loadEventExpected) {
- sendOk(command_id);
+ sendOk(commandID);
return;
}
// If requested setup a timer to detect a possible page load
if (useUnloadTimer) {
this.timerPageUnload = Cc["@mozilla.org/timer;1"]
.createInstance(Ci.nsITimer);
this.timerPageUnload.initWithCallback(
this, 200, Ci.nsITimer.TYPE_ONE_SHOT);
}
}).catch(err => {
if (loadEventExpected) {
this.stop();
}
- sendError(err, command_id);
+ sendError(err, commandID);
});
},
};
/**
* Called when listener is first started up. The listener sends its
* unique window ID and its current URI to the actor. If the actor returns
* an ID, we start the listeners. Otherwise, nothing happens.
@@ -502,17 +502,17 @@ function registerSelf() {
// Perhaps one could even conceive having a separate instance of
// CommandProcessor for the listener, because the code is mostly the same.
function dispatch(fn) {
if (typeof fn != "function") {
throw new TypeError("Provided dispatch handler is not a function");
}
return function(msg) {
- let id = msg.json.command_id;
+ let id = msg.json.commandID;
let req = (async () => {
if (typeof msg.json == "undefined" || msg.json instanceof Array) {
return fn.apply(null, msg.json);
}
return fn(msg.json);
})();
@@ -1153,141 +1153,141 @@ function cancelRequest() {
}
/**
* This implements the latter part of a get request (for the case we need
* to resume one when the frame script has been reloaded in the middle of a
* navigate request). This is most of of the work of a navigate request,
* but doesn't assume DOMContentLoaded is yet to fire.
*
- * @param {number} command_id
+ * @param {number} commandID
* ID of the currently handled message between the driver and
* listener.
* @param {number} pageTimeout
* Timeout in seconds the method has to wait for the page being
* finished loading.
* @param {number} startTime
* Unix timestap when the navitation request got triggred.
*/
function waitForPageLoaded(msg) {
- let {command_id, pageTimeout, startTime} = msg.json;
+ let {commandID, pageTimeout, startTime} = msg.json;
loadListener.waitForLoadAfterFramescriptReload(
- command_id, pageTimeout, startTime);
+ commandID, pageTimeout, startTime);
}
/**
* Navigate to the given URL. The operation will be performed on the
* current browsing context, which means it handles the case where we
* navigate within an iframe. All other navigation is handled by the driver
* (in chrome space).
*/
function get(msg) {
- let {command_id, pageTimeout, url, loadEventExpected = null} = msg.json;
+ let {commandID, pageTimeout, url, loadEventExpected = null} = msg.json;
try {
if (typeof url == "string") {
try {
if (loadEventExpected === null) {
loadEventExpected = navigate.isLoadEventExpected(
curContainer.frame.location, url);
}
} catch (e) {
let err = new InvalidArgumentError("Malformed URL: " + e.message);
- sendError(err, command_id);
+ sendError(err, commandID);
return;
}
}
// We need to move to the top frame before navigating
sendSyncMessage("Marionette:switchedToFrame", {frameValue: null});
curContainer.frame = content;
loadListener.navigate(() => {
curContainer.frame.location = url;
- }, command_id, pageTimeout, loadEventExpected);
+ }, commandID, pageTimeout, loadEventExpected);
} catch (e) {
- sendError(e, command_id);
+ sendError(e, commandID);
}
}
/**
* Cause the browser to traverse one step backward in the joint history
* of the current browsing context.
*
- * @param {number} command_id
+ * @param {number} commandID
* ID of the currently handled message between the driver and
* listener.
* @param {number} pageTimeout
* Timeout in milliseconds the method has to wait for the page being
* finished loading.
*/
function goBack(msg) {
- let {command_id, pageTimeout} = msg.json;
+ let {commandID, pageTimeout} = msg.json;
try {
loadListener.navigate(() => {
curContainer.frame.history.back();
- }, command_id, pageTimeout);
+ }, commandID, pageTimeout);
} catch (e) {
- sendError(e, command_id);
+ sendError(e, commandID);
}
}
/**
* Cause the browser to traverse one step forward in the joint history
* of the current browsing context.
*
- * @param {number} command_id
+ * @param {number} commandID
* ID of the currently handled message between the driver and
* listener.
* @param {number} pageTimeout
* Timeout in milliseconds the method has to wait for the page being
* finished loading.
*/
function goForward(msg) {
- let {command_id, pageTimeout} = msg.json;
+ let {commandID, pageTimeout} = msg.json;
try {
loadListener.navigate(() => {
curContainer.frame.history.forward();
- }, command_id, pageTimeout);
+ }, commandID, pageTimeout);
} catch (e) {
- sendError(e, command_id);
+ sendError(e, commandID);
}
}
/**
* Causes the browser to reload the page in in current top-level browsing
* context.
*
- * @param {number} command_id
+ * @param {number} commandID
* ID of the currently handled message between the driver and
* listener.
* @param {number} pageTimeout
* Timeout in milliseconds the method has to wait for the page being
* finished loading.
*/
function refresh(msg) {
- let {command_id, pageTimeout} = msg.json;
+ let {commandID, pageTimeout} = msg.json;
try {
// We need to move to the top frame before navigating
sendSyncMessage("Marionette:switchedToFrame", {frameValue: null});
curContainer.frame = content;
loadListener.navigate(() => {
curContainer.frame.location.reload(true);
- }, command_id, pageTimeout);
+ }, commandID, pageTimeout);
} catch (e) {
- sendError(e, command_id);
+ sendError(e, commandID);
}
}
/**
* Get source of the current browsing context's DOM.
*/
function getPageSource() {
return curContainer.frame.document.documentElement.outerHTML;
@@ -1337,47 +1337,47 @@ async function findElementsContent(strat
function getActiveElement() {
let el = curContainer.frame.document.activeElement;
return evaluate.toJSON(el, seenEls);
}
/**
* Send click event to element.
*
- * @param {number} command_id
+ * @param {number} commandID
* ID of the currently handled message between the driver and
* listener.
* @param {WebElement} id
* Reference to the web element to click.
* @param {number} pageTimeout
* Timeout in milliseconds the method has to wait for the page being
* finished loading.
*/
function clickElement(msg) {
- let {command_id, id, pageTimeout} = msg.json;
+ let {commandID, id, pageTimeout} = msg.json;
try {
let loadEventExpected = true;
let target = getElementAttribute(id, "target");
if (target === "_blank") {
loadEventExpected = false;
}
loadListener.navigate(() => {
return interaction.clickElement(
seenEls.get(id, curContainer),
capabilities.get("moz:accessibilityChecks"),
capabilities.get("specificationLevel") >= 1
);
- }, command_id, pageTimeout, loadEventExpected, true);
+ }, commandID, pageTimeout, loadEventExpected, true);
} catch (e) {
- sendError(e, command_id);
+ sendError(e, commandID);
}
}
function getElementAttribute(id, name) {
let el = seenEls.get(id, curContainer);
if (element.isBooleanAttribute(el, name)) {
if (el.hasAttribute(name)) {
return "true";
@@ -1573,25 +1573,25 @@ function switchToShadowRoot(id) {
*/
function switchToParentFrame(msg) {
curContainer.frame = curContainer.frame.parent;
let parentElement = seenEls.add(curContainer.frame);
sendSyncMessage(
"Marionette:switchedToFrame", {frameValue: parentElement});
- sendOk(msg.json.command_id);
+ sendOk(msg.json.commandID);
}
/**
* Switch to frame given either the server-assigned element id,
* its index in window.frames, or the iframe's name or id.
*/
function switchToFrame(msg) {
- let command_id = msg.json.command_id;
+ let commandID = msg.json.commandID;
let foundFrame = null;
let frames = [];
let parWindow = null;
// Check of the curContainer.frame reference is dead
try {
frames = curContainer.frame.frames;
// Until Bug 761935 lands, we won't have multiple nested OOP
@@ -1613,27 +1613,27 @@ function switchToFrame(msg) {
// returning to root frame
sendSyncMessage("Marionette:switchedToFrame", {frameValue: null});
curContainer.frame = content;
if (msg.json.focus == true) {
curContainer.frame.focus();
}
- sendOk(command_id);
+ sendOk(commandID);
return;
}
let id = msg.json.element;
if (seenEls.has(id)) {
let wantedFrame;
try {
wantedFrame = seenEls.get(id, curContainer);
} catch (e) {
- sendError(e, command_id);
+ sendError(e, commandID);
}
if (frames.length > 0) {
for (let i = 0; i < frames.length; i++) {
// use XPCNativeWrapper to compare elements; see bug 834266
let frameEl = frames[i].frameElement;
let wrappedItem = new XPCNativeWrapper(frameEl);
let wrappedWanted = new XPCNativeWrapper(wantedFrame);
@@ -1674,17 +1674,17 @@ function switchToFrame(msg) {
// level browsing context so should treat it accordingly.
sendSyncMessage("Marionette:switchedToFrame", {frameValue: null});
curContainer.frame = content;
if (msg.json.focus == true) {
curContainer.frame.focus();
}
- sendOk(command_id);
+ sendOk(commandID);
return;
}
} catch (e) {
// Since window.frames does not return OOP frames it will throw
// and we land up here. Let's not give up and check if there are
// iframes and switch to the indexed frame there
let doc = curContainer.frame.document;
let iframes = doc.getElementsByTagName("iframe");
@@ -1694,41 +1694,41 @@ function switchToFrame(msg) {
}
}
}
}
if (foundFrame === null) {
let failedFrame = msg.json.id || msg.json.element;
let err = new NoSuchFrameError(`Unable to locate frame: ${failedFrame}`);
- sendError(err, command_id);
+ sendError(err, commandID);
return;
}
// send a synchronous message to let the server update the currently active
// frame element (for getActiveFrame)
let frameValue = evaluate.toJSON(
curContainer.frame.wrappedJSObject, seenEls)[element.Key];
sendSyncMessage("Marionette:switchedToFrame", {"frameValue": frameValue});
if (curContainer.frame.contentWindow === null) {
// The frame we want to switch to is a remote/OOP frame;
// notify our parent to handle the switch
curContainer.frame = content;
let rv = {win: parWindow, frame: foundFrame};
- sendResponse(rv, command_id);
+ sendResponse(rv, commandID);
} else {
curContainer.frame = curContainer.frame.contentWindow;
if (msg.json.focus) {
curContainer.frame.focus();
}
- sendOk(command_id);
+ sendOk(commandID);
}
}
/**
* Perform a screen capture in content context.
*
* Accepted values for |opts|:
*