2010-03-10 21:33:00 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-10 21:33:00 -08:00
|
|
|
|
|
|
|
// head_crtestutils.js doesn't get included in the child by default
|
|
|
|
if (typeof registerManifests === "undefined") {
|
|
|
|
load("../unit/head_crtestutils.js");
|
|
|
|
}
|
|
|
|
|
2010-08-02 21:26:27 -07:00
|
|
|
let manifestFile = do_get_file("../unit/data/test_resolve_uris.manifest");
|
|
|
|
|
|
|
|
let manifests = [ manifestFile ];
|
2010-03-10 21:33:00 -08:00
|
|
|
registerManifests(manifests);
|
|
|
|
|
2010-08-02 21:26:27 -07:00
|
|
|
let ios = Cc["@mozilla.org/network/io-service;1"].
|
|
|
|
getService(Ci.nsIIOService);
|
|
|
|
|
2010-03-10 21:33:00 -08:00
|
|
|
function do_run_test()
|
|
|
|
{
|
|
|
|
let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
|
|
|
|
getService(Ci.nsIChromeRegistry);
|
|
|
|
|
2010-07-05 11:46:31 -07:00
|
|
|
// If we don't have libxul or e10s then we don't have process separation, so
|
|
|
|
// we don't need to worry about checking for new chrome.
|
|
|
|
var appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
|
|
|
if (!appInfo ||
|
|
|
|
(appInfo.getService(Ci.nsIXULRuntime).processType ==
|
|
|
|
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT)) {
|
2010-03-10 21:33:00 -08:00
|
|
|
cr.checkForNewChrome();
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if our various things were able to register
|
|
|
|
let registrationTypes = [
|
|
|
|
"content",
|
|
|
|
"locale",
|
|
|
|
"skin",
|
|
|
|
"override",
|
|
|
|
"resource",
|
|
|
|
];
|
|
|
|
|
|
|
|
for (let j = 0; j < registrationTypes.length; j++) {
|
|
|
|
let type = registrationTypes[j];
|
|
|
|
dump("Testing type '" + type + "'\n");
|
|
|
|
let expectedURI = "resource://foo/foo-" + type + "/";
|
|
|
|
let sourceURI = "chrome://foo/" + type + "/";
|
|
|
|
switch (type) {
|
|
|
|
case "content":
|
|
|
|
expectedURI += "foo.xul";
|
|
|
|
break;
|
|
|
|
case "locale":
|
|
|
|
expectedURI += "foo.dtd";
|
|
|
|
break;
|
|
|
|
case "skin":
|
|
|
|
expectedURI += "foo.css";
|
|
|
|
break;
|
|
|
|
case "override":
|
|
|
|
sourceURI = "chrome://good-package/content/override-me.xul";
|
|
|
|
expectedURI += "override-me.xul";
|
|
|
|
break;
|
|
|
|
case "resource":
|
2010-08-02 21:26:27 -07:00
|
|
|
expectedURI = ios.newFileURI(manifestFile.parent).spec;
|
2010-03-10 21:33:00 -08:00
|
|
|
sourceURI = "resource://foo/";
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
try {
|
|
|
|
sourceURI = ios.newURI(sourceURI, null, null);
|
|
|
|
let uri;
|
|
|
|
if (type == "resource") {
|
|
|
|
// resources go about a slightly different way than everything else
|
|
|
|
let rph = ios.getProtocolHandler("resource").
|
|
|
|
QueryInterface(Ci.nsIResProtocolHandler);
|
|
|
|
uri = rph.resolveURI(sourceURI);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
uri = cr.convertChromeURL(sourceURI).spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
do_check_eq(expectedURI, uri);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
dump(e + "\n");
|
|
|
|
do_throw("Should have registered a handler for type '" +
|
|
|
|
type + "'\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof run_test === "undefined") {
|
|
|
|
run_test = function() {
|
|
|
|
do_run_test();
|
|
|
|
};
|
|
|
|
}
|