| 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/. */ |
| 5 | |
| 6 | /* |
| 7 | * Date: 04 September 2001 |
| 8 | * |
| 9 | * SUMMARY: Regression test for Bugzilla bug 98306 |
| 10 | * "JS parser crashes in ParseAtom for script using Regexp()" |
| 11 | * |
| 12 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=98306 |
| 13 | */ |
| 14 | //----------------------------------------------------------------------------- |
| 15 | var gTestfile = 'regress-98306.js'; |
| 16 | var BUGNUMBER = 98306; |
| 17 | var summary = "Testing that we don't crash on this code -"; |
| 18 | var cnUBOUND = 10; |
| 19 | var re; |
| 20 | var s; |
| 21 | |
| 22 | |
| 23 | //----------------------------------------------------------------------------- |
| 24 | test(); |
| 25 | //----------------------------------------------------------------------------- |
| 26 | |
| 27 | |
| 28 | function test() |
| 29 | { |
| 30 | enterFunc ('test'); |
| 31 | printBugNumber(BUGNUMBER); |
| 32 | printStatus (summary); |
| 33 | |
| 34 | s = '"Hello".match(/[/]/)'; |
| 35 | tryThis(s); |
| 36 | |
| 37 | s = 're = /[/'; |
| 38 | tryThis(s); |
| 39 | |
| 40 | s = 're = /[/]/'; |
| 41 | tryThis(s); |
| 42 | |
| 43 | s = 're = /[//]/'; |
| 44 | tryThis(s); |
| 45 | |
| 46 | reportCompare('No Crash', 'No Crash', ''); |
| 47 | exitFunc ('test'); |
| 48 | } |
| 49 | |
| 50 | |
| 51 | // Try to provoke a crash - |
| 52 | function tryThis(sCode) |
| 53 | { |
| 54 | // sometimes more than one attempt is necessary - |
| 55 | for (var i=0; i<cnUBOUND; i++) |
| 56 | { |
| 57 | try |
| 58 | { |
| 59 | eval(sCode); |
| 60 | } |
| 61 | catch(e) |
| 62 | { |
| 63 | // do nothing; keep going - |
| 64 | } |
| 65 | } |
| 66 | } |