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 michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: var MANIFESTS = [ michael@0: do_get_file("data/test_bug399707.manifest") michael@0: ]; michael@0: michael@0: registerManifests(MANIFESTS); michael@0: michael@0: var XULAppInfo = { michael@0: vendor: "Mozilla", michael@0: name: "XPCShell", michael@0: ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}", michael@0: version: "5", michael@0: appBuildID: "2007010101", michael@0: platformVersion: "1.9", michael@0: platformBuildID: "2007010101", michael@0: inSafeMode: false, michael@0: logConsoleErrors: true, michael@0: OS: "XPCShell", michael@0: XPCOMABI: "noarch-spidermonkey", michael@0: michael@0: QueryInterface: function QueryInterface(iid) { michael@0: if (iid.equals(Ci.nsIXULAppInfo) michael@0: || iid.equals(Ci.nsIXULRuntime) michael@0: || iid.equals(Ci.nsISupports)) michael@0: return this; michael@0: michael@0: throw Components.results.NS_ERROR_NO_INTERFACE; michael@0: } michael@0: }; michael@0: michael@0: var XULAppInfoFactory = { michael@0: createInstance: function (outer, iid) { michael@0: if (outer != null) michael@0: throw Components.results.NS_ERROR_NO_AGGREGATION; michael@0: return XULAppInfo.QueryInterface(iid); michael@0: } michael@0: }; michael@0: var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); michael@0: registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo", michael@0: XULAPPINFO_CONTRACTID, XULAppInfoFactory); michael@0: michael@0: var gIOS = Cc["@mozilla.org/network/io-service;1"] michael@0: .getService(Ci.nsIIOService); michael@0: var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"] michael@0: .getService(Ci.nsIChromeRegistry); michael@0: chromeReg.checkForNewChrome(); michael@0: michael@0: var target = gIOS.newFileURI(do_get_file("data")); michael@0: target = target.spec + "test/test.xul"; michael@0: michael@0: function test_succeeded_mapping(namespace) michael@0: { michael@0: var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul", michael@0: null, null); michael@0: try { michael@0: var result = chromeReg.convertChromeURL(uri); michael@0: do_check_eq(result.spec, target); michael@0: } michael@0: catch (ex) { michael@0: do_throw(namespace); michael@0: } michael@0: } michael@0: michael@0: function test_failed_mapping(namespace) michael@0: { michael@0: var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul", michael@0: null, null); michael@0: try { michael@0: var result = chromeReg.convertChromeURL(uri); michael@0: do_throw(namespace); michael@0: } michael@0: catch (ex) { michael@0: } michael@0: } michael@0: michael@0: function run_test() michael@0: { michael@0: test_succeeded_mapping("test1"); michael@0: test_succeeded_mapping("test2"); michael@0: test_succeeded_mapping("test3"); michael@0: test_failed_mapping("test4"); michael@0: test_failed_mapping("test5"); michael@0: test_failed_mapping("test6"); michael@0: test_failed_mapping("test7"); michael@0: test_failed_mapping("test8"); michael@0: }