2012-05-21 15:12:37 +04: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/.
|
2007-12-21 22:32:54 +03:00
|
|
|
*/
|
|
|
|
|
2009-03-21 18:20:00 +03:00
|
|
|
var MANIFESTS = [do_get_file("data/test_bug401153.manifest")];
|
2007-12-21 22:32:54 +03:00
|
|
|
|
2008-04-11 17:39:43 +04:00
|
|
|
registerManifests(MANIFESTS);
|
2007-12-21 22:32:54 +03:00
|
|
|
|
2018-01-30 08:17:48 +03:00
|
|
|
ChromeUtils.import("resource://testing-common/AppInfo.jsm", this);
|
2016-03-16 10:58:29 +03:00
|
|
|
updateAppInfo({
|
2007-12-21 22:32:54 +03:00
|
|
|
name: "XPCShell",
|
|
|
|
ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
|
|
|
|
version: "5",
|
|
|
|
platformVersion: "1.9",
|
2016-03-16 10:58:29 +03:00
|
|
|
});
|
2007-12-21 22:32:54 +03:00
|
|
|
|
|
|
|
var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
|
|
|
|
Ci.nsIChromeRegistry
|
|
|
|
);
|
|
|
|
chromeReg.checkForNewChrome();
|
|
|
|
|
|
|
|
var rph = Services.io
|
|
|
|
.getProtocolHandler("resource")
|
|
|
|
.QueryInterface(Ci.nsIResProtocolHandler);
|
|
|
|
|
2017-10-26 23:56:18 +03:00
|
|
|
function test_succeeded_mapping(namespace, target) {
|
2007-12-21 22:32:54 +03:00
|
|
|
try {
|
|
|
|
Assert.ok(rph.hasSubstitution(namespace));
|
2008-12-10 00:27:42 +03:00
|
|
|
var uri = Services.io.newURI("resource://" + namespace);
|
|
|
|
dump(
|
|
|
|
"### checking for " + target + ", getting " + rph.resolveURI(uri) + "\n"
|
|
|
|
);
|
|
|
|
Assert.equal(rph.resolveURI(uri), target);
|
2017-10-26 23:56:18 +03:00
|
|
|
} catch (ex) {
|
2008-12-10 00:27:42 +03:00
|
|
|
dump(ex + "\n");
|
2007-12-21 22:32:54 +03:00
|
|
|
do_throw(namespace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-26 23:56:18 +03:00
|
|
|
function test_failed_mapping(namespace) {
|
2007-12-21 22:32:54 +03:00
|
|
|
Assert.ok(!rph.hasSubstitution(namespace));
|
|
|
|
}
|
|
|
|
|
2017-10-26 23:56:18 +03:00
|
|
|
function run_test() {
|
2009-03-21 18:20:00 +03:00
|
|
|
var data = Services.io.newFileURI(do_get_file("data")).spec;
|
2008-12-10 00:27:42 +03:00
|
|
|
test_succeeded_mapping("test1", data + "test1/");
|
|
|
|
test_succeeded_mapping("test3", "jar:" + data + "test3.jar!/resources/");
|
2007-12-21 22:32:54 +03:00
|
|
|
test_failed_mapping("test4");
|
2008-12-10 00:27:42 +03:00
|
|
|
test_succeeded_mapping("test5", data + "test5/");
|
2007-12-21 22:32:54 +03:00
|
|
|
}
|