From 6fe75e30aacff1f2e9b10a01e20bebd68fe56474 Mon Sep 17 00:00:00 2001 From: Josh Wolfe Date: Tue, 19 Dec 2017 12:14:44 -0700 Subject: [PATCH] Reland: Enable --harmony-function-tostring by default Update tests to work with new behavior. Thanks Yang Guo for fixing the GC problem in ad126d46bb5cb7630189c641613043546960ee70 R=adamk@chromium.org, machenbach@chromium.org Q_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel Bug: v8:4958 Change-Id: Ia7d9417f80087fb6df4ef877d0b4357875ee6c30 Reviewed-on: https://chromium-review.googlesource.com/834458 Reviewed-by: Adam Klein Commit-Queue: Josh Wolfe Cr-Commit-Position: refs/heads/master@{#50486} --- src/flag-definitions.h | 2 +- test/message/fail/paren_in_arg_string.out | 8 ++++---- test/mjsunit/harmony/async-generators-basic.js | 6 +++--- test/mjsunit/regress/regress-2470.js | 2 +- test/mjsunit/regress/regress-crbug-109362.js | 11 ++++++----- test/mjsunit/regress/regress-crbug-663410.js | 2 +- test/mozilla/mozilla.status | 4 ++++ 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/flag-definitions.h b/src/flag-definitions.h index b29b043ef3..5021dbd411 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -211,7 +211,6 @@ DEFINE_IMPLICATION(harmony_class_fields, harmony_static_fields) // Features that are complete (but still behind --harmony/es-staging flag). #define HARMONY_STAGED(V) \ - V(harmony_function_tostring, "harmony Function.prototype.toString") \ V(harmony_restrict_constructor_return, \ "harmony disallow non undefined primitive return value from class " \ "constructor") \ @@ -225,6 +224,7 @@ DEFINE_IMPLICATION(harmony_class_fields, harmony_static_fields) V(harmony_regexp_named_captures, "harmony regexp named captures") \ V(harmony_regexp_property, "harmony Unicode regexp property classes") \ V(harmony_async_iteration, "harmony async iteration") \ + V(harmony_function_tostring, "harmony Function.prototype.toString") \ V(harmony_promise_finally, "harmony Promise.prototype.finally") #ifdef V8_INTL_SUPPORT diff --git a/test/message/fail/paren_in_arg_string.out b/test/message/fail/paren_in_arg_string.out index 9784712ab8..d71e952122 100644 --- a/test/message/fail/paren_in_arg_string.out +++ b/test/message/fail/paren_in_arg_string.out @@ -1,6 +1,6 @@ -*%(basename)s:29: SyntaxError: Function arg string contains parenthesis -var paren_in_arg_string_bad = new Function(')', 'return;'); - ^ -SyntaxError: Function arg string contains parenthesis +undefined:1: SyntaxError: Arg string terminates parameters early +(function anonymous() + ^ +SyntaxError: Arg string terminates parameters early at new Function () at *%(basename)s:29:31 diff --git a/test/mjsunit/harmony/async-generators-basic.js b/test/mjsunit/harmony/async-generators-basic.js index 29441b119b..39ca6c8b0f 100644 --- a/test/mjsunit/harmony/async-generators-basic.js +++ b/test/mjsunit/harmony/async-generators-basic.js @@ -153,7 +153,7 @@ async function* asyncGeneratorForToString() {} assertEquals("async function* asyncGeneratorForToString() {}", asyncGeneratorForToString.toString()); -assertEquals("async function* () {}", async function*() {}.toString()); +assertEquals("async function*() {}", async function*() {}.toString()); assertEquals("async function* namedAsyncGeneratorForToString() {}", async function* namedAsyncGeneratorForToString() {}.toString()); @@ -164,9 +164,9 @@ assertEquals("async *method() { }", assertEquals("async *method() { }", (new (class { async *method() { } })).method.toString()); -assertEquals("async function* anonymous() {\n\n}", +assertEquals("async function* anonymous(\n) {\n\n}", AsyncGeneratorFunction().toString()); -assertEquals("async function* anonymous() {\n\n}", +assertEquals("async function* anonymous(\n) {\n\n}", (new AsyncGeneratorFunction()).toString()); // ---------------------------------------------------------------------------- diff --git a/test/mjsunit/regress/regress-2470.js b/test/mjsunit/regress/regress-2470.js index cba1b06c3e..708af54ca3 100644 --- a/test/mjsunit/regress/regress-2470.js +++ b/test/mjsunit/regress/regress-2470.js @@ -46,4 +46,4 @@ assertThrows('Function("a", "", "//", "//")', SyntaxError); // Some embedders rely on the string representation of the resulting // function in cases where no formal parameters are specified. var asString = Function("return 23").toString(); -assertSame("function anonymous() {\nreturn 23\n}", asString); +assertSame("function anonymous(\n) {\nreturn 23\n}", asString); diff --git a/test/mjsunit/regress/regress-crbug-109362.js b/test/mjsunit/regress/regress-crbug-109362.js index 20285f614d..cf7cd4e5fa 100644 --- a/test/mjsunit/regress/regress-crbug-109362.js +++ b/test/mjsunit/regress/regress-crbug-109362.js @@ -14,15 +14,16 @@ function test(expectation, f) { } /* -(function() { +(function( +) { 1 + reference_error //@ sourceURL=evaltest }) */ -test("2:5", new Function( +test("3:5", new Function( '1 + reference_error //@ sourceURL=evaltest')); /* (function(x -/\**\/) { +) { 1 + reference_error //@ sourceURL=evaltest }) @@ -34,7 +35,7 @@ test("4:6", new Function( ,z// ,y -/\**\/) { +) { 1 + reference_error //@ sourceURL=evaltest }) @@ -44,7 +45,7 @@ test("7:6", new Function( /* (function(x/\*,z// ,y*\/ -/\**\/) { +) { 1 + reference_error //@ sourceURL=evaltest }) */ diff --git a/test/mjsunit/regress/regress-crbug-663410.js b/test/mjsunit/regress/regress-crbug-663410.js index 5bef089f11..6d2a487715 100644 --- a/test/mjsunit/regress/regress-crbug-663410.js +++ b/test/mjsunit/regress/regress-crbug-663410.js @@ -4,5 +4,5 @@ function alert(x) {}; assertThrows( - Function("a=`","`,xss=1){alert(xss)") + 'Function("a=`","`,xss=1){alert(xss)")' ); diff --git a/test/mozilla/mozilla.status b/test/mozilla/mozilla.status index d64b74f354..a589a2fa47 100644 --- a/test/mozilla/mozilla.status +++ b/test/mozilla/mozilla.status @@ -118,6 +118,10 @@ # Invalid according to ES2015 syntax. (Details: crbug.com/726625) 'ecma_3/extensions/regress-368516': [FAIL], + # Function.prototype.toString revision. + # (https://chromium-review.googlesource.com/c/546941#message-5dc0f5efe277388501e8870e39ec70383dfc7db8) + 'js1_5/Scope/regress-185485': [FAIL], + ##################### SKIPPED TESTS ##################### # This test checks that we behave properly in an out-of-memory