Backed out changeset 9947bd361636 (bug 945729) for wpt test failures

This commit is contained in:
Carsten "Tomcat" Book 2015-04-21 16:01:40 +02:00
parent 99c57528e6
commit b741df7041
4 changed files with 37 additions and 17 deletions

View File

@ -56,7 +56,7 @@ this.Response = function(cmdId, okHandler, respHandler, msg, sanitizer) {
this.data = new Map([
["sessionId", msg.sessionId ? msg.sessionId : null],
["status", msg.status ? msg.status : "success"],
["status", msg.status ? msg.status : 0 /* success */],
["value", msg.value ? msg.value : undefined],
]);
};
@ -93,10 +93,10 @@ Response.prototype.send = function() {
/**
* @param {(Error|Object)} err
* The error to send, either an instance of the Error prototype,
* or an object with the properties "message", "status", and "stack".
* or an object with the properties "message", "code", and "stack".
*/
Response.prototype.sendError = function(err) {
this.status = "status" in err ? err.status : new UnknownError().status;
this.status = "code" in err ? err.code : new UnknownError().code;
this.value = error.toJSON(err);
this.send();

View File

@ -124,7 +124,7 @@ Dispatcher.prototype.quitApplication = function(msg) {
if (this.driver.appName != "Firefox") {
this.sendError({
"message": "In app initiated quit only supported on Firefox",
"status": "webdriver error",
"status": 500
}, id);
return;
}

View File

@ -58,25 +58,25 @@ error.toJSON = function(err) {
return {
message: err.message,
stacktrace: err.stack || null,
status: err.status
status: err.code
};
};
/**
* Determines if the given status is successful.
* Determines if the given status code is successful.
*/
error.isSuccess = status => status === "success";
error.isSuccess = code => code === 0;
/**
* Old-style errors are objects that has all of the properties
* "message", "status", and "stack".
* "message", "code", and "stack".
*
* When listener.js starts forwarding real errors by CPOW
* we can remove this.
*/
let isOldStyleError = function(obj) {
return typeof obj == "object" &&
["message", "status", "stack"].every(c => obj.hasOwnProperty(c));
["message", "code", "stack"].every(c => obj.hasOwnProperty(c));
}
/**
@ -146,6 +146,7 @@ this.WebDriverError = function(msg) {
this.name = "WebDriverError";
this.message = msg;
this.status = "webdriver error";
this.code = 500; // overridden
};
WebDriverError.prototype = Object.create(Error.prototype);
@ -153,6 +154,7 @@ this.ElementNotAccessibleError = function(msg) {
WebDriverError.call(this, msg);
this.name = "ElementNotAccessibleError";
this.status = "element not accessible";
this.code = 56;
};
ElementNotAccessibleError.prototype = Object.create(WebDriverError.prototype);
@ -160,6 +162,7 @@ this.ElementNotVisibleError = function(msg) {
WebDriverError.call(this, msg);
this.name = "ElementNotVisibleError";
this.status = "element not visible";
this.code = 11;
};
ElementNotVisibleError.prototype = Object.create(WebDriverError.prototype);
@ -168,6 +171,7 @@ this.FrameSendFailureError = function(frame) {
WebDriverError.call(this, this.message);
this.name = "FrameSendFailureError";
this.status = "frame send failure error";
this.code = 55;
this.frame = frame;
this.errMsg = `${this.message} ${this.frame}; frame not responding.`;
};
@ -178,6 +182,7 @@ this.FrameSendNotInitializedError = function(frame) {
WebDriverError.call(this, this.message);
this.name = "FrameSendNotInitializedError";
this.status = "frame send not initialized error";
this.code = 54;
this.frame = frame;
this.errMsg = `${this.message} ${this.frame}; frame has closed.`;
};
@ -187,6 +192,7 @@ this.IllegalArgumentError = function(msg) {
WebDriverError.call(this, msg);
this.name = "IllegalArgumentError";
this.status = "illegal argument";
this.code = 13; // unknown error
};
IllegalArgumentError.prototype = Object.create(WebDriverError.prototype);
@ -194,6 +200,7 @@ this.InvalidElementStateError = function(msg) {
WebDriverError.call(this, msg);
this.name = "InvalidElementStateError";
this.status = "invalid element state";
this.code = 12;
};
InvalidElementStateError.prototype = Object.create(WebDriverError.prototype);
@ -201,6 +208,7 @@ this.InvalidSelectorError = function(msg) {
WebDriverError.call(this, msg);
this.name = "InvalidSelectorError";
this.status = "invalid selector";
this.code = 32;
};
InvalidSelectorError.prototype = Object.create(WebDriverError.prototype);
@ -255,6 +263,7 @@ this.JavaScriptError = function(err, fnName, file, line, script) {
WebDriverError.call(this, msg);
this.name = "JavaScriptError";
this.status = "javascript error";
this.code = 17;
this.stack = trace;
};
JavaScriptError.prototype = Object.create(WebDriverError.prototype);
@ -263,6 +272,7 @@ this.NoAlertOpenError = function(msg) {
WebDriverError.call(this, msg);
this.name = "NoAlertOpenError";
this.status = "no such alert";
this.code = 27;
}
NoAlertOpenError.prototype = Object.create(WebDriverError.prototype);
@ -270,6 +280,7 @@ this.NoSuchElementError = function(msg) {
WebDriverError.call(this, msg);
this.name = "NoSuchElementError";
this.status = "no such element";
this.code = 7;
};
NoSuchElementError.prototype = Object.create(WebDriverError.prototype);
@ -277,6 +288,7 @@ this.NoSuchFrameError = function(msg) {
WebDriverError.call(this, msg);
this.name = "NoSuchFrameError";
this.status = "no such frame";
this.code = 8;
};
NoSuchFrameError.prototype = Object.create(WebDriverError.prototype);
@ -284,6 +296,7 @@ this.NoSuchWindowError = function(msg) {
WebDriverError.call(this, msg);
this.name = "NoSuchWindowError";
this.status = "no such window";
this.code = 23;
};
NoSuchWindowError.prototype = Object.create(WebDriverError.prototype);
@ -291,6 +304,7 @@ this.ScriptTimeoutError = function(msg) {
WebDriverError.call(this, msg);
this.name = "ScriptTimeoutError";
this.status = "script timeout";
this.code = 28;
};
ScriptTimeoutError.prototype = Object.create(WebDriverError.prototype);
@ -298,6 +312,8 @@ this.SessionNotCreatedError = function(msg) {
WebDriverError.call(this, msg);
this.name = "SessionNotCreatedError";
this.status = "session not created";
// should be 33 to match Selenium
this.code = 71;
};
SessionNotCreatedError.prototype = Object.create(WebDriverError.prototype);
@ -305,6 +321,7 @@ this.StaleElementReferenceError = function(msg) {
WebDriverError.call(this, msg);
this.name = "StaleElementReferenceError";
this.status = "stale element reference";
this.code = 10;
};
StaleElementReferenceError.prototype = Object.create(WebDriverError.prototype);
@ -312,6 +329,7 @@ this.TimeoutError = function(msg) {
WebDriverError.call(this, msg);
this.name = "TimeoutError";
this.status = "timeout";
this.code = 21;
};
TimeoutError.prototype = Object.create(WebDriverError.prototype);
@ -319,6 +337,7 @@ this.UnknownCommandError = function(msg) {
WebDriverError.call(this, msg);
this.name = "UnknownCommandError";
this.status = "unknown command";
this.code = 9;
};
UnknownCommandError.prototype = Object.create(WebDriverError.prototype);
@ -326,6 +345,7 @@ this.UnknownError = function(msg) {
WebDriverError.call(this, msg);
this.name = "UnknownError";
this.status = "unknown error";
this.code = 13;
};
UnknownError.prototype = Object.create(WebDriverError.prototype);
@ -333,5 +353,6 @@ this.UnsupportedOperationError = function(msg) {
WebDriverError.call(this, msg);
this.name = "UnsupportedOperationError";
this.status = "unsupported operation";
this.code = 405;
};
UnsupportedOperationError.prototype = Object.create(WebDriverError.prototype);

View File

@ -522,8 +522,7 @@ function createExecuteContentSandbox(aWindow, timeout) {
inactivityTimeoutId = null;
}
};
sandbox.finish = function() {
sandbox.finish = function sandbox_finish() {
if (asyncTestRunning) {
sandbox.asyncComplete(marionette.generate_results(), sandbox.asyncTestCommandId);
} else {
@ -700,6 +699,11 @@ function executeWithCallback(msg, useFinish) {
}
sandbox.tag = script;
// Error code 28 is scriptTimeout, but spec says execute_async should return 21 (Timeout),
// see http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/execute_async.
// However Selenium code returns 28, see
// http://code.google.com/p/selenium/source/browse/trunk/javascript/firefox-driver/js/evaluate.js.
// We'll stay compatible with the Selenium code.
asyncTestTimeoutId = curFrame.setTimeout(function() {
sandbox.asyncComplete(new ScriptTimeoutError("timed out"), asyncTestCommandId);
}, msg.json.timeout);
@ -1441,7 +1445,7 @@ function isElementDisplayed(msg) {
* the element that will be checked
* 'propertyName' is the CSS rule that is being requested
*/
function getElementValueOfCssProperty(msg) {
function getElementValueOfCssProperty(msg){
let command_id = msg.json.command_id;
let propertyName = msg.json.propertyName;
try {
@ -1613,11 +1617,6 @@ function clearElement(msg) {
}
sendOk(command_id);
} catch (e) {
// Bug 964738: Newer atoms contain status codes which makes wrapping
// this in an error prototype that has a status property unnecessary
if (e.name == "InvalidElementStateError") {
e = new InvalidElementStateError(e.message);
}
sendError(e, command_id);
}
}