B2G/gecko/webapprt/content/mochitest.js
/**
 * Transmogrify the runtime session into one for the given webapp.
 *
 * @param {String} manifestURL
 *        The URL of the webapp's manifest, relative to the base URL.
 *        Note that the base URL points to the *chrome* WebappRT mochitests,
 *        so you must supply an absolute URL to manifests elsewhere.
 * @param {Object} parameters
 *        The value to pass as the "parameters" argument to
 *        mozIDOMApplicationRegistry.install, e.g., { receipts: ... }.
 *        Use undefined to pass nothing.
 * @param {Function} onBecome
 *        The callback to call once the transmogrification is complete.
 */
Transmogrify the runtime session into one for the given webapp.
@param {String} manifestURL
The URL of the webapp's manifest, relative to the base URL.
Note that the base URL points to the *chrome* WebappRT mochitests,
so you must supply an absolute URL to manifests elsewhere.
@param {Object} parameters
The value to pass as the "parameters" argument to
mozIDOMApplicationRegistry.install, e.g., { receipts: ...
Transmogrify the runtime session into one for the given webapp . @param { String } manifestURL The URL of the webapp ' s manifest relative to the base URL . Note that the base URL points to the * chrome * WebappRT mochitests so you must supply an absolute URL to manifests elsewhere . @param { Object } parameters The value to pass as the " parameters " argument to mozIDOMApplicationRegistry . install e . g . { receipts : ...
function becomeWebapp(manifestURL, parameters, onBecome) {
  function observeInstall(subj, topic, data) {
    Services.obs.removeObserver(observeInstall, "webapps-ask-install");
    let scope = {};
    Cu.import("resource://gre/modules/Webapps.jsm", scope);
    scope.DOMApplicationRegistry.confirmInstall(JSON.parse(data));
    let installRecord = JSON.parse(data);
    installRecord.mm = subj;
    installRecord.registryDir = Services.dirsvc.get("ProfD", Ci.nsIFile).path;
    WebappRT.config = installRecord;
    onBecome();
  }
  Services.obs.addObserver(observeInstall, "webapps-ask-install", false);
  let url = Services.io.newURI(manifestURL, null, MANIFEST_URL_BASE);
  navigator.mozApps.install(url.spec, parameters);
}
function becomeWebapp ( manifestURL , parameters , onBecome ) { function observeInstall ( subj , topic , data ) { Services . obs . removeObserver ( observeInstall , "webapps-ask-install" ) ; let scope = { } ; Cu . import ( "resource://gre/modules/Webapps.jsm" , scope ) ; scope . DOMApplicationRegistry . confirmInstall ( JSON . parse ( data ) ) ; let installRecord = JSON . parse ( data ) ; installRecord . mm = subj ; installRecord . registryDir = Services . dirsvc . get ( "ProfD" , Ci . nsIFile ) . path ; WebappRT . config = installRecord ; onBecome ( ) ; } Services . obs . addObserver ( observeInstall , "webapps-ask-install" , false ) ; let url = Services . io . newURI ( manifestURL , null , MANIFEST_URL_BASE ) ; navigator . mozApps . install ( url . spec , parameters ) ; }
Transmogrify the runtime session into one for the given webapp.
Transmogrify the runtime session into one for the given webapp .
// Step 2: Configure the runtime session to represent the app. // We load DOMApplicationRegistry into a local scope to avoid appearing // to leak it. // Step 1: Install the app at the URL specified by the manifest.