зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1337743 - Command parameters may be null; r=whimboo
The fourth element of the command packet may be null and for that to hit our default type check in message.Command's constructor we need to interpret null as undefined. This allows us to receive packets such as [<number>, <number>, <string>, <null or value>] MozReview-Commit-ID: EcAmsPAzz5p --HG-- extra : rebase_source : c3613c85a4b5383d2894d9b102eee16c02935236
This commit is contained in:
Родитель
0a3aacab95
Коммит
10153d5028
|
@ -98,8 +98,8 @@ Message.fromMsg = function (data) {
|
|||
* Command parameters.
|
||||
*/
|
||||
this.Command = class {
|
||||
constructor(msgId, name, params={}) {
|
||||
this.id = msgId;
|
||||
constructor(msgID, name, params = {}) {
|
||||
this.id = msgID;
|
||||
this.name = name;
|
||||
this.parameters = params;
|
||||
|
||||
|
@ -133,11 +133,18 @@ this.Command = class {
|
|||
toString() {
|
||||
return "Command {id: " + this.id + ", " +
|
||||
"name: " + JSON.stringify(this.name) + ", " +
|
||||
"parameters: " + JSON.stringify(this.parameters) + "}"
|
||||
"parameters: " + JSON.stringify(this.parameters) + "}";
|
||||
}
|
||||
|
||||
static fromMsg(msg) {
|
||||
return new Command(msg[1], msg[2], msg[3]);
|
||||
let [msgID, name, params] = [msg[1], msg[2], msg[3]];
|
||||
|
||||
// if parameters are given but null, treat them as undefined
|
||||
if (params === null) {
|
||||
params = undefined;
|
||||
}
|
||||
|
||||
return new Command(msgID, name, params);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче