mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
484147825c
--HG-- rename : dom/apps/tests/test_uninstall_errors.html => dom/apps/tests/test_bug_795164.html
113 lines
3.0 KiB
HTML
113 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>
|
|
<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();
|
|
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;
|
|
|
|
// 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;
|
|
|
|
// 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=795164">Mozilla Bug 795164</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
</pre>
|
|
</body>
|
|
</html>
|