test_bug580508.js (1071B)
1 "use strict"; 2 3 var ioService = Services.io; 4 var resProt = ioService 5 .getProtocolHandler("resource") 6 .QueryInterface(Ci.nsIResProtocolHandler); 7 8 function run_test() { 9 // Define a resource:// alias that points to another resource:// URI. 10 let greModulesURI = ioService.newURI("resource://gre/modules/"); 11 resProt.setSubstitution("my-gre-modules", greModulesURI); 12 13 // When we ask for the alias, we should not get the resource:// 14 // URI that we registered it for but the original file URI. 15 let greFileSpec = ioService.newURI( 16 "modules/", 17 null, 18 resProt.getSubstitution("gre") 19 ).spec; 20 let aliasURI = resProt.getSubstitution("my-gre-modules"); 21 Assert.equal(aliasURI.spec, greFileSpec); 22 23 // Resolving URIs using the original resource path and the alias 24 // should yield the same result. 25 let greNetUtilURI = ioService.newURI("resource://gre/modules/NetUtil.jsm"); 26 let myNetUtilURI = ioService.newURI("resource://my-gre-modules/NetUtil.jsm"); 27 Assert.equal( 28 resProt.resolveURI(greNetUtilURI), 29 resProt.resolveURI(myNetUtilURI) 30 ); 31 }