Bug 1403577 - Rename TYPE identifier to Type. r?whimboo
MozReview-Commit-ID: KqN7GPnI288
--- a/testing/marionette/message.js
+++ b/testing/marionette/message.js
@@ -44,20 +44,20 @@ class Message {
*
* @throws {TypeError}
* If the message type is not recognised.
*/
static fromPacket(data) {
const [type] = data;
switch (type) {
- case Command.TYPE:
+ case Command.Type:
return Command.fromPacket(data);
- case Response.TYPE:
+ case Response.Type:
return Response.fromPacket(data);
default:
throw new TypeError(
"Unrecognised message type in packet: " + JSON.stringify(data));
}
}
}
@@ -152,17 +152,17 @@ class Command extends Message {
/**
* Encodes the command to a packet.
*
* @return {Array}
* Packet.
*/
toPacket() {
return [
- Command.TYPE,
+ Command.Type,
this.id,
this.name,
this.parameters,
];
}
/**
* Converts a data packet into {@link Command}.
@@ -174,27 +174,27 @@ class Command extends Message {
* @return {Command}
* Representation of packet.
*
* @throws {TypeError}
* If the message type is not recognised.
*/
static fromPacket(payload) {
let [type, msgID, name, params] = payload;
- assert.that(n => n === Command.TYPE)(type);
+ assert.that(n => n === Command.Type)(type);
// if parameters are given but null, treat them as undefined
if (params === null) {
params = undefined;
}
return new Command(msgID, name, params);
}
}
-Command.TYPE = 0;
+Command.Type = 0;
const validator = {
exclusionary: {
"capabilities": ["error", "value"],
"error": ["value", "sessionId", "capabilities"],
"sessionId": ["error", "value"],
"value": ["error", "sessionId", "capabilities"],
},
@@ -321,17 +321,17 @@ class Response extends Message {
/**
* Encodes the response to a packet.
*
* @return {Array}
* Packet.
*/
toPacket() {
return [
- Response.TYPE,
+ Response.Type,
this.id,
this.error,
this.body,
];
}
/**
* Converts a data packet into {@link Response}.
@@ -343,22 +343,22 @@ class Response extends Message {
* @return {Response}
* Representation of packet.
*
* @throws {TypeError}
* If the message type is not recognised.
*/
static fromPacket(payload) {
let [type, msgID, err, body] = payload;
- assert.that(n => n === Response.TYPE)(type);
+ assert.that(n => n === Response.Type)(type);
let resp = new Response(msgID);
resp.error = assert.string(err);
resp.body = body;
return resp;
}
}
-Response.TYPE = 1;
+Response.Type = 1;
this.Message = Message;
this.Command = Command;
this.Response = Response;
--- a/testing/marionette/test_message.js
+++ b/testing/marionette/test_message.js
@@ -63,17 +63,17 @@ add_test(function test_Command_onrespons
run_next_test();
});
add_test(function test_Command_ctor() {
let cmd = new Command(42, "bar", {bar: "baz"});
let msg = cmd.toPacket();
- equal(Command.TYPE, msg[0]);
+ 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() {
@@ -100,18 +100,18 @@ add_test(function test_Command_fromPacke
Assert.throws(() => Command.fromPacket([0, 2, "foo", false]));
let nullParams = Command.fromPacket([0, 2, "foo", null]);
equal("[object Object]", Object.prototype.toString.call(nullParams.parameters));
run_next_test();
});
-add_test(function test_Command_TYPE() {
- equal(0, Command.TYPE);
+add_test(function test_Command_Type() {
+ equal(0, Command.Type);
run_next_test();
});
add_test(function test_Response_ctor() {
let handler = () => run_next_test();
let resp = new Response(42, handler);
equal(42, resp.id);
@@ -195,17 +195,17 @@ add_test(function test_Response_sendErro
run_next_test();
});
add_test(function test_Response_toPacket() {
let resp = new Response(42, () => {});
let msg = resp.toPacket();
- equal(Response.TYPE, msg[0]);
+ 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() {
@@ -234,12 +234,12 @@ add_test(function test_Response_fromPack
Assert.throws(() => Response.fromPacket([0, 2, "foo", {}]));
Assert.throws(() => Response.fromPacket([1, null, "foo", {}]));
Assert.throws(() => Response.fromPacket([1, 2, null, {}]));
Response.fromPacket([1, 2, "foo", null]);
run_next_test();
});
-add_test(function test_Response_TYPE() {
- equal(1, Response.TYPE);
+add_test(function test_Response_Type() {
+ equal(1, Response.Type);
run_next_test();
});