Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-96128-n.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 /*
7 * Date: 29 Aug 2001
8 *
9 * SUMMARY: Negative test that JS infinite recursion protection works.
10 * We expect the code here to fail (i.e. exit code 3), but NOT crash.
11 *
12 * See http://bugzilla.mozilla.org/show_bug.cgi?id=96128
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = 'regress-96128-n.js';
16 var BUGNUMBER = 96128;
17 var summary = 'Testing that JS infinite recursion protection works';
18
19
20 function objRecurse()
21 {
22 /*
23 * jband:
24 *
25 * Causes a stack overflow crash in debug builds of both the browser
26 * and the shell. In the release builds this is safely caught by the
27 * "too much recursion" mechanism. If I remove the 'new' from the code below
28 * this is safely caught in both debug and release builds. The 'new' causes a
29 * lookup for the Constructor name and seems to (at least) double the number
30 * of items on the C stack for the given interpLevel depth.
31 */
32 return new objRecurse();
33 }
34
35
36
37 //-----------------------------------------------------------------------------
38 test();
39 //-----------------------------------------------------------------------------
40
41
42 function test()
43 {
44 enterFunc ('test');
45 printBugNumber(BUGNUMBER);
46 printStatus (summary);
47
48 // we expect this to fail (exit code 3), but NOT crash. -
49 var obj = new objRecurse();
50
51 exitFunc ('test');
52 }