dom/apps/tests/file_app.template.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <html>
     2 <head>
     3 <script>
     5 function sendMessage(msg) {
     6   alert(msg);
     7 }
     9 function ok(p, msg) {
    10   if (p)
    11     sendMessage("OK: " + msg);
    12   else
    13     sendMessage("KO: " + msg);
    14 }
    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 }
    23 function installed(p) {
    24   if (p)
    25     sendMessage("IS_INSTALLED");
    26   else
    27     sendMessage("NOT_INSTALLED");
    28 }
    30 function finish() {
    31   sendMessage("VERSION: MyWebApp vVERSIONTOKEN");
    32   sendMessage("DONE");
    33 }
    35 function cbError() {
    36   ok(false, "Error callback invoked");
    37   finish();
    38 }
    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 }
    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 }
    63 </script>
    64 </head>
    65 <body onload="go();">
    66 App Body. Version: VERSIONTOKEN
    67 </body></html>

mercurial