test_bug399707.js (1536B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 */ 5 6 var MANIFESTS = [do_get_file("data/test_bug399707.manifest")]; 7 8 registerManifests(MANIFESTS); 9 10 const { updateAppInfo } = ChromeUtils.importESModule( 11 "resource://testing-common/AppInfo.sys.mjs" 12 ); 13 updateAppInfo({ 14 name: "XPCShell", 15 ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}", 16 version: "5", 17 platformVersion: "1.9", 18 }); 19 20 var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService( 21 Ci.nsIChromeRegistry 22 ); 23 chromeReg.checkForNewChrome(); 24 25 var target = Services.io.newFileURI(do_get_file("data")); 26 target = target.spec + "test/test.xul"; 27 28 function test_succeeded_mapping(namespace) { 29 var uri = Services.io.newURI("chrome://" + namespace + "/content/test.xul"); 30 try { 31 var result = chromeReg.convertChromeURL(uri); 32 Assert.equal(result.spec, target); 33 } catch (ex) { 34 do_throw(namespace); 35 } 36 } 37 38 function test_failed_mapping(namespace) { 39 var uri = Services.io.newURI("chrome://" + namespace + "/content/test.xul"); 40 try { 41 chromeReg.convertChromeURL(uri); 42 do_throw(namespace); 43 } catch (ex) {} 44 } 45 46 function run_test() { 47 test_succeeded_mapping("test1"); 48 test_succeeded_mapping("test2"); 49 test_succeeded_mapping("test3"); 50 test_failed_mapping("test4"); 51 test_failed_mapping("test5"); 52 test_failed_mapping("test6"); 53 test_failed_mapping("test7"); 54 test_failed_mapping("test8"); 55 }