2012-06-29 15:52:43 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-08-14 15:27:26 -07:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-06-29 15:52:43 -07:00
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
|
2012-08-14 15:27:26 -07:00
|
|
|
// Some of the code we want to provide to chrome mochitests is in another file
|
|
|
|
// so we can share it with the mochitest shim window, thus we need to load it.
|
|
|
|
Services.scriptloader.loadSubScript("chrome://webapprt/content/mochitest.js",
|
|
|
|
this);
|
|
|
|
|
2013-07-18 07:20:55 -07:00
|
|
|
const MANIFEST_URL_BASE = Services.io.newURI(
|
|
|
|
"http://test/webapprtChrome/webapprt/test/chrome/", null, null);
|
|
|
|
|
2012-06-29 15:52:43 -07:00
|
|
|
/**
|
2012-08-14 15:27:26 -07:00
|
|
|
* Load the webapp in the app browser.
|
2012-06-29 15:52:43 -07:00
|
|
|
*
|
2012-08-14 15:27:26 -07:00
|
|
|
* @param {String} manifestURL
|
|
|
|
* @see becomeWebapp
|
|
|
|
* @param {Object} parameters
|
|
|
|
* @see becomeWebapp
|
|
|
|
* @param {Function} onLoad
|
|
|
|
* The callback to call once the webapp is loaded.
|
2012-06-29 15:52:43 -07:00
|
|
|
*/
|
2012-08-14 15:27:26 -07:00
|
|
|
function loadWebapp(manifest, parameters, onLoad) {
|
2013-07-18 07:20:55 -07:00
|
|
|
let url = Services.io.newURI(manifest, null, MANIFEST_URL_BASE);
|
|
|
|
|
|
|
|
becomeWebapp(url.spec, parameters, function onBecome() {
|
2012-08-14 15:27:26 -07:00
|
|
|
function onLoadApp() {
|
|
|
|
gAppBrowser.removeEventListener("load", onLoadApp, true);
|
|
|
|
onLoad();
|
|
|
|
}
|
|
|
|
gAppBrowser.addEventListener("load", onLoadApp, true);
|
2013-08-01 18:51:12 -07:00
|
|
|
gAppBrowser.setAttribute("src", WebappRT.launchURI.spec);
|
2012-08-14 15:27:26 -07:00
|
|
|
});
|
2013-07-18 07:20:55 -07:00
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
// We load DOMApplicationRegistry into a local scope to avoid appearing
|
|
|
|
// to leak it.
|
|
|
|
let scope = {};
|
|
|
|
Cu.import("resource://gre/modules/Webapps.jsm", scope);
|
|
|
|
scope.DOMApplicationRegistry.uninstall(url.spec);
|
|
|
|
});
|
2012-06-29 15:52:43 -07:00
|
|
|
}
|