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,110 @@
'use strict';
var mozprofile = require('mozilla-profile-builder'),
debug = require('debug')('marionette-profile-builder');
/**
* Merge two objects and their properties (when objects)
*
* mergeOptions({ prefs: { locked: true } }, { prefs: { debug: true } });
*
* // { prefs: { locked: true, debug: true } }
*
* @private
* @param {Object} a first object to merge.
* @param {Object} b second object to merge.
* @return {Object} merged objects.
*/
function mergeOptions(a, b) {
// so we don't mutate the original state of either object
var result = {};
// "a" is merged first
for (var key in a) {
result[key] = a[key];
}
// "b" is then merged
for (key in b) {
// when both a and b have a property that is an object do a merge
// of those properties rather then an override.
if (typeof a[key] === 'object' && typeof b[key] === 'object') {
result[key] = mergeOptions(a[key], b[key]);
continue;
}
// otherwise simply override a's property with b's property
result[key] = b[key];
}
return result;
}
/**
* Default profile builder API.
*
* @param {Function} options for profile builder.
* options are directly passed to mozilla-profile-builder's .create method.
*/
function ProfileBuilder(options) {
options = options || {};
// copy options into local object so we don't mutate the given object.
this.options = {};
for (var key in options) {
this.options[key] = options[key];
}
}
ProfileBuilder.prototype = {
/**
* Profile instance class.
*
* @type {mozilla-profile-builder/profile}.
*/
profile: null,
/**
* Build the initial version of the profile.
*
* @param {Object} overrides to default build options.
* @param {Function} callback [Error err, Profile].
*/
build: function(overrides, callback) {
// merge options from the defaults and the overrides for this run.
var options = mergeOptions(this.options, overrides || {});
debug('build', options);
mozprofile.create(options, function(err, profile) {
if (err) return callback(err);
// we keep a local copy of profile on this instance.
this.profile = profile;
// to limit the api surface we only expose the path to the profile.
callback(null, profile.path);
}.bind(this));
},
/**
* Destroy the profile.
*
* @param {Function} callback [Error err].
*/
destroy: function(callback) {
debug('destroy');
// skip if build has not been called.
if (!this.profile)
return process.nextTick(callback);
this.profile.destroy(function(err) {
var path = this.profile.path;
this.profile = null;
callback(err, path);
}.bind(this));
}
};
module.exports = ProfileBuilder;

View file

@ -0,0 +1,12 @@
{
"name": "marionette-profile-builder",
"version": "0.0.4",
"author": "James Lal [:lightsofapollo]",
"description": "Default profile builder for marionette-js-runner",
"main": "index.js",
"dependencies" : {
"debug": "*",
"mozilla-profile-builder": "file:../mozilla-profile-builder"
}
}

View file

@ -0,0 +1,8 @@
'use strict';
var assert = require('assert');
global.assert = assert;
global.sinon = require('sinon');
// so we can call assert.calledWith
global.sinon.assert.expose(assert, { prefix: '' });

View file

@ -0,0 +1,95 @@
/* global assert */
'use strict';
suite('ProfileBuilder', function() {
var sinon;
setup(function() {
sinon = global.sinon.sandbox.create();
});
teardown(function() {
sinon.restore();
});
var ProfileBuilder = require('../'),
mozprofile = require('mozilla-profile-builder');
var subject;
var options = {
prefs: { original: true }
};
// profile returned by mozprofile.create
var profile = { path: '/path/to/profile' };
setup(function() {
subject = new ProfileBuilder(options);
});
test('initialization', function() {
assert.deepEqual(subject.options, options);
});
suite('#build', function() {
var stub,
// overrides on the profile options
overrides = { a: true, prefs: { override: true } },
// expected profile options (subject.options + overrides)
expectedOptions,
// profile path returned by build
profilePath;
setup(function(done) {
stub = sinon.stub(mozprofile, 'create');
// expected merge result
expectedOptions = {
a: true,
prefs: { original: true, override: true }
};
// invoke the callback given to the stub async
stub.callsArgWithAsync(1, null, profile);
subject.build(overrides, function(err, _profilePath) {
if (err) return done(err);
profilePath = _profilePath;
done();
});
});
test('profile path', function() {
assert.equal(profile.path, profilePath);
});
test('options given to mozprofile.create', function() {
var call = stub.lastCall;
assert.deepEqual(call.args[0], expectedOptions);
});
});
suite('#destroy', function() {
test('without profile', function(done) {
subject.destroy(done);
});
test('with profile', function(done) {
var calledDestroy = false;
var profile = {
path: '/path/to/profile',
destroy: function(callback) {
calledDestroy = true;
process.nextTick(callback);
}
};
subject.profile = profile;
subject.destroy(function(err, path) {
assert.equal(path, profile.path, 'returns path');
assert.ok(!subject.profile, 'resets profile');
done(err);
});
});
});
});