1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/test/unit/test_bug371473.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +function test_not_too_long() { 1.5 + var ios = Cc["@mozilla.org/network/io-service;1"]. 1.6 + getService(Ci.nsIIOService); 1.7 + 1.8 + var spec = "jar:http://example.com/bar.jar!/"; 1.9 + try { 1.10 + var newURI = ios.newURI(spec, null, null); 1.11 + } 1.12 + catch (e) { 1.13 + do_throw("newURI threw even though it wasn't passed a large nested URI?"); 1.14 + } 1.15 +} 1.16 + 1.17 +function test_too_long() { 1.18 + var ios = Cc["@mozilla.org/network/io-service;1"]. 1.19 + getService(Ci.nsIIOService); 1.20 + 1.21 + var i; 1.22 + var prefix = "jar:"; 1.23 + for (i = 0; i < 16; i++) { 1.24 + prefix = prefix + prefix; 1.25 + } 1.26 + var suffix = "!/"; 1.27 + for (i = 0; i < 16; i++) { 1.28 + suffix = suffix + suffix; 1.29 + } 1.30 + 1.31 + var spec = prefix + "http://example.com/bar.jar" + suffix; 1.32 + try { 1.33 + // The following will produce a recursive call that if 1.34 + // unchecked would lead to a stack overflow. If we 1.35 + // do not crash here and thus an exception is caught 1.36 + // we have passed the test. 1.37 + var newURI = ios.newURI(spec, null, null); 1.38 + } 1.39 + catch (e) { 1.40 + return; 1.41 + } 1.42 +} 1.43 + 1.44 +function run_test() { 1.45 + test_not_too_long(); 1.46 + test_too_long(); 1.47 +}