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,298 @@
/* global SettingsListener*/
'use strict';
suite('Sound > SliderHandler', function() {
var sliderHandler;
var realMozSettings;
var dom = document.createElement('li');
var modules = [
'shared_mocks/mock_navigator_moz_settings',
'shared_mocks/mock_settings_listener',
'panels/sound/slider_handler'
];
var maps = {
'*': {
'shared/settings_listener': 'shared_mocks/mock_settings_listener',
'modules/settings_cache': 'unit/mock_settings_cache'
}
};
setup(function(done) {
testRequire(modules, maps, function(
MockNavigatorSettings, MockSettingsListener, module) {
window.SettingsListener = MockSettingsListener;
// mock mozSettings
realMozSettings = navigator.mozSettings;
window.navigator.mozSettings = MockNavigatorSettings;
sliderHandler = module();
done();
});
});
teardown(function() {
window.navigator.mozSettings = realMozSettings;
});
suite('initiation', function() {
setup(function() {
this.sinon.stub(SettingsListener, 'observe');
this.sinon.stub(dom, 'addEventListener');
});
test('we would get correct channelType', function() {
sliderHandler.init(dom, 'content');
assert.equal(sliderHandler._channelType, 'content');
});
test('we would get correct toneURL', function() {
sliderHandler.init(dom, 'content');
assert.equal(sliderHandler._toneURL,
'/shared/resources/media/notifications/notifier_firefox.opus');
sliderHandler.init(dom, 'alarm');
assert.equal(sliderHandler._toneURL,
'/shared/resources/media/alarms/ac_awake.opus');
sliderHandler.init(dom, 'notification');
assert.equal(sliderHandler._toneURL,
'/shared/resources/media/ringtones/ringer_firefox.opus');
});
test('we would get correct toneKey', function() {
sliderHandler.init(dom, 'content');
assert.equal(sliderHandler._toneKey, 'media.ringtone');
sliderHandler.init(dom, 'alarm');
assert.equal(sliderHandler._toneKey, 'alarm.ringtone');
sliderHandler.init(dom, 'notification');
assert.equal(sliderHandler._toneKey, 'dialer.ringtone');
});
test('we would observe channelKey', function() {
sliderHandler.init(dom, 'content');
assert.ok(SettingsListener.observe.calledWith(
sliderHandler._channelKey, '', sliderHandler._boundSetSliderValue));
});
test('we would call addEventListener on element', function() {
sliderHandler.init(dom, 'content');
assert.ok(dom.addEventListener.calledWith('touchstart'));
assert.ok(dom.addEventListener.calledWith('input'));
assert.ok(dom.addEventListener.calledWith('touchend'));
});
test('we would get correct previous value', function() {
sliderHandler.init(dom, 'content');
sliderHandler._setSliderValue(4);
assert.equal(sliderHandler._previous, 4);
sliderHandler._setSliderValue(8);
assert.equal(sliderHandler._previous, 4);
});
});
suite('_stopTone', function() {
setup(function() {
this.sinon.stub(sliderHandler._player, 'pause');
this.sinon.stub(sliderHandler._player, 'removeAttribute');
this.sinon.stub(sliderHandler._player, 'load');
sliderHandler._stopTone();
});
test('we would call player operations', function() {
assert.ok(sliderHandler._player.pause.called);
assert.ok(sliderHandler._player.removeAttribute.calledWith('src'));
assert.ok(sliderHandler._player.load.called);
});
});
suite('_setupTone', function() {
var fakeBlob;
setup(function() {
fakeBlob = new Blob([], {type: 'audio/ogg'});
this.sinon.stub(URL, 'createObjectURL');
sliderHandler._player = {
load: sinon.stub(),
play: sinon.stub(),
mozAudioChannelType: 'fakeChannelType'
};
});
suite('_setupTone with channelType: content', function() {
setup(function() {
sliderHandler._channelType = 'content';
});
test('we would call player operations', function() {
sliderHandler._setupTone(fakeBlob);
assert.ok(URL.createObjectURL.calledWith(fakeBlob));
assert.ok(sliderHandler._player.load.called);
assert.equal(sliderHandler._player.loop, true);
});
test('we would not change play mozAudioChannelType', function() {
var originalChannelType = sliderHandler._player.mozAudioChannelType;
sliderHandler._setupTone(fakeBlob);
assert.equal(sliderHandler._player.mozAudioChannelType,
originalChannelType);
});
});
suite('_setupTone with channelType: alarm', function() {
setup(function() {
sliderHandler._channelType = 'alarm';
sliderHandler._setupTone(fakeBlob);
});
test('we would change play mozAudioChannelType when ' +
'channelType is not content', function() {
assert.equal(sliderHandler._player.mozAudioChannelType,
sliderHandler._channelType);
});
});
});
suite('_touchStartHandler', function() {
setup(function() {
this.sinon.stub(SettingsListener, 'unobserve');
this.sinon.stub(sliderHandler, '_stopTone');
this.sinon.stub(sliderHandler, '_getToneBlob');
sliderHandler._touchStartHandler();
});
test('we would make sure properties are set', function() {
assert.isTrue(sliderHandler._isTouching);
assert.isTrue(sliderHandler._isFirstInput);
});
test('we would call _stopTone', function() {
assert.ok(sliderHandler._stopTone.called);
});
test('we would unobserve channelKey', function() {
assert.ok(SettingsListener.unobserve.calledWith(
sliderHandler._channelKey, sliderHandler._boundSetSliderValue));
});
test('we would call _getToneBlob', function() {
assert.ok(sliderHandler._getToneBlob.called);
});
});
suite('_setVolume', function() {
setup(function() {
sliderHandler.init(dom, 'content');
this.sinon.stub(sliderHandler._player, 'play');
});
test('we would not play tone if no volume change', function() {
sliderHandler._element.value = 5;
sliderHandler._previous = 5;
sliderHandler._setVolume();
assert.isFalse(sliderHandler._player.play.called);
});
test('we would play tone if volume is changed', function() {
sliderHandler._element.value = 5;
sliderHandler._previous = 4;
sliderHandler._setVolume();
assert.ok(sliderHandler._player.play.called);
});
});
suite('_inputHandler', function() {
setup(function() {
this.clock = sinon.useFakeTimers();
this.sinon.spy(window, 'clearTimeout');
this.sinon.spy(window, 'setInterval');
this.sinon.spy(window, 'setTimeout');
this.sinon.stub(sliderHandler, '_setVolume');
this.sinon.stub(sliderHandler, '_stopTone');
this.sinon.stub(SettingsListener, 'observe');
});
teardown(function() {
this.clock.restore();
});
test('we would make sure _isFirstInput is unset', function() {
sliderHandler._isFirstInput = true;
sliderHandler._inputHandler();
assert.isFalse(sliderHandler._isFirstInput);
});
test('we would skip this function if is not FirstInput', function() {
sliderHandler._isFirstInput = false;
sliderHandler._inputHandler();
assert.isFalse(window.setInterval.called);
});
test('we would call _setVolume', function() {
sliderHandler._isFirstInput = true;
sliderHandler._inputHandler();
assert.ok(sliderHandler._setVolume.called);
});
test('we would call setInterval', function() {
sliderHandler._isFirstInput = true;
sliderHandler._inputHandler();
assert.ok(window.setInterval.calledOnce);
});
test('we would call setTimeout', function() {
sliderHandler._isFirstInput = true;
sliderHandler._inputHandler();
assert.ok(window.setTimeout.calledOnce);
});
test('we would still call setTimeout if is not FirstInput', function() {
sliderHandler._isFirstInput = false;
sliderHandler._inputHandler();
assert.ok(window.setTimeout.calledOnce);
});
test('we would observe channelKey', function() {
sliderHandler._inputHandler();
this.clock.tick(1000);
assert.ok(SettingsListener.observe.calledWith(
sliderHandler._channelKey, '', sliderHandler._boundSetSliderValue));
});
test('we would call _stopTone', function() {
sliderHandler._inputHandler();
this.clock.tick(1000);
assert.ok(sliderHandler._stopTone.called);
});
});
suite('_touchEndHandler', function() {
setup(function() {
this.sinon.spy(window, 'clearInterval');
this.sinon.stub(sliderHandler, '_setVolume');
sliderHandler._intervalID = 123;
sliderHandler._isTouching = true;
sliderHandler._touchEndHandler();
});
teardown(function() {
window.clearInterval.restore();
});
test('we would make sure _isTouching is unset', function() {
assert.isFalse(sliderHandler._isTouching);
});
test('we would call _setVolume', function() {
assert.ok(sliderHandler._setVolume.called);
});
test('we would call clearInterval', function() {
assert.ok(clearInterval.calledWith(sliderHandler._intervalID));
});
});
});

View file

@ -0,0 +1,328 @@
'use strict';
suite('Sound > ToneManager', function() {
var toneManager;
var realL10n, realTelephony, realMozSettings, realMozActivity;
var mockSettingsListener, mockSettingsCache, mockForwardLock;
var dom = document.createElement('div');
var mockElements = {
toneSelector: dom,
alertToneSelection: dom,
ringToneSelection: dom,
ringer: dom,
vibrationSetting: dom,
manageTones: dom
};
var modules = [
'shared_mocks/mock_navigator_moz_telephony',
'shared_mocks/mock_l20n',
'shared_mocks/mock_navigator_moz_settings',
'shared_mocks/mock_settings_listener',
'unit/mock_settings_cache',
'shared_mocks/mock_omadrm_fl',
'shared_mocks/mock_moz_activity',
'panels/sound/tone_manager'
];
var maps = {
'*': {
'shared/settings_listener': 'shared_mocks/mock_settings_listener',
'modules/settings_cache': 'unit/mock_settings_cache',
'shared/omadrm/fl': 'shared_mocks/mock_omadrm_fl'
}
};
setup(function(done) {
testRequire(modules, maps, function(
MockNavigatorMozTelephony, MockL10n,
MockNavigatorSettings, MockSettingsListener,
MockSettingsCache, MockForwardLock, MockMozActivity, module) {
toneManager = module();
mockSettingsListener = MockSettingsListener;
mockSettingsCache = MockSettingsCache;
mockForwardLock = MockForwardLock;
// mock l10n
realL10n = document.l10n;
document.l10n = MockL10n;
// mock navigator.mozTelephony
realTelephony = navigator.mozTelephony;
window.navigator.mozTelephony = MockNavigatorMozTelephony;
// mock mozSettings
realMozSettings = navigator.mozSettings;
window.navigator.mozSettings = MockNavigatorSettings;
realMozActivity = window.MozActivity;
window.MozActivity = MockMozActivity;
window.MozActivity.mSetup();
done();
});
});
teardown(function() {
document.l10n = realL10n;
window.navigator.mozTelephony = realTelephony;
window.navigator.mozSettings = realMozSettings;
window.MozActivity.mTeardown();
window.MozActivity = realMozActivity;
});
suite('initiation', function() {
setup(function() {
this.sinon.stub(toneManager, '_configureTones');
this.sinon.stub(toneManager, '_handleTones');
toneManager.init(mockElements);
});
test('we would set _elements from param', function() {
assert.equal(mockElements, toneManager._elements);
});
test('we would call _configureTones and _handleTones in init',
function() {
assert.ok(toneManager._configureTones.called);
assert.ok(toneManager._handleTones.called);
});
});
suite('_configureTones', function() {
var mockTelephony;
setup(function() {
mockTelephony = navigator.mozTelephony;
});
teardown(function() {
navigator.mozTelephony = mockTelephony;
});
test('we would push alerttone by default in tones list', function() {
navigator.mozTelephony = null;
toneManager.init(mockElements);
assert.equal(toneManager._tones.length, 1);
assert.equal(toneManager._tones[0].pickType, 'alerttone');
});
test('If device support telephony API, show the section for ringtones',
function() {
navigator.mozTelephony = {};
toneManager.init(mockElements);
assert.equal(toneManager._tones.length, 2);
assert.equal(toneManager._tones[1].pickType, 'ringtone');
});
});
suite('_renderTone', function() {
var tone, result;
var fakeBlob = new Blob([], {type: 'audio/ogg'});
var secret = 'fakesecret';
setup(function() {
tone = {
pickType: 'alerttone',
settingsKey: 'notification.ringtone',
allowNone: true,
button: dom,
desc: dom
};
result = {
l10nID: '',
name: '',
blob: fakeBlob,
id: ''
};
this.sinon.stub(toneManager, '_setRingtone');
this.sinon.stub(window, 'alert');
this.sinon.spy(mockForwardLock, 'unlockBlob');
});
teardown(function() {
tone.button.textContent = null;
tone.button.removeAttribute('data-l10n-id');
});
suite('is playable', function() {
setup(function() {
this.sinon.stub(toneManager, '_isPlayableTone', function() {
return Promise.resolve(true);
});
});
test('ForwardLock is called when blob mime is matched', function() {
mockForwardLock.mSetupMimeSubtype('ogg');
toneManager._renderTone(tone, result, secret);
assert.equal(tone.button.dataset.l10nId, 'saving-tone');
assert.ok(mockForwardLock.unlockBlob.calledWith(secret, fakeBlob));
});
test('ForwardLock is not called when blob mime is not matched',
function() {
mockForwardLock.mSetupMimeSubtype('mp3');
toneManager._renderTone(tone, result, secret);
assert.equal(tone.button.dataset.l10nId, 'saving-tone');
assert.isFalse(mockForwardLock.unlockBlob.calledWith(secret,
fakeBlob));
});
test('_setRingtone is called when tone is playable', function(done) {
toneManager._renderTone(tone, result, secret).then(() => {
assert.isTrue(toneManager._setRingtone.calledWith(
tone.settingsKey, result.l10nID,
result.name, result.blob, result.id));
}).then(done, done);
});
});
suite('is not playable', function() {
setup(function() {
this.sinon.stub(toneManager, '_isPlayableTone', function() {
return Promise.resolve(false);
});
});
test('alert is called when tone is playable', function(done) {
toneManager._renderTone(tone, result, secret).then(() => {
assert.isTrue(toneManager._isPlayableTone.called);
assert.isTrue(window.alert.called);
assert.isFalse(toneManager._setRingtone.called);
}).then(done, done);
});
test('textContent is set to origin name ' +
'when data-l10n-id is not found', function(done) {
tone.button.textContent = 'test';
toneManager._renderTone(tone, result, secret).then(() => {
assert.isTrue(window.alert.called);
assert.isFalse(toneManager._setRingtone.called);
assert.equal(tone.button.getAttribute('data-l10n-id'), null);
assert.equal(tone.button.textContent, 'test');
}).then(done, done);
});
test('textContent is set to data-l10n-id ' +
'when data-l10n-id is found', function(done) {
var toneId = 'fake-tone';
tone.button.textContent = 'test';
tone.button.setAttribute('data-l10n-id', toneId);
toneManager._renderTone(tone, result, secret).then(() => {
assert.isTrue(window.alert.called);
assert.isFalse(toneManager._setRingtone.called);
assert.equal(tone.button.getAttribute('data-l10n-id'), toneId);
assert.equal(tone.button.textContent, 'test');
}).then(done, done);
});
});
});
suite('_pickTone', function() {
var tone;
var secret = 'fakesecret';
var fakeBlob = new Blob([], {type: 'audio/ogg'});
setup(function() {
this.clock = sinon.useFakeTimers();
tone = {
pickType: 'alerttone',
settingsKey: 'notification.ringtone',
allowNone: true,
button: dom,
desc: dom
};
this.sinon.spy(toneManager, '_setRingtone');
this.sinon.stub(toneManager, '_renderTone');
this.sinon.stub(window, 'alert');
});
teardown(function(){
this.clock.restore();
});
test('pick activity is called', function() {
window.MozActivity.successResult = { blob: fakeBlob };
toneManager._pickTone(tone, '123', secret);
this.clock.tick(100);
assert.equal(window.MozActivity.calls[0].name, 'pick');
assert.equal(window.MozActivity.calls[0].data.includeLocked, true);
assert.equal(window.MozActivity.calls[0].data.type, tone.pickType);
assert.equal(window.MozActivity.calls[0].data.allowNone, true);
});
test('generally blob is exist, _setRingtone and alert are not called',
function(done) {
window.MozActivity.successResult = { blob: fakeBlob };
toneManager._pickTone(tone, '123', secret);
this.clock.tick(100);
Promise.resolve().then(() => {
assert.isFalse(window.alert.called);
assert.isFalse(toneManager._setRingtone.called);
assert.isTrue(toneManager._renderTone.calledWith(
tone, window.MozActivity.successResult, secret));
done();
});
});
test('_setRingtone is called while blob is not exist and ' +
'tone.allowNone is true', function(done) {
window.MozActivity.successResult = {};
toneManager._pickTone(tone, '123', secret);
this.clock.tick(100);
Promise.resolve().then(() => {
assert.isFalse(window.alert.called);
assert.isTrue(toneManager._setRingtone.called);
assert.isFalse(toneManager._renderTone.called);
done();
});
});
test('alert is called while blob is not exist and ' +
'tone.allowNone is false', function(done) {
var tone2 = {
pickType: 'alerttone',
settingsKey: 'notification.ringtone',
allowNone: false,
button: dom
};
window.MozActivity.successResult = {};
toneManager._pickTone(tone2, '123', secret);
this.clock.tick(100);
Promise.resolve().then(() => {
assert.isTrue(window.alert.called);
assert.isFalse(toneManager._setRingtone.called);
assert.isFalse(toneManager._renderTone.called);
done();
});
});
});
suite('_handleTones', function() {
var nameKey = 'notification.ringtone.name';
setup(function() {
toneManager._tones = [{
pickType: 'alerttone',
settingsKey: 'notification.ringtone',
allowNone: true, // Allow "None" as a choice for alert tones.
button: dom,
desc: dom
}];
this.sinon.spy(mockSettingsCache, 'getSettings');
this.sinon.spy(mockForwardLock, 'getKey');
this.sinon.stub(toneManager, '_pickTone');
mockSettingsCache.mockSettings({'notification.ringtone.id': 'demo'});
toneManager._handleTones();
});
teardown(function() {
navigator.mozSettings.mTeardown();
mockSettingsCache.mTeardown();
});
test('we would set button textContent in SettingsListener', function() {
mockSettingsListener.mCallbacks[nameKey]('classic');
assert.equal(toneManager._tones[0].button.textContent, 'classic');
});
test('we would click button and make sure _pickTone is called', function() {
toneManager._tones[0].button.dispatchEvent(new CustomEvent('click'));
assert.ok(mockSettingsCache.getSettings.called);
assert.ok(mockForwardLock.getKey.called);
mockForwardLock.getKey.args[0][0]();
assert.ok(toneManager._pickTone.calledWith(toneManager._tones[0],
'demo'));
});
});
});

View file

@ -0,0 +1,57 @@
'use strict';
suite('Sound > VolumeManager', function() {
var volumeManager;
var dom = document.createElement('li');
var modules = [
'panels/sound/volume_manager'
];
var maps = {
'*': {
'panels/sound/slider_handler': 'MockSliderHandler'
}
};
setup(function(done) {
var that = this;
// Define MockSliderHandler
this.MockSliderHandler = {
init: function(element, type) {}
};
define('MockSliderHandler', function() {
return function() {
return that.MockSliderHandler;
};
});
testRequire(modules, maps, function(module) {
volumeManager = module();
done();
});
});
suite('initiation', function() {
setup(function() {
this.sinon.spy(this.MockSliderHandler, 'init');
});
test('we would call _sliderHandler for each item',
function() {
var element = {
media: dom,
notification: dom,
alarm: dom
};
volumeManager.init(element);
assert.ok(this.MockSliderHandler.init.calledThrice);
assert.ok(this.MockSliderHandler.init.calledWith(
volumeManager._elements.media, 'content'));
assert.ok(this.MockSliderHandler.init.calledWith(
volumeManager._elements.notification, 'notification'));
assert.ok(this.MockSliderHandler.init.calledWith(
volumeManager._elements.alarm, 'alarm'));
});
});
});