netwerk/test/unit/test_bug371473.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 function test_not_too_long() {
     2   var ios = Cc["@mozilla.org/network/io-service;1"].
     3     getService(Ci.nsIIOService);
     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 }
    14 function test_too_long() {
    15   var ios = Cc["@mozilla.org/network/io-service;1"].
    16     getService(Ci.nsIIOService);
    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   }
    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 }
    41 function run_test() {
    42   test_not_too_long();
    43   test_too_long();
    44 }

mercurial