webapprt/content/mochitest.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:0f646d66cc51
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/. */
4
5 const Ci = Components.interfaces;
6 const Cu = Components.utils;
7
8 Cu.import("resource://gre/modules/Services.jsm");
9
10 Services.scriptloader
11 .loadSubScript("chrome://webapprt/content/mochitest-shared.js", this);
12
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 };
20
21 Cu.import("resource://gre/modules/Webapps.jsm");
22
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");
27
28 if (testUrl) {
29 let win = Services.wm.getMostRecentWindow("webapprt:webapp");
30 win.document.getElementById("content").setAttribute("src", testUrl);
31 }
32 }
33
34 window.close();
35 });

mercurial