1/* 2* The contents of this file are subject to the Netscape Public 3* License Version 1.1 (the "License"); you may not use this file 4* except in compliance with the License. You may obtain a copy of 5* the License at http://www.mozilla.org/NPL/ 6* 7* Software distributed under the License is distributed on an "AS 8* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9* implied. See the License for the specific language governing 10* rights and limitations under the License. 11* 12* The Original Code is mozilla.org code. 13* 14* The Initial Developer of the Original Code is Netscape 15* Communications Corporation. Portions created by Netscape are 16* Copyright (C) 1998 Netscape Communications Corporation. All 17* Rights Reserved. 18* 19* Contributor(s): 20*/ 21 22/** 23 * File Name: regress-9141.js 24 * Reference: "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; 25 * Description: 26 * From waldemar@netscape.com: 27 * 28 * The following page crashes the system: 29 * 30 * <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 31 * "http://www.w3.org/TR/REC-html40/loose.dtd"> 32 * <HTML> 33 * <HEAD> 34 * </HEAD> 35 * <BODY> 36 * <SCRIPT type="text/javascript"> 37 * var s = "x"; 38 * for (var i = 0; i != 13; i++) s += s; 39 * var a = /(?:xx|x)*[slash](s); 40 * var b = /(xx|x)*[slash](s); 41 * document.write("Results = " + a.length + "," + b.length); 42 * </SCRIPT> 43 * </BODY> 44 */ 45 46 var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) 47 var VERSION = "ECMA_2"; // Version of JavaScript or ECMA 48 var TITLE = "Regression test for bugzilla # 9141"; // Provide ECMA section title or a description 49 var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; // Provide URL to bugsplat or bugzilla report 50 51 startTest(); // leave this alone 52 53 /* 54 * Calls to AddTestCase here. AddTestCase is a function that is defined 55 * in shell.js and takes three arguments: 56 * - a string representation of what is being tested 57 * - the expected result 58 * - the actual result 59 * 60 * For example, a test might look like this: 61 * 62 * var zip = /[\d]{5}$/; 63 * 64 * AddTestCase( 65 * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test 66 * "02134", // expected result 67 * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result 68 * 69 */ 70 71 var s = "x"; 72 for (var i = 0; i != 13; i++) s += s; 73 var a = /(?:xx|x)*/(s); 74 var b = /(xx|x)*/(s); 75 76 AddTestCase( "var s = 'x'; for (var i = 0; i != 13; i++) s += s; " + 77 "a = /(?:xx|x)*/(s); a.length", 78 1, 79 a.length ); 80 81 AddTestCase( "var b = /(xx|x)*/(s); b.length", 82 2, 83 b.length ); 84 85 test(); // leave this alone. this executes the test cases and 86 // displays results. 87