Bug 830258 - [Webapps] .uninstall() should return "Webapps:Uninstall:Return:KO" when uninstalling a non-removable app (part 2, provide test case). r=fabrice

This commit is contained in:
Gene Lian 2013-01-30 12:00:55 +08:00
parent 20d50f0b1f
commit fed214b1e7
2 changed files with 83 additions and 0 deletions

View File

@ -28,6 +28,7 @@ MOCHITEST_CHROME_FILES = \
test_install_receipts.xul \
test_getNotInstalled.xul \
test_launch_paths.xul \
test_uninstall_errors.xul \
$(NULL)
MOCHITEST_FILES = \

View File

@ -0,0 +1,82 @@
<?xml version="1.0"?>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Mozilla Bug 830258">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="head.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=830258"
target="_blank">Mozilla Bug 830258</a>
</body>
<script>
var url1 = "http://test1.example.com/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
var url2 = "http://test2.example.com/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
var app1, app2;
var steps = [
installTwoApps,
uninstallApp1,
uninstallApp1Again,
uninstallApp2
];
runAll(steps);
function installTwoApps(next) {
confirmNextInstall();
navigator.mozApps.install(url1, null).onsuccess = function onInstallApp1(evt) {
app1 = evt.target.result;
confirmNextInstall();
navigator.mozApps.install(url2, null).onsuccess = function onInstallApp2(evt) {
app2 = evt.target.result;
next();
};
};
}
function uninstallApp1(next) {
var request = navigator.mozApps.mgmt.uninstall(app1);
request.onsuccess = function onUninstallApp1Success() {
ok(true, "Succeed to uninstall the app1 as expected");
next();
};
request.onerror = function onUninstallApp1Error() {
ok(false, "Fail to uninstall the app1");
next();
};
}
function uninstallApp1Again(next) {
var request = navigator.mozApps.mgmt.uninstall(app1);
request.onsuccess = function onUninstallApp1AgainSuccess() {
ok(false, "Shouldn't be able to uninstall the app1 again");
next();
};
request.onerror = function onUninstallApp1AgainError() {
is(this.error.name, "NOT_INSTALLED", "Error name should be 'NOT_INSTALLED'");
next();
};
}
function uninstallApp2(next) {
var request = navigator.mozApps.mgmt.uninstall(app2);
request.onsuccess = function onUninstallApp2Success() {
ok(true, "Succeed to uninstall the app2 as expected");
next();
};
request.onerror = function onUninstallApp2Error() {
ok(false, "Fail to uninstall the app2");
next();
};
}
</script>
</window>