test_bug371473.js (830B)
1 "use strict"; 2 3 function test_not_too_long() { 4 var spec = "jar:http://example.com/bar.jar!/"; 5 try { 6 Services.io.newURI(spec); 7 } catch (e) { 8 do_throw("newURI threw even though it wasn't passed a large nested URI?"); 9 } 10 } 11 12 function test_too_long() { 13 var i; 14 var prefix = "jar:"; 15 for (i = 0; i < 16; i++) { 16 prefix = prefix + prefix; 17 } 18 var suffix = "!/"; 19 for (i = 0; i < 16; i++) { 20 suffix = suffix + suffix; 21 } 22 23 var spec = prefix + "http://example.com/bar.jar" + suffix; 24 try { 25 // The following will produce a recursive call that if 26 // unchecked would lead to a stack overflow. If we 27 // do not crash here and thus an exception is caught 28 // we have passed the test. 29 Services.io.newURI(spec); 30 } catch (e) {} 31 } 32 33 function run_test() { 34 test_not_too_long(); 35 test_too_long(); 36 }