--- a/testing/marionette/marionette-actors.js
+++ b/testing/marionette/marionette-actors.js
@@ -127,37 +127,16 @@ function MarionetteRemoteFrame(windowId,
this.frameId = frameId;
this.targetFrameId = null;
this.messageManager = null;
this.command_id = null;
}
// persistent list of remote frames that Marionette has loaded a frame script in
let remoteFrames = [];
-/*
- * Custom exceptions
- */
-function FrameSendNotInitializedError(frame) {
- this.code = 54;
- this.frame = frame;
- this.message = "Error sending message to frame (NS_ERROR_NOT_INITIALIZED)";
- this.toString = function() {
- return this.message + " " + this.frame + "; frame has closed.";
- }
-}
-
-function FrameSendFailureError(frame) {
- this.code = 55;
- this.frame = frame;
- this.message = "Error sending message to frame (NS_ERROR_FAILURE)";
- this.toString = function() {
- return this.message + " " + this.frame + "; frame not responding.";
- }
-}
-
/**
* This actor is responsible for all marionette API calls. It gets created
* for each connection and manages all chrome and browser based calls. It
* mediates content calls by issuing appropriate messages to the content process.
*/
function MarionetteDriverActor(aConnection)
{
this.uuidGen = Cc["@mozilla.org/uuid-generator;1"]
@@ -201,64 +180,43 @@ MarionetteDriverActor.prototype = {
* ChromeMessageSender. Has no effect if the global ChromeMessageBroadcaster is already
* in use. If this replaces a frame-specific ChromeMessageSender, it removes the message
* listeners from that sender, and then puts the corresponding frame script "to sleep",
* which removes most of the message listeners from it as well.
*/
switchToGlobalMessageManager: function MDA_switchToGlobalMM() {
if (this.currentRemoteFrame !== null) {
this.removeMessageManagerListeners(this.messageManager);
- this.sendAsync("sleepSession", null, null, true);
+ try {
+ // this can fail if the frame is already gone
+ this.sendAsync("sleepSession");
+ }
+ catch(e) {}
}
this.messageManager = this.globalMessageManager;
this.currentRemoteFrame = null;
},
/**
* Helper method to send async messages to the content listener
*
* @param string name
* Suffix of the targetted message listener (Marionette:<suffix>)
* @param object values
* Object to send to the listener
*/
- sendAsync: function MDA_sendAsync(name, values, commandId, ignoreFailure) {
- let success = true;
- if (values instanceof Object && commandId) {
- values.command_id = commandId;
- }
+ sendAsync: function MDA_sendAsync(name, values) {
if (this.currentRemoteFrame !== null) {
- try {
- this.messageManager.sendAsyncMessage(
- "Marionette:" + name + this.currentRemoteFrame.targetFrameId, values);
- }
- catch(e) {
- if (!ignoreFailure) {
- success = false;
- let error = e;
- switch(e.result) {
- case Components.results.NS_ERROR_FAILURE:
- error = new FrameSendFailureError(this.currentRemoteFrame);
- break;
- case Components.results.NS_ERROR_NOT_INITIALIZED:
- error = new FrameSendNotInitializedError(this.currentRemoteFrame);
- break;
- default:
- break;
- }
- code = error.hasOwnProperty('code') ? e.code : 500;
- this.sendError(error.toString(), code, error.stack, commandId);
- }
- }
+ this.messageManager.sendAsyncMessage(
+ "Marionette:" + name + this.currentRemoteFrame.targetFrameId, values);
}
else {
this.messageManager.broadcastAsyncMessage(
"Marionette:" + name + this.curBrowser.curFrameId, values);
}
- return success;
},
/**
* Adds listeners for messages from content frame scripts.
*
* @param object messageManager
* The messageManager object (ChromeMessageBroadcaster or ChromeMessageSender)
* to which the listeners should be added.
@@ -783,25 +741,22 @@ MarionetteDriverActor.prototype = {
let command_id = this.command_id = this.getCommandId();
this.logRequest("execute", aRequest);
if (aRequest.newSandbox == undefined) {
//if client does not send a value in newSandbox,
//then they expect the same behaviour as webdriver
aRequest.newSandbox = true;
}
if (this.context == "content") {
- this.sendAsync("executeScript",
- {
- value: aRequest.value,
- args: aRequest.args,
- newSandbox: aRequest.newSandbox,
- timeout: timeout,
- specialPowers: aRequest.specialPowers
- },
- command_id);
+ this.sendAsync("executeScript", {value: aRequest.value,
+ args: aRequest.args,
+ newSandbox: aRequest.newSandbox,
+ timeout: timeout,
+ command_id: command_id,
+ specialPowers: aRequest.specialPowers});
return;
}
let curWindow = this.getCurrentWindow();
let marionette = new Marionette(this, curWindow, "chrome",
this.marionetteLog, this.marionettePerf,
timeout, this.testName);
let _chromeSandbox = this.createExecuteSandbox(curWindow,
@@ -874,26 +829,23 @@ MarionetteDriverActor.prototype = {
if (aRequest.async) {
this.executeWithCallback(aRequest, aRequest.async);
}
else {
this.execute(aRequest, true);
}
}
else {
- this.sendAsync("executeJSScript",
- {
- value: aRequest.value,
- args: aRequest.args,
- newSandbox: aRequest.newSandbox,
- async: aRequest.async,
- timeout: timeout,
- specialPowers: aRequest.specialPowers
- },
- command_id);
+ this.sendAsync("executeJSScript", { value: aRequest.value,
+ args: aRequest.args,
+ newSandbox: aRequest.newSandbox,
+ async: aRequest.async,
+ timeout: timeout,
+ command_id: command_id,
+ specialPowers: aRequest.specialPowers });
}
},
/**
* This function is used by executeAsync and executeJSScript to execute a script
* in a sandbox.
*
* For executeJSScript, it will return a message only when the finish() method is called.
@@ -913,26 +865,23 @@ MarionetteDriverActor.prototype = {
this.logRequest("executeWithCallback", aRequest);
if (aRequest.newSandbox == undefined) {
//if client does not send a value in newSandbox,
//then they expect the same behaviour as webdriver
aRequest.newSandbox = true;
}
if (this.context == "content") {
- this.sendAsync("executeAsyncScript",
- {
- value: aRequest.value,
- args: aRequest.args,
- id: this.command_id,
- newSandbox: aRequest.newSandbox,
- timeout: timeout,
- specialPowers: aRequest.specialPowers
- },
- command_id);
+ this.sendAsync("executeAsyncScript", {value: aRequest.value,
+ args: aRequest.args,
+ id: this.command_id,
+ newSandbox: aRequest.newSandbox,
+ timeout: timeout,
+ command_id: command_id,
+ specialPowers: aRequest.specialPowers});
return;
}
let curWindow = this.getCurrentWindow();
let original_onerror = curWindow.onerror;
let that = this;
that.timeout = timeout;
let marionette = new Marionette(this, curWindow, "chrome",
@@ -1022,17 +971,17 @@ MarionetteDriverActor.prototype = {
* @param object aRequest
* 'value' member holds the url to navigate to
*/
goUrl: function MDA_goUrl(aRequest) {
let command_id = this.command_id = this.getCommandId();
if (this.context != "chrome") {
aRequest.command_id = command_id;
aRequest.pageTimeout = this.pageTimeout;
- this.sendAsync("goUrl", aRequest, command_id);
+ this.sendAsync("goUrl", aRequest);
return;
}
this.getCurrentWindow().location.href = aRequest.value;
let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
let start = new Date().getTime();
let end = null;
function checkLoad() {
@@ -1059,66 +1008,66 @@ MarionetteDriverActor.prototype = {
* Gets current url
*/
getUrl: function MDA_getUrl() {
this.command_id = this.getCommandId();
if (this.context == "chrome") {
this.sendResponse(this.getCurrentWindow().location.href, this.command_id);
}
else {
- this.sendAsync("getUrl", {}, this.command_id);
+ this.sendAsync("getUrl", {command_id: this.command_id});
}
},
/**
* Gets the current title of the window
*/
getTitle: function MDA_getTitle() {
this.command_id = this.getCommandId();
- this.sendAsync("getTitle", {}, this.command_id);
+ this.sendAsync("getTitle", {command_id: this.command_id});
},
/**
* Gets the page source of the content document
*/
getPageSource: function MDA_getPageSource(){
this.command_id = this.getCommandId();
if (this.context == "chrome"){
var curWindow = this.getCurrentWindow();
var XMLSerializer = curWindow.XMLSerializer;
var pageSource = new XMLSerializer().serializeToString(curWindow.document);
this.sendResponse(pageSource, this.command_id);
}
else {
- this.sendAsync("getPageSource", {}, this.command_id);
+ this.sendAsync("getPageSource", {command_id: this.command_id});
}
},
/**
* Go back in history
*/
goBack: function MDA_goBack() {
this.command_id = this.getCommandId();
- this.sendAsync("goBack", {}, this.command_id);
+ this.sendAsync("goBack", {command_id: this.command_id});
},
/**
* Go forward in history
*/
goForward: function MDA_goForward() {
this.command_id = this.getCommandId();
- this.sendAsync("goForward", {}, this.command_id);
+ this.sendAsync("goForward", {command_id: this.command_id});
},
/**
* Refresh the page
*/
refresh: function MDA_refresh() {
this.command_id = this.getCommandId();
- this.sendAsync("refresh", {}, this.command_id);
+ this.sendAsync("refresh", {command_id: this.command_id});
},
/**
* Get the current window's server-assigned ID
*/
getWindow: function MDA_getWindow() {
this.command_id = this.getCommandId();
for (let i in this.browsers) {
@@ -1273,17 +1222,17 @@ MarionetteDriverActor.prototype = {
(this.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();
}
aRequest.command_id = command_id;
- this.sendAsync("switchToFrame", aRequest, command_id);
+ this.sendAsync("switchToFrame", aRequest);
}
},
/**
* Set timeout for searching for elements
*
* @param object aRequest
* 'value' holds the search timeout in milliseconds
@@ -1295,19 +1244,18 @@ MarionetteDriverActor.prototype = {
this.curBrowser.elementManager.setSearchTimeout(aRequest.value);
this.sendOk(this.command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, this.command_id);
}
}
else {
- this.sendAsync("setSearchTimeout",
- { value: aRequest.value },
- this.command_id);
+ this.sendAsync("setSearchTimeout", {value: aRequest.value,
+ command_id: this.command_id});
}
},
/**
* Set timeout for page loading, searching and scripts
*
* @param object aRequest
* 'type' hold the type of timeout
@@ -1347,23 +1295,20 @@ MarionetteDriverActor.prototype = {
this.command_id = this.getCommandId();
let serId = aRequest.element;
let x = aRequest.x;
let y = aRequest.y;
if (this.context == "chrome") {
this.sendError("Not in Chrome", 500, null, this.command_id);
}
else {
- this.sendAsync("singleTap",
- {
- value: serId,
- corx: x,
- cory: y
- },
- this.command_id);
+ this.sendAsync("singleTap", {value: serId,
+ corx: x,
+ cory: y,
+ command_id: this.command_id});
}
},
/**
* Double Tap
*
* @param object aRequest
* 'element' represents the ID of the element to double tap on
@@ -1372,23 +1317,20 @@ MarionetteDriverActor.prototype = {
this.command_id = this.getCommandId();
let serId = aRequest.element;
let x = aRequest.x;
let y = aRequest.y;
if (this.context == "chrome") {
this.sendError("Not in Chrome", 500, null, this.command_id);
}
else {
- this.sendAsync("doubleTap",
- {
- value: serId,
- corx: x,
- cory: y
- },
- this.command_id);
+ this.sendAsync("doubleTap", {value: serId,
+ corx: x,
+ cory: y,
+ command_id: this.command_id});
}
},
/**
* Start touch
*
* @param object aRequest
* 'element' represents the ID of the element to touch
@@ -1397,23 +1339,20 @@ MarionetteDriverActor.prototype = {
this.command_id = this.getCommandId();
let element = aRequest.element;
let x = aRequest.x;
let y = aRequest.y;
if (this.context == "chrome") {
this.sendError("Not in Chrome", 500, null, this.command_id);
}
else {
- this.sendAsync("press",
- {
- value: element,
- corx: x,
- cory: y
- },
- this.command_id);
+ this.sendAsync("press", {value: element,
+ corx: x,
+ cory: y,
+ command_id: this.command_id});
}
},
/**
* Cancel touch
*
* @param object aRequest
* 'element' represents the ID of the element to touch
@@ -1421,22 +1360,19 @@ MarionetteDriverActor.prototype = {
cancelTouch: function MDA_cancelTouch(aRequest) {
this.command_id = this.getCommandId();
let element = aRequest.element;
let touchId = aRequest.touchId;
if (this.context == "chrome") {
this.sendError("Not in Chrome", 500, null, this.command_id);
}
else {
- this.sendAsync("cancelTouch",
- {
- value: element,
- touchId: touchId
- },
- this.command_id);
+ this.sendAsync("cancelTouch", {value: element,
+ touchId: touchId,
+ command_id: this.command_id});
}
},
/**
* End touch
*
* @param object aRequest
* 'element' represents the ID of the element to end the touch
@@ -1446,45 +1382,39 @@ MarionetteDriverActor.prototype = {
let element = aRequest.element;
let touchId = aRequest.touchId;
let x = aRequest.x;
let y = aRequest.y;
if (this.context == "chrome") {
this.sendError("Not in Chrome", 500, null, this.command_id);
}
else {
- this.sendAsync("release",
- {
- value: element,
- touchId: touchId,
- corx: x,
- cory: y
- },
- this.command_id);
+ this.sendAsync("release", {value: element,
+ touchId: touchId,
+ corx: x,
+ cory: y,
+ command_id: this.command_id});
}
},
/**
* actionChain
*
* @param object aRequest
* 'value' represents a nested array: inner array represents each event; outer array represents collection of events
*/
actionChain: function MDA_actionChain(aRequest) {
this.command_id = this.getCommandId();
if (this.context == "chrome") {
this.sendError("Not in Chrome", 500, null, this.command_id);
}
else {
- this.sendAsync("actionChain",
- {
- chain: aRequest.chain,
- nextId: aRequest.nextId
- },
- this.command_id);
+ this.sendAsync("actionChain", {chain: aRequest.chain,
+ nextId: aRequest.nextId,
+ command_id: this.command_id});
}
},
/**
* multiAction
*
* @param object aRequest
* 'value' represents a nested array: inner array represents each event;
@@ -1493,22 +1423,19 @@ MarionetteDriverActor.prototype = {
*/
multiAction: function MDA_multiAction(aRequest) {
this.command_id = this.getCommandId();
if (this.context == "chrome") {
this.sendError("Not in Chrome", 500, null, this.command_id);
}
else {
- this.sendAsync("multiAction",
- {
- value: aRequest.value,
- maxlen: aRequest.max_length
- },
- this.command_id);
+ this.sendAsync("multiAction", {value: aRequest.value,
+ maxlen: aRequest.max_length,
+ command_id: this.command_id});
}
},
/**
* Find an element using the indicated search strategy.
*
* @param object aRequest
* 'using' member indicates which search method to use
@@ -1530,23 +1457,20 @@ MarionetteDriverActor.prototype = {
command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
return;
}
}
else {
- this.sendAsync("findElementContent",
- {
- value: aRequest.value,
- using: aRequest.using,
- element: aRequest.element
- },
- command_id);
+ this.sendAsync("findElementContent", {value: aRequest.value,
+ using: aRequest.using,
+ element: aRequest.element,
+ command_id: command_id});
}
},
/**
* Find elements using the indicated search strategy.
*
* @param object aRequest
* 'using' member indicates which search method to use
@@ -1567,32 +1491,29 @@ MarionetteDriverActor.prototype = {
command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
return;
}
}
else {
- this.sendAsync("findElementsContent",
- {
- value: aRequest.value,
- using: aRequest.using,
- element: aRequest.element
- },
- command_id);
+ this.sendAsync("findElementsContent", {value: aRequest.value,
+ using: aRequest.using,
+ element: aRequest.element,
+ command_id: command_id});
}
},
/**
* Return the active element on the page
*/
getActiveElement: function MDA_getActiveElement(){
let command_id = this.command_id = this.getCommandId();
- this.sendAsync("getActiveElement", {}, command_id);
+ this.sendAsync("getActiveElement", {command_id: command_id});
},
/**
* Send click event to element
*
* @param object aRequest
* 'element' member holds the reference id to
* the element that will be clicked
@@ -1619,19 +1540,18 @@ MarionetteDriverActor.prototype = {
let curWindow = this.getCurrentWindow();
let self = this;
this.mozBrowserClose = function() {
curWindow.removeEventListener('mozbrowserclose', self.mozBrowserClose, true);
self.switchToGlobalMessageManager();
self.sendError("The frame closed during the click, recovering to allow further communications", 500, null, command_id);
};
curWindow.addEventListener('mozbrowserclose', this.mozBrowserClose, true);
- this.sendAsync("clickElement",
- { element: aRequest.element },
- command_id);
+ this.sendAsync("clickElement", {element: aRequest.element,
+ command_id: command_id});
}
},
/**
* Get a given attribute of an element
*
* @param object aRequest
* 'element' member holds the reference id to
@@ -1647,22 +1567,19 @@ MarionetteDriverActor.prototype = {
this.sendResponse(utils.getElementAttribute(el, aRequest.name),
command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
}
}
else {
- this.sendAsync("getElementAttribute",
- {
- element: aRequest.element,
- name: aRequest.name
- },
- command_id);
+ this.sendAsync("getElementAttribute", {element: aRequest.element,
+ name: aRequest.name,
+ command_id: command_id});
}
},
/**
* Get the text of an element, if any. Includes the text of all child elements.
*
* @param object aRequest
* 'element' member holds the reference id to
@@ -1680,19 +1597,18 @@ MarionetteDriverActor.prototype = {
lines = lines.join("\n");
this.sendResponse(lines, command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
}
}
else {
- this.sendAsync("getElementText",
- { element: aRequest.element },
- command_id);
+ this.sendAsync("getElementText", {element: aRequest.element,
+ command_id: command_id});
}
},
/**
* Get the tag name of the element.
*
* @param object aRequest
* 'element' member holds the reference id to
@@ -1706,19 +1622,18 @@ MarionetteDriverActor.prototype = {
aRequest.element, this.getCurrentWindow());
this.sendResponse(el.tagName.toLowerCase(), command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
}
}
else {
- this.sendAsync("getElementTagName",
- { element: aRequest.element },
- command_id);
+ this.sendAsync("getElementTagName", {element: aRequest.element,
+ command_id: command_id});
}
},
/**
* Check if element is displayed
*
* @param object aRequest
* 'element' member holds the reference id to
@@ -1732,19 +1647,18 @@ MarionetteDriverActor.prototype = {
aRequest.element, this.getCurrentWindow());
this.sendResponse(utils.isElementDisplayed(el), command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
}
}
else {
- this.sendAsync("isElementDisplayed",
- { element:aRequest.element },
- command_id);
+ this.sendAsync("isElementDisplayed", {element:aRequest.element,
+ command_id: command_id});
}
},
/**
* Check if element is enabled
*
* @param object aRequest
* 'element' member holds the reference id to
@@ -1764,19 +1678,18 @@ MarionetteDriverActor.prototype = {
this.sendResponse(true, command_id);
}
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
}
}
else {
- this.sendAsync("isElementEnabled",
- { element:aRequest.element },
- command_id);
+ this.sendAsync("isElementEnabled", {element:aRequest.element,
+ command_id: command_id});
}
},
/**
* Check if element is selected
*
* @param object aRequest
* 'element' member holds the reference id to
@@ -1799,19 +1712,18 @@ MarionetteDriverActor.prototype = {
this.sendResponse(true, command_id);
}
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
}
}
else {
- this.sendAsync("isElementSelected",
- { element:aRequest.element },
- command_id);
+ this.sendAsync("isElementSelected", {element:aRequest.element,
+ command_id: command_id});
}
},
getElementSize: function MDA_getElementSize(aRequest) {
let command_id = this.command_id = this.getCommandId();
if (this.context == "chrome") {
try {
let el = this.curBrowser.elementManager.getKnownElement(
@@ -1820,19 +1732,18 @@ MarionetteDriverActor.prototype = {
this.sendResponse({width: clientRect.width, height: clientRect.height},
command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
}
}
else {
- this.sendAsync("getElementSize",
- { element:aRequest.element },
- command_id);
+ this.sendAsync("getElementSize", {element:aRequest.element,
+ command_id: command_id});
}
},
/**
* Send key presses to element after focusing on it
*
* @param object aRequest
* 'element' member holds the reference id to
@@ -1849,37 +1760,33 @@ MarionetteDriverActor.prototype = {
utils.sendString(aRequest.value.join(""), utils.window);
this.sendOk(command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
}
}
else {
- this.sendAsync("sendKeysToElement",
- {
- element:aRequest.element,
- value: aRequest.value
- },
- command_id);
+ this.sendAsync("sendKeysToElement", {element:aRequest.element,
+ value: aRequest.value,
+ command_id: command_id});
}
},
/**
* Sets the test name
*
* The test name is used in logging messages.
*/
setTestName: function MDA_setTestName(aRequest) {
this.command_id = this.getCommandId();
this.logRequest("setTestName", aRequest);
this.testName = aRequest.value;
- this.sendAsync("setTestName",
- { value: aRequest.value },
- this.command_id);
+ this.sendAsync("setTestName", {value: aRequest.value,
+ command_id: this.command_id});
},
/**
* Clear the text of an element
*
* @param object aRequest
* 'element' member holds the reference id to
* the element that will be cleared
@@ -1899,63 +1806,59 @@ MarionetteDriverActor.prototype = {
}
this.sendOk(command_id);
}
catch (e) {
this.sendError(e.message, e.code, e.stack, command_id);
}
}
else {
- this.sendAsync("clearElement",
- { element:aRequest.element },
- command_id);
+ this.sendAsync("clearElement", {element:aRequest.element,
+ command_id: command_id});
}
},
getElementPosition: function MDA_getElementPosition(aRequest) {
this.command_id = this.getCommandId();
- this.sendAsync("getElementPosition",
- { element:aRequest.element },
- this.command_id);
+ this.sendAsync("getElementPosition", {element:aRequest.element,
+ command_id: this.command_id});
},
/**
* Add a cookie to the document.
*/
addCookie: function MDA_addCookie(aRequest) {
this.command_id = this.getCommandId();
- this.sendAsync("addCookie",
- { cookie:aRequest.cookie },
- command_id);
+ this.sendAsync("addCookie", {cookie:aRequest.cookie,
+ command_id: this.command_id});
},
/**
* Get all visible cookies for a document
*/
getAllCookies: function MDA_getAllCookies() {
this.command_id = this.getCommandId();
- this.sendAsync("getAllCookies", {}, this.command_id);
+ this.sendAsync("getAllCookies", {command_id: this.command_id});
},
/**
* Delete all cookies that are visible to a document
*/
deleteAllCookies: function MDA_deleteAllCookies() {
this.command_id = this.getCommandId();
- this.sendAsync("deleteAllCookies", {}, this.command_id);
+ this.sendAsync("deleteAllCookies", {command_id: this.command_id});
},
/**
* Delete a cookie by name
*/
deleteCookie: function MDA_deleteCookie(aRequest) {
this.command_id = this.getCommandId();
- this.sendAsync("deleteCookie",
- { name:aRequest.name },
- this.command_id);
+ this.sendAsync("deleteCookie", {name:aRequest.name,
+ command_id: this.command_id});
},
/**
* Closes the Browser Window.
*
* If it is B2G it returns straight away and does not do anything
*
* If is desktop it calculates how many windows are open and if there is only
@@ -2044,17 +1947,17 @@ MarionetteDriverActor.prototype = {
}
},
/**
* Returns the current status of the Application Cache
*/
getAppCacheStatus: function MDA_getAppCacheStatus(aRequest) {
this.command_id = this.getCommandId();
- this.sendAsync("getAppCacheStatus", {}, this.command_id);
+ this.sendAsync("getAppCacheStatus", {command_id: this.command_id});
},
_emu_cb_id: 0,
_emu_cbs: null,
runEmulatorCmd: function runEmulatorCmd(cmd, callback) {
if (callback) {
if (!this._emu_cbs) {
this._emu_cbs = {};
@@ -2062,17 +1965,17 @@ MarionetteDriverActor.prototype = {
this._emu_cbs[this._emu_cb_id] = callback;
}
this.sendToClient({emulator_cmd: cmd, id: this._emu_cb_id}, -1);
this._emu_cb_id += 1;
},
emulatorCmdResult: function emulatorCmdResult(message) {
if (this.context != "chrome") {
- this.sendAsync("emulatorCmdResult", message, -1);
+ this.sendAsync("emulatorCmdResult", message);
return;
}
if (!this._emu_cbs) {
return;
}
let cb = this._emu_cbs[message.id];
@@ -2105,34 +2008,30 @@ MarionetteDriverActor.prototype = {
FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE);
this.importedScripts.permissions = parseInt("0666", 8); //actually set permissions
}
file.write(aRequest.script, aRequest.script.length);
file.close();
this.sendOk(command_id);
}
else {
- this.sendAsync("importScript",
- { script: aRequest.script },
- command_id);
+ this.sendAsync("importScript", {script: aRequest.script,
+ command_id: command_id});
}
},
/**
* Takes a screenshot of a DOM node. If there is no node given a screenshot
* of the window will be taken.
*/
screenShot: function MDA_saveScreenshot(aRequest) {
this.command_id = this.getCommandId();
- this.sendAsync("screenShot",
- {
- element: aRequest.element,
- highlights: aRequest.highlights
- },
- this.command_id);
+ this.sendAsync("screenShot", {element: aRequest.element,
+ highlights: aRequest.highlights,
+ command_id: this.command_id});
},
/**
* Helper function to convert an outerWindowID into a UID that Marionette
* tracks.
*/
generateFrameId: function MDA_generateFrameId(id) {
let uid = id + (appName == "B2G" ? "-b2g" : "");
@@ -2226,43 +2125,38 @@ MarionetteDriverActor.prototype = {
// independent window list. So, it will either be null (!listenerWindow)
// or it will point to some random window, which will hopefully
// cause an href mistmach. Currently this only happens
// in B2G for OOP frames registered in Marionette:switchToFrame, so
// we'll acknowledge the switchToFrame message here.
// XXX: Should have a better way of determining that this message
// is from a remote frame.
this.currentRemoteFrame.targetFrameId = this.generateFrameId(message.json.value);
- this.sendAsync("setState",
- {
- scriptTimeout: this.scriptTimeout,
- searchTimeout: this.curBrowser.elementManager.searchTimeout
- },
- this.currentRemoteFrame.command_id);
+ this.sendAsync(
+ "setState",
+ {scriptTimeout: this.scriptTimeout,
+ searchTimeout: this.curBrowser.elementManager.searchTimeout,
+ command_id: this.currentRemoteFrame.command_id});
}
let browserType;
try {
browserType = message.target.getAttribute("type");
} catch (ex) {
// browserType remains undefined.
}
let reg = {};
if (!browserType || browserType != "content") {
reg.id = this.curBrowser.register(this.generateFrameId(message.json.value),
message.json.href);
}
this.curBrowser.elementManager.seenItems[reg.id] = listenerWindow; //add to seenItems
reg.importedScripts = this.importedScripts.path;
if (nullPrevious && (this.curBrowser.curFrameId != null)) {
- if (!this.sendAsync("newSession",
- { B2G: (appName == "B2G") },
- this.newSessionCommandId)) {
- return;
- }
+ this.sendAsync("newSession", {B2G: (appName == "B2G")});
if (this.curBrowser.newSession) {
this.sendResponse(reg.id, this.newSessionCommandId);
this.newSessionCommandId = null;
}
}
return reg;
}
}