Backed out changeset 664a2230e5c7 (bug 843793) because of Marionette test failures

Landed on a CLOSED TREE
This commit is contained in:
Ehsan Akhgari 2013-04-08 18:49:33 -04:00
parent dd2b8fecee
commit e9b9bebd68
3 changed files with 119 additions and 236 deletions

View File

@ -28,8 +28,6 @@ class ErrorCodes(object):
INVALID_XPATH_SELECTOR = 51
INVALID_XPATH_SELECTOR_RETURN_TYPER = 52
INVALID_RESPONSE = 53
FRAME_SEND_NOT_INITIALIZED_ERROR = 54
FRAME_SEND_FAILURE_ERROR = 55
MARIONETTE_ERROR = 500
class MarionetteException(Exception):
@ -102,8 +100,3 @@ class InvalidSelectorException(MarionetteException):
class MoveTargetOutOfBoundsException(MarionetteException):
pass
class FrameSendNotInitializedError(MarionetteException):
pass
class FrameSendFailureError(MarionetteException):
pass

View File

@ -372,11 +372,7 @@ class Marionette(object):
or status == ErrorCodes.INVALID_XPATH_SELECTOR_RETURN_TYPER:
raise InvalidSelectorException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.MOVE_TARGET_OUT_OF_BOUNDS:
raise MoveTargetOutOfBoundsException(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.FRAME_SEND_NOT_INITIALIZED_ERROR:
raise FrameSendNotInitializedError(message=message, status=status, stacktrace=stacktrace)
elif status == ErrorCodes.FRAME_SEND_FAILURE_ERROR:
raise FrameSendFailureError(message=message, status=status, stacktrace=stacktrace)
MoveTargetOutOfBoundsException(message=message, status=status, stacktrace=stacktrace)
else:
raise MarionetteException(message=message, status=status, stacktrace=stacktrace)
raise MarionetteException(message=response, status=500)

View File

@ -132,27 +132,6 @@ function MarionetteRemoteFrame(windowId, frameId) {
// 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
@ -206,7 +185,11 @@ MarionetteDriverActor.prototype = {
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;
@ -220,40 +203,15 @@ MarionetteDriverActor.prototype = {
* @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;
},
/**
@ -788,15 +746,12 @@ MarionetteDriverActor.prototype = {
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;
}
@ -879,16 +834,13 @@ MarionetteDriverActor.prototype = {
}
}
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 });
}
},
@ -918,16 +870,13 @@ MarionetteDriverActor.prototype = {
}
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;
}
@ -1027,7 +976,7 @@ MarionetteDriverActor.prototype = {
if (this.context != "chrome") {
aRequest.command_id = command_id;
aRequest.pageTimeout = this.pageTimeout;
this.sendAsync("goUrl", aRequest, command_id);
this.sendAsync("goUrl", aRequest);
return;
}
@ -1064,7 +1013,7 @@ MarionetteDriverActor.prototype = {
this.sendResponse(this.getCurrentWindow().location.href, this.command_id);
}
else {
this.sendAsync("getUrl", {}, this.command_id);
this.sendAsync("getUrl", {command_id: this.command_id});
}
},
@ -1073,7 +1022,7 @@ MarionetteDriverActor.prototype = {
*/
getTitle: function MDA_getTitle() {
this.command_id = this.getCommandId();
this.sendAsync("getTitle", {}, this.command_id);
this.sendAsync("getTitle", {command_id: this.command_id});
},
/**
@ -1088,7 +1037,7 @@ MarionetteDriverActor.prototype = {
this.sendResponse(pageSource, this.command_id);
}
else {
this.sendAsync("getPageSource", {}, this.command_id);
this.sendAsync("getPageSource", {command_id: this.command_id});
}
},
@ -1097,7 +1046,7 @@ MarionetteDriverActor.prototype = {
*/
goBack: function MDA_goBack() {
this.command_id = this.getCommandId();
this.sendAsync("goBack", {}, this.command_id);
this.sendAsync("goBack", {command_id: this.command_id});
},
/**
@ -1105,7 +1054,7 @@ MarionetteDriverActor.prototype = {
*/
goForward: function MDA_goForward() {
this.command_id = this.getCommandId();
this.sendAsync("goForward", {}, this.command_id);
this.sendAsync("goForward", {command_id: this.command_id});
},
/**
@ -1113,7 +1062,7 @@ MarionetteDriverActor.prototype = {
*/
refresh: function MDA_refresh() {
this.command_id = this.getCommandId();
this.sendAsync("refresh", {}, this.command_id);
this.sendAsync("refresh", {command_id: this.command_id});
},
/**
@ -1278,7 +1227,7 @@ MarionetteDriverActor.prototype = {
this.switchToGlobalMessageManager();
}
aRequest.command_id = command_id;
this.sendAsync("switchToFrame", aRequest, command_id);
this.sendAsync("switchToFrame", aRequest);
}
},
@ -1300,9 +1249,8 @@ MarionetteDriverActor.prototype = {
}
}
else {
this.sendAsync("setSearchTimeout",
{ value: aRequest.value },
this.command_id);
this.sendAsync("setSearchTimeout", {value: aRequest.value,
command_id: this.command_id});
}
},
@ -1352,13 +1300,10 @@ MarionetteDriverActor.prototype = {
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});
}
},
@ -1377,13 +1322,10 @@ MarionetteDriverActor.prototype = {
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});
}
},
@ -1402,13 +1344,10 @@ MarionetteDriverActor.prototype = {
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});
}
},
@ -1426,12 +1365,9 @@ MarionetteDriverActor.prototype = {
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});
}
},
@ -1451,14 +1387,11 @@ MarionetteDriverActor.prototype = {
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});
}
},
@ -1474,12 +1407,9 @@ MarionetteDriverActor.prototype = {
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});
}
},
@ -1498,12 +1428,9 @@ MarionetteDriverActor.prototype = {
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});
}
},
@ -1535,13 +1462,10 @@ MarionetteDriverActor.prototype = {
}
}
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});
}
},
@ -1572,13 +1496,10 @@ MarionetteDriverActor.prototype = {
}
}
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});
}
},
@ -1587,7 +1508,7 @@ MarionetteDriverActor.prototype = {
*/
getActiveElement: function MDA_getActiveElement(){
let command_id = this.command_id = this.getCommandId();
this.sendAsync("getActiveElement", {}, command_id);
this.sendAsync("getActiveElement", {command_id: command_id});
},
/**
@ -1624,9 +1545,8 @@ MarionetteDriverActor.prototype = {
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});
}
},
@ -1652,12 +1572,9 @@ MarionetteDriverActor.prototype = {
}
}
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});
}
},
@ -1685,9 +1602,8 @@ MarionetteDriverActor.prototype = {
}
}
else {
this.sendAsync("getElementText",
{ element: aRequest.element },
command_id);
this.sendAsync("getElementText", {element: aRequest.element,
command_id: command_id});
}
},
@ -1711,9 +1627,8 @@ MarionetteDriverActor.prototype = {
}
}
else {
this.sendAsync("getElementTagName",
{ element: aRequest.element },
command_id);
this.sendAsync("getElementTagName", {element: aRequest.element,
command_id: command_id});
}
},
@ -1737,9 +1652,8 @@ MarionetteDriverActor.prototype = {
}
}
else {
this.sendAsync("isElementDisplayed",
{ element:aRequest.element },
command_id);
this.sendAsync("isElementDisplayed", {element:aRequest.element,
command_id: command_id});
}
},
@ -1769,9 +1683,8 @@ MarionetteDriverActor.prototype = {
}
}
else {
this.sendAsync("isElementEnabled",
{ element:aRequest.element },
command_id);
this.sendAsync("isElementEnabled", {element:aRequest.element,
command_id: command_id});
}
},
@ -1804,9 +1717,8 @@ MarionetteDriverActor.prototype = {
}
}
else {
this.sendAsync("isElementSelected",
{ element:aRequest.element },
command_id);
this.sendAsync("isElementSelected", {element:aRequest.element,
command_id: command_id});
}
},
@ -1825,9 +1737,8 @@ MarionetteDriverActor.prototype = {
}
}
else {
this.sendAsync("getElementSize",
{ element:aRequest.element },
command_id);
this.sendAsync("getElementSize", {element:aRequest.element,
command_id: command_id});
}
},
@ -1854,12 +1765,9 @@ MarionetteDriverActor.prototype = {
}
}
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});
}
},
@ -1872,9 +1780,8 @@ MarionetteDriverActor.prototype = {
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});
},
/**
@ -1904,17 +1811,15 @@ MarionetteDriverActor.prototype = {
}
}
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});
},
/**
@ -1922,9 +1827,8 @@ MarionetteDriverActor.prototype = {
*/
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});
},
/**
@ -1932,7 +1836,7 @@ MarionetteDriverActor.prototype = {
*/
getAllCookies: function MDA_getAllCookies() {
this.command_id = this.getCommandId();
this.sendAsync("getAllCookies", {}, this.command_id);
this.sendAsync("getAllCookies", {command_id: this.command_id});
},
/**
@ -1940,7 +1844,7 @@ MarionetteDriverActor.prototype = {
*/
deleteAllCookies: function MDA_deleteAllCookies() {
this.command_id = this.getCommandId();
this.sendAsync("deleteAllCookies", {}, this.command_id);
this.sendAsync("deleteAllCookies", {command_id: this.command_id});
},
/**
@ -1948,9 +1852,8 @@ MarionetteDriverActor.prototype = {
*/
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});
},
/**
@ -2049,7 +1952,7 @@ MarionetteDriverActor.prototype = {
*/
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,
@ -2067,7 +1970,7 @@ MarionetteDriverActor.prototype = {
emulatorCmdResult: function emulatorCmdResult(message) {
if (this.context != "chrome") {
this.sendAsync("emulatorCmdResult", message, -1);
this.sendAsync("emulatorCmdResult", message);
return;
}
@ -2110,9 +2013,8 @@ MarionetteDriverActor.prototype = {
this.sendOk(command_id);
}
else {
this.sendAsync("importScript",
{ script: aRequest.script },
command_id);
this.sendAsync("importScript", {script: aRequest.script,
command_id: command_id});
}
},
@ -2122,12 +2024,9 @@ MarionetteDriverActor.prototype = {
*/
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});
},
/**
@ -2231,12 +2130,11 @@ MarionetteDriverActor.prototype = {
// 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;
@ -2253,11 +2151,7 @@ MarionetteDriverActor.prototype = {
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;