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
216
gaia/tests/jsmarionette/plugins/marionette-js-logger/test/client_test.js
Executable file
216
gaia/tests/jsmarionette/plugins/marionette-js-logger/test/client_test.js
Executable file
|
|
@ -0,0 +1,216 @@
|
|||
'use strict';
|
||||
var Server = require('./server_helper/server');
|
||||
var assert = require('assert');
|
||||
var requireGaia = require('./require_gaia');
|
||||
|
||||
var Rocketbar = requireGaia('apps/system/test/marionette/lib/rocketbar');
|
||||
var System = requireGaia('apps/system/test/marionette/lib/system');
|
||||
|
||||
suite('client', function() {
|
||||
var rocketbar, server, system;
|
||||
|
||||
marionette.plugin('logger', require('../'));
|
||||
marionette.plugin('apps', require('marionette-apps'));
|
||||
marionette.plugin('helper', require('marionette-helper'));
|
||||
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
settings: {
|
||||
'ftu.manifestURL': '',
|
||||
'screen.timeout': 0,
|
||||
'lockscreen.enabled': false,
|
||||
'lockscreen.locked': false
|
||||
}
|
||||
},
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
|
||||
/**
|
||||
* Generate a local url
|
||||
*/
|
||||
function localUrl(path) {
|
||||
return 'http://localhost:' + server.port + '/' + path;
|
||||
}
|
||||
|
||||
suiteSetup(function(done) {
|
||||
Server.create(function(err, _server) {
|
||||
server = _server;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
rocketbar = new Rocketbar(client);
|
||||
system = new System(client);
|
||||
system.waitForStartup();
|
||||
});
|
||||
|
||||
suiteTeardown(function() {
|
||||
server.stop();
|
||||
});
|
||||
|
||||
test('console', function() {
|
||||
var gotMessage = false;
|
||||
|
||||
// - Check that waitForLogMessage works against our same chrome context
|
||||
// This also exercises grabAtLeastOneNewMessage
|
||||
client.logger.on('message', function(msg) {
|
||||
if (msg.message.indexOf('foobar!') !== -1) {
|
||||
gotMessage = true;
|
||||
}
|
||||
});
|
||||
|
||||
// NOTE! There is up to a 15ms delay before this log message will actually
|
||||
// be logged.
|
||||
client.executeScript(function() {
|
||||
console.log('foobar!', { 'muy thing': true });
|
||||
});
|
||||
client.logger.waitForLogMessage(function(msg) {
|
||||
return (msg.message.indexOf('foobar!') !== -1);
|
||||
});
|
||||
|
||||
assert(gotMessage);
|
||||
|
||||
// - Now check that our synchronous grabLogMessages works too
|
||||
gotMessage = false;
|
||||
|
||||
// make sure the message didn't get stuck in the system so that we keep
|
||||
// seeing it over and over!
|
||||
client.logger.grabLogMessages();
|
||||
assert(!gotMessage);
|
||||
|
||||
// log it again...
|
||||
client.executeScript(function() {
|
||||
console.log('foobar!', { 'moo thing': true });
|
||||
});
|
||||
// and wait long enough for the Firefox 15ms batching to have definitely
|
||||
// expired.
|
||||
client.helper.wait(30);
|
||||
client.logger.grabLogMessages();
|
||||
assert(gotMessage);
|
||||
|
||||
// - Now check our timeout mechanism without us logging anything
|
||||
// (Note that other things may cause logging to happen, so this may end up
|
||||
// doing what our next case tries to do too.)
|
||||
|
||||
// Disable the default onScriptTimeout which likes to take a screenshot
|
||||
// and spams stdout.
|
||||
client.onScriptTimeout = null;
|
||||
|
||||
var clockStartedAt = Date.now();
|
||||
assert.throws(function() {
|
||||
client.logger.waitForLogMessage(function() {
|
||||
// never match anything!
|
||||
return false;
|
||||
}, 100);
|
||||
}, Error);
|
||||
var clockStoppedAt = Date.now();
|
||||
assert(clockStoppedAt > clockStartedAt + 95, 'correct duration');
|
||||
|
||||
// - Check our timeout with us logging a few things
|
||||
clockStartedAt = Date.now();
|
||||
assert.throws(function() {
|
||||
client.executeScript(function() {
|
||||
console.log('0ms');
|
||||
window.setTimeout(function() {
|
||||
console.log('20ms');
|
||||
}, 20);
|
||||
window.setTimeout(function() {
|
||||
console.log('40ms');
|
||||
}, 40);
|
||||
window.setTimeout(function() {
|
||||
console.log('60ms');
|
||||
}, 60);
|
||||
window.setTimeout(function() {
|
||||
console.log('80ms');
|
||||
}, 80);
|
||||
});
|
||||
client.logger.waitForLogMessage(function() {
|
||||
// never match anything!
|
||||
return false;
|
||||
}, 100);
|
||||
}, Error);
|
||||
clockStoppedAt = Date.now();
|
||||
assert(clockStoppedAt > clockStartedAt + 95, 'correct duration');
|
||||
});
|
||||
|
||||
test('get logs from (nested) mozbrowser iframes', function() {
|
||||
var unique = '____I_AM_SO_UNIQUE___';
|
||||
var gotEmitted = false;
|
||||
|
||||
// this gets emitted before our waitForLogMessage gets a chance
|
||||
client.logger.on('message', function(msg) {
|
||||
if (msg.message.indexOf(unique) !== -1) {
|
||||
gotEmitted = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Launch browser and navigate to index.html.
|
||||
rocketbar.homescreenFocus();
|
||||
rocketbar.enterText(localUrl('index.html') + '\uE006');
|
||||
|
||||
client.logger.waitForLogMessage(function(msg) {
|
||||
return msg.message.indexOf(unique) !== -1;
|
||||
});
|
||||
assert(gotEmitted);
|
||||
});
|
||||
|
||||
test('Catches content errors', function() {
|
||||
var gotEmitted = false;
|
||||
|
||||
// this gets emitted before our waitForLogMessage gets a chance
|
||||
client.logger.on('message', function(msg) {
|
||||
if (msg.message.indexOf('SyntaxError') !== -1 &&
|
||||
msg.filename.indexOf('error.html') !== -1) {
|
||||
gotEmitted = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Launch browser and navigate to error.html.
|
||||
rocketbar.homescreenFocus();
|
||||
rocketbar.enterText(localUrl('error.html') + '\uE006');
|
||||
|
||||
client.logger.waitForLogMessage(function(msg) {
|
||||
return msg.message.indexOf('SyntaxError') !== -1;
|
||||
});
|
||||
assert(gotEmitted);
|
||||
});
|
||||
|
||||
test('#pollMessages should catch all logs', function(done) {
|
||||
var remaining = ['a', 'b', 'c', '1', '2', '3'];
|
||||
|
||||
client.logger.on('message', function onmessage(msg) {
|
||||
var index = remaining.indexOf(msg.message);
|
||||
if (index === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
remaining.splice(index, 1);
|
||||
if (!remaining.length) {
|
||||
client.logger.removeListener('message', onmessage);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
client.executeScript(function() {
|
||||
console.log('a');
|
||||
setTimeout(function() {
|
||||
console.log('b');
|
||||
setTimeout(function() {
|
||||
console.log('c');
|
||||
setTimeout(function() {
|
||||
console.log('1');
|
||||
setTimeout(function() {
|
||||
console.log('2');
|
||||
setTimeout(function() {
|
||||
console.log('3');
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
});
|
||||
|
||||
client.logger.pollMessages(10);
|
||||
});
|
||||
});
|
||||
13
gaia/tests/jsmarionette/plugins/marionette-js-logger/test/fixtures/error.html
vendored
Executable file
13
gaia/tests/jsmarionette/plugins/marionette-js-logger/test/fixtures/error.html
vendored
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title>Foo</title>
|
||||
</head>
|
||||
<body>
|
||||
foo
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
total syntax error
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
10
gaia/tests/jsmarionette/plugins/marionette-js-logger/test/fixtures/frame.html
vendored
Executable file
10
gaia/tests/jsmarionette/plugins/marionette-js-logger/test/fixtures/frame.html
vendored
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body>
|
||||
foo
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
console.log('____I_AM_SO_UNIQUE___');
|
||||
console.error('___I_AM_SO_BROKEN___');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
8
gaia/tests/jsmarionette/plugins/marionette-js-logger/test/fixtures/index.html
vendored
Executable file
8
gaia/tests/jsmarionette/plugins/marionette-js-logger/test/fixtures/index.html
vendored
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title>Foo</title>
|
||||
</head>
|
||||
<iframe src="./frame.html"></iframe>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
'use strict';
|
||||
module.exports = function(path) {
|
||||
return require(__dirname + '/../../../../../' + path);
|
||||
};
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
'use strict';
|
||||
function Server(port, child) {
|
||||
this.port = port;
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
Server.prototype = {
|
||||
/**
|
||||
* Formats given input with localhost and port.
|
||||
*
|
||||
* @param {String} path part of url.
|
||||
* @return {String} url of location.
|
||||
*/
|
||||
url: function(path) {
|
||||
return 'http://localhost:' + this.port + '/' + path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sends signal to stop child process and stop server.
|
||||
*/
|
||||
stop: function() {
|
||||
this.child.send('stop');
|
||||
this.child.kill();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Spawn the child process where the http server lives.
|
||||
*
|
||||
* @param {Function} callback [Error err, Server server].
|
||||
*/
|
||||
function create(callback) {
|
||||
var fork = require('child_process').fork;
|
||||
var child = fork(__dirname + '/server_child.js');
|
||||
|
||||
// wait for start message ['start', PORT_NUMBER].
|
||||
child.on('message', function(data) {
|
||||
if (Array.isArray(data) && data[0] === 'start') {
|
||||
callback(null, new Server(data[1], child));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Server.create = create;
|
||||
|
||||
module.exports = Server;
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
'use strict';
|
||||
var Static = require('node-static'),
|
||||
http = require('http'),
|
||||
emptyPort = require('empty-port');
|
||||
|
||||
var Server = {
|
||||
/**
|
||||
* Http server running in this process.
|
||||
*/
|
||||
http: null,
|
||||
|
||||
stop: function() {
|
||||
if (this.http) {
|
||||
this.http.close();
|
||||
}
|
||||
},
|
||||
|
||||
start: function(port) {
|
||||
// using node-static for now we can do fancy stuff in the future.
|
||||
var file = new Static.Server(__dirname + '/../fixtures/');
|
||||
this.http = http.createServer(function(req, res) {
|
||||
req.addListener('end', function() {
|
||||
// hand off request to node-static
|
||||
file.serve(req, res);
|
||||
}).resume();
|
||||
}).listen(port);
|
||||
}
|
||||
};
|
||||
|
||||
// figure out which port we are on
|
||||
emptyPort({}, function(err, port) {
|
||||
Server.start(port);
|
||||
process.send(['start', port]);
|
||||
});
|
||||
|
||||
// handle process messages
|
||||
process.on('message', function(data) {
|
||||
switch (data) {
|
||||
case 'stop':
|
||||
Server.stop();
|
||||
break;
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue