summaryrefslogtreecommitdiffstats
path: root/js/src/tests/js1_5/Regress/regress-146596.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/js1_5/Regress/regress-146596.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/js1_5/Regress/regress-146596.js')
-rw-r--r--js/src/tests/js1_5/Regress/regress-146596.js124
1 files changed, 124 insertions, 0 deletions
diff --git a/js/src/tests/js1_5/Regress/regress-146596.js b/js/src/tests/js1_5/Regress/regress-146596.js
new file mode 100644
index 000000000..a96b2d3b8
--- /dev/null
+++ b/js/src/tests/js1_5/Regress/regress-146596.js
@@ -0,0 +1,124 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ *
+ * Date: 18 Jun 2002
+ * SUMMARY: Shouldn't crash when catch parameter is "hidden" by varX
+ * See http://bugzilla.mozilla.org/show_bug.cgi?id=146596
+ *
+ */
+//-----------------------------------------------------------------------------
+var UBound = 0;
+var BUGNUMBER = 146596;
+var summary = "Shouldn't crash when catch parameter is 'hidden' by varX";
+var status = '';
+var statusitems = [];
+var actual = '';
+var actualvalues = [];
+var expect= '';
+var expectedvalues = [];
+
+
+/*
+ * Just seeing we don't crash when executing this function -
+ * This example provided by jim-patterson@ncf.ca
+ *
+ * Brendan: "Jim, thanks for the testcase. But note that |var|
+ * in a JS function makes a function-scoped variable -- JS lacks
+ * block scope apart from for catch variables within catch blocks.
+ *
+ * Therefore the catch variable hides the function-local variable."
+ */
+function F()
+{
+ try
+ {
+ return "A simple exception";
+ }
+ catch(e)
+ {
+ var e = "Another exception";
+ }
+
+ return 'XYZ';
+}
+
+status = inSection(1);
+actual = F();
+expect = "A simple exception";
+addThis();
+
+
+
+/*
+ * Sanity check by Brendan: "This should output
+ *
+ * 24
+ * 42
+ * undefined
+ *
+ * and throw no uncaught exception."
+ *
+ */
+function f(obj)
+{
+ var res = [];
+
+ try
+ {
+ throw 42;
+ }
+ catch(e)
+ {
+ with(obj)
+ {
+ var e;
+ res[0] = e; // |with| binds tighter than |catch|; s/b |obj.e|
+ }
+
+ res[1] = e; // |catch| binds tighter than function scope; s/b 42
+ }
+
+ res[2] = e; // |var e| has function scope; s/b visible but contain |undefined|
+ return res;
+}
+
+status = inSection(2);
+actual = f({e:24});
+expect = [24, 42, undefined];
+addThis();
+
+
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+
+
+function addThis()
+{
+ statusitems[UBound] = status;
+ actualvalues[UBound] = actual.toString();
+ expectedvalues[UBound] = expect.toString();
+ UBound++;
+}
+
+
+function test()
+{
+ enterFunc('test');
+ printBugNumber(BUGNUMBER);
+ printStatus(summary);
+
+ for (var i=0; i<UBound; i++)
+ {
+ reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
+ }
+
+ exitFunc ('test');
+}