1/*
2* The contents of this file are subject to the Netscape Public
3* License Version 1.1 (the "License"); you may not use this file
4* except in compliance with the License. You may obtain a copy of
5* the License at http://www.mozilla.org/NPL/
6*
7* Software distributed under the License is distributed on an "AS
8* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9* implied. See the License for the specific language governing
10* rights and limitations under the License.
11*
12* The Original Code is mozilla.org code.
13*
14* The Initial Developer of the Original Code is Netscape
15* Communications Corporation.  Portions created by Netscape are
16* Copyright (C) 1998 Netscape Communications Corporation.
17* All Rights Reserved.
18*
19* Contributor(s): jband@netscape.com, pschwartau@netscape.com
20* Date: 29 Aug 2001
21*
22* SUMMARY: Negative test that JS infinite recursion protection works.
23* We expect the code here to fail (i.e. exit code 3), but NOT crash.
24*
25* See http://bugzilla.mozilla.org/show_bug.cgi?id=96128
26*/
27//-----------------------------------------------------------------------------
28var bug = 96128;
29var summary = 'Testing that JS infinite recursion protection works';
30
31
32function objRecurse()
33{
34  /*
35   * jband:
36   *
37   * Causes a stack overflow crash in debug builds of both the browser
38   * and the shell. In the release builds this is safely caught by the
39   * "too much recursion" mechanism. If I remove the 'new' from the code below
40   * this is safely caught in both debug and release builds. The 'new' causes a
41   * lookup for the Constructor name and seems to (at least) double the number
42   * of items on the C stack for the given interpLevel depth.
43   */
44  return new objRecurse();
45}
46
47
48
49//-----------------------------------------------------------------------------
50test();
51//-----------------------------------------------------------------------------
52
53
54function test()
55{
56  enterFunc ('test');
57  printBugNumber (bug);
58  printStatus (summary);
59
60  // we expect this to fail (exit code 3), but NOT crash. -
61  var obj = new objRecurse();
62
63  exitFunc ('test');
64}
65