1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/extensions/catchguard-001.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +test(); 1.11 + 1.12 +function test() 1.13 +{ 1.14 + enterFunc ("test"); 1.15 + 1.16 + var EXCEPTION_DATA = "String exception"; 1.17 + var e = "foo"; 1.18 + var caught = false; 1.19 + 1.20 + printStatus ("Basic catchguard test."); 1.21 + 1.22 + try 1.23 + { 1.24 + throw EXCEPTION_DATA; 1.25 + } 1.26 + catch (e if true) 1.27 + { 1.28 + caught = true; 1.29 + e = "this change should not propagate outside of this scope"; 1.30 + } 1.31 + catch (e if false) 1.32 + { 1.33 + reportCompare('PASS', 'FAIL', "Catch block (e if false) should not have executed."); 1.34 + } 1.35 + catch (e) 1.36 + { 1.37 + reportCompare('PASS', 'FAIL', "Catch block (e) should not have executed."); 1.38 + } 1.39 + 1.40 + if (!caught) 1.41 + reportCompare('PASS', 'FAIL', "Exception was never caught."); 1.42 + 1.43 + if (e != "foo") 1.44 + reportCompare('PASS', 'FAIL', "Exception data modified inside catch() scope should " + 1.45 + "not be visible in the function scope (e = '" + 1.46 + e + "'.)"); 1.47 + 1.48 + reportCompare('PASS', 'PASS', ''); 1.49 + exitFunc ("test"); 1.50 +}