Skip to content
Permalink
Browse files
Unreviewed, rolling in the rest of r237254
https://bugs.webkit.org/show_bug.cgi?id=190340

JSTests:

* ChakraCore/test/Function/FuncBodyES5.baseline-jsc:
* stress/function-cache-with-parameters-end-position.js: Added.
(shouldBe):
(shouldThrow):
(i.anonymous):
* stress/function-constructor-name.js: Added.
(shouldBe):
(GeneratorFunction):
(AsyncFunction.async):
(AsyncGeneratorFunction.async):
(anonymous):
(async.anonymous):
* test262/expectations.yaml:

LayoutTests/imported/w3c:

* web-platform-tests/html/webappapis/scripting/events/inline-event-handler-ordering-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-late-expected.txt:
* web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-attribute-expected.txt:
* web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-body-onerror-expected.txt:

Source/JavaScriptCore:

* parser/ParserModes.h:
* parser/ParserTokens.h:
(JSC::JSTextPosition::JSTextPosition):
(JSC::JSTokenLocation::JSTokenLocation): Deleted.
* runtime/CodeCache.cpp:
(JSC::CodeCache::getUnlinkedGlobalFunctionExecutable):
* runtime/FunctionConstructor.cpp:
(JSC::constructFunctionSkippingEvalEnabledCheck):

LayoutTests:

* fast/dom/attribute-event-listener-errors-expected.txt:
* fast/events/attribute-listener-deletion-crash-expected.txt:
* fast/events/window-onerror-syntax-error-in-attr-expected.txt:
* js/dom/invalid-syntax-for-function-expected.txt:
* js/dom/script-start-end-locations-expected.txt:

Canonical link: https://commits.webkit.org/206541@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238365 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Constellation committed Nov 18, 2018
1 parent 69e643b commit 944f6df1d7ae913de0603aa0393e1cd05413548a
@@ -9,13 +9,13 @@ PASS: 7: new Function succeeded as expected
PASS: 8: new Function succeeded as expected
PASS: 9: new Function succeeded as expected
PASS: 10: new Function succeeded as expected
PASS: 100: new Function failed as expected. SyntaxError: Unexpected token '{'. Expected ')' to end a compound expression.
PASS: 100: new Function failed as expected. SyntaxError: Unexpected token '{'. Expected ')' to end a compound expression.
PASS: 101: new Function failed as expected. SyntaxError: Unexpected keyword 'function'. Expected ')' to end a compound expression.
PASS: 102: new Function failed as expected. SyntaxError: Unexpected keyword 'function'. Expected ')' to end a compound expression.
PASS: 103: new Function failed as expected. SyntaxError: Unexpected keyword 'function'. Expected ')' to end a compound expression.
PASS: 104: new Function failed as expected. SyntaxError: Unexpected token ';'. Expected ')' to end a compound expression.
PASS: 105: new Function failed as expected. SyntaxError: Unexpected token ';'. Expected ')' to end a compound expression.
PASS: 100: new Function failed as expected. SyntaxError: Parser error
PASS: 100: new Function failed as expected. SyntaxError: Parser error
PASS: 101: new Function failed as expected. SyntaxError: Parser error
PASS: 102: new Function failed as expected. SyntaxError: Parameters should match arguments offered as parameters in Function constructor.
PASS: 103: new Function failed as expected. SyntaxError: Parser error
PASS: 104: new Function failed as expected. SyntaxError: Parameters should match arguments offered as parameters in Function constructor.
PASS: 105: new Function failed as expected. SyntaxError: Parser error
PASS: 200: new Function failed as expected. SyntaxError: Unexpected token ','. Expected a parameter pattern or a ')' in parameter list.
PASS: 200: new Function failed as expected. SyntaxError: Unexpected token ','. Expected a parameter pattern or a ')' in parameter list.
PASS: 201: new Function failed as expected. SyntaxError: Unexpected token ','. Expected a parameter pattern or a ')' in parameter list.
@@ -1,3 +1,22 @@
2018-11-18 Yusuke Suzuki <yusukesuzuki@slowstart.org>

Unreviewed, rolling in the rest of r237254
https://bugs.webkit.org/show_bug.cgi?id=190340

* ChakraCore/test/Function/FuncBodyES5.baseline-jsc:
* stress/function-cache-with-parameters-end-position.js: Added.
(shouldBe):
(shouldThrow):
(i.anonymous):
* stress/function-constructor-name.js: Added.
(shouldBe):
(GeneratorFunction):
(AsyncFunction.async):
(AsyncGeneratorFunction.async):
(anonymous):
(async.anonymous):
* test262/expectations.yaml:

2018-11-16 Filip Pizlo <fpizlo@apple.com>

All users of ArrayBuffer should agree on the same max size
@@ -0,0 +1,40 @@
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}

function shouldThrow(func, errorMessage) {
var errorThrown = false;
var error = null;
try {
func();
} catch (e) {
errorThrown = true;
error = e;
}
if (!errorThrown)
throw new Error('not thrown');
if (String(error) !== errorMessage)
throw new Error(`bad error: ${String(error)}`);
}

for (var i = 0; i < 10; ++i) {
var f = Function('/*) {\n*/', 'return 42');
shouldBe(f.toString(),
`function anonymous(/*) {
*/) {
return 42
}`);
}
shouldThrow(() => Function('/*', '*/){\nreturn 42'), `SyntaxError: Parameters should match arguments offered as parameters in Function constructor.`);

shouldThrow(() => Function('/*', '*/){\nreturn 43'), `SyntaxError: Parameters should match arguments offered as parameters in Function constructor.`);
for (var i = 0; i < 10; ++i) {
var f = Function('/*) {\n*/', 'return 43');
shouldBe(f.toString(),
`function anonymous(/*) {
*/) {
return 43
}`);
}

@@ -0,0 +1,36 @@
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}

var GeneratorFunction = function*(){}.constructor;
var AsyncFunction = async function(){}.constructor;
var AsyncGeneratorFunction = async function*(){}.constructor;

var f = Function(`return 42`);
shouldBe(typeof anonymous, `undefined`);
shouldBe(f.toString(),
`function anonymous() {
return 42
}`);

var gf = GeneratorFunction(`return 42`);
shouldBe(typeof anonymous, `undefined`);
shouldBe(gf.toString(),
`function* anonymous() {
return 42
}`);

var af = AsyncFunction(`return 42`);
shouldBe(typeof anonymous, `undefined`);
shouldBe(af.toString(),
`async function anonymous() {
return 42
}`);

var agf = AsyncGeneratorFunction(`return 42`);
shouldBe(typeof anonymous, `undefined`);
shouldBe(agf.toString(),
`async function* anonymous() {
return 42
}`);
@@ -900,14 +900,14 @@ test/built-ins/Function/prototype/restricted-property-caller.js:
default: "ReferenceError: Can't find variable: verifyNotEnumerable"
strict mode: "ReferenceError: Can't find variable: verifyNotEnumerable"
test/built-ins/Function/prototype/toString/AsyncFunction.js:
default: "SyntaxError: Unexpected token '}'. Expected a ')' or a ',' after a parameter declaration."
strict mode: "SyntaxError: Unexpected token '}'. Expected a ')' or a ',' after a parameter declaration."
default: "SyntaxError: Unexpected token ';'. Expected a ')' or a ',' after a parameter declaration."
strict mode: "SyntaxError: Unexpected token ';'. Expected a ')' or a ',' after a parameter declaration."
test/built-ins/Function/prototype/toString/Function.js:
default: "SyntaxError: Unexpected token '}'. Expected a ')' or a ',' after a parameter declaration."
strict mode: "SyntaxError: Unexpected token '}'. Expected a ')' or a ',' after a parameter declaration."
default: "SyntaxError: Unexpected token ';'. Expected a ')' or a ',' after a parameter declaration."
strict mode: "SyntaxError: Unexpected token ';'. Expected a ')' or a ',' after a parameter declaration."
test/built-ins/Function/prototype/toString/GeneratorFunction.js:
default: "SyntaxError: Unexpected token '}'. Expected a ')' or a ',' after a parameter declaration."
strict mode: "SyntaxError: Unexpected token '}'. Expected a ')' or a ',' after a parameter declaration."
default: "SyntaxError: Unexpected keyword 'yield'. Expected a ')' or a ',' after a parameter declaration."
strict mode: "SyntaxError: Unexpected keyword 'yield'. Expected a ')' or a ',' after a parameter declaration."
test/built-ins/Function/prototype/toString/async-arrow-function.js:
default: "Test262Error: Conforms to NativeFunction Syntax: 'async ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ }'.(async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ })"
strict mode: "Test262Error: Conforms to NativeFunction Syntax: 'async ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ }'.(async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ })"
@@ -1,3 +1,14 @@
2018-11-18 Yusuke Suzuki <yusukesuzuki@slowstart.org>

Unreviewed, rolling in the rest of r237254
https://bugs.webkit.org/show_bug.cgi?id=190340

* fast/dom/attribute-event-listener-errors-expected.txt:
* fast/events/attribute-listener-deletion-crash-expected.txt:
* fast/events/window-onerror-syntax-error-in-attr-expected.txt:
* js/dom/invalid-syntax-for-function-expected.txt:
* js/dom/script-start-end-locations-expected.txt:

2018-11-17 Devin Rousso <drousso@apple.com>

Web Inspector: Network: add button to show system certificate dialog
@@ -1,4 +1,4 @@
CONSOLE MESSAGE: line 4: ReferenceError: Can't find variable: error
CONSOLE MESSAGE: line 9: SyntaxError: Invalid character: '@'
CONSOLE MESSAGE: line 5: SyntaxError: Invalid character: '@'
This test verifies that an attribute event listener error shows the right line number even if the attribute contains newlines.

@@ -1,21 +1,21 @@
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 2: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
CONSOLE MESSAGE: line 1: SyntaxError: Unexpected token '|'
PASS
@@ -1,6 +1,6 @@
Test that window.onerror is called on window object when there is a syntax error in attribute handler. Bug 70991.

Main frame window.onerror: SyntaxError: Unexpected token '%' at window-onerror-syntax-error-in-attr.html:11:38 SyntaxError: Unexpected token '%'
Main frame window.onerror: SyntaxError: Unexpected token '%' at window-onerror-syntax-error-in-attr.html:37:38 SyntaxError: Unexpected token '%'
Main frame window.onerror: SyntaxError: Unexpected token '%' at window-onerror-syntax-error-in-attr.html:37:14 SyntaxError: Unexpected token '%'
Main frame window.onerror: SyntaxError: Unexpected token '%' at window-onerror-syntax-error-in-attr.html:10:38 SyntaxError: Unexpected token '%'
Main frame window.onerror: SyntaxError: Unexpected token '%' at window-onerror-syntax-error-in-attr.html:36:38 SyntaxError: Unexpected token '%'
Main frame window.onerror: SyntaxError: Unexpected token '%' at window-onerror-syntax-error-in-attr.html:36:14 SyntaxError: Unexpected token '%'
Button 1 Button 2 Button 3
@@ -1,3 +1,13 @@
2018-11-18 Yusuke Suzuki <yusukesuzuki@slowstart.org>

Unreviewed, rolling in the rest of r237254
https://bugs.webkit.org/show_bug.cgi?id=190340

* web-platform-tests/html/webappapis/scripting/events/inline-event-handler-ordering-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-late-expected.txt:
* web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-attribute-expected.txt:
* web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-body-onerror-expected.txt:

2018-11-15 Truitt Savell <tsavell@apple.com>

Unreviewed, rolling out r238244.
@@ -1,5 +1,5 @@
CONSOLE MESSAGE: line 19: SyntaxError: Unexpected token '}'
CONSOLE MESSAGE: line 54: SyntaxError: Unexpected token '}'
CONSOLE MESSAGE: line 52: SyntaxError: Unexpected token '}'

PASS Inline event handlers retain their ordering when invalid and force-compiled
PASS Inline event handlers retain their ordering when invalid and force-compiled via dispatch
@@ -1,5 +1,5 @@
CONSOLE MESSAGE: line 26: SyntaxError: Unexpected token '}'. Expected ')' to end a compound expression.
CONSOLE MESSAGE: line 21: SyntaxError: Unexpected token '}'. Expected ')' to end a compound expression.
CONSOLE MESSAGE: line 24: SyntaxError: Parser error
CONSOLE MESSAGE: line 21: SyntaxError: Parser error

FAIL Invalid uncompiled raw handlers should only be compiled when about to call them. assert_array_equals: lengths differ, expected 3 got 4

@@ -1,4 +1,4 @@
CONSOLE MESSAGE: line 26: SyntaxError: Unexpected token ')'
CONSOLE MESSAGE: line 24: SyntaxError: Unexpected end of script

PASS window.onerror - compile error in attribute
PASS window.onerror - compile error in attribute (column)
@@ -1,5 +1,5 @@
CONSOLE MESSAGE: line 19: SyntaxError: Unexpected token ')'
CONSOLE MESSAGE: line 18: SyntaxError: Unexpected token ')'
CONSOLE MESSAGE: line 16: SyntaxError: Unexpected end of script

PASS window.onerror - compile error in <body onerror>

@@ -1,3 +1,3 @@
CONSOLE MESSAGE: line 2: SyntaxError: Invalid character: '#'
CONSOLE MESSAGE: line 1: SyntaxError: Invalid character: '#'
This test ensures we don't crash when we are given garbage for an attribute expecting a function.
https://bugs.webkit.org/show_bug.cgi?id=19025
@@ -243,32 +243,32 @@ function "exi2b" { 1:138 - 1:221 }
eval { 1:1 - 1:56 }

new Function Object:
function "anonymous" { 1:20 - 2:228 }
function "anonymous" { 1:19 - 2:228 }
function "nf1a" { 2:57 - 2:219 }
function "nf1b" { 2:87 - 2:209 }
function "nf1c" { 2:117 - 2:199 }
eval { 1:1 - 1:56 }
function "anonymous" { 1:20 - 18:8 }
function "anonymous" { 1:19 - 18:8 }
function "nf2a" { 5:18 - 16:5 }
function "nf2b" { 7:22 - 14:9 }
function "nf2c" { 9:26 - 12:13 }
eval { 1:1 - 1:56 }
function "anonymous" { 1:20 - 2:228 }
function "anonymous" { 1:19 - 2:228 }
function "nf1a" { 2:57 - 2:219 }
function "nf1b" { 2:87 - 2:209 }
function "nf1c" { 2:117 - 2:199 }
eval { 1:1 - 1:56 }
function "anonymous" { 1:20 - 2:237 }
function "anonymous" { 1:19 - 2:237 }
function "nfi1a" { 2:58 - 2:227 }
function "nfi1b" { 2:90 - 2:216 }
function "nfi1c" { 2:122 - 2:205 }
eval { 1:1 - 1:56 }
function "anonymous" { 1:20 - 18:8 }
function "anonymous" { 1:19 - 18:8 }
function "nf2a" { 5:18 - 16:5 }
function "nf2b" { 7:22 - 14:9 }
function "nf2c" { 9:26 - 12:13 }
eval { 1:1 - 1:56 }
function "anonymous" { 1:20 - 18:9 }
function "anonymous" { 1:19 - 18:9 }
function "nfi2a" { 5:19 - 16:5 }
function "nfi2b" { 7:23 - 14:9 }
function "nfi2c" { 9:27 - 12:13 }
@@ -1,3 +1,17 @@
2018-11-18 Yusuke Suzuki <yusukesuzuki@slowstart.org>

Unreviewed, rolling in the rest of r237254
https://bugs.webkit.org/show_bug.cgi?id=190340

* parser/ParserModes.h:
* parser/ParserTokens.h:
(JSC::JSTextPosition::JSTextPosition):
(JSC::JSTokenLocation::JSTokenLocation): Deleted.
* runtime/CodeCache.cpp:
(JSC::CodeCache::getUnlinkedGlobalFunctionExecutable):
* runtime/FunctionConstructor.cpp:
(JSC::constructFunctionSkippingEvalEnabledCheck):

2018-11-17 Devin Rousso <drousso@apple.com>

Web Inspector: Network: add button to show system certificate dialog
@@ -33,7 +33,6 @@ namespace JSC {
enum class JSParserStrictMode { NotStrict, Strict };
enum class JSParserBuiltinMode { NotBuiltin, Builtin };
enum class JSParserScriptMode { Classic, Module };
enum class JSParserCodeType { Program, Function, Module };

enum class ConstructorKind { None, Base, Extends };
enum class SuperBinding { Needed, NotNeeded };
@@ -193,7 +193,6 @@ enum JSTokenType {
struct JSTextPosition {
JSTextPosition() = default;
JSTextPosition(int _line, int _offset, int _lineStartOffset) : line(_line), offset(_offset), lineStartOffset(_lineStartOffset) { }
JSTextPosition(const JSTextPosition& other) : line(other.line), offset(other.offset), lineStartOffset(other.lineStartOffset) { }

JSTextPosition operator+(int adjustment) const { return JSTextPosition(line, offset + adjustment, lineStartOffset); }
JSTextPosition operator+(unsigned adjustment) const { return *this + static_cast<int>(adjustment); }
@@ -246,13 +245,6 @@ union JSTokenData {

struct JSTokenLocation {
JSTokenLocation() = default;
JSTokenLocation(const JSTokenLocation& location)
{
line = location.line;
lineStartOffset = location.lineStartOffset;
startOffset = location.startOffset;
endOffset = location.endOffset;
}

int line { 0 };
unsigned lineStartOffset { 0 };
@@ -119,25 +119,14 @@ UnlinkedFunctionExecutable* CodeCache::getUnlinkedGlobalFunctionExecutable(VM& v
}

JSTextPosition positionBeforeLastNewline;
std::unique_ptr<ProgramNode> program = parse<ProgramNode>(
&vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin,
JSParserStrictMode::NotStrict, JSParserScriptMode::Classic, SourceParseMode::ProgramMode, SuperBinding::NotNeeded,
error, &positionBeforeLastNewline);
std::unique_ptr<ProgramNode> program = parseFunctionForFunctionConstructor(vm, source, error, &positionBeforeLastNewline, functionConstructorParametersEndPosition);
if (!program) {
RELEASE_ASSERT(error.isValid());
return nullptr;
}

// This function assumes an input string that would result in a single function declaration.
StatementNode* statement = program->singleStatement();
if (UNLIKELY(!statement)) {
JSToken token;
error = ParserError(ParserError::SyntaxError, ParserError::SyntaxErrorIrrecoverable, token, "Parser error", -1);
return nullptr;
}
ASSERT(statement->isBlock());

StatementNode* funcDecl = static_cast<BlockNode*>(statement)->singleStatement();
StatementNode* funcDecl = program->singleStatement();
if (UNLIKELY(!funcDecl)) {
JSToken token;
error = ParserError(ParserError::SyntaxError, ParserError::SyntaxErrorIrrecoverable, token, "Parser error", -1);

0 comments on commit 944f6df

Please sign in to comment.