Files
palemoon27/dom/apps/tests/test_langpacks.html
T
roytam1 b6d6258762 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1182537 - Use channel->ascynOpen2 in dom/security/nsCORSListenerProxy (r=sicking) (5c4b779a12)
- Bug 1155758 - Make about:serviceworkers work in B2G. r=fabrice (195eca3894)
- Bug 1162920 - JavaScript error at aboutServiceWorkers.js when updating the service worker. r=fabrice (2d3a831a8c)
- Bug 1155153 - [e10s] about:serviceworkers should work in e10s mode. Update B2G implementation. r=baku (0d1c2999c1)
- Bug 1171915 - about:serviceworkers in b2g should use originAttributes when calling ServiceWorkerManager. r=baku,fabrice (faa3725da9)
- Bug 1179161 - originAttributes does not have such isInBrowser member (follow-up bug 1171915). r=ferjm (a217140ae5)
- Bug 1171917 - Improve about:serviceworkers tests on b2g. r=ferjm (5fd9d2f478)
- Bug 1179557 - Add userContextId to originAttributes with tests. r=bholley, r=tanvi (8ddf96d921)
- Bug 1179557 - Add getters for userContextId. r=bholley, r=tanvi (ebec5f7c7e)
- Bug 1174110 - The service worker still remains registered when uninstalling the service-worker-enabled application. r=fabrice (c1c93b1250)
- Bug 1144689 - Allow setting manually a fetch time and modified time for cache entries. r=fabrice (8e9dd47425)
- Bug 1150199 - Langpacks should not have to be privileged r=ferjm (d41af25648)
- Bug 1111961 - Developer mode support r=ferjm,pauljt (9b523402ac)
- Bug 1168300 - notify clear-cookiejar-data. r=sicking (7d88bff29d)
- Bug 1136434 - RequestSync API should delete all the timers when a task is unregistered, r=ehsan (5f92977920)
- Bug 1151082 - RequestSyncAPI - avoid infinite loop when processing pending messages, r=ehsan (b5afcd55e8)
- Bug 1165787 - Use origin in RequestSyncService.jsm. r=ehsan (b6fad2bd68)
- Bug 1182347 - Migrate existing code away from .cookieJar. r=sicking,r=allstars.chh (304cbfd660)
- Bug 1118946 - API to provide localized properties r=ferjm,sicking (a28aecaf19)
- Bug 1077168 - Cancel in-flight Webapp install jobs from windows that change location. r=myk. (d55dc8ff6d)
- Bug 1150660 - Fix sendAsyncMessage() uses to not trigger warnings in dom/apps r=fabrice (b087adcc23)
- Bug 1169344 - Allow server apps to restrict access to their IAC ports. r=ferjm (82c8570555)
- Bug 1068400 - Fix devtools when morphing non-e10s tab into e10s one. r=jryans (55be5ccdf5)
- Bug 1145049 - Prevent caching tab actors in child processes. r=jryans (1a3ee9f278)
- Bug 1145049 - Stop leaking tab actors and root actor on disconnect. r=jryans (26f259b441)
- Bug 1181930 - Refactoring: move the message broadcaster out of Webapps.jsm r=ferjm (b1f8bb8b6d)
-  Bu 1115619 - Use a preference to guarantee app permission loading to permissions.sqlite. r=fabrice (5689c459d7)
- Bug 1191579 - Remove useless getAll() implementation in Webapps.jsm (74f0d6874a)
2022-03-24 11:03:39 +08:00

317 lines
8.9 KiB
HTML

<!DOCTYPE HTML><!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1108096
-->
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug 1108096 - Langpack support</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="application/javascript;version=1.7">
/**
* Test for Bug 1108096
* This file covers testing langpacks.
*
* The setup is as follows:
* - app is the localizable application.
* - langpack1 provides the French locale.
* - langpack2 provides the German and Polish locales.
*/
SimpleTest.waitForExplicitFinish();
const uriPrefix = "http://mochi.test:8888/tests/dom/apps/tests/langpack/";
let appManifestURL = uriPrefix + "manifest.webapp";
let lang1ManifestURL = uriPrefix + "lang1.webapp";
let lang2ManifestURL = uriPrefix + "lang2.webapp";
let gGenerator = runTest();
function go() {
gGenerator.next();
}
function continueTest() {
try {
gGenerator.next();
} catch (e if e instanceof StopIteration) {
SimpleTest.finish();
}
}
function mozAppsError() {
ok(false, "mozApps error: " + this.error.name);
SimpleTest.finish();
}
// Triggers one navigation test to the given page.
// Waits for alert() messages before tearing down the iframe.
function openPage(pageURL, messages) {
info("Navigating to " + pageURL);
let ifr = document.createElement("iframe");
let listener = function(event) {
let message = messages.shift();
is(event.detail.message, message, "Checking alert message for " + pageURL);
if (messages.length == 0) {
ifr.removeEventListener("mozbrowsershowmodalprompt", listener);
ifr.parentNode.removeChild(ifr);
continueTest();
}
}
ifr.addEventListener("mozbrowsershowmodalprompt", listener, false);
// Open the app url in an iframe.
ifr.setAttribute("mozapp", appManifestURL);
ifr.setAttribute("mozbrowser", "true");
ifr.setAttribute("src", uriPrefix + pageURL);
document.getElementById("container").appendChild(ifr);
}
let apps = [];
function installApp(manifestURL) {
info("About to install app at " + manifestURL);
let req = navigator.mozApps.install(manifestURL);
req.onsuccess = function() {
is(req.result.manifestURL, manifestURL, "app installed");
if (req.result.installState == "installed") {
is(req.result.installState, "installed", "app downloaded");
continueTest();
} else {
req.result.ondownloadapplied = function() {
is(req.result.installState, "installed", "app downloaded");
continueTest();
}
}
}
req.onerror = mozAppsError;
}
function runTest() {
// Set up.
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.pushPrefEnv({'set': [
["dom.mozBrowserFramesEnabled", true],
["dom.apps.allow_unsigned_langpacks", true] ]},continueTest);
yield undefined;
SpecialPowers.pushPermissions(
[{ "type": "webapps-manage", "allow": 1, "context": document },
{ "type": "embed-apps", "allow": 1, "context": document },
{ "type": "browser", "allow": 1, "context": document } ],
continueTest);
yield undefined;
navigator.mozApps.mgmt.oninstall = function(evt) {
apps.push(evt.application);
};
let _ = JSON.stringify;
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
// Install test app.
installApp(appManifestURL);
yield undefined;
// Opens the iframe to the test page, initial state.
// No locale is available.
openPage("index.html", [_({})]);
yield undefined;
// Install the fr langpack.
installApp(lang1ManifestURL);
yield undefined;
// Opens the iframe to the test page.
// Only the French locale is available.
openPage("index.html",
[_({"fr":[{"revision":201411051234,"name":"Français","target":"2.2"}]})]);
yield undefined;
// Install the de and pl langpack.
installApp(lang2ManifestURL);
yield undefined;
// Opens the iframe to the test page.
// French, German and Polish locales are available.
openPage("index.html",
[_({"fr":[{"revision":201411051234,"name":"Français","target":"2.2"}],"de":[{"revision":201411051234,"name":"Deutsch","target":"2.2"}],"pl":[{"revision":201411051234,"name":"Polski","target":"2.2"}]})]);
yield undefined;
// Uninstall the second langpack.
{
let app = apps.pop();
info("Uninstalling " + app.manifestURL);
req = navigator.mozApps.mgmt.uninstall(app);
req.onsuccess = continueTest;
req.onerror = mozAppsError;
yield undefined;
}
// Opens the iframe to the test page.
// Only the French locale is available.
openPage("index.html",
[_({"fr":[{"revision":201411051234,"name":"Français","target":"2.2"}]})]);
yield undefined;
// Uninstall the first langpack.
{
let app = apps.pop();
info("Uninstalling " + app.manifestURL);
req = navigator.mozApps.mgmt.uninstall(app);
req.onsuccess = continueTest;
req.onerror = mozAppsError;
yield undefined;
}
// Opens the iframe to the test page, initial state.
// No locale is available.
openPage("index.html",
["{}"]);
yield undefined;
// Opens the iframe to the event test page.
// Will get additionallanguageschange events.
openPage("event.html",
[_({"fr":[{"revision":201411051234,"name":"Français","target":"2.2"}]}),
_({"fr":[{"revision":201411051234,"name":"Français","target":"2.2"}],"de":[{"revision":201411051234,"name":"Deutsch","target":"2.2"}]}),
_({"fr":[{"revision":201411051234,"name":"Français","target":"2.2"}],"de":[{"revision":201411051234,"name":"Deutsch","target":"2.2"}],"pl":[{"revision":201411051234,"name":"Polski","target":"2.2"}]})]);
yield undefined;
// Opens the iframe to the resource test page.
openPage("resources.html",
["UnavailableResource",
"UnavailableLanguage",
"UnavailableVersion",
"BadUrl",
"hello=Bonjour",
"hello=Bonjour",
_({"hello":"Bonjour"})]);
yield undefined;
// Clean up after ourselves by uninstalling apps.
info(apps.length + " applications to uninstall.");
while (apps.length) {
let app = apps.pop();
req = navigator.mozApps.mgmt.uninstall(app);
req.onsuccess = continueTest;
req.onerror = mozAppsError;
yield undefined;
}
// Test localized values with a x.y manifest version.
installApp(appManifestURL);
yield undefined;
// Install the fr langpack.
installApp(lang1ManifestURL);
yield undefined;
// Install the de and pl langpack.
installApp(lang2ManifestURL);
yield undefined;
// Opens the iframe to the localized values test page.
openPage("localizedvalues.html",
["Localization test app",
"UnknownProperty",
"Version française.",
"dialer",
"téléphone"]);
yield undefined;
// Clean up after ourselves by uninstalling apps.
info(apps.length + " applications to uninstall.");
while (apps.length) {
let app = apps.pop();
req = navigator.mozApps.mgmt.uninstall(app);
req.onsuccess = continueTest;
req.onerror = mozAppsError;
yield undefined;
}
// Test localized values with versionless manifest.
appManifestURL = uriPrefix + "manifest_no_version.webapp";
installApp(appManifestURL);
yield undefined;
// Install the fr langpack.
installApp(lang1ManifestURL);
yield undefined;
// Install the de and pl langpack.
installApp(lang2ManifestURL);
yield undefined;
// Opens the iframe to the localized values test page.
openPage("localizedvalues.html",
["Localization test app",
"UnknownProperty",
"Localization test app",
"dialer",
"dialer"]);
yield undefined;
// Clean up after ourselves by uninstalling apps.
info(apps.length + " applications to uninstall.");
while (apps.length) {
let app = apps.pop();
req = navigator.mozApps.mgmt.uninstall(app);
req.onsuccess = continueTest;
req.onerror = mozAppsError;
yield undefined;
}
// Test localized values with a x.y.z manifest version.
appManifestURL = uriPrefix + "manifest_version_xyz.webapp"
installApp(appManifestURL);
yield undefined;
// Install the fr langpack.
installApp(lang1ManifestURL);
yield undefined;
// Install the de and pl langpack.
installApp(lang2ManifestURL);
yield undefined;
// Opens the iframe to the localized values test page.
openPage("localizedvalues.html",
["Localization test app",
"UnknownProperty",
"Version française.",
"dialer",
"téléphone"]);
yield undefined;
// Clean up after ourselves by uninstalling apps.
info(apps.length + " applications to uninstall.");
while (apps.length) {
let app = apps.pop();
req = navigator.mozApps.mgmt.uninstall(app);
req.onsuccess = continueTest;
req.onerror = mozAppsError;
yield undefined;
}
}
</script>
</head>
<body onload="go()">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<div id="container"></div>
</body>
</html>