gecko-dev/dom/apps/tests/test_uninstall_errors.html
Marco Castelluccio 628ae5cc73 Bug 855765 - Move test_bug_795164 to dom/apps and avoid UI confirmation. r=fabrice
--HG--
rename : dom/apps/tests/test_uninstall_errors.html => dom/apps/tests/test_bug_795164.html
2013-09-25 09:37:21 -04:00

113 lines
3.0 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=830258
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 830258</title>
<script type="application/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 830258 **/
SimpleTest.waitForExplicitFinish();
var url1 = 'http://test1.example.com/tests/dom/apps/tests/file_app.sjs?apptype=hosted&getmanifest=true';
var url2 = 'http://test2.example.com/tests/dom/apps/tests/file_app.sjs?apptype=hosted&getmanifest=true';
var gGenerator = runTest();
var launchableValue = undefined;
function go() {
SpecialPowers.pushPermissions(
[{ "type": "webapps-manage", "allow": 1, "context": document }],
function() { gGenerator.next() });
}
function continueTest() {
try { gGenerator.next(); }
catch (e) { dump("Got exception: " + e + "\n"); }
}
function mozAppsError() {
ok(false, "mozApps error: " + this.error.name);
finish();
}
function runTest() {
// Set up.
launchableValue = SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
let request = navigator.mozApps.install(url1);
request.onerror = mozAppsError;
request.onsuccess = continueTest;
yield undefined;
let app1 = request.result;
ok(app1, "App1 is non-null");
request = navigator.mozApps.install(url2);
request.onerror = mozAppsError;
request.onsuccess = continueTest;
yield undefined;
let app2 = request.result;
ok(app2, "App2 is non-null");
request = navigator.mozApps.mgmt.uninstall(app1);
request.onsuccess = function() {
ok(true, "Succeed to uninstall the app1 as expected");
continueTest();
};
request.onerror = function() {
ok(false, "Fail to uninstall the app1");
continueTest();
};
yield undefined;
request = navigator.mozApps.mgmt.uninstall(app1);
request.onsuccess = function() {
ok(false, "Shouldn't be able to uninstall the app1 again");
continueTest();
};
request.onerror = function() {
is(this.error.name, "NOT_INSTALLED", "Error name should be 'NOT_INSTALLED'");
continueTest();
};
yield undefined;
request = navigator.mozApps.mgmt.uninstall(app2);
request.onsuccess = function() {
ok(true, "Succeed to uninstall the app2 as expected");
continueTest();
};
request.onerror = function() {
ok(false, "Fail to uninstall the app2");
continueTest();
};
yield undefined;
// All done.
ok(true, "All done");
finish();
}
function finish() {
SpecialPowers.setAllAppsLaunchable(launchableValue);
SimpleTest.finish();
}
</script>
</head>
<body onload="go()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=830258">Mozilla Bug 830258</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>