mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
240 lines
8.3 KiB
HTML
240 lines
8.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id={821589}
|
|
-->
|
|
<head>
|
|
<title>Test for Bug {821589} Packaged apps installation and update</title>
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="test_packaged_app_common.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id={821589}">Mozilla Bug {821589}</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
"use strict";
|
|
|
|
function debug(aMsg) {
|
|
//dump("== Tests debug == " + aMsg + "\n");
|
|
}
|
|
|
|
function checkAppInstallError(aMiniManifestURL, aExpectedError) {
|
|
var req = navigator.mozApps.installPackage(aMiniManifestURL);
|
|
req.onsuccess = function() {
|
|
ok(false, "We are supposed to throw " + aExpectedError);
|
|
PackagedTestHelper.finish();
|
|
};
|
|
req.onerror = function(evt) {
|
|
var error = evt.target.error.name;
|
|
if (error == aExpectedError) {
|
|
ok(true, "Got expected " + aExpectedError);
|
|
PackagedTestHelper.next();
|
|
} else {
|
|
ok(false, "Got unexpected " + error);
|
|
PackagedTestHelper.finish();
|
|
}
|
|
};
|
|
}
|
|
|
|
function checkUninstallApp(aApp) {
|
|
var req = navigator.mozApps.mgmt.uninstall(aApp);
|
|
req.onsuccess = function() {
|
|
ok(true, "App uninstalled");
|
|
aApp.ondownloadsuccess = null;
|
|
aApp.ondownloaderror = null;
|
|
aApp.onprogress = null;
|
|
PackagedTestHelper.next();
|
|
};
|
|
req.onerror = function(evt) {
|
|
ok(false, "Got unexpected " + evt.target.error.name);
|
|
PackagedTestHelper.finish();
|
|
};
|
|
}
|
|
|
|
function checkInstalledApp(aMiniManifestURL,
|
|
aVersion,
|
|
aExpectedApp,
|
|
aLaunchable,
|
|
aCb) {
|
|
var req = navigator.mozApps.checkInstalled(aMiniManifestURL);
|
|
req.onsuccess = function(evt) {
|
|
ok(req.result, "The app is installed");
|
|
|
|
if (!req.result) {
|
|
PackagedTestHelper.finish();
|
|
}
|
|
|
|
PackagedTestHelper.checkAppState(evt.application, aVersion, aExpectedApp,
|
|
aLaunchable, false, aCb);
|
|
};
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
var steps = [
|
|
function() {
|
|
// Set up
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
|
SpecialPowers.addPermission("webapps-manage", true, document);
|
|
ok(true, "Set up");
|
|
PackagedTestHelper.next();
|
|
},
|
|
function() {
|
|
ok(true, "autoConfirmAppInstall");
|
|
SpecialPowers.autoConfirmAppInstall(PackagedTestHelper.next);
|
|
},
|
|
function() {
|
|
PackagedTestHelper.setAppVersion(0, PackagedTestHelper.next);
|
|
},
|
|
function() {
|
|
// Bug 927699 - navigator.mozApps.install(url) lets NS_ERROR_FAILURE onto
|
|
// the web.
|
|
ok(true, "== TEST == INVALID_URL");
|
|
checkAppInstallError("", "INVALID_URL");
|
|
},
|
|
function() {
|
|
// Test network error.
|
|
ok(true, "== TEST == Network error");
|
|
checkAppInstallError("http://notvalidurl", "NETWORK_ERROR");
|
|
},
|
|
function() {
|
|
// Test wrong mini-manifest content type.
|
|
ok(true, "== TEST == Not valid mini-manifest content type");
|
|
var miniManifestURL = PackagedTestHelper.gSJS +
|
|
"?getManifest=true" +
|
|
"&noManifestContentType=true";
|
|
checkAppInstallError(miniManifestURL, "INVALID_MANIFEST");
|
|
},
|
|
function() {
|
|
// Test mini-manifest 'size' value is not number. Bug 839435.
|
|
ok(true, "== TEST == Size value is not a number");
|
|
var miniManifestURL = PackagedTestHelper.gSJS +
|
|
"?getManifest=true" +
|
|
"&packageSize=\"NotANumber\"";
|
|
checkAppInstallError(miniManifestURL, "INVALID_MANIFEST");
|
|
},
|
|
function() {
|
|
// Test mini-manifest negative 'size' value. Bug 839435.
|
|
ok(true, "== TEST == Negative size value");
|
|
var miniManifestURL = PackagedTestHelper.gSJS +
|
|
"?getManifest=true" +
|
|
"&packageSize=-1";
|
|
checkAppInstallError(miniManifestURL, "INVALID_MANIFEST");
|
|
},
|
|
function() {
|
|
// Test wrong package path
|
|
ok(true, "== TEST == Installing app with wrong package path");
|
|
var miniManifestURL = PackagedTestHelper.gSJS +
|
|
"?getManifest=true" +
|
|
"&wrongPackagePath=true";
|
|
checkAppInstallError(miniManifestURL, "INVALID_MANIFEST");
|
|
},
|
|
function() {
|
|
// Test no manifest in zip file.
|
|
ok(true, "== TEST == No manifest in the zip file");
|
|
var miniManifestURL = PackagedTestHelper.gSJS + "?getManifest=true";
|
|
PackagedTestHelper.checkAppDownloadError(miniManifestURL,
|
|
"MISSING_MANIFEST", 0, true, true,
|
|
PackagedTestHelper.gAppName);
|
|
},
|
|
function() {
|
|
PackagedTestHelper.setAppVersion(1, PackagedTestHelper.next);
|
|
},
|
|
function() {
|
|
// Test mini-manifest app name is different from the webapp manifest name.
|
|
// Bug 844243.
|
|
ok(true, "== TEST == Mini-manifest app name is different from webapp " +
|
|
"manifest name");
|
|
var miniManifestURL = PackagedTestHelper.gSJS +
|
|
"?getManifest=true" +
|
|
"&appName=arandomname";
|
|
PackagedTestHelper.checkAppDownloadError(miniManifestURL,
|
|
"MANIFEST_MISMATCH", 1, true, true,
|
|
"arandomname");
|
|
},
|
|
function() {
|
|
// Test mini-manifest dev name is different from the webapp manifest dev
|
|
// name.
|
|
ok (true, "== TEST == Mini-manifest dev name is different from manifest " +
|
|
"dev name");
|
|
var miniManifestURL = PackagedTestHelper.gSJS +
|
|
"?getManifest=true" +
|
|
"&devName=arandomdevname";
|
|
PackagedTestHelper.checkAppDownloadError(miniManifestURL,
|
|
"MANIFEST_MISMATCH", 1, true, true,
|
|
PackagedTestHelper.gAppName);
|
|
},
|
|
function() {
|
|
// Test mini-manifest dev url is different from the webapp manifest dev
|
|
// url.
|
|
ok (true, "== TEST == Mini-manifest dev url is different from manifest " +
|
|
"dev url");
|
|
var miniManifestURL = PackagedTestHelper.gSJS +
|
|
"?getManifest=true" +
|
|
"&devUrl=arandomdevurl";
|
|
PackagedTestHelper.checkAppDownloadError(miniManifestURL,
|
|
"MANIFEST_MISMATCH", 1, true, true,
|
|
PackagedTestHelper.gAppName);
|
|
},
|
|
function() {
|
|
PackagedTestHelper.setAppVersion(2, PackagedTestHelper.next);
|
|
},
|
|
function() {
|
|
ok(true, "== TEST == Install packaged app");
|
|
var miniManifestURL = PackagedTestHelper.gSJS +
|
|
"?getManifest=true";
|
|
navigator.mozApps.mgmt.oninstall = function(evt) {
|
|
ok(true, "Got oninstall event");
|
|
PackagedTestHelper.gApp = evt.application;
|
|
PackagedTestHelper.gApp.ondownloaderror = function() {
|
|
ok(false, "Download error " +
|
|
PackagedTestHelper.gApp.downloadError.name);
|
|
PackagedTestHelper.finish();
|
|
};
|
|
PackagedTestHelper.gApp.ondownloadsuccess = function() {
|
|
ok(true, "App downloaded");
|
|
var expected = {
|
|
name: PackagedTestHelper.gAppName,
|
|
manifestURL: miniManifestURL,
|
|
installOrigin: PackagedTestHelper.gInstallOrigin,
|
|
progress: 0,
|
|
installState: "installed",
|
|
downloadAvailable: false,
|
|
downloading: false,
|
|
downloadSize: 0,
|
|
size: 0,
|
|
readyToApplyDownload: false
|
|
};
|
|
PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, 2, expected,
|
|
true, false, PackagedTestHelper.next);
|
|
};
|
|
};
|
|
|
|
var request = navigator.mozApps.installPackage(miniManifestURL);
|
|
request.onerror = PackagedTestHelper.mozAppsError;
|
|
request.onsuccess = function() {
|
|
ok(true, "Application installed");
|
|
};
|
|
},
|
|
function() {
|
|
ok(true, "all done!\n");
|
|
PackagedTestHelper.finish();
|
|
}
|
|
];
|
|
|
|
PackagedTestHelper.setSteps(steps);
|
|
|
|
addLoadEvent(PackagedTestHelper.start);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|