Bug 663331 - Make U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR match the LineTerminator production when parsing code. r=njn

--HG--
extra : rebase_source : 9d6c02d03a5631e90b06fed4394d3867e5a29d5f
This commit is contained in:
Jeff Walden 2011-06-10 11:22:06 -07:00
parent 44a8747e80
commit 7f7f1141f6
3 changed files with 57 additions and 5 deletions

View File

@ -1350,12 +1350,12 @@ TokenStream::getTokenInternal()
* early allows subsequent checking to be faster.
*/
if (JS_UNLIKELY(c >= 128)) {
if (JS_ISSPACE_OR_BOM(c))
goto retry;
if (JS_ISSPACE_OR_BOM(c)) {
if (c == LINE_SEPARATOR || c == PARA_SEPARATOR) {
updateLineInfoForEOL();
updateFlagsForEOL();
}
if (c == LINE_SEPARATOR || c == PARA_SEPARATOR) {
updateLineInfoForEOL();
updateFlagsForEOL();
goto retry;
}

View File

@ -1,5 +1,6 @@
url-prefix ../../jsreftest.html?test=ecma_5/misc/
script global-numeric-properties.js
script line-paragraph-separator-parse-as-lineterminator.js
script redeclare-var-non-writable-property.js
script enumerate-undefined.js
script unwrapped-no-such-method.js

View File

@ -0,0 +1,51 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
//-----------------------------------------------------------------------------
var BUGNUMBER = 663331;
var summary =
"U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR must match the " +
"LineTerminator production when parsing code";
print(BUGNUMBER + ": " + summary);
/**************
* BEGIN TEST *
**************/
var hidden = 17;
var assigned;
assigned = 42;
assertEq(eval('"use strict"; var hidden\u2028assigned = 5; typeof hidden'),
"undefined");
assertEq(assigned, 5);
assigned = 42;
function t1()
{
assertEq(eval('var hidden\u2028assigned = 5; typeof hidden'), "undefined");
assertEq(assigned, 5);
}
t1();
assigned = 42;
assertEq(eval('"use strict"; var hidden\u2029assigned = 5; typeof hidden'),
"undefined");
assertEq(assigned, 5);
assigned = 42;
function t2()
{
assertEq(eval('var hidden\u2029assigned = 5; typeof hidden'), "undefined");
assertEq(assigned, 5);
}
t2();
/******************************************************************************/
reportCompare(true, true);
print("All tests passed!");