netwerk/test/unit/test_bug580508.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/test/unit/test_bug580508.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,26 @@
     1.4 +let ioService = Cc["@mozilla.org/network/io-service;1"]
     1.5 +                .getService(Ci.nsIIOService);
     1.6 +let resProt = ioService.getProtocolHandler("resource")
     1.7 +              .QueryInterface(Ci.nsIResProtocolHandler);
     1.8 +
     1.9 +function run_test() {
    1.10 +    // Define a resource:// alias that points to another resource:// URI.
    1.11 +    let greModulesURI = ioService.newURI("resource://gre/modules/", null, null);
    1.12 +    resProt.setSubstitution("my-gre-modules", greModulesURI);
    1.13 +
    1.14 +    // When we ask for the alias, we should not get the resource://
    1.15 +    // URI that we registered it for but the original file URI.
    1.16 +    let greFileSpec = ioService.newURI("modules/", null,
    1.17 +                                       resProt.getSubstitution("gre")).spec;
    1.18 +    let aliasURI = resProt.getSubstitution("my-gre-modules");
    1.19 +    do_check_eq(aliasURI.spec, greFileSpec);
    1.20 +
    1.21 +    // Resolving URIs using the original resource path and the alias
    1.22 +    // should yield the same result.
    1.23 +    let greNetUtilURI = ioService.newURI("resource://gre/modules/NetUtil.jsm",
    1.24 +                                         null, null);
    1.25 +    let myNetUtilURI = ioService.newURI("resource://my-gre-modules/NetUtil.jsm",
    1.26 +                                        null, null);
    1.27 +    do_check_eq(resProt.resolveURI(greNetUtilURI),
    1.28 +                resProt.resolveURI(myNetUtilURI));
    1.29 +}

mercurial