webapprt/content/mochitest.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/webapprt/content/mochitest.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +const Ci = Components.interfaces;
     1.9 +const Cu = Components.utils;
    1.10 +
    1.11 +Cu.import("resource://gre/modules/Services.jsm");
    1.12 +
    1.13 +Services.scriptloader
    1.14 +        .loadSubScript("chrome://webapprt/content/mochitest-shared.js", this);
    1.15 +
    1.16 +// In test mode, the runtime isn't configured until we tell it to become
    1.17 +// an app, which requires us to use DOMApplicationRegistry to install one.
    1.18 +// But DOMApplicationRegistry needs to know the location of its registry dir,
    1.19 +// so we need to configure the runtime with at least that information.
    1.20 +WebappRT.config = {
    1.21 +  registryDir: Services.dirsvc.get("ProfD", Ci.nsIFile).path,
    1.22 +};
    1.23 +
    1.24 +Cu.import("resource://gre/modules/Webapps.jsm");
    1.25 +
    1.26 +becomeWebapp("http://mochi.test:8888/tests/webapprt/test/content/test.webapp",
    1.27 +             undefined, function onBecome() {
    1.28 +  if (window.arguments && window.arguments[0]) {
    1.29 +    let testUrl = window.arguments[0].QueryInterface(Ci.nsIPropertyBag2).get("url");
    1.30 +
    1.31 +    if (testUrl) {
    1.32 +      let win = Services.wm.getMostRecentWindow("webapprt:webapp");
    1.33 +      win.document.getElementById("content").setAttribute("src", testUrl);
    1.34 +    }
    1.35 +  }
    1.36 +
    1.37 +  window.close();
    1.38 +});

mercurial