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