michael@0: function test_not_too_long() { michael@0: var ios = Cc["@mozilla.org/network/io-service;1"]. michael@0: getService(Ci.nsIIOService); michael@0: michael@0: var spec = "jar:http://example.com/bar.jar!/"; michael@0: try { michael@0: var newURI = ios.newURI(spec, null, null); michael@0: } michael@0: catch (e) { michael@0: do_throw("newURI threw even though it wasn't passed a large nested URI?"); michael@0: } michael@0: } michael@0: michael@0: function test_too_long() { michael@0: var ios = Cc["@mozilla.org/network/io-service;1"]. michael@0: getService(Ci.nsIIOService); michael@0: michael@0: var i; michael@0: var prefix = "jar:"; michael@0: for (i = 0; i < 16; i++) { michael@0: prefix = prefix + prefix; michael@0: } michael@0: var suffix = "!/"; michael@0: for (i = 0; i < 16; i++) { michael@0: suffix = suffix + suffix; michael@0: } michael@0: michael@0: var spec = prefix + "http://example.com/bar.jar" + suffix; michael@0: try { michael@0: // The following will produce a recursive call that if michael@0: // unchecked would lead to a stack overflow. If we michael@0: // do not crash here and thus an exception is caught michael@0: // we have passed the test. michael@0: var newURI = ios.newURI(spec, null, null); michael@0: } michael@0: catch (e) { michael@0: return; michael@0: } michael@0: } michael@0: michael@0: function run_test() { michael@0: test_not_too_long(); michael@0: test_too_long(); michael@0: }