webapprt/test/chrome/head.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 Cu.import("resource://gre/modules/Services.jsm");
michael@0 6
michael@0 7 // Some of the code we want to provide to chrome mochitests is in another file
michael@0 8 // so we can share it with the mochitest shim window, thus we need to load it.
michael@0 9 Services.scriptloader
michael@0 10 .loadSubScript("chrome://webapprt/content/mochitest-shared.js", this);
michael@0 11
michael@0 12 const MANIFEST_URL_BASE = Services.io.newURI(
michael@0 13 "http://test/webapprtChrome/webapprt/test/chrome/", null, null);
michael@0 14
michael@0 15 /**
michael@0 16 * Load the webapp in the app browser.
michael@0 17 *
michael@0 18 * @param {String} manifestURL
michael@0 19 * @see becomeWebapp
michael@0 20 * @param {Object} parameters
michael@0 21 * @see becomeWebapp
michael@0 22 * @param {Function} onLoad
michael@0 23 * The callback to call once the webapp is loaded.
michael@0 24 */
michael@0 25 function loadWebapp(manifest, parameters, onLoad) {
michael@0 26 let url = Services.io.newURI(manifest, null, MANIFEST_URL_BASE);
michael@0 27
michael@0 28 becomeWebapp(url.spec, parameters, function onBecome() {
michael@0 29 function onLoadApp() {
michael@0 30 gAppBrowser.removeEventListener("DOMContentLoaded", onLoadApp, true);
michael@0 31 onLoad();
michael@0 32 }
michael@0 33 gAppBrowser.addEventListener("DOMContentLoaded", onLoadApp, true);
michael@0 34 gAppBrowser.setAttribute("src", WebappRT.launchURI);
michael@0 35 });
michael@0 36
michael@0 37 registerCleanupFunction(function() {
michael@0 38 // We load DOMApplicationRegistry into a local scope to avoid appearing
michael@0 39 // to leak it.
michael@0 40 let scope = {};
michael@0 41 Cu.import("resource://gre/modules/Webapps.jsm", scope);
michael@0 42 scope.DOMApplicationRegistry.uninstall(url.spec);
michael@0 43 });
michael@0 44 }

mercurial