michael@0: let ioService = Cc["@mozilla.org/network/io-service;1"] michael@0: .getService(Ci.nsIIOService); michael@0: let resProt = ioService.getProtocolHandler("resource") michael@0: .QueryInterface(Ci.nsIResProtocolHandler); michael@0: michael@0: function run_test() { michael@0: // Define a resource:// alias that points to another resource:// URI. michael@0: let greModulesURI = ioService.newURI("resource://gre/modules/", null, null); michael@0: resProt.setSubstitution("my-gre-modules", greModulesURI); michael@0: michael@0: // When we ask for the alias, we should not get the resource:// michael@0: // URI that we registered it for but the original file URI. michael@0: let greFileSpec = ioService.newURI("modules/", null, michael@0: resProt.getSubstitution("gre")).spec; michael@0: let aliasURI = resProt.getSubstitution("my-gre-modules"); michael@0: do_check_eq(aliasURI.spec, greFileSpec); michael@0: michael@0: // Resolving URIs using the original resource path and the alias michael@0: // should yield the same result. michael@0: let greNetUtilURI = ioService.newURI("resource://gre/modules/NetUtil.jsm", michael@0: null, null); michael@0: let myNetUtilURI = ioService.newURI("resource://my-gre-modules/NetUtil.jsm", michael@0: null, null); michael@0: do_check_eq(resProt.resolveURI(greNetUtilURI), michael@0: resProt.resolveURI(myNetUtilURI)); michael@0: }