|
1 function test_not_too_long() { |
|
2 var ios = Cc["@mozilla.org/network/io-service;1"]. |
|
3 getService(Ci.nsIIOService); |
|
4 |
|
5 var spec = "jar:http://example.com/bar.jar!/"; |
|
6 try { |
|
7 var newURI = ios.newURI(spec, null, null); |
|
8 } |
|
9 catch (e) { |
|
10 do_throw("newURI threw even though it wasn't passed a large nested URI?"); |
|
11 } |
|
12 } |
|
13 |
|
14 function test_too_long() { |
|
15 var ios = Cc["@mozilla.org/network/io-service;1"]. |
|
16 getService(Ci.nsIIOService); |
|
17 |
|
18 var i; |
|
19 var prefix = "jar:"; |
|
20 for (i = 0; i < 16; i++) { |
|
21 prefix = prefix + prefix; |
|
22 } |
|
23 var suffix = "!/"; |
|
24 for (i = 0; i < 16; i++) { |
|
25 suffix = suffix + suffix; |
|
26 } |
|
27 |
|
28 var spec = prefix + "http://example.com/bar.jar" + suffix; |
|
29 try { |
|
30 // The following will produce a recursive call that if |
|
31 // unchecked would lead to a stack overflow. If we |
|
32 // do not crash here and thus an exception is caught |
|
33 // we have passed the test. |
|
34 var newURI = ios.newURI(spec, null, null); |
|
35 } |
|
36 catch (e) { |
|
37 return; |
|
38 } |
|
39 } |
|
40 |
|
41 function run_test() { |
|
42 test_not_too_long(); |
|
43 test_too_long(); |
|
44 } |