regress-350312.js (1389B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 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 var BUGNUMBER = 350312; 8 var summary = 'Accessing wrong stack slot with nested catch/finally'; 9 var actual = ''; 10 var expect = ''; 11 12 13 //----------------------------------------------------------------------------- 14 test(); 15 //----------------------------------------------------------------------------- 16 17 function test() 18 { 19 printBugNumber(BUGNUMBER); 20 printStatus (summary); 21 22 var counter = 0; 23 24 function f(x,y) { 25 26 try 27 { 28 throw x; 29 } 30 catch(e) 31 { 32 if (y) 33 throw e; 34 } 35 finally 36 { 37 try 38 { 39 actual += 'finally,'; 40 throw 42; 41 } 42 catch(e2) 43 { 44 actual += e2; 45 if (++counter > 10) 46 { 47 throw 'Infinite loop...'; 48 } 49 } 50 } 51 return 'returned'; 52 } 53 54 expect = 'finally,42'; 55 actual = ''; 56 57 try 58 { 59 print('test 1'); 60 f(2, 1); 61 } 62 catch(ex) 63 { 64 } 65 reportCompare(expect, actual, summary); 66 67 actual = ''; 68 try 69 { 70 print('test 2'); 71 f(2, 0); 72 } 73 catch(ex) 74 { 75 } 76 reportCompare(expect, actual, summary); 77 }