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,225 @@
/* global DeviceInteraction, MockDriver, exampleCmds, assert, helper */
'use strict';
suite('marionette/actions', function() {
var driver, subject, client, device,
Actions, Client;
helper.require('actions', function(obj) {
Actions = obj;
});
helper.require('client', function(obj) {
Client = obj;
});
device = new DeviceInteraction(exampleCmds, function() {
return subject;
});
setup(function() {
driver = new MockDriver();
client = new Client(driver);
subject = new Actions(client);
});
suite('initialization', function() {
test('should set client', function() {
assert.strictEqual(subject.client, client);
});
});
suite('.press', function() {
var element, x, y;
setup(function() {
element = { id: '{fake-uuid-root}' };
x = 0;
y = 0;
subject.press(element, x, y);
});
test('should have a press action in the chain', function() {
var pressAction = [['press', element.id, x, y]];
assert.deepEqual(subject.actionChain, pressAction);
});
});
suite('.release', function() {
setup(function() {
subject.release();
});
test('should have a release action in the chain', function() {
var releaseAction = [['release']];
assert.deepEqual(subject.actionChain, releaseAction);
});
});
suite('.move', function() {
var element;
setup(function() {
element = { id: '{fake-uuid-root}' };
subject.move(element);
});
test('should have a move action in the chain', function() {
var moveAction = [['move', element.id]];
assert.deepEqual(subject.actionChain, moveAction);
});
});
suite('.moveByOffset', function() {
var x, y;
setup(function() {
x = 1;
y = 1;
subject.moveByOffset(x, y);
});
test('should have a move by offset action in the chain', function() {
var moveByOffsetAction = [['moveByOffset', x, y]];
assert.deepEqual(subject.actionChain, moveByOffsetAction);
});
});
suite('.wait', function() {
var time;
setup(function() {
time = 1;
subject.wait(time);
});
test('should have a wait action in the chain', function() {
var waitAction = [['wait', time]];
assert.deepEqual(subject.actionChain, waitAction);
});
});
suite('.cancel', function() {
setup(function() {
subject.cancel();
});
test('should have a cancel action in the chain', function() {
var cancelAction = [['cancel']];
assert.deepEqual(subject.actionChain, cancelAction);
});
});
suite('.tap', function() {
var element, x, y;
setup(function() {
element = { id: '{fake-uuid-root}' };
x = 0;
y = 0;
subject.tap(element, x, y);
});
test('should have a tap action in the chain', function() {
var tapAction = [
['press', element.id, x, y],
['release']
];
assert.deepEqual(subject.actionChain, tapAction);
});
});
suite('.doubleTap', function() {
var element, x, y;
setup(function() {
element = { id: '{fake-uuid-root}' };
x = 0;
y = 0;
subject.doubleTap(element, x, y);
});
test('should have a double tap action in the chain', function() {
var doubleTapAction = [
['press', element.id, x, y],
['release'],
['press', element.id, x, y],
['release']
];
assert.deepEqual(subject.actionChain, doubleTapAction);
});
});
suite('.flick', function() {
var element, x1, y1, x2, y2;
setup(function() {
element = { id: '{fake-uuid-root}' };
x1 = 0;
y1 = 0;
x2 = 100;
y2 = 100;
});
function shouldHaveFlickAction() {
var firstAction = ['press', element.id, x1, y1];
var lastAction = ['release'];
var lastActionIndex = subject.actionChain.length - 1;
assert.deepEqual(subject.actionChain[0], firstAction);
for (var i = 1; i < lastActionIndex; i += 2) {
assert.strictEqual(subject.actionChain[i][0], 'moveByOffset');
assert.strictEqual(subject.actionChain[i + 1][0], 'wait');
}
assert.deepEqual(subject.actionChain[lastActionIndex], lastAction);
}
test('should have a flick action in the chain', function() {
subject.flick(element, x1, y1, x2, y2);
shouldHaveFlickAction();
});
test('should have a flick action in the chain ' +
'when the duration param is 300', function() {
var duration = 300;
subject.flick(element, x1, y1, x2, y2, duration);
shouldHaveFlickAction();
});
});
suite('.longPress', function() {
var element, time;
setup(function() {
element = { id: '{fake-uuid-root}' };
time = 1;
subject.longPress(element, time);
});
test('should have a long press action in the chain', function() {
var longPressAction = [
['press', element.id],
['wait', time],
['release']
];
assert.deepEqual(subject.actionChain, longPressAction);
});
});
suite('.perform', function() {
device.
issues('perform').
shouldSend({
name: 'actionChain',
parameters: {
chain: [],
nextId: null
}
}).
serverResponds('value').
callbackReceives('value');
});
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,213 @@
/* global assert, helper */
'use strict';
suite('marionette/command-stream', function() {
var subject, socket,
Responder,
CommandStream;
helper.require('responder', function(obj) {
Responder = obj;
});
helper.require('command-stream', function(obj) {
CommandStream = obj;
});
setup(function() {
socket = new Responder();
subject = new CommandStream(socket);
});
suite('initialization', function() {
test('should save socket', function() {
assert.strictEqual(subject.socket, socket);
});
test('should be an event emitter', function() {
assert.instanceOf(subject.on, Function);
});
});
suite('socket event: data', function() {
var calledWith, data;
setup(function() {
data = {};
subject.on('command', function() {
calledWith = Array.prototype.slice.call(arguments);
});
subject.socket.emit('data', new Buffer(subject.stringify(data)));
});
test('should call add', function() {
assert.deepEqual(calledWith, [data]);
});
});
suite('.stringify', function() {
var command = {works: true},
result;
function shouldStringify() {
test('should return json (n:json)', function() {
var string = JSON.stringify(command);
assert.strictEqual(result, String(string.length) + ':' + string);
});
}
suite('when given an object', function() {
setup(function() {
result = subject.stringify(command);
});
shouldStringify();
});
suite('when given a string', function() {
setup(function() {
command = 'some random string';
result = subject.stringify(command);
});
shouldStringify();
});
});
suite('.send', function() {
var calledWith = [], data = {uniq: true};
function sendsToSocket(fnName) {
setup(function() {
subject.socket[fnName] = function() {
calledWith = Array.prototype.slice.call(arguments);
};
subject.send(data);
});
test('should write to socket', function() {
assert.strictEqual(calledWith[0], subject.stringify(data));
});
}
suite('when using socket.send', function() {
sendsToSocket('send');
});
suite('when using socket.write', function() {
sendsToSocket('write');
test('should write in utf8', function() {
assert.strictEqual(calledWith[1], 'utf8');
});
});
});
suite('.add', function() {
var commands = [],
chunks = {},
commandList = {
success: {'from': 'someX'},
fail: {'from': 'zya'}
};
function add(string, log) {
var buffer = new Buffer(string);
subject.add(buffer);
}
function emitsCommand(name, index) {
index = index || 0;
name = name || 'success';
test('should emit ' + name + ' command at #' + index + '', function() {
assert.deepEqual(commands[index], commandList[name]);
});
}
function hasCommands(number) {
test('should have ' + String(number) + ' of commands', function() {
assert.strictEqual(commands.length, number);
});
}
setup(function() {
commands = [];
Object.keys(commandList).forEach(function(key) {
chunks[key] = subject.stringify(commandList[key]);
});
subject.on(subject.commandEvent, function(response) {
commands.push(response);
});
});
suite('when given the entire command', function() {
setup(function() {
add(chunks.success);
});
emitsCommand('success', 0);
hasCommands(1);
});
suite('when given single command in multiple chunks', function() {
setup(function() {
add(chunks.success.slice(0, 1));
add(chunks.success.slice(1, 2));
add(chunks.success.slice(2));
});
emitsCommand('success', 0);
hasCommands(1);
});
suite('when given multiple commands in two chunks', function() {
setup(function() {
var chunk = chunks.success + chunks.fail,
piece1,
piece2,
half = Math.floor(chunk.length / 2);
piece1 = chunk.slice(0, half);
piece2 = chunk.slice(half);
//sanity check
assert.strictEqual(piece1 + piece2, chunk);
add(piece1);
add(piece2);
});
emitsCommand('success', 0);
emitsCommand('fail', 1);
hasCommands(2);
});
suite('when given both commands in one chunk', function() {
setup(function() {
add(chunks.fail + chunks.success);
});
emitsCommand('fail', 0);
emitsCommand('success', 1);
hasCommands(2);
});
});
});

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);
});
});
});

View file

@ -0,0 +1,283 @@
/* global DeviceInteraction, MockDriver, assert, exampleCmds, helper */
'use strict';
// this is hack to ensure device interactions are loaded
suite('marionette/element', function() {
var driver, subject, client, id, device,
Element, Client;
helper.require('element', function(obj) {
Element = obj;
});
helper.require('client', function(obj) {
Client = obj;
});
id = '{fake-uuid-root}';
function simpleCommand(method, type, response, key) {
suite('.' + method, function() {
device.
issues(method).
shouldSend({
name: type,
parameters: {
id: id
}
}).
serverResponds(response).
callbackReceives(key);
});
}
device = new DeviceInteraction(exampleCmds, function() {
return subject;
});
setup(function() {
driver = new MockDriver();
client = new Client(driver);
subject = new Element(id, client);
});
suite('initialization', function() {
test('should set id', function() {
assert.strictEqual(subject.id, id);
});
test('should set client', function() {
assert.strictEqual(subject.client, client);
});
});
suite('._sendCommand', function() {
device.
issues('_sendCommand', {name: 'test'}).
shouldSend({name: 'test', parameters: {id: id}}).
serverResponds('value').
callbackReceives('value');
});
suite('.findElement', function() {
device.
issues('findElement', '#id').
shouldSend({
name: 'findElement',
parameters: {
value: '#id',
element: id,
using: 'css selector'
}
}).
serverResponds('findElementResponse');
test('should send callback a single element', function() {
var value = device.commandCallback.value;
var resultId = exampleCmds.findElementResponse().value;
assert.instanceOf(value, Element);
assert.strictEqual(value.id, resultId);
});
});
suite('.findElements', function() {
device.
issues('findElements', '#id').
shouldSend({
name: 'findElements',
parameters: {
value: '#id',
element: id,
using: 'css selector'
}
}).
serverResponds('findElementsResponse');
test('should send callback an element instance', function() {
var map = device.commandCallback.value.map(function(el) {
return el.id;
});
assert.deepEqual(map, exampleCmds.findElementsResponse().value);
});
});
suite('.scriptWith', function() {
var calledWith,
fn = function() {},
cb = function() {};
setup(function() {
subject.client.executeScript = function() {
calledWith = arguments;
};
});
test('should call client.executeScript with ' +
'element as argument', function() {
subject.scriptWith(fn);
assert.strictEqual(calledWith[0], fn);
assert.deepEqual(calledWith[1], [
subject
]);
assert.strictEqual(calledWith[2], undefined);
});
test('should call client.executeScript with element ' +
' + callback', function(){
subject.scriptWith(fn, cb);
assert.strictEqual(calledWith[0], fn);
assert.deepEqual(calledWith[1], [
subject
]);
assert.strictEqual(calledWith[2], cb);
});
test('should call client.executeScript with element ' +
' + args + callback', function(){
subject.scriptWith(fn, ['foo', 'bar'], cb);
assert.strictEqual(calledWith[0], fn);
assert.deepEqual(calledWith[1], [
subject, 'foo', 'bar'
]);
assert.strictEqual(calledWith[2], cb);
});
});
suite('.equals', function() {
var equals;
var notEquals;
setup(function() {
equals = new Element(id, client);
notEquals = new Element('___I_AM_TITAN', client);
});
test('equals', function() {
assert.isTrue(subject.equals(equals));
});
test('not equal', function() {
assert.isFalse(subject.equals(notEquals));
});
});
suite('.getAttribute', function() {
var attr = 'name';
device.
issues('getAttribute', attr).
shouldSend({
name: 'getElementAttribute',
parameters: {
name: attr,
id: id
}
}).
serverResponds('value').
callbackReceives('value');
});
suite('.sendKeys', function() {
suite('when given a array', function() {
var input = ['f', 'o', 'o'];
device.
issues('sendKeys', input).
shouldSend({
name: 'sendKeysToElement',
parameters: {
value: input,
id: id
}
}).
serverResponds('ok').
callbackReceives();
});
suite('when given a string', function() {
var msg = 'foo';
device.
issues('sendKeys', msg).
shouldSend({
name: 'sendKeysToElement',
parameters: {
value: [msg],
id: id
}
}).
serverResponds('ok').
callbackReceives();
});
});
suite('.cssProperty', function() {
var property = 'margin';
device.
issues('cssProperty', property).
shouldSend({
name: 'getElementValueOfCssProperty',
parameters: {
propertyName: property,
id: id
}
}).
serverResponds('value').
callbackReceives('value');
});
suite('.tap', function() {
suite('when given the x and y offsets', function() {
var x = 10;
var y = 15;
device.
issues('tap', x, y).
shouldSend({
name: 'singleTap',
parameters: {
x: x,
y: y,
id: id
}
}).
serverResponds('value').
callbackReceives('value');
});
suite('when given the x offset only', function() {
var x = 10;
device.
issues('tap', x).
shouldSend({
name: 'singleTap',
parameters: {
x: x,
id: id
}
}).
serverResponds('value').
callbackReceives('value');
});
suite('when no x and y offsets', function() {
simpleCommand('tap', 'singleTap', 'value');
});
});
simpleCommand('tagName', 'getElementTagName', 'value', 'value');
simpleCommand('click', 'clickElement', 'ok');
simpleCommand('text', 'getElementText', 'value', 'value');
simpleCommand('clear', 'clearElement', 'ok');
simpleCommand('selected', 'isElementSelected', 'value', 'value');
simpleCommand('enabled', 'isElementEnabled', 'value', 'value');
simpleCommand('displayed', 'isElementDisplayed', 'value', 'value');
simpleCommand('size', 'getElementRect', 'value', 'value');
simpleCommand('location', 'getElementRect', 'value', 'value');
simpleCommand('rect', 'getElementRect', 'value', 'value');
});

View file

@ -0,0 +1,80 @@
/* global assert, helper */
'use strict';
suite('marionette/error', function() {
var MarionetteError;
helper.require('error', function(obj) {
MarionetteError = obj;
});
test('should expose .ERRORS', function() {
assert.property(MarionetteError, 'ERRORS');
});
suite('#error', function() {
test('should populate message', function() {
var err = new MarionetteError({}, {message: 'msg'});
assert.property(err, 'message');
assert.include(err.message, 'msg');
});
test('should populate stacktrace', function() {
var trace = 'brie';
var err = new MarionetteError({}, {stacktrace: trace});
assert.property(err, 'stack');
assert.include(err.message, trace);
assert.include(err.stack, trace);
});
test('should populate type', function() {
var err = new MarionetteError({}, {});
assert.property(err, 'type');
});
test('should recognise known error code', function() {
var err = new MarionetteError({}, {error: 'no such element'});
assert.property(err, 'type');
assert.equal(err.type, 'NoSuchElement');
});
test('should fall back to GenericError for unknown error code', function() {
var err = new MarionetteError({}, {error: 'brunost'});
assert.property(err, 'type');
assert.equal(err.type, 'GenericError');
});
test('should support all errors', function() {
for (var s in MarionetteError.ERRORS) {
var err = new MarionetteError({}, {error: s});
assert.strictEqual(err.type, MarionetteError.ERRORS[s]);
assert.include(err.message, MarionetteError.ERRORS[s]);
assert.instanceOf(err, Error);
}
});
test('should contain client', function() {
var client = {};
var result = new MarionetteError(client, {
status: 7777,
message: 'foo',
stack: 'bar'
});
assert.equal(result.client, client);
assert.strictEqual(
result.name,
MarionetteError.ERRORS['webdriver error']
);
});
test('should use GenericError error when unknown error code', function() {
var result = new MarionetteError({}, {error: 'cheese'});
assert.strictEqual(
result.name,
MarionetteError.ERRORS['webdriver error']
);
});
});
});

View file

@ -0,0 +1,32 @@
/* global assert, helper */
'use strict';
suite('marionette/index', function() {
var Index;
suiteSetup(function() {
Index = helper.requireLib('marionette/index');
});
test('should have paths', function() {
assert.instanceOf(Index.Element, Object);
assert.instanceOf(Index.Client, Object);
assert.instanceOf(Index.Drivers, Object);
assert.instanceOf(Index.CommandStream, Object);
assert.instanceOf(Index.Drivers.Abstract, Object);
if (typeof(window) === 'undefined') {
assert.instanceOf(Index.Drivers.Tcp, Object);
} else {
try {
if (typeof(window.navigator.mozTCPSocket) !== 'undefined') {
assert.instanceOf(Index.Drivers.MozTcp, Object);
}
} catch(e) {
}
}
});
});

View file

@ -0,0 +1,57 @@
/* global DeviceInteraction, MockDriver, assert, exampleCmds, helper */
'use strict';
suite('marionette/multi-actions', function() {
var driver, subject, actions, client, device,
MultiActions, Actions, Client;
helper.require('multi-actions', function(obj) {
MultiActions = obj;
});
helper.require('actions', function(obj) {
Actions = obj;
});
helper.require('client', function(obj) {
Client = obj;
});
device = new DeviceInteraction(exampleCmds, function() {
return subject;
});
setup(function() {
driver = new MockDriver();
client = new Client(driver);
actions = new Actions(client);
subject = new MultiActions(client);
});
suite('initialization', function() {
test('should set client', function() {
assert.strictEqual(subject.client, client);
});
});
suite('.add', function() {
setup(function() {
subject.add(actions);
});
test('should have a action chain', function() {
assert.deepEqual(subject.multiActions[0], actions.actionChain);
});
});
suite('.perform', function() {
device.
issues('perform').
shouldSend({
type: 'multiAction',
value: [],
max_length: 0
}).
serverResponds('ok').
callbackReceives();
});
});