1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/chrome/test/unit/test_bug399707.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + */ 1.8 + 1.9 +var MANIFESTS = [ 1.10 + do_get_file("data/test_bug399707.manifest") 1.11 +]; 1.12 + 1.13 +registerManifests(MANIFESTS); 1.14 + 1.15 +var XULAppInfo = { 1.16 + vendor: "Mozilla", 1.17 + name: "XPCShell", 1.18 + ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}", 1.19 + version: "5", 1.20 + appBuildID: "2007010101", 1.21 + platformVersion: "1.9", 1.22 + platformBuildID: "2007010101", 1.23 + inSafeMode: false, 1.24 + logConsoleErrors: true, 1.25 + OS: "XPCShell", 1.26 + XPCOMABI: "noarch-spidermonkey", 1.27 + 1.28 + QueryInterface: function QueryInterface(iid) { 1.29 + if (iid.equals(Ci.nsIXULAppInfo) 1.30 + || iid.equals(Ci.nsIXULRuntime) 1.31 + || iid.equals(Ci.nsISupports)) 1.32 + return this; 1.33 + 1.34 + throw Components.results.NS_ERROR_NO_INTERFACE; 1.35 + } 1.36 +}; 1.37 + 1.38 +var XULAppInfoFactory = { 1.39 + createInstance: function (outer, iid) { 1.40 + if (outer != null) 1.41 + throw Components.results.NS_ERROR_NO_AGGREGATION; 1.42 + return XULAppInfo.QueryInterface(iid); 1.43 + } 1.44 +}; 1.45 +var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); 1.46 +registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo", 1.47 + XULAPPINFO_CONTRACTID, XULAppInfoFactory); 1.48 + 1.49 +var gIOS = Cc["@mozilla.org/network/io-service;1"] 1.50 + .getService(Ci.nsIIOService); 1.51 +var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"] 1.52 + .getService(Ci.nsIChromeRegistry); 1.53 +chromeReg.checkForNewChrome(); 1.54 + 1.55 +var target = gIOS.newFileURI(do_get_file("data")); 1.56 +target = target.spec + "test/test.xul"; 1.57 + 1.58 +function test_succeeded_mapping(namespace) 1.59 +{ 1.60 + var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul", 1.61 + null, null); 1.62 + try { 1.63 + var result = chromeReg.convertChromeURL(uri); 1.64 + do_check_eq(result.spec, target); 1.65 + } 1.66 + catch (ex) { 1.67 + do_throw(namespace); 1.68 + } 1.69 +} 1.70 + 1.71 +function test_failed_mapping(namespace) 1.72 +{ 1.73 + var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul", 1.74 + null, null); 1.75 + try { 1.76 + var result = chromeReg.convertChromeURL(uri); 1.77 + do_throw(namespace); 1.78 + } 1.79 + catch (ex) { 1.80 + } 1.81 +} 1.82 + 1.83 +function run_test() 1.84 +{ 1.85 + test_succeeded_mapping("test1"); 1.86 + test_succeeded_mapping("test2"); 1.87 + test_succeeded_mapping("test3"); 1.88 + test_failed_mapping("test4"); 1.89 + test_failed_mapping("test5"); 1.90 + test_failed_mapping("test6"); 1.91 + test_failed_mapping("test7"); 1.92 + test_failed_mapping("test8"); 1.93 +}