dom/apps/tests/file_app.template.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:4e4657193c43
1 <html>
2 <head>
3 <script>
4
5 function sendMessage(msg) {
6 alert(msg);
7 }
8
9 function ok(p, msg) {
10 if (p)
11 sendMessage("OK: " + msg);
12 else
13 sendMessage("KO: " + msg);
14 }
15
16 function is(a, b, msg) {
17 if (a == b)
18 sendMessage("OK: " + a + " == " + b + " - " + msg);
19 else
20 sendMessage("KO: " + a + " != " + b + " - " + msg);
21 }
22
23 function installed(p) {
24 if (p)
25 sendMessage("IS_INSTALLED");
26 else
27 sendMessage("NOT_INSTALLED");
28 }
29
30 function finish() {
31 sendMessage("VERSION: MyWebApp vVERSIONTOKEN");
32 sendMessage("DONE");
33 }
34
35 function cbError() {
36 ok(false, "Error callback invoked");
37 finish();
38 }
39
40 function go() {
41 ok(true, "Launched app");
42 var request = window.navigator.mozApps.getSelf();
43 request.onsuccess = function() {
44 var app = request.result;
45 checkApp(app);
46 }
47 request.onerror = cbError;
48 }
49
50 function checkApp(app) {
51 // If the app is installed, |app| will be non-null. If it is, verify its state.
52 installed(!!app);
53 if (app) {
54 var appName = "Really Rapid Release (APPTYPETOKEN)";
55 var manifest = SpecialPowers.wrap(app.manifest);
56 is(manifest.name, appName, "Manifest name should be correct");
57 is(app.origin, "http://test", "App origin should be correct");
58 is(app.installOrigin, "http://mochi.test:8888", "Install origin should be correct");
59 }
60 finish();
61 }
62
63 </script>
64 </head>
65 <body onload="go();">
66 App Body. Version: VERSIONTOKEN
67 </body></html>

mercurial