зеркало из https://github.com/mozilla/gecko-dev.git
Completely rethinking this testcase. Reduced test as much as possible, added try...catch blocks and for-loop to stress-test the code.
This commit is contained in:
Родитель
e4e13ceab0
Коммит
ed10eb7850
|
@ -19,24 +19,17 @@
|
||||||
* Contributor(s): jrgm@netscape.com, pschwartau@netscape.com
|
* Contributor(s): jrgm@netscape.com, pschwartau@netscape.com
|
||||||
* Date: 04 September 2001
|
* Date: 04 September 2001
|
||||||
*
|
*
|
||||||
* SUMMARY: Regression test for Bugzilla bug 98306:
|
* SUMMARY: Regression test for Bugzilla bug 98306
|
||||||
* "JS parser crashes in ParseAtom for script using Regexp()"
|
* "JS parser crashes in ParseAtom for script using Regexp()"
|
||||||
*
|
*
|
||||||
* See http://bugzilla.mozilla.org/show_bug.cgi?id=98306
|
* See http://bugzilla.mozilla.org/show_bug.cgi?id=98306
|
||||||
* As noted there, we could generate this crash with just one line:
|
|
||||||
*
|
|
||||||
* "Hello".match(/[/]/);
|
|
||||||
*
|
|
||||||
* However, we include the longer testcase as originally reported -
|
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
var bug = 98306;
|
var bug = 98306;
|
||||||
var summary = "Testing that we don't crash on this code -";
|
var summary = "Testing that we don't crash on this code -";
|
||||||
var cnUSERAGENT = 'Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.3+) Gecko/20010828';
|
|
||||||
var cnUBOUND = 10;
|
var cnUBOUND = 10;
|
||||||
var obj;
|
|
||||||
var re;
|
var re;
|
||||||
|
var s;
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -51,81 +44,35 @@ function test()
|
||||||
printBugNumber (bug);
|
printBugNumber (bug);
|
||||||
printStatus (summary);
|
printStatus (summary);
|
||||||
|
|
||||||
// Sometimes it was necessary to try these more than once to crash
|
s = '"Hello".match(/[/]/)';
|
||||||
for (var i=0; i<cnUBOUND; i++)
|
tryThis(s);
|
||||||
{
|
|
||||||
// This alone caused a crash -
|
|
||||||
obj = new BrowserData('Hello');
|
|
||||||
|
|
||||||
// Here is a more realistic string. Test this, too.
|
s = 're = /[/';
|
||||||
obj = new BrowserData(cnUSERAGENT);
|
tryThis(s);
|
||||||
|
|
||||||
// These also caused crashes -
|
s = 're = /[/]/';
|
||||||
"Hello".match(/[/]/);
|
tryThis(s);
|
||||||
re = /[/;
|
|
||||||
re = /[/]/;
|
s = 're = /[//]/';
|
||||||
re = /[//]/;
|
tryThis(s);
|
||||||
}
|
|
||||||
|
|
||||||
exitFunc ('test');
|
exitFunc ('test');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
// Try to provoke a crash -
|
||||||
* BrowserData() constructor
|
function tryThis(sCode)
|
||||||
*
|
|
||||||
* .userAgent: (string) the HTTP_USER_AGENT input string
|
|
||||||
* .browser: (string) "MSIE", "Opera", "Nav", "Other"
|
|
||||||
* .majorVer: (integer) major version
|
|
||||||
* .minorVer: (string) minor (dot) version
|
|
||||||
* .betaVer: (string) beta version
|
|
||||||
* .platform: (string) operating system
|
|
||||||
* .getsNavBar (boolean) whether browser gets the DHTML menus
|
|
||||||
* .doesActiveX (boolean) whether browser does 32-bit ActiveX
|
|
||||||
*/
|
|
||||||
function BrowserData(sUA)
|
|
||||||
{
|
{
|
||||||
this.userAgent = sUA.toString();
|
// sometimes more than one attempt was necessary -
|
||||||
var rPattern = /(MSIE)\s(\d+)\.(\d+)((b|p)([^(s|;)]+))?;?(.*(98|95|NT|3.1|32|Mac|X11))?\s*([^\)]*)/;
|
for (var i=0; i<cnUBOUND; i++)
|
||||||
|
|
||||||
if (this.userAgent.match(rPattern))
|
|
||||||
{
|
{
|
||||||
this.browser = "MSIE";
|
try
|
||||||
this.majorVer = parseInt(RegExp.$2) || 0;
|
{
|
||||||
this.minorVer = RegExp.$3.toString() || "0";
|
eval(sCode);
|
||||||
this.betaVer = RegExp.$6.toString() || "0";
|
}
|
||||||
this.platform = RegExp.$8 || "Other";
|
catch(e)
|
||||||
this.platVer = RegExp.$9 || "0";
|
{
|
||||||
|
// do nothing; keep going -
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (this.userAgent.match(/Mozilla[/].*(95[/]NT|95|NT|98|3.1).*Opera.*(\d+)\.(\d+)/))
|
|
||||||
{
|
|
||||||
//"Mozilla/4.0 (Windows NT 5.0;US) Opera 3.60 [en]";
|
|
||||||
this.browser = "Opera";
|
|
||||||
this.majorVer = parseInt(RegExp.$2) || parseInt(RegExp.$2) || 0;
|
|
||||||
this.minorVer = RegExp.$3.toString() || RegExp.$3.toString() || "0";
|
|
||||||
this.platform = RegExp.$1 || "Other";
|
|
||||||
}
|
|
||||||
else if (this.userAgent.match(/Mozilla[/](\d*)\.?(\d*)(.*(98|95|NT|32|16|68K|PPC|X11))?/))
|
|
||||||
{
|
|
||||||
//"Mozilla/4.5 [en] (WinNT; I)"
|
|
||||||
this.browser = "Nav";
|
|
||||||
this.majorVer = parseInt(RegExp.$1) || 0;
|
|
||||||
this.minorVer = RegExp.$2.toString() || "0";
|
|
||||||
this.platform = RegExp.$4 || "Other";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.browser = "Other";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.getsNavBar = ("MSIE" == this.browser && 4 <= this.majorVer &&
|
|
||||||
"Mac" != this.platform && "X11" != this.platform);
|
|
||||||
|
|
||||||
this.doesActiveX = ("MSIE" == this.browser && 3 <= this.majorVer &&
|
|
||||||
("95" == this.platform || "98" == this.platform || "NT" == this.platform));
|
|
||||||
|
|
||||||
this.fullVer = parseFloat( this.majorVer + "." + this.minorVer );
|
|
||||||
|
|
||||||
this.doesPersistence = ("MSIE" == this.browser && 5 <= this.majorVer &&
|
|
||||||
"Mac" != this.platform && "X11" != this.platform);
|
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче