2013-09-19 23:38:45 +04:00
|
|
|
<!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();
|
|
|
|
|
|
|
|
function go() {
|
|
|
|
SpecialPowers.pushPermissions(
|
|
|
|
[{ "type": "webapps-manage", "allow": 1, "context": document }],
|
|
|
|
function() { gGenerator.next() });
|
|
|
|
}
|
|
|
|
|
|
|
|
function continueTest() {
|
2014-03-19 16:48:24 +04:00
|
|
|
try {
|
|
|
|
gGenerator.next();
|
|
|
|
} catch (e if e instanceof StopIteration) {
|
2014-04-18 00:43:04 +04:00
|
|
|
SimpleTest.finish();
|
2014-03-19 16:48:24 +04:00
|
|
|
}
|
2013-09-19 23:38:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function mozAppsError() {
|
|
|
|
ok(false, "mozApps error: " + this.error.name);
|
2014-04-18 00:43:04 +04:00
|
|
|
SimpleTest.finish();
|
2013-09-19 23:38:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function runTest() {
|
|
|
|
// Set up.
|
2014-04-18 00:43:04 +04:00
|
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
2013-09-19 23:38:45 +04:00
|
|
|
SpecialPowers.autoConfirmAppInstall(continueTest);
|
|
|
|
yield undefined;
|
|
|
|
|
2014-06-12 01:33:02 +04:00
|
|
|
SpecialPowers.autoConfirmAppUninstall(continueTest);
|
|
|
|
yield undefined;
|
|
|
|
|
2013-09-19 23:38:45 +04:00
|
|
|
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;
|
|
|
|
|
2013-09-25 17:37:21 +04:00
|
|
|
request = navigator.mozApps.mgmt.uninstall(app2);
|
2013-09-19 23:38:45 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
</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>
|