Bumping manifests a=b2g-bump
[gecko.git] / dom / apps / tests / test_install_multiple_apps_origin.html
blobe31630dca2f3f88ffdabbe6fc280f04e3d0dd949
1 <!DOCTYPE html>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id={778277}
5 -->
6 <head>
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" />
11 </head>
12 <body>
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id={778277}">Mozilla Bug {778277}</a>
15 <p id="display"></p>
16 <div id="content" style="display: none">
18 </div>
19 <pre id="test">
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();
25 function go() {
26 SpecialPowers.pushPermissions(
27 [{ "type": "webapps-manage", "allow": 1, "context": document }],
28 function() { gGenerator.next() });
31 function continueTest() {
32 try {
33 gGenerator.next();
34 } catch (e if e instanceof StopIteration) {
35 finish();
39 function finish() {
40 SimpleTest.finish();
43 function cbError(aEvent) {
44 ok(false, "Error callback invoked " +
45 aEvent.target.error.name + " " + aEvent.target.error.message);
46 finish();
49 SimpleTest.waitForExplicitFinish();
51 /**
52 * Install 2 apps from the same origin and uninstall them.
54 function runTest() {
55 SpecialPowers.setAllAppsLaunchable(true);
57 var manifestURL1 = gManifestURL + "&app=1";
58 var manifestURL2 = gManifestURL + "&app=2";
60 SpecialPowers.autoConfirmAppInstall(continueTest);
61 yield undefined;
63 SpecialPowers.autoConfirmAppUninstall(continueTest);
64 yield undefined;
66 request = navigator.mozApps.mgmt.getAll();
67 request.onerror = cbError;
68 request.onsuccess = continueTest;
69 yield undefined;
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;
76 yield undefined;
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;
85 yield undefined;
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.");
96 continueTest();
98 request = navigator.mozApps.mgmt.uninstall(app1);
99 request.onerror = cbError;
100 request.onsuccess = continueTest;
101 yield undefined;
102 yield undefined;
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;
109 yield undefined;
110 is(request.result, manifestURL2, "App 2 uninstalled.");
112 request = navigator.mozApps.mgmt.getAll();
113 request.onerror = cbError;
114 request.onsuccess = continueTest;
115 yield undefined;
116 is(request.result.length, initialAppsCount, "All apps are uninstalled.");
119 addLoadEvent(go);
121 </script>
122 </pre>
123 </body>
124 </html>