https://github.com/mozilla/gecko-dev
Raw File
Tip revision: d1b2176fac58c0587b243402b3264a52a20f8a9c authored by ffxbld on 09 February 2016, 23:00:42 UTC
Added FIREFOX_44_0_2_RELEASE FIREFOX_44_0_2_BUILD2 tag(s) for changeset ffb9dc33a724. DONTBUILD CLOSED TREE a=release
Tip revision: d1b2176
file_script.template.js
function sendMessage(msg) {
  alert(msg);
}

function ok(p, msg) {
  if (p)
    sendMessage("OK: " + msg);
  else
    sendMessage("KO: " + msg);
}

function is(a, b, msg) {
  if (a == b)
    sendMessage("OK: " + a + " == " + b + " - " + msg);
  else
    sendMessage("KO: " + a + " != " + b + " - " + msg);
}

function installed(p) {
  if (p)
    sendMessage("IS_INSTALLED");
  else
    sendMessage("NOT_INSTALLED");
}

function finish() {
  sendMessage("VERSION: MyWebApp vVERSIONTOKEN");
  sendMessage("DONE");
}

function cbError() {
  ok(false, "Error callback invoked");
  finish();
}

function go() {
  ok(true, "Launched APPTYPETOKEN app");
  var request = window.navigator.mozApps.getSelf();
  request.onsuccess = function() {
    var app = request.result;
    checkApp(app);
  }
  request.onerror = cbError;
}

function checkApp(app) {
  // If the app is installed, |app| will be non-null. If it is, verify its state.
  installed(!!app);
  if (app) {
    var appName = "Really Rapid Release (APPTYPETOKEN)";
    var manifest = SpecialPowers.wrap(app.manifest);
    is(manifest.name, appName, "Manifest name should be correct");
    is(app.origin, "http://test", "App origin should be correct");
    is(app.installOrigin, "http://mochi.test:8888", "Install origin should be correct");
  }
  finish();
}

go();
back to top