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
96 changed files with 9982925 additions and 369 deletions

View file

@ -0,0 +1,437 @@
'use strict';
/* jshint node: true, mocha: true */
/* global suiteSetup */
var assert = require('chai').assert;
var path = require('path');
var fs = require('fs');
var helper = require('helper');
var AdmZip = require('adm-zip');
var jsdom = require('jsdom').jsdom;
function checkLayoutsJSON(zipPath, expectedArr) {
var zip = new AdmZip(zipPath);
var entry = zip.getEntry('js/settings/layouts.json');
var actualArr = JSON.parse(zip.readAsText(entry));
actualArr.forEach(function(layout) {
assert.isTrue(
!!layout.dictFileSize,
'Expect layout contain to non-zero dictFileSize, id=' + layout.id);
delete layout.dictFileSize;
});
expectedArr.forEach(function(layout) {
delete layout.dictFileSize;
});
assert.deepEqual(actualArr, expectedArr);
}
suite('Keyboard layouts building tests', function() {
suiteSetup(helper.cleanupWorkspace);
teardown(helper.cleanupWorkspace);
// default make -- build with selected layouts and dictionaries
test('APP=keyboard make', function(done) {
var cmd = 'APP=keyboard make';
helper.exec(cmd, function(error, stdout, stderr) {
helper.checkError(error, stdout, stderr);
var config = JSON.parse(process.env.BUILD_CONFIG);
var layoutIds = ['ar',
'bn-Avro',
'bn-Probhat',
'de',
'de-Neo',
'dz-BT',
'en',
'en-Colemak',
'en-Dvorak',
'en-Neo',
'eo',
'es',
'es-Americas',
'fa',
'fr',
'fr-CA',
'fr-CH',
'fr-Dvorak-bepo',
'he',
'hi',
'ig',
'ko',
'mk',
'my',
'pl',
'pt-BR',
'ta',
'te',
'th',
'uk',
'vi-Qwerty',
'vi-Telex',
'vi-Typewriter',
'wo',
'zh-Hans-Pinyin'];
var zipPath = path.join(process.cwd(), 'profile',
'webapps', 'keyboard.gaiamobile.org', 'application.zip');
var appDirPath = config.GAIA_DIR + '/apps/keyboard';
var layouts = layoutIds.map(function(layout) {
return 'js/layouts/' + layout + '.js';
});
// Unfortunately we can only whilelist files here because we shouldn't
// throw error if excluded files are missing (e.g. README).
var imes = [
'js/imes/jshangul/jshangul.js',
'js/imes/jspinyin/empinyin_files.data',
'js/imes/jspinyin/empinyin_files.js',
'js/imes/jspinyin/jspinyin.js',
'js/imes/jspinyin/libpinyin.js',
'js/imes/jspinyin/worker.js',
'js/imes/latin/latin.js',
'js/imes/latin/predictions.js',
'js/imes/latin/worker.js'
];
var dicts = [
'js/imes/latin/dictionaries/de.dict',
'js/imes/latin/dictionaries/en_us.dict',
'js/imes/latin/dictionaries/es.dict',
'js/imes/latin/dictionaries/fr.dict',
'js/imes/latin/dictionaries/pl.dict',
'js/imes/latin/dictionaries/pt_br.dict'
];
var checkList = [].concat(layouts, imes, dicts);
checkList.forEach(function(path) {
helper.checkFileInZip(zipPath, path, appDirPath + '/' + path);
});
// Verify inputs entry in manifest
var zip = new AdmZip(zipPath);
var entry = zip.getEntry('manifest.webapp');
var manifest = JSON.parse(zip.readAsText(entry));
var inputKeysInManifest = Object.keys(manifest.inputs);
assert.deepEqual(inputKeysInManifest.sort(),
[].concat(layoutIds, 'number', 'emoji').sort());
// Verify dictionary config
var dictJSON = JSON.parse(fs.readFileSync(
appDirPath +
'/test/build/integration/resources/' +
'default-make-layouts.json'));
checkLayoutsJSON(zipPath, dictJSON);
done();
});
});
// Build with all layouts and dictionaries
test('APP=keyboard GAIA_KEYBOARD_LAYOUTS=* make', function(done) {
var cmd = 'APP=keyboard GAIA_KEYBOARD_LAYOUTS=* make';
helper.exec(cmd, function(error, stdout, stderr) {
helper.checkError(error, stdout, stderr);
var config = JSON.parse(process.env.BUILD_CONFIG);
var zipPath = path.join(process.cwd(), 'profile',
'webapps', 'keyboard.gaiamobile.org', 'application.zip');
var appDirPath = config.GAIA_DIR + '/apps/keyboard';
var layoutIds =
fs.readdirSync(appDirPath + '/js/layouts').filter(function(filename) {
return (path.extname(filename) === '.js');
}).map(function(filename) {
return path.basename(filename, '.js');
}).filter(function(layoutId) {
// Exclude noIncludeInExpandLayoutIdSet layouts
return (['emoji'].indexOf(layoutId) === -1);
});
var layouts = layoutIds.map(function(layout) {
return 'js/layouts/' + layout + '.js';
});
// Unfortunately we can only whilelist files here because we shouldn't
// throw error if excluded files are missing (e.g. README).
// For the sake of simplicity let's only check the main scripts.
var imes = [
'js/imes/handwriting/handwriting.js',
'js/imes/india/india.js',
'js/imes/jshangul/jshangul.js',
'js/imes/jskanji/jskanji.js',
'js/imes/jspinyin/jspinyin.js',
'js/imes/latin/latin.js',
'js/imes/vietnamese/vietnamese.js',
'js/imes/myanmar/myanmar.js'
];
var dicts = [
'js/imes/latin/dictionaries/bg.dict',
'js/imes/latin/dictionaries/bs.dict',
'js/imes/latin/dictionaries/ca.dict',
'js/imes/latin/dictionaries/cs.dict',
'js/imes/latin/dictionaries/da.dict',
'js/imes/latin/dictionaries/de.dict',
'js/imes/latin/dictionaries/el.dict',
'js/imes/latin/dictionaries/en_gb.dict',
'js/imes/latin/dictionaries/en_us.dict',
'js/imes/latin/dictionaries/es.dict',
'js/imes/latin/dictionaries/eu.dict',
'js/imes/latin/dictionaries/fr.dict',
'js/imes/latin/dictionaries/ga.dict',
'js/imes/latin/dictionaries/gd.dict',
'js/imes/latin/dictionaries/gl.dict',
'js/imes/latin/dictionaries/gv.dict',
'js/imes/latin/dictionaries/hr.dict',
'js/imes/latin/dictionaries/hu.dict',
'js/imes/latin/dictionaries/it.dict',
'js/imes/latin/dictionaries/lt.dict',
'js/imes/latin/dictionaries/lv.dict',
'js/imes/latin/dictionaries/nb.dict',
'js/imes/latin/dictionaries/nl.dict',
'js/imes/latin/dictionaries/pl.dict',
'js/imes/latin/dictionaries/pt_br.dict',
'js/imes/latin/dictionaries/pt_pt.dict',
'js/imes/latin/dictionaries/ro.dict',
'js/imes/latin/dictionaries/ru.dict',
'js/imes/latin/dictionaries/sk.dict',
'js/imes/latin/dictionaries/sq.dict',
'js/imes/latin/dictionaries/sr-Cyrl.dict',
'js/imes/latin/dictionaries/sr-Latn.dict',
'js/imes/latin/dictionaries/sv.dict',
'js/imes/latin/dictionaries/tr.dict',
'js/imes/latin/dictionaries/af.dict'
];
var checkList = [].concat(layouts, imes, dicts);
checkList.forEach(function(path) {
helper.checkFileInZip(zipPath, path, appDirPath + '/' + path);
});
// Verify inputs entry in manifest
var zip = new AdmZip(zipPath);
var entry = zip.getEntry('manifest.webapp');
var manifest = JSON.parse(zip.readAsText(entry));
var inputKeysInManifest = Object.keys(manifest.inputs);
assert.deepEqual(inputKeysInManifest.sort(),
[].concat(layoutIds, 'number', 'emoji').sort());
// Verify dictionary config
var dictJSON = JSON.parse(fs.readFileSync(
appDirPath +
'/test/build/integration/resources/' +
'all-layout-make-layouts.json'));
checkLayoutsJSON(zipPath, dictJSON);
done();
});
});
// Build with all layouts with no dictionaries
// (preload ko layout here to avoid empty check.)
test('APP=keyboard GAIA_KEYBOARD_LAYOUTS=ko ' +
'GAIA_KEYBOARD_DOWNLOADABLE_LAYOUTS=noPreloadDictRequired make',
function(done) {
var cmd = 'APP=keyboard GAIA_KEYBOARD_LAYOUTS=ko ' +
'GAIA_KEYBOARD_DOWNLOADABLE_LAYOUTS=noPreloadDictRequired make';
helper.exec(cmd, function(error, stdout, stderr) {
helper.checkError(error, stdout, stderr);
var config = JSON.parse(process.env.BUILD_CONFIG);
var zipPath = path.join(process.cwd(), 'profile',
'webapps', 'keyboard.gaiamobile.org', 'application.zip');
var appDirPath = config.GAIA_DIR + '/apps/keyboard';
// For this test, we verify there isn't any dictionary
// in the zip.
var zip = new AdmZip(zipPath);
var entries = zip.getEntries();
var imePath = 'js/imes';
var sizeLimit = (1 << 10) * 100; // 100K
entries.forEach(function(entry) {
if (entry.entryName.substr(0, imePath.length) !== imePath) {
return;
}
var fileSize = entry.getData().length;
assert.isTrue(fileSize < sizeLimit,
'IME file is larger than non-dictionary limit: ' + entry.entryName +
', size: ' + fileSize + ' bytes.');
});
// Verify dictionary config
var dictJSON = JSON.parse(fs.readFileSync(
appDirPath +
'/test/build/integration/resources/' +
'no-preload-dict-required-make-layouts.json'));
checkLayoutsJSON(zipPath, dictJSON);
done();
});
});
// Build default layouts with only en dictionary, and extra IMEs
test('APP=keyboard GAIA_KEYBOARD_LAYOUTS=en ' +
'GAIA_KEYBOARD_DOWNLOADABLE_LAYOUTS=' +
'en,pt-BR,es,de,fr,fr-CA,pl,ko,zh-Hans-Pinyin,en-Dvorak make',
function(done) {
var cmd = 'APP=keyboard GAIA_KEYBOARD_LAYOUTS=en ' +
'GAIA_KEYBOARD_DOWNLOADABLE_LAYOUTS=' +
'en,pt-BR,es,de,fr,fr-CA,pl,ko,zh-Hans-Pinyin,en-Dvorak make';
helper.exec(cmd, function(error, stdout, stderr) {
helper.checkError(error, stdout, stderr);
var config = JSON.parse(process.env.BUILD_CONFIG);
var zipPath = path.join(process.cwd(), 'profile',
'webapps', 'keyboard.gaiamobile.org', 'application.zip');
var appDirPath = config.GAIA_DIR + '/apps/keyboard';
var layoutIds = config.GAIA_KEYBOARD_LAYOUTS.split(',').sort()
.filter(function(layoutId) {
// Exclude noIncludeInExpandLayoutIdSet layouts
return (['emoji'].indexOf(layoutId) === -1);
});
var layouts = layoutIds.map(function(layout) {
return 'js/layouts/' + layout + '.js';
});
// Unfortunately we can only whilelist files here because we shouldn't
// throw error if excluded files are missing (e.g. README).
var imes = [
'js/imes/jshangul/jshangul.js',
'js/imes/jspinyin/empinyin_files.data',
'js/imes/jspinyin/empinyin_files.js',
'js/imes/jspinyin/jspinyin.js',
'js/imes/jspinyin/libpinyin.js',
'js/imes/jspinyin/worker.js',
'js/imes/latin/latin.js',
'js/imes/latin/predictions.js',
'js/imes/latin/worker.js'
];
var dicts = [
'js/imes/latin/dictionaries/es.dict',
'js/imes/latin/dictionaries/fr.dict',
'js/imes/latin/dictionaries/pl.dict',
'js/imes/latin/dictionaries/pt_br.dict'
];
var checkList = [].concat(layouts, imes);
checkList.forEach(function(path) {
helper.checkFileInZip(zipPath, path, appDirPath + '/' + path);
});
// Verify inputs entry in manifest
var zip = new AdmZip(zipPath);
var entry = zip.getEntry('manifest.webapp');
var manifest = JSON.parse(zip.readAsText(entry));
var inputKeysInManifest = Object.keys(manifest.inputs);
// Only layouts with dictionaries should be declaried.
// Noted that en-Dvorak use the same dictionary as en so it should also
// be declaried.
assert.deepEqual(inputKeysInManifest.sort(),
['en', 'en-Dvorak', 'ko', 'number', 'zh-Hans-Pinyin']);
// Verify dictionaries are not built (except en_us.dict)
dicts.forEach(function(dict) {
var entry = zip.getEntry(dict);
assert.equal(entry, null, 'Dictionary should not be built: ' + dict);
});
// Verify dictionary config
var dictJSON = JSON.parse(fs.readFileSync(
appDirPath +
'/test/build/integration/resources/' +
'default-make-en-dict-layouts.json'));
checkLayoutsJSON(zipPath, dictJSON);
done();
});
});
});
suite('Keyboard settings building tests', function() {
suiteSetup(helper.cleanupWorkspace);
teardown(helper.cleanupWorkspace);
// parse settings.html and return domDoc.
var getSettingsDomDoc = function() {
var zipPath = path.join(process.cwd(), 'profile',
'webapps', 'keyboard.gaiamobile.org', 'application.zip');
// Verify settings.html content in manifest
var zip = new AdmZip(zipPath);
var entry = zip.getEntry('settings.html');
return jsdom(zip.readAsText(entry));
};
// return an array of <scripts> tag in <head>
var getScriptsFromDomDoc = function(domDoc) {
// We don't have Array.from in our node version, so use an old way to
// convert HTMLCollections to array
return Array.prototype.slice.call(
domDoc.head.getElementsByTagName('script'));
};
suite('For handwriting', function() {
// return an array of <sections> in the general panel
var getSectionsFromGeneralPanel = function(domDoc) {
return Array.prototype.slice.call(
domDoc.querySelectorAll('#general-container > section'));
};
// default: there shouldn't be handwriting elements in resulting file
test('APP=keyboard make', function(done) {
var cmd = 'APP=keyboard make';
helper.exec(cmd, function(error, stdout, stderr) {
helper.checkError(error, stdout, stderr);
var settingsDOMDoc = getSettingsDomDoc();
assert.isTrue(getScriptsFromDomDoc(settingsDOMDoc).every(function(elem){
return elem.src !== 'js/settings/handwriting_settings_view.js';
}), 'No script should include handwriting_settings_view.js');
assert.isTrue(
getSectionsFromGeneralPanel(settingsDOMDoc).every(function(elem){
return elem.id !== 'handwriting-settings';
}), 'No section in general panel should include handwriting settings');
done();
});
});
test('GAIA_KEYBOARD_LAYOUTS=zh-Hans-Handwriting APP=keyboard make',
function(done) {
var cmd = 'GAIA_KEYBOARD_LAYOUTS=zh-Hans-Handwriting APP=keyboard make';
helper.exec(cmd, function(error, stdout, stderr) {
helper.checkError(error, stdout, stderr);
var settingsDOMDoc = getSettingsDomDoc();
assert.isTrue(getScriptsFromDomDoc(settingsDOMDoc).some(function(elem){
return elem.src === 'js/settings/handwriting_settings_view.js';
}), 'Some script should include handwriting_settings_view.js');
assert.isTrue(
getSectionsFromGeneralPanel(settingsDOMDoc).some(function(elem){
return elem.id === 'handwriting-settings';
}),
'Some section in general panel should include handwriting settings');
done();
});
});
});
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,146 @@
[
{
"id": "de",
"name": "Deutsch",
"imEngineId": "latin",
"types": [
"email",
"password",
"text",
"url"
],
"dictFileSize": 2344627,
"preloaded": false,
"dictFilename": "de.dict",
"dictFilePath": "dictionaries/de.dict"
},
{
"id": "en",
"name": "English",
"imEngineId": "latin",
"types": [
"email",
"password",
"text",
"url"
],
"dictFileSize": 1451390,
"preloaded": true,
"dictFilename": "en_us.dict",
"dictFilePath": "dictionaries/en_us.dict"
},
{
"id": "en-Dvorak",
"name": "Dvorak",
"imEngineId": "latin",
"types": [
"email",
"password",
"text",
"url"
],
"dictFileSize": 1451390,
"preloaded": true,
"dictFilename": "en_us.dict",
"dictFilePath": "dictionaries/en_us.dict"
},
{
"id": "es",
"name": "Español",
"imEngineId": "latin",
"types": [
"email",
"password",
"text",
"url"
],
"dictFileSize": 1564842,
"preloaded": false,
"dictFilename": "es.dict",
"dictFilePath": "dictionaries/es.dict"
},
{
"id": "fr",
"name": "Français",
"imEngineId": "latin",
"types": [
"email",
"password",
"text",
"url"
],
"dictFileSize": 1874745,
"preloaded": false,
"dictFilename": "fr.dict",
"dictFilePath": "dictionaries/fr.dict"
},
{
"id": "fr-CA",
"name": "Français (Canadien)",
"imEngineId": "latin",
"types": [
"email",
"password",
"text",
"url"
],
"dictFileSize": 1874745,
"preloaded": false,
"dictFilename": "fr.dict",
"dictFilePath": "dictionaries/fr.dict"
},
{
"id": "ko",
"name": "한국어",
"imEngineId": "jshangul",
"types": [
"email",
"text",
"url"
],
"dictFileSize": 9562,
"preloaded": true
},
{
"id": "pl",
"name": "Polski",
"imEngineId": "latin",
"types": [
"email",
"password",
"text",
"url"
],
"dictFileSize": 1644422,
"preloaded": false,
"dictFilename": "pl.dict",
"dictFilePath": "dictionaries/pl.dict"
},
{
"id": "pt-BR",
"name": "Português (do Brasil)",
"imEngineId": "latin",
"types": [
"email",
"password",
"text",
"url"
],
"dictFileSize": 1524964,
"preloaded": false,
"dictFilename": "pt_br.dict",
"dictFilePath": "dictionaries/pt_br.dict"
},
{
"id": "zh-Hans-Pinyin",
"name": "拼音",
"imEngineId": "jspinyin",
"types": [
"email",
"text",
"url"
],
"dictFileSize": 2139624,
"preloaded": true
}
]

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,9 @@
{
"extends": "../../../../.jshintrc",
"node": true,
"predef": [
"test",
"setup",
"marionette"
]
}

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
<meta charset="utf-8">
<title>Keyboard Test App</title>
<script type="text/javascript" src="js/main.js"></script>
<link rel="stylesheet" type="text/css" href="style/keyboard.css" />
</head>
<body>
<div id="keyboard" class="ime-test-app">
<button id="sendKey" class="key">Send Key: \o/ </button>
<button id="switchLayout" class="key">Switch layout</button>
</div>
</body>
</html>

View file

@ -0,0 +1,73 @@
'use strict';
/* global KeyEvent */
var inputContext = null;
var keyboardElement;
function init() {
keyboardElement = document.getElementById('keyboard');
window.navigator.mozInputMethod.oninputcontextchange = function() {
inputContext = navigator.mozInputMethod.inputcontext;
resizeWindow();
};
window.addEventListener('resize', resizeWindow);
keyboardElement.addEventListener('mousedown', function onMouseDown(evt) {
// Prevent loosing focus to the currently focused app
// Otherwise, right after mousedown event, the app will receive a focus event.
evt.preventDefault();
});
var sendKeyElement = document.getElementById('sendKey');
sendKeyElement.addEventListener('click', function sendKeyHandler() {
var testString = '\\o/';
for (var i = 0; i < testString.length; i++) {
sendKey(testString.charCodeAt(i));
}
});
var switchElement = document.getElementById('switchLayout');
switchElement.addEventListener('click', function switchHandler() {
var mgmt = navigator.mozInputMethod.mgmt;
mgmt.next();
});
// long press to trigger IME menu
var menuTimeout = 0;
switchElement.addEventListener('touchstart', function longHandler() {
menuTimeout = window.setTimeout(function menuTimeout() {
var mgmt = navigator.mozInputMethod.mgmt;
mgmt.showAll();
}, 700);
});
switchElement.addEventListener('touchend', function longHandler() {
clearTimeout(menuTimeout);
});
}
function resizeWindow() {
window.resizeTo(window.innerWidth, keyboardElement.clientHeight);
}
function sendKey(keyCode) {
switch (keyCode) {
case KeyEvent.DOM_VK_BACK_SPACE:
case KeyEvent.DOM_VK_RETURN:
if (inputContext) {
inputContext.sendKey(keyCode, 0, 0);
}
break;
default:
if (inputContext) {
inputContext.sendKey(0, keyCode, 0);
}
break;
}
}
window.addEventListener('load', init);

View file

@ -0,0 +1,19 @@
'use strict';
/* global MozActivity */
document.getElementById('back').addEventListener('click', function() {
document.addEventListener('visibilitychange', function() {
// Close ourself after the activity transition is completed.
window.close();
});
var activity = new MozActivity({
name: 'configure',
data: {
target: 'device'
}
});
activity.onerror = function() {};
});

View file

@ -0,0 +1,25 @@
{
"name": "LOL Keyboard",
"description": "An useless virtual keyboard that sends \\o/.",
"type": "privileged",
"role": "input",
"launch_path": "/settings.html",
"developer": {
"name": "The Gaia Team",
"url": "https://github.com/mozilla-b2g/gaia"
},
"permissions": {
"input": {
"description": "Send key events and characters to user focused input fields."
}
},
"inputs": {
"lol": {
"launch_path": "/index.html",
"name": "\\o/",
"description": "LOL layout",
"types": ["text", "number"]
}
},
"default_locale": "en-US"
}

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
<meta charset="utf-8">
<title>LOL Keyboard Settings</title>
<script defer src="./js/settings.js"></script>
<style>
button {
font-size: 2em;
}
</style>
</head>
<body>
<h1>LOL Keyboard Settings</h1>
<p>Nothing to see here.</p>
<button id="back">&lt; Back</button>
</body>
</html>

View file

@ -0,0 +1,25 @@
html {
font-size: 10px;
pointer-events: none;
}
body {
margin: 0;
}
#keyboard {
width: 100%;
height: 20rem;
position: absolute;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
pointer-events: auto;
}
.key {
background-color: #333;
font-size: 2.4rem;
border: 0.2rem solid gray;
color: white;
margin: 0.2rem;
}

View file

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Keyboard APP Test</title>
<script defer src="script.js"></script>
</head>
<body class="keyboard-test-app">
<div>
<label for="textInput">Text</label>
<input type="text" id="textInput"/>
</div>
<div>
<label for="textareInput">Textarea</label>
<textarea id="textareaInput"></textarea>
</div>
<div>
<label for="urlInput">URL</label>
<input type="url" id="urlInput"/>
</div>
<div>
<label for="emailInput">Email</label>
<input type="email" id="emailInput"/>
</div>
<div>
<label for="passwordInput">Password</label>
<input type="password" id="passwordInput"/>
</div>
<div>
<label for="searchInput">Search</label>
<input type="search" id="searchInput"/>
</div>
<div>
<label for="numberInput">Number</label>
<input type="number" id="numberInput"/>
</div>
<div>
<label for="telInput">Tel</label>
<input type="tel" id="telInput"/>
</div>
<div>
<div id="nonInput" style="height: 100px;">
</div>
</div>
<button type="button" id="triggerPromptButton">Prompt</button>
<p id="promptResult"></p>
</body>
</html>

View file

@ -0,0 +1,9 @@
{
"name": "keyboard tests",
"description": "A keyboard testing app.",
"launch_path": "/index.html",
"developer": {
"name": "The Gaia Team",
"url": "https://github.com/mozilla-b2g/gaia"
}
}

View file

@ -0,0 +1,9 @@
'use strict';
document.getElementById('triggerPromptButton').onclick = () => {
// setTimeout is needed so we don't block marionette itself.
window.setTimeout(() => {
var str = window.prompt('The quick brown fox jumps over a', '');
document.getElementById('promptResult').textContent = str;
});
};

View file

@ -0,0 +1,187 @@
/* global suite */
'use strict';
var KeyboardTestApp = require('./lib/keyboard_test_app'),
Keyboard = require('./lib/keyboard'),
KeyboardSettings = require('./lib/keyboard_settings.js'),
assert = require('assert');
marionette('Keyboard Auto correction tests', function() {
var apps = {};
var keyboardTestApp = null;
var keyboard = null;
var keyboardSettings = null;
var client = null;
var system = null;
apps[KeyboardTestApp.ORIGIN] = __dirname + '/apps/keyboardtestapp';
client = marionette.client({
profile: {
apps: apps,
prefs: {
'focusmanager.testmode': true
},
settings: {
'lockscreen.enabled': false,
'ftu.manifestURL': null,
'keyboard.autocorrect': true
}
},
desiredCapabilities: { raisesAccessibilityExceptions: false }
});
setup(function() {
system = client.loader.getAppClass('system');
system.waitForFullyLoaded();
keyboard = new Keyboard(client);
keyboardSettings = new KeyboardSettings(client);
keyboardTestApp = new KeyboardTestApp(client);
keyboard.waitForKeyboardReady();
});
suite('AutoCorrect switch', function() {
setup(function() {
keyboardSettings.launch();
});
test('Auto correct switch should equal to settings context',
function() {
var currentSwitch = client.settings.get('keyboard.autocorrect');
keyboardSettings.switchTo();
// Toggle one time
keyboardSettings.clickAutoCorrectOption();
assert.equal(keyboardSettings.autoCorrect, !currentSwitch);
// Toggle again
keyboardSettings.clickAutoCorrectOption();
assert.equal(keyboardSettings.autoCorrect, !!currentSwitch);
});
});
suite('With autocorrect on', function() {
setup(function () {
keyboardTestApp.launch();
keyboardTestApp.switchTo();
keyboardTestApp.textInput.tap();
keyboard.switchTo();
});
test('Predictive tests', function() {
// Test 1 - type first 7 letters of the expected word
// select suggestion will append a space.
var expectedWord = 'keyboard ';
keyboard.type(expectedWord.slice(0, 7));
keyboard.tapAutoCorrectWord();
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), expectedWord);
// Test 2 - tap second suggestion, then press space
keyboard.switchTo();
keyboard.type('Tes');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), 'keyboard Tes');
keyboard.switchTo();
keyboard.tapSuggestionWord('Tea');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), 'keyboard Tea ');
// Test 3 - type something with autocorrect and press space
keyboard.switchTo();
keyboard.type('ye ');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), 'keyboard Tea he ');
// Test 4 - autocorrect, dot and backspace
keyboard.switchTo();
keyboard.type('wot.');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'),
'keyboard Tea he wit.');
keyboard.switchTo();
keyboard.tapBackspaceKey();
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), 'keyboard Tea he wot');
});
// For Bug 1073870
test('Move caret before autocorrect', function() {
keyboard.type('Hello worl');
keyboardTestApp.switchTo();
client.executeScript(
'var el = document.activeElement;' +
'el.selectionStart = el.selectionEnd = 5;');
keyboard.switchTo();
keyboard.type(' ');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), 'Hello worl');
});
});
suite('With autocorrect off', function() {
setup(function () {
client.settings.set('keyboard.autocorrect', false);
keyboardTestApp.launch();
keyboardTestApp.switchTo();
keyboardTestApp.textInput.tap();
keyboard.switchTo();
});
test('No autocorrect while typing', function() {
keyboard.type('Tes');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), 'Tes');
keyboard.switchTo();
keyboard.tapSuggestionWord('Tea');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), 'Tea ');
keyboard.switchTo();
keyboard.type('ye.');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), 'Tea ye.');
keyboard.switchTo();
keyboard.tapBackspaceKey();
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.textInput.getAttribute('value'), 'Tea ye');
});
});
});

View file

@ -0,0 +1,84 @@
'use strict';
var KeyboardTestApp = require('./lib/keyboard_test_app'),
Keyboard = require('./lib/keyboard'),
assert = require('assert');
marionette('Dimiss the keyboard', function() {
var apps = {};
var keyboardTestApp = null;
var keyboard = null;
var systemInputMgmt = null;
var system = null;
var actions;
apps[KeyboardTestApp.ORIGIN] = __dirname + '/apps/keyboardtestapp';
var client = marionette.client({
profile: {
apps: apps,
prefs: {
'focusmanager.testmode': true
}
},
desiredCapabilities: { raisesAccessibilityExceptions: false }
});
setup(function() {
systemInputMgmt = client.loader.getAppClass('system', 'input_management');
system = client.loader.getAppClass('system');
system.waitForFullyLoaded();
actions = client.loader.getActions();
keyboard = new Keyboard(client);
keyboardTestApp = new KeyboardTestApp(client);
keyboard.waitForKeyboardReady();
keyboardTestApp.launch();
keyboardTestApp.switchTo();
keyboardTestApp.textInput.click();
keyboard.switchTo();
});
test('Longpressing the space bar should dismiss the keyboard', function() {
// The time needed for dismiss is 500ms.
keyboard.longPressSpaceBar(0.7);
client.waitFor(() => {
return !systemInputMgmt.keyboardFrameDisplayed();
});
assert.ok(true);
});
test('Longpressing for only 0.5 sec should not dimiss keyboard', function() {
keyboard.longPressSpaceBar(0.5);
var keyboardContainer = keyboard.currentPanel;
assert.ok(keyboardContainer.displayed());
});
test('Click on a non-input field, should dimiss keyboard', function() {
keyboardTestApp.switchTo();
keyboardTestApp.nonInputArea.click();
client.waitFor(() => {
return !systemInputMgmt.keyboardFrameDisplayed();
});
assert.ok(true);
});
test('Pressing [Home] button should dimiss keyboard', function() {
system.tapHome();
client.waitFor(() => {
return !systemInputMgmt.keyboardFrameDisplayed();
});
assert.ok(true);
});
});

View file

@ -0,0 +1,81 @@
'use strict';
var KeyboardTestApp = require('./lib/keyboard_test_app'),
Keyboard = require('./lib/keyboard'),
assert = require('assert');
marionette('Email keyboard input tests', function() {
var apps = {};
var keyboardTestApp = null;
var keyboard = null;
var client = null;
var system = null;
apps[KeyboardTestApp.ORIGIN] = __dirname + '/apps/keyboardtestapp';
client = marionette.client({
profile: {
apps: apps,
prefs: {
'focusmanager.testmode': true
},
settings: {
'lockscreen.enabled': false,
'ftu.manifestURL': null
}
},
desiredCapabilities: { raisesAccessibilityExceptions: false }
});
setup(function() {
system = client.loader.getAppClass('system');
system.waitForFullyLoaded();
keyboard = new Keyboard(client);
keyboardTestApp = new KeyboardTestApp(client);
keyboard.waitForKeyboardReady();
keyboardTestApp.launch();
keyboardTestApp.switchTo();
keyboardTestApp.emailInput.tap();
keyboard.switchTo();
});
test('Should be email layout', function() {
var atSymbol = '@';
var commaSymbol = ',';
assert.equal(keyboard.isKeyPresent(atSymbol), true);
assert.equal(keyboard.isKeyPresent(commaSymbol), false);
});
test('Type post@mydomain.com', function() {
keyboard.type('post');
keyboardTestApp.switchTo();
keyboardTestApp.emailInput.tap();
keyboard.switchTo();
keyboard.type('@');
keyboard.type('mydomain.com');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.emailInput.getAttribute('value'), 'post@mydomain.com');
});
test('Type post123@mydomain.com', function() {
keyboard.type('post123');
keyboard.type('@');
keyboard.type('mydomain.com');
keyboardTestApp.switchTo();
assert.equal(
keyboardTestApp.emailInput.getAttribute('value'),
'post123@mydomain.com');
});
});

View file

@ -0,0 +1,119 @@
'use strict';
var KeyboardTestApp = require('./lib/keyboard_test_app'),
Keyboard = require('./lib/keyboard'),
assert = require('assert');
marionette('Launch Keyboard APP', function() {
var apps = {};
var keyboardTestApp = null;
var keyboard = null;
var client = null;
var system = null;
apps[KeyboardTestApp.ORIGIN] = __dirname + '/apps/keyboardtestapp';
client = marionette.client({
profile: {
apps: apps,
prefs: {
'focusmanager.testmode': true
}
},
desiredCapabilities: { raisesAccessibilityExceptions: false }
});
setup(function() {
system = client.loader.getAppClass('system');
system.waitForFullyLoaded();
keyboard = new Keyboard(client);
keyboardTestApp = new KeyboardTestApp(client);
keyboard.waitForKeyboardReady();
keyboardTestApp.launch();
keyboardTestApp.switchTo();
keyboardTestApp.textInput.click();
keyboard.switchTo();
});
test('Should show lowercase layout', function() {
// XXX: Workaround
// To get the #keyboard element to instead of the body element.
// The value of `client.findElement('body').displayed()` could not be true
// when the keyboard app is show up in the screen currently.
// Please refer to http://bugzil.la/995865.
var keyboardContainer = keyboard.currentPanel;
assert.ok(keyboardContainer.displayed());
var shiftKey = keyboard.shiftKey;
assert.ok(shiftKey.getAttribute('aria-pressed') === 'false');
var alphaKey = keyboard.getKey('a');
assert.ok(alphaKey.displayed());
});
test('Switch between inputs w/o waiting for layout loading', function() {
var keyboardContainer = keyboard.currentPanel;
assert.ok(keyboardContainer.displayed());
var shiftKey = keyboard.shiftKey;
var alphaKey = keyboard.getKey('a');
assert.ok(shiftKey.getAttribute('aria-pressed') === 'false');
assert.ok(alphaKey.displayed());
// Switch to test app frame.
keyboardTestApp.switchTo();
// Focus on the 2nd input
keyboardTestApp.numberInput.click();
// Without waiting for the keyboard, focus the 3rd input
keyboardTestApp.textareaInput.click();
// Switch back to keyboard
keyboard.switchTo();
// Should remain, or switched back to alpha keyboard.
client.waitFor(() => {
return alphaKey.displayed();
});
// Since the 3rd input is a <textarea>,
// we should reach upper case at this point.
client.waitFor(() => {
return (shiftKey.getAttribute('aria-pressed') === 'true');
});
});
test('Keys and buttons should be have aria-label set', function() {
var returnKey = keyboard.returnKey;
client.waitFor(() => {
return (returnKey.getAttribute('aria-label') === 'return');
});
var dismissSuggestionsKey = keyboard.dismissSuggestionsKey;
client.waitFor(() => {
var label = dismissSuggestionsKey.getAttribute('aria-label');
return (label === 'Dismiss');
});
});
test('Touching the status bar should not dismiss keyboard', function() {
// Click on the status bar
client.switchToFrame();
var topPanel = client.findElement('#top-panel');
topPanel.click();
client.helper.wait(3000);
keyboard.switchTo();
var keyboardContainer = keyboard.currentPanel;
assert.ok(keyboardContainer.displayed());
});
});

View file

@ -0,0 +1,10 @@
{
"extends": "../../../../../.jshintrc",
"node": true,
"predef": [
"test",
"setup",
"marionette",
"client"
]
}

Some files were not shown because too many files have changed in this diff Show more