4 https://bugzilla.mozilla.org/show_bug.cgi?id={778277}
7 <title>Test for Bug {
778277}
</title>
8 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
9 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
14 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id={778277}">Mozilla Bug {
778277}
</a>
16 <div id=
"content" style=
"display: none">
20 <script class=
"testbody" type=
"application/javascript;version=1.7">
22 var gManifestURL =
"http://test/tests/dom/apps/tests/file_app.sjs?apptype=hosted&getmanifest=true";
23 var gGenerator = runTest();
26 SpecialPowers.pushPermissions(
27 [{
"type":
"webapps-manage",
"allow":
1,
"context": document }],
28 function() { gGenerator.next() });
31 function continueTest() {
34 } catch (e if e instanceof StopIteration) {
43 function cbError(aEvent) {
44 ok(false,
"Error callback invoked " +
45 aEvent.target.error.name +
" " + aEvent.target.error.message);
49 SimpleTest.waitForExplicitFinish();
52 * Install
2 apps from the same origin and uninstall them.
55 SpecialPowers.setAllAppsLaunchable(true);
57 var manifestURL1 = gManifestURL +
"&app=1";
58 var manifestURL2 = gManifestURL +
"&app=2";
60 SpecialPowers.autoConfirmAppInstall(continueTest);
63 SpecialPowers.autoConfirmAppUninstall(continueTest);
66 request = navigator.mozApps.mgmt.getAll();
67 request.onerror = cbError;
68 request.onsuccess = continueTest;
70 var initialAppsCount = request.result.length;
71 info(
"Starting with " + initialAppsCount +
" apps installed.");
73 var request = navigator.mozApps.install(manifestURL1, { });
74 request.onerror = cbError;
75 request.onsuccess = continueTest;
78 var app1 = request.result;
79 ok(app1,
"App 1 is non-null");
80 is(app1.manifestURL, manifestURL1,
"App 1 manifest url is correct.");
82 request = navigator.mozApps.install(manifestURL2, { });
83 request.onerror = cbError;
84 request.onsuccess = continueTest;
87 var app2 = request.result;
88 ok(app2,
"App 2 is non-null");
89 is(app2.manifestURL, manifestURL2,
"App 2 manifest url is correct.");
91 navigator.mozApps.mgmt.onuninstall = function(event) {
92 var app = event.application;
93 is(app.manifestURL, manifestURL1,
"App 1 uninstall event ok.");
94 is(app.manifest.name,
"Really Rapid Release (hosted)",
95 "App 1 uninstall manifest ok.");
98 request = navigator.mozApps.mgmt.uninstall(app1);
99 request.onerror = cbError;
100 request.onsuccess = continueTest;
103 is(request.result, manifestURL1,
"App 1 uninstalled.");
104 navigator.mozApps.mgmt.onuninstall = null;
106 request = navigator.mozApps.mgmt.uninstall(app2);
107 request.onerror = cbError;
108 request.onsuccess = continueTest;
110 is(request.result, manifestURL2,
"App 2 uninstalled.");
112 request = navigator.mozApps.mgmt.getAll();
113 request.onerror = cbError;
114 request.onsuccess = continueTest;
116 is(request.result.length, initialAppsCount,
"All apps are uninstalled.");