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/. */
9
* SUMMARY: "Too much recursion" errors should be safely caught by try...catch
10
* See http://bugzilla.mozilla.org/show_bug.cgi?id=121658
12
* In the cases below, we expect i>0. The bug was filed because we
13
* were getting i===0; i.e. |i| did not retain the value it had at the
14
* location of the error.
17
//-----------------------------------------------------------------------------
19
var BUGNUMBER = 121658;
20
var msg = '"Too much recursion" errors should be safely caught by try...catch';
21
var TEST_PASSED = 'i retained the value it had at location of error';
22
var TEST_FAILED = 'i did NOT retain this value';
26
var actualvalues = [];
28
var expectedvalues = [];
36
// try...catch should catch the "too much recursion" error to ensue
48
status = inSection(1);
55
// Now try in function scope -
63
status = inSection(2);
70
// Now try in eval scope -
71
var sEval = 'function h(){++i; try{h();} catch(e){}}; i=0; h();';
73
status = inSection(3);
80
// Try in eval scope and mix functions up -
81
sEval = 'function a(){++i; try{h();} catch(e){}}; i=0; a();';
83
status = inSection(4);
91
//-----------------------------------------------------------------------------
93
//-----------------------------------------------------------------------------
99
statusitems[UBound] = status;
100
actualvalues[UBound] = formatThis(actual);
101
expectedvalues[UBound] = formatThis(expect);
106
function formatThis(bool)
108
return bool? TEST_PASSED : TEST_FAILED;
115
printBugNumber(BUGNUMBER);
118
for (var i=0; i<UBound; i++)
120
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);