|
1 // Regression test for bug 278262 - JAR URIs should resolve relative URIs in the base section. |
|
2 |
|
3 const Cc = Components.classes; |
|
4 const Ci = Components.interfaces; |
|
5 const path = "data/test_bug333423.zip"; |
|
6 |
|
7 function test_relative_sub() { |
|
8 var ios = Cc["@mozilla.org/network/io-service;1"]. |
|
9 getService(Ci.nsIIOService); |
|
10 |
|
11 var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/"; |
|
12 var base = ios.newURI(spec, null, null); |
|
13 var uri = ios.newURI("../modules/libjar", null, base); |
|
14 |
|
15 // This is the URI we expect to see. |
|
16 var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec + |
|
17 "!/modules/libjar"; |
|
18 |
|
19 do_check_eq(uri.spec, expected); |
|
20 } |
|
21 |
|
22 function test_relative_base() { |
|
23 var ios = Cc["@mozilla.org/network/io-service;1"]. |
|
24 getService(Ci.nsIIOService); |
|
25 |
|
26 var base = ios.newFileURI(do_get_file("data/empty")); |
|
27 var uri = ios.newURI("jar:../" + path + "!/", null, base); |
|
28 |
|
29 // This is the URI we expect to see. |
|
30 var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec + |
|
31 "!/"; |
|
32 |
|
33 do_check_eq(uri.spec, expected); |
|
34 } |
|
35 |
|
36 function run_test() { |
|
37 test_relative_sub(); |
|
38 test_relative_base(); |
|
39 } |