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:
OverSu 2026-09-30 23:13:03 +02:00
commit b38dea0597
25901 changed files with 9982925 additions and 369 deletions

View file

@ -0,0 +1,358 @@
/* global assert, exampleCmds, helper */
'use strict';
suite('marionette/drivers/abstract', function() {
var subject,
Backend,
sent = [];
helper.require('drivers/abstract', function(obj) {
Backend = obj;
});
setup(function() {
subject = new Backend();
sent = [];
subject._sendCommand = function() {
sent.push(arguments);
};
});
suite('initialization', function() {
test('should setup ._sendQueue', function() {
assert.deepEqual(subject._sendQueue, []);
});
test('should not be ready', function() {
assert.strictEqual(subject.ready, false);
});
test('should setup ._responseQueue', function() {
assert.instanceOf(subject._responseQueue, Array);
});
test('should have timeout set to 10000', function() {
assert.strictEqual(subject.timeout, 10000);
});
test('should be _waiting', function() {
assert.strictEqual(subject._waiting, true);
});
});
suite('event: device response', function() {
var callback,
callbackResponse,
response;
setup(function() {
callbackResponse = null;
response = {
id: 10,
response: {
from: 'marionette',
value: 'hit'
}
};
//emulate connect
subject.connectionId = 10;
subject.ready = true;
subject._waiting = false;
callback = function() {
callbackResponse = arguments;
};
subject.send(exampleCmds.newSession(), callback);
assert.strictEqual(subject._waiting, true);
});
suite('when response is for different device', function() {
setup(function() {
subject.connectionId = 101;
subject._onDeviceResponse(response);
});
test('should trigger response callbacks', function() {
assert.strictEqual(callbackResponse, null);
});
});
suite('when response is for device id', function() {
var calledNext;
setup(function() {
calledNext = false;
subject._nextCommand = function() {
calledNext = true;
Backend.prototype._nextCommand.apply(this, arguments);
};
subject._onDeviceResponse(response);
});
test('should trigger response callbacks', function() {
assert.deepEqual(callbackResponse[0], response.response);
});
test('should clear response queue', function() {
assert.strictEqual(subject._responseQueue.length, 0);
});
test('should not be waiting', function() {
assert.strictEqual(subject._waiting, false);
});
});
});
suite('.close', function() {
var calledClose;
setup(function() {
calledClose = false;
subject.ready = true;
subject._responseQueue = [function() {}];
subject._close = function() {
calledClose = true;
};
subject.close();
});
test('should call _close', function() {
assert.strictEqual(calledClose, true);
});
test('should not be ready', function() {
assert.strictEqual(subject.ready, false);
});
test('should clean up _responseQueue', function() {
assert.strictEqual(subject._responseQueue.length, 0);
});
});
suite('.connect with protocol 1', function() {
var cmd, calledChild;
setup(function(done) {
cmd = exampleCmds.connectProto1();
calledChild = false;
subject._connect = function() {
subject.connectionId = 10;
calledChild = true;
//this will cause connect to callback to fire
subject._onDeviceResponse({
id: 10,
response: cmd
});
};
assert.strictEqual(subject._waiting, true);
subject.connect(function() {
done();
});
});
test('should set .marionetteProtocol', function() {
assert.property(subject, 'marionetteProtocol');
assert.strictEqual(subject.marionetteProtocol, 1 /* fallback */);
});
test('should set .applicationType', function() {
assert.property(subject, 'applicationType');
assert.strictEqual(subject.applicationType, cmd.applicationType);
});
test('should set .traits', function() {
assert.property(subject, 'traits');
assert.strictEqual(subject.traits, cmd.traits);
});
test('should call _connect', function() {
assert.strictEqual(calledChild, true);
});
test('should not be waiting', function() {
assert.strictEqual(subject._waiting, false);
});
test('should be ready', function() {
assert.strictEqual(subject.ready, true);
});
});
suite('.connect with protocol 2', function() {
var cmd, calledChild;
setup(function(done) {
cmd = exampleCmds.connectProto2();
calledChild = false;
subject._connect = function() {
subject.connectionId = 10;
calledChild = true;
//this will cause connect to callback to fire
subject._onDeviceResponse({
id: 10,
response: cmd
});
};
assert.strictEqual(subject._waiting, true);
subject.connect(function() {
done();
});
});
test('should set .marionetteProtocol', function() {
assert.property(subject, 'marionetteProtocol');
assert.strictEqual(subject.marionetteProtocol, cmd.marionetteProtocol);
});
test('should set .applicationType', function() {
assert.property(subject, 'applicationType');
assert.strictEqual(subject.applicationType, cmd.applicationType);
});
test('should call _connect', function() {
assert.strictEqual(calledChild, true);
});
test('should not be waiting', function() {
assert.strictEqual(subject._waiting, false);
});
test('should be ready', function() {
assert.strictEqual(subject.ready, true);
});
});
suite('._nextCommand', function() {
var cmd1, cmd2;
setup(function() {
cmd1 = exampleCmds.newSession();
cmd2 = exampleCmds.newSession({isOther: true});
subject._sendQueue[0] = cmd1;
subject._sendQueue[1] = cmd2;
});
suite('when waiting', function() {
setup(function() {
subject._waiting = true;
subject._nextCommand();
});
test('should not send command to server', function() {
assert.strictEqual(sent.length, 0);
});
});
suite('when not waiting', function() {
setup(function() {
subject._waiting = false;
subject._nextCommand();
});
test('should be waiting', function() {
assert.strictEqual(subject._waiting, true);
});
test('should send command to server', function() {
assert.deepEqual(sent[0][0], cmd1);
});
});
suite('when there are no comamnds and we are not waiting', function() {
setup(function() {
//emulate connect
subject._waiting = false;
subject._responseQueue = [];
subject._sendQueue = [];
subject._nextCommand();
});
test('should not be waiting', function() {
assert.strictEqual(subject._waiting, false);
});
});
});
suite('.send', function() {
var cmd, cb = function() {};
setup(function() {
cmd = exampleCmds.newSession();
});
suite('when device is not ready', function() {
test('should throw an error', function() {
assert.throws(function() {
subject.send({ type: 'newSession' });
}, /not ready/);
});
});
suite('when not waiting for a response', function() {
setup(function() {
//emulate connect
subject.ready = true;
subject._waiting = false;
subject.send(cmd, cb);
});
test('should send command', function() {
assert.strictEqual(sent.length, 1);
});
test('should be waiting', function() {
assert.strictEqual(subject._waiting, true);
});
});
suite('when waiting for a response', function() {
var nextCalled;
setup(function() {
subject.ready = true;
subject._waiting = true;
nextCalled = false;
subject._nextCommand = function() {
nextCalled = true;
};
subject.send(cmd, cb);
});
test('should call next', function() {
assert.strictEqual(nextCalled, true);
});
test('should add send command to queue', function() {
assert.strictEqual(subject._sendQueue[0], cmd);
});
test('should add calback to response queue', function() {
assert.strictEqual(subject._responseQueue[0], cb);
});
});
});
});

View file

@ -0,0 +1,33 @@
'use strict';
var debug = require('debug')('marionette:tcp-sync-test-server');
var net = require('net');
var response = '54:{"applicationType": "gecko", "marionetteProtocol": 2}';
var server = net.createServer(function(connection) { //'connection' listener
debug('server connected');
connection.on('end', function() {
debug('server disconnected');
});
connection.on('error', function(e) {
debug('error', e);
});
connection.write(response);
connection.pipe(connection);
});
function runServer(port) {
server.listen(port, function() { //'listening' listener
debug('server bound');
});
}
if (require.main === module) {
try {
runServer(1234);
}
catch(e) {
}
}

View file

@ -0,0 +1,34 @@
'use strict';
var fork = require('child_process').fork;
suite('marionette/drivers/tcp-sync', function() {
var child = null;
teardown(function() {
if (child) {
child.kill();
child = null;
}
});
test('can wait for marionette socket', function(done) {
this.timeout(5000);
var TcpSync =
require(__dirname + '/../../../lib/marionette/drivers/tcp-sync');
var tcpSync = new TcpSync({port: 1234, host: 'localhost'});
tcpSync.waitForSocket( {timeout: 3000} , function() {
done();
});
setTimeout(function () {
fork(__dirname + '/tcp-sync-test-server.js');
}, 1000);
});
});

View file

@ -0,0 +1,155 @@
/* global assert, helper */
'use strict';
suite('marionette/drivers/tcp', function() {
if (typeof(window) !== 'undefined') {
return;
}
var Abstract,
Driver = require('../../../lib/marionette/drivers/tcp'),
FakeSocket = require('../../support/socket');
helper.require(
'marionette/drivers/abstract',
'Marionette.Drivers.Abstract', function(obj) {
Abstract = obj;
}
);
function issueFirstResponse() {
subject._onDeviceResponse({
id: subject.connectionId,
response: {}
});
}
var subject,
RealSocket,
sockets = [];
var socketRetry = require('socket-retry-connect');
var realWaitForSocket;
setup(function() {
realWaitForSocket = socketRetry.waitForSocket;
RealSocket = Driver.Socket;
Driver.Socket = FakeSocket;
FakeSocket.sockets = sockets;
socketRetry.waitForSocket = function(options, callback) {
var socket = new FakeSocket(options.port);
callback(null, socket);
};
});
teardown(function() {
socketRetry.waitForSocket = realWaitForSocket;
Driver.Socket = RealSocket;
});
setup(function() {
subject = new Driver();
});
test('should accept port and host', function() {
var subject = new Driver({
port: 8888,
host: 'foobar'
});
assert.strictEqual(subject.port, 8888);
assert.strictEqual(subject.host, 'foobar');
});
suite('._sendCommand', function() {
var sent = [];
setup(function(done) {
subject.connect(function() {
subject.client.send = function() {
sent.push(arguments);
};
subject.client.send({
type: 'foo',
});
done();
});
// issue first response so connect will fire
issueFirstResponse();
});
test('should send request to socket', function() {
assert.deepEqual(sent, [
[{type: 'foo'}]
]);
});
});
// TODO(gaye): What is going on here / what is emtest()?
suite.skip('client event: command', function() {
var sent = [];
setup(function() {
sent.length = 0;
subject._onDeviceResponse = function() {
sent.push(arguments);
};
subject._connect();
subject.client.emtest('command', { type: 'foo' });
});
test('should call onDeviceResponse', function() {
assert.deepEqual(sent, [
[{ id: 0, response: {type: 'foo'} }]
]);
});
});
suite('._connect', function() {
suite('retrying', function() {
var net = require('net');
var port = 60066;
setup(function() {
Driver.Socket = RealSocket;
socketRetry.waitForSocket = realWaitForSocket;
subject = new Driver({ port: port });
});
test('should eventually connect', function(done) {
subject._connect();
setTimeout(function() {
var server = net.createServer(function(socket) {
server.close();
done();
}).listen(port);
}, 50);
});
});
});
suite('._close', function() {
setup(function(done) {
subject.connect(function() {
subject.close();
done();
});
issueFirstResponse();
});
test('should close socket', function() {
assert.strictEqual(subject.socket.destroyed, true);
});
});
});