mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-09-11 02:56:06 +00:00
110 lines
3.0 KiB
HTML
110 lines
3.0 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=795164
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for Bug 795164</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="application/javascript" src="common.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
<script type="application/javascript;version=1.7">
|
|
|
|
/** Test for Bug 795164 **/
|
|
|
|
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() {
|
|
try {
|
|
gGenerator.next();
|
|
} catch (e if e instanceof StopIteration) {
|
|
SimpleTest.finish();
|
|
}
|
|
}
|
|
|
|
function mozAppsError() {
|
|
ok(false, "mozApps error: " + this.error.name);
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function runTest() {
|
|
// Set up.
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
|
SpecialPowers.autoConfirmAppInstall(continueTest);
|
|
yield undefined;
|
|
|
|
SpecialPowers.autoConfirmAppUninstall(continueTest);
|
|
yield undefined;
|
|
|
|
// Keeping track of the number of times `mozApps.mgmt.onuninstall` gets triggered
|
|
let uninstallCount = 0;
|
|
|
|
navigator.mozApps.mgmt.onuninstall = function() {
|
|
uninstallCount++;
|
|
};
|
|
|
|
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(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;
|
|
|
|
is(uninstallCount, 2, "mgmt.onuninstall got triggered only twice");
|
|
|
|
navigator.mozApps.mgmt.onuninstall = null;
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="prepareEnv(go)">
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795164">Mozilla Bug 795164</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
</pre>
|
|
</body>
|
|
</html>
|