/* -*- 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:10Apr2002 *Revised:14July2002 * *SUMMARY:JSshouldNOTerroron|for(iinundefined)|,|for(iinnull)| * *ECMA-2623rdEditionFinalspecsayssuchstatementsSHOULDerror.See: * *Section12.6.4Thefor-inStatement *Section9.9ToObject * * *ButSpiderMonkeyhasdecidedNOTtofollowthis;it'sabuginthespec. *Seehttp://bugzilla.mozilla.org/show_bug.cgi?id=131348 * *Update:Rhinohasalsodecidednottofollowthespeconthis *Seehttp://bugzilla.mozilla.org/show_bug.cgi?id=136893
*/ //----------------------------------------------------------------------------- var UBound = 0; var BUGNUMBER = 131348; var summary = 'JS should not error on |for(i in undefined)|, |for(i in null)|'; var TEST_PASSED = 'No error'; var TEST_FAILED = 'An error was generated!!!'; var status = ''; var statusitems = []; var actual = ''; var actualvalues = []; var expect= ''; var expectedvalues = [];
status = inSection(1);
expect = TEST_PASSED;
actual = TEST_PASSED; try
{ for (var i in undefined)
{
print(i);
}
} catch(e)
{
actual = TEST_FAILED;
}
addThis();
status = inSection(2);
expect = TEST_PASSED;
actual = TEST_PASSED; try
{ for (var i in null)
{
print(i);
}
} catch(e)
{
actual = TEST_FAILED;
}
addThis();
status = inSection(3);
expect = TEST_PASSED;
actual = TEST_PASSED; /* *VariablenamesthatcannotbelookedupgenerateReferenceErrors;however, *propertynameslikeobj.ZZZthatcannotbelookeduparesetto|undefined| * *Therefore,thisshouldindirectlytest|for(variinundefined)|
*/ try
{ for (var i in this.ZZZ)
{
print(i);
}
} catch(e)
{
actual = TEST_FAILED;
}
addThis();
status = inSection(4);
expect = TEST_PASSED;
actual = TEST_PASSED; /* *Theresultofanunsuccessfulregexpmatchisthenullvalue *Therefore,thisshouldindirectlytest|for(variinnull)|
*/ try
{ for (var i in 'bbb'.match(/aaa/))
{
print(i);
}
} catch(e)
{
actual = TEST_FAILED;
}
addThis();
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.