Backed out 3 changesets (bug 1239373) for xpcshell bustage on emulator

Backed out changeset 308b5e2bb5df (bug 1239373)
Backed out changeset 783077fc10a2 (bug 1239373)
Backed out changeset 32e6e21daeda (bug 1239373)
This commit is contained in:
Nigel Babu 2016-01-19 13:16:37 +05:30
parent c727b67b98
commit 7e3df13568
4 changed files with 4 additions and 497 deletions

View File

@ -1,8 +1,9 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ["components", "atoms"]
DIRS += ['components', 'atoms']
JAR_MANIFESTS += ["jar.mn"]
XPCSHELL_TESTS_MANIFESTS += ["unit.ini"]
JAR_MANIFESTS += ['jar.mn']

View File

@ -1,278 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const {utils: Cu} = Components;
Cu.import("chrome://marionette/content/error.js");
function run_test() {
run_next_test();
}
function notok(condition) {
ok(!(condition));
}
add_test(function test_isError() {
notok(error.isError(null));
notok(error.isError([]));
notok(error.isError(new Date()));
ok(error.isError(new Components.Exception()));
ok(error.isError(new Error()));
ok(error.isError(new WebDriverError()));
ok(error.isError(new InvalidArgumentError()));
run_next_test();
});
add_test(function test_isWebDriverError() {
notok(error.isWebDriverError(new Components.Exception()));
notok(error.isWebDriverError(new Error()));
ok(error.isWebDriverError(new WebDriverError()));
ok(error.isWebDriverError(new InvalidArgumentError()));
run_next_test();
});
add_test(function test_stringify() {
equal("<unprintable error>", error.stringify());
equal("<unprintable error>", error.stringify("foo"));
equal("[object Object]", error.stringify({}));
equal("[object Object]\nfoo", error.stringify({stack: "foo"}));
equal("Error: foo", error.stringify(new Error("foo")).split("\n")[0]);
equal("WebDriverError: foo",
error.stringify(new WebDriverError("foo")).split("\n")[0]);
equal("InvalidArgumentError: foo",
error.stringify(new InvalidArgumentError("foo")).split("\n")[0]);
run_next_test();
});
add_test(function test_toJson() {
deepEqual({error: "a", message: null, stacktrace: null},
error.toJson({status: "a"}));
deepEqual({error: "a", message: "b", stacktrace: null},
error.toJson({status: "a", message: "b"}));
deepEqual({error: "a", message: "b", stacktrace: "c"},
error.toJson({status: "a", message: "b", stack: "c"}));
let e1 = new Error("b");
deepEqual({error: undefined, message: "b", stacktrace: e1.stack},
error.toJson(e1));
let e2 = new WebDriverError("b");
deepEqual({error: e2.status, message: "b", stacktrace: null},
error.toJson(e2));
run_next_test();
});
add_test(function test_WebDriverError() {
let err = new WebDriverError("foo");
equal("WebDriverError", err.name);
equal("foo", err.message);
equal("webdriver error", err.status);
equal(Error.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_ElementNotAccessibleError() {
let err = new ElementNotAccessibleError("foo");
equal("ElementNotAccessibleError", err.name);
equal("foo", err.message);
equal("element not accessible", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_ElementNotVisibleError() {
let err = new ElementNotVisibleError("foo");
equal("ElementNotVisibleError", err.name);
equal("foo", err.message);
equal("element not visible", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_InvalidArgumentError() {
let err = new InvalidArgumentError("foo");
equal("InvalidArgumentError", err.name);
equal("foo", err.message);
equal("invalid argument", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_InvalidElementStateError() {
let err = new InvalidElementStateError("foo");
equal("InvalidElementStateError", err.name);
equal("foo", err.message);
equal("invalid element state", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_InvalidSelectorError() {
let err = new InvalidSelectorError("foo");
equal("InvalidSelectorError", err.name);
equal("foo", err.message);
equal("invalid selector", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_InvalidSessionIdError() {
let err = new InvalidSessionIdError("foo");
equal("InvalidSessionIdError", err.name);
equal("foo", err.message);
equal("invalid session id", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_JavaScriptError() {
let err = new JavaScriptError("foo");
equal("JavaScriptError", err.name);
equal("foo", err.message);
equal("javascript error", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
equal("undefined", new JavaScriptError(undefined).message);
// TODO(ato): Bug 1240550
//equal("funcname @file", new JavaScriptError("message", "funcname", "file").stack);
equal("funcname @file, line line",
new JavaScriptError("message", "funcname", "file", "line").stack);
// TODO(ato): More exhaustive tests for JS stack computation
run_next_test();
});
add_test(function test_NoAlertOpenError() {
let err = new NoAlertOpenError("foo");
equal("NoAlertOpenError", err.name);
equal("foo", err.message);
equal("no such alert", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_NoSuchElementError() {
let err = new NoSuchElementError("foo");
equal("NoSuchElementError", err.name);
equal("foo", err.message);
equal("no such element", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_NoSuchFrameError() {
let err = new NoSuchFrameError("foo");
equal("NoSuchFrameError", err.name);
equal("foo", err.message);
equal("no such frame", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_NoSuchWindowError() {
let err = new NoSuchWindowError("foo");
equal("NoSuchWindowError", err.name);
equal("foo", err.message);
equal("no such window", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_ScriptTimeoutError() {
let err = new ScriptTimeoutError("foo");
equal("ScriptTimeoutError", err.name);
equal("foo", err.message);
equal("script timeout", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_SessionNotCreatedError() {
let err = new SessionNotCreatedError("foo");
equal("SessionNotCreatedError", err.name);
equal("foo", err.message);
equal("session not created", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_StaleElementReferenceError() {
let err = new StaleElementReferenceError("foo");
equal("StaleElementReferenceError", err.name);
equal("foo", err.message);
equal("stale element reference", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_TimeoutError() {
let err = new TimeoutError("foo");
equal("TimeoutError", err.name);
equal("foo", err.message);
equal("timeout", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_UnableToSetCookieError() {
let err = new UnableToSetCookieError("foo");
equal("UnableToSetCookieError", err.name);
equal("foo", err.message);
equal("unable to set cookie", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_UnknownCommandError() {
let err = new UnknownCommandError("foo");
equal("UnknownCommandError", err.name);
equal("foo", err.message);
equal("unknown command", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_UnknownError() {
let err = new UnknownError("foo");
equal("UnknownError", err.name);
equal("foo", err.message);
equal("unknown error", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});
add_test(function test_UnsupportedOperationError() {
let err = new UnsupportedOperationError("foo");
equal("UnsupportedOperationError", err.name);
equal("foo", err.message);
equal("unsupported operation", err.status);
equal(WebDriverError.prototype.toString(), Object.getPrototypeOf(err).toString());
run_next_test();
});

View File

@ -1,208 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const {utils: Cu} = Components;
Cu.import("chrome://marionette/content/error.js");
Cu.import("chrome://marionette/content/message.js");
function run_test() {
run_next_test();
}
add_test(function test_MessageOrigin() {
equal(0, MessageOrigin.Client);
equal(1, MessageOrigin.Server);
run_next_test();
});
add_test(function test_Message_fromMsg() {
let cmd = new Command(4, "foo");
let resp = new Response(5, () => {});
ok(Message.fromMsg(cmd.toMsg()) instanceof Command);
ok(Message.fromMsg(resp.toMsg()) instanceof Response);
Assert.throws(() => Message.fromMsg([3, 4, 5, 6]),
/Unrecognised message type in packet/);
run_next_test();
});
add_test(function test_Command() {
let cmd = new Command(42, "foo", {bar: "baz"});
equal(42, cmd.id);
equal("foo", cmd.name);
deepEqual({bar: "baz"}, cmd.parameters);
equal(null, cmd.onerror);
equal(null, cmd.onresult);
equal(MessageOrigin.Client, cmd.origin);
equal(false, cmd.sent);
run_next_test();
});
add_test(function test_Command_onresponse() {
let onerrorOk = false;
let onresultOk = false;
let cmd = new Command();
cmd.onerror = () => onerrorOk = true;
cmd.onresult = () => onresultOk = true;
let errorResp = new Response();
errorResp.error = new WebDriverError("foo");
let bodyResp = new Response();
bodyResp.body = "bar";
cmd.onresponse(errorResp);
equal(true, onerrorOk);
equal(false, onresultOk);
cmd.onresponse(bodyResp);
equal(true, onresultOk);
run_next_test();
});
add_test(function test_Command_fromMsg() {
let cmd = new Command(42, "bar", {bar: "baz"});
let msg = cmd.toMsg();
equal(Command.TYPE, msg[0]);
equal(cmd.id, msg[1]);
equal(cmd.name, msg[2]);
equal(cmd.parameters, msg[3]);
run_next_test();
});
add_test(function test_Command_toString() {
let cmd = new Command(42, "foo", {bar: "baz"});
equal(`Command {id: ${cmd.id}, ` +
`name: ${JSON.stringify(cmd.name)}, ` +
`parameters: ${JSON.stringify(cmd.parameters)}}`,
cmd.toString());
run_next_test();
});
add_test(function test_Command_fromMsg() {
let c1 = new Command(42, "foo", {bar: "baz"});
let msg = c1.toMsg();
let c2 = Command.fromMsg(msg);
equal(c1.id, c2.id);
equal(c1.name, c2.name);
equal(c1.parameters, c2.parameters);
run_next_test();
});
add_test(function test_Command_TYPE() {
equal(0, Command.TYPE);
run_next_test();
});
add_test(function test_Response() {
let handler = () => run_next_test();
let resp = new Response(42, handler);
equal(42, resp.id);
equal(null, resp.error);
ok("origin" in resp);
equal(MessageOrigin.Server, resp.origin);
equal(false, resp.sent);
equal(handler, resp.respHandler_);
run_next_test();
});
add_test(function test_Response_sendConditionally() {
let fired = false;
let resp = new Response(42, () => fired = true);
resp.sendConditionally(r => false);
equal(false, resp.sent);
equal(false, fired);
resp.sendConditionally(r => true);
equal(true, resp.sent);
equal(true, fired);
run_next_test();
});
add_test(function test_Response_send() {
let fired = false;
let resp = new Response(42, () => fired = true);
resp.send();
equal(true, resp.sent);
equal(true, fired);
run_next_test();
});
add_test(function test_Response_sendError() {
let err = new WebDriverError();
let resp = new Response(42, r => {
deepEqual(error.toJson(err), r.error);
equal(null, r.body);
equal(false, r.sent);
});
resp.sendError(err);
equal(true, resp.sent);
Assert.throws(() => resp.send(), /already been sent/);
resp.sent = false;
Assert.throws(() => resp.sendError(new Error()));
run_next_test();
});
add_test(function test_Response_toMsg() {
let resp = new Response(42);
let msg = resp.toMsg();
equal(Response.TYPE, msg[0]);
equal(resp.id, msg[1]);
equal(resp.error, msg[2]);
equal(resp.body, msg[3]);
run_next_test();
});
add_test(function test_Response_toString() {
let resp = new Response(42);
resp.error = "foo";
resp.body = "bar";
equal(`Response {id: ${resp.id}, ` +
`error: ${JSON.stringify(resp.error)}, ` +
`body: ${JSON.stringify(resp.body)}}`,
resp.toString());
run_next_test();
});
add_test(function test_Response_fromMsg() {
let r1 = new Response(42);
r1.error = "foo";
r1.body = "bar";
let msg = r1.toMsg();
let r2 = Response.fromMsg(msg);
equal(r1.id, r2.id);
equal(r1.error, r2.error);
equal(r1.body, r2.body);
run_next_test();
});
add_test(function test_Response_TYPE() {
equal(1, Response.TYPE);
run_next_test();
});

View File

@ -1,8 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# xpcshell unit tests for Marionette
[test_error.js]
[test_message.js]