webapprt/content/mochitest.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.

     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 const Ci = Components.interfaces;
     6 const Cu = Components.utils;
     8 Cu.import("resource://gre/modules/Services.jsm");
    10 Services.scriptloader
    11         .loadSubScript("chrome://webapprt/content/mochitest-shared.js", this);
    13 // In test mode, the runtime isn't configured until we tell it to become
    14 // an app, which requires us to use DOMApplicationRegistry to install one.
    15 // But DOMApplicationRegistry needs to know the location of its registry dir,
    16 // so we need to configure the runtime with at least that information.
    17 WebappRT.config = {
    18   registryDir: Services.dirsvc.get("ProfD", Ci.nsIFile).path,
    19 };
    21 Cu.import("resource://gre/modules/Webapps.jsm");
    23 becomeWebapp("http://mochi.test:8888/tests/webapprt/test/content/test.webapp",
    24              undefined, function onBecome() {
    25   if (window.arguments && window.arguments[0]) {
    26     let testUrl = window.arguments[0].QueryInterface(Ci.nsIPropertyBag2).get("url");
    28     if (testUrl) {
    29       let win = Services.wm.getMostRecentWindow("webapprt:webapp");
    30       win.document.getElementById("content").setAttribute("src", testUrl);
    31     }
    32   }
    34   window.close();
    35 });

mercurial