netwerk/test/unit/test_bug371473.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

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

mercurial