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

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

mercurial