1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_2/regexp/regress-9141.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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 + 1.11 +/** 1.12 + * File Name: regress-9141.js 1.13 + * Reference: "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; 1.14 + * Description: 1.15 + * From waldemar@netscape.com: 1.16 + * 1.17 + * The following page crashes the system: 1.18 + * 1.19 + * <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 1.20 + * "http://www.w3.org/TR/REC-html40/loose.dtd"> 1.21 + * <HTML> 1.22 + * <HEAD> 1.23 + * </HEAD> 1.24 + * <BODY> 1.25 + * <SCRIPT type="text/javascript"> 1.26 + * var s = "x"; 1.27 + * for (var i = 0; i != 13; i++) s += s; 1.28 + * var a = /(?:xx|x)*[slash](s); 1.29 + * var b = /(xx|x)*[slash](s); 1.30 + * document.write("Results = " + a.length + "," + b.length); 1.31 + * </SCRIPT> 1.32 + * </BODY> 1.33 + */ 1.34 + 1.35 +var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) 1.36 +var VERSION = "ECMA_2"; // Version of JavaScript or ECMA 1.37 +var TITLE = "Regression test for bugzilla # 9141"; // Provide ECMA section title or a description 1.38 +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; // Provide URL to bugsplat or bugzilla report 1.39 + 1.40 +startTest(); // leave this alone 1.41 + 1.42 +/* 1.43 + * Calls to AddTestCase here. AddTestCase is a function that is defined 1.44 + * in shell.js and takes three arguments: 1.45 + * - a string representation of what is being tested 1.46 + * - the expected result 1.47 + * - the actual result 1.48 + * 1.49 + * For example, a test might look like this: 1.50 + * 1.51 + * var zip = /[\d]{5}$/; 1.52 + * 1.53 + * AddTestCase( 1.54 + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test 1.55 + * "02134", // expected result 1.56 + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result 1.57 + * 1.58 + */ 1.59 + 1.60 +var s = "x"; 1.61 +for (var i = 0; i != 13; i++) s += s; 1.62 +var a = /(?:xx|x)*/.exec(s); 1.63 +var b = /(xx|x)*/.exec(s); 1.64 + 1.65 +AddTestCase( "var s = 'x'; for (var i = 0; i != 13; i++) s += s; " + 1.66 + "a = /(?:xx|x)*/.exec(s); a.length", 1.67 + 1, 1.68 + a.length ); 1.69 + 1.70 +AddTestCase( "var b = /(xx|x)*/.exec(s); b.length", 1.71 + 2, 1.72 + b.length ); 1.73 + 1.74 +test(); // leave this alone. this executes the test cases and 1.75 +// displays results.