/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* * *Date:08Jan2002 *SUMMARY:Justtestingthatwedon'tcrashonthiscode *Seehttp://bugzilla.mozilla.org/show_bug.cgi?id=118849 * *http://developer.netscape.com:80/docs/manuals/js/core/jsref/function.htm *TheFunctionconstructor: *Function([arg1[,arg2[,...argN]],]functionBody) * *Parameters *arg1,arg2,...argN *(Optional)Namestobeusedbythefunctionasformalargumentnames. *EachmustbeastringthatcorrespondstoavalidJavaScriptidentifier. * *functionBody *AstringcontainingJSstatementscomprisingthefunctiondefinition.
*/ //----------------------------------------------------------------------------- var UBound = 0; var BUGNUMBER = 118849; var summary = 'Should not crash if we provide Function() with bad arguments' var status = ''; var statusitems = []; var actual = ''; var actualvalues = []; var expect= ''; var expectedvalues = []; var cnFAIL_1 = 'LEGAL call to Function() caused an ERROR!!!'; var cnFAIL_2 = 'ILLEGAL call to Function() FAILED to cause an error'; var cnSTRING = 'ASDF'; var cnNUMBER = 123;
/***********************************************************/ /**** THESE ARE LEGITMATE CALLS AND SHOULD ALL SUCCEED ***/ /***********************************************************/
status = inSection(1);
actual = cnFAIL_1; // initialize to failure try
{ Function(cnSTRING); Function(cnNUMBER); // cnNUMBER is a valid functionBody Function(cnSTRING,cnSTRING); Function(cnSTRING,cnNUMBER); Function(cnSTRING,cnSTRING,cnNUMBER);
/**********************************************************/ /*** EACH CASE THAT FOLLOWS SHOULD TRIGGER AN ERROR ***/ /*** (BUT NOT A CRASH) ***/ /*** NOTE WE NOW USE cnFAIL_2 INSTEAD OF cnFAIL_1 ***/ /**********************************************************/
status = inSection(2);
actual = cnFAIL_2; try
{ Function(cnNUMBER,cnNUMBER); // cnNUMBER is an invalid JS identifier name
} catch(e)
{
actual = expect;
}
addThis();
status = inSection(3);
actual = cnFAIL_2; try
{ Function(cnNUMBER,cnSTRING,cnSTRING);
} catch(e)
{
actual = expect;
}
addThis();
status = inSection(4);
actual = cnFAIL_2; try
{ newFunction(cnNUMBER,cnNUMBER);
} catch(e)
{
actual = expect;
}
addThis();
status = inSection(5);
actual = cnFAIL_2; try
{ newFunction(cnNUMBER,cnSTRING,cnSTRING);
} catch(e)
{
actual = expect;
}
addThis();
function test()
{
printBugNumber(BUGNUMBER);
printStatus (summary);
for (var i = 0; i < UBound; i++)
{
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.11Bemerkung:
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.