modules/libjar/test/unit/test_bug278262.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libjar/test/unit/test_bug278262.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,39 @@
     1.4 +// Regression test for bug 278262 - JAR URIs should resolve relative URIs in the base section.
     1.5 +
     1.6 +const Cc = Components.classes;
     1.7 +const Ci = Components.interfaces;
     1.8 +const path = "data/test_bug333423.zip";
     1.9 +
    1.10 +function test_relative_sub() {
    1.11 +  var ios = Cc["@mozilla.org/network/io-service;1"].
    1.12 +            getService(Ci.nsIIOService);
    1.13 +
    1.14 +  var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/";
    1.15 +  var base = ios.newURI(spec, null, null);
    1.16 +  var uri = ios.newURI("../modules/libjar", null, base);
    1.17 +
    1.18 +  // This is the URI we expect to see.
    1.19 +  var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec +
    1.20 +    "!/modules/libjar";
    1.21 +  
    1.22 +  do_check_eq(uri.spec, expected);
    1.23 +}
    1.24 +
    1.25 +function test_relative_base() {
    1.26 +  var ios = Cc["@mozilla.org/network/io-service;1"].
    1.27 +            getService(Ci.nsIIOService);
    1.28 +
    1.29 +  var base = ios.newFileURI(do_get_file("data/empty"));
    1.30 +  var uri = ios.newURI("jar:../" + path + "!/", null, base);
    1.31 +
    1.32 +  // This is the URI we expect to see.
    1.33 +  var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec +
    1.34 +    "!/";
    1.35 +
    1.36 +  do_check_eq(uri.spec, expected);
    1.37 +}
    1.38 +
    1.39 +function run_test() {
    1.40 +  test_relative_sub();
    1.41 +  test_relative_base();
    1.42 +}

mercurial