webapprt/test/chrome/head.js

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

mercurial