michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: Services.scriptloader michael@0: .loadSubScript("chrome://webapprt/content/mochitest-shared.js", this); michael@0: michael@0: // In test mode, the runtime isn't configured until we tell it to become michael@0: // an app, which requires us to use DOMApplicationRegistry to install one. michael@0: // But DOMApplicationRegistry needs to know the location of its registry dir, michael@0: // so we need to configure the runtime with at least that information. michael@0: WebappRT.config = { michael@0: registryDir: Services.dirsvc.get("ProfD", Ci.nsIFile).path, michael@0: }; michael@0: michael@0: Cu.import("resource://gre/modules/Webapps.jsm"); michael@0: michael@0: becomeWebapp("http://mochi.test:8888/tests/webapprt/test/content/test.webapp", michael@0: undefined, function onBecome() { michael@0: if (window.arguments && window.arguments[0]) { michael@0: let testUrl = window.arguments[0].QueryInterface(Ci.nsIPropertyBag2).get("url"); michael@0: michael@0: if (testUrl) { michael@0: let win = Services.wm.getMostRecentWindow("webapprt:webapp"); michael@0: win.document.getElementById("content").setAttribute("src", testUrl); michael@0: } michael@0: } michael@0: michael@0: window.close(); michael@0: });