1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // head_crtestutils.js doesn't get included in the child by default
7 if (typeof registerManifests === "undefined") {
8 load("../unit/head_crtestutils.js");
11 var manifestFile = do_get_file("../unit/data/test_resolve_uris.manifest");
13 var manifests = [manifestFile];
14 registerManifests(manifests);
16 function do_run_test() {
17 let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
21 // If we don't have libxul or e10s then we don't have process separation, so
22 // we don't need to worry about checking for new chrome.
23 var appInfo = Cc["@mozilla.org/xre/app-info;1"];
26 // eslint-disable-next-line mozilla/use-services
27 appInfo.getService(Ci.nsIXULRuntime).processType ==
28 Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
30 cr.checkForNewChrome();
33 // See if our various things were able to register
34 let registrationTypes = ["content", "locale", "skin", "override", "resource"];
36 for (let j = 0; j < registrationTypes.length; j++) {
37 let type = registrationTypes[j];
38 dump("Testing type '" + type + "'\n");
39 let expectedURI = "resource://foo/foo-" + type + "/";
40 let sourceURI = "chrome://foo/" + type + "/";
43 expectedURI += "foo.xul";
46 expectedURI += "foo.dtd";
49 expectedURI += "foo.css";
52 sourceURI = "chrome://good-package/content/override-me.xul";
53 expectedURI += "override-me.xul";
56 expectedURI = Services.io.newFileURI(manifestFile.parent).spec;
57 sourceURI = "resource://foo/";
61 sourceURI = Services.io.newURI(sourceURI);
63 if (type == "resource") {
64 // resources go about a slightly different way than everything else
66 .getProtocolHandler("resource")
67 .QueryInterface(Ci.nsIResProtocolHandler);
68 uri = rph.resolveURI(sourceURI);
70 uri = cr.convertChromeURL(sourceURI).spec;
73 Assert.equal(expectedURI, uri);
76 do_throw("Should have registered a handler for type '" + type + "'\n");
81 if (typeof run_test === "undefined") {
82 // eslint-disable-next-line no-global-assign
83 run_test = function () {