Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
67
gaia/tests/jsmarionette/client/marionette-client/lib/marionette/message.js
Executable file
67
gaia/tests/jsmarionette/client/marionette-client/lib/marionette/message.js
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
/* 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/. */
|
||||
|
||||
'use strict';
|
||||
|
||||
function Command(body) {
|
||||
this.id = null;
|
||||
this.name = body.name;
|
||||
this.params = body.parameters || {};
|
||||
}
|
||||
|
||||
Command.prototype.toString = function() {
|
||||
return 'Command ' + JSON.stringify({
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
params: this.params
|
||||
});
|
||||
};
|
||||
|
||||
Command.prototype.toMsg = function() {
|
||||
if (!this.id) {
|
||||
throw new RangeError('Command ID must be specified');
|
||||
}
|
||||
return [Command.TYPE, this.id, this.name, this.params];
|
||||
};
|
||||
|
||||
Command.fromMsg = function(msg) {
|
||||
return new Command(msg[1], msg[2], msg[3]);
|
||||
};
|
||||
|
||||
Command.TYPE = 0;
|
||||
|
||||
function Response(msgId, obj) {
|
||||
this.id = msgId;
|
||||
this.error = null;
|
||||
this.result = null;
|
||||
|
||||
if (obj instanceof Error) {
|
||||
this.error = obj;
|
||||
} else {
|
||||
this.result = obj;
|
||||
}
|
||||
}
|
||||
|
||||
Response.prototype.toString = function() {
|
||||
return 'Response ' + JSON.stringify({
|
||||
id: this.id,
|
||||
error: this.error,
|
||||
result: this.result
|
||||
});
|
||||
};
|
||||
|
||||
Response.prototype.toMsg = function() {
|
||||
return [Response.TYPE, this.id, this.error, this.result];
|
||||
};
|
||||
|
||||
Response.fromMsg = function(msg) {
|
||||
return new Response(msg[1], msg[2] || msg[3]);
|
||||
};
|
||||
|
||||
Response.TYPE = 1;
|
||||
|
||||
module.exports = {
|
||||
Command: Command,
|
||||
Response: Response,
|
||||
};
|
||||
Loading…
Reference in a new issue