From 5a82cf769f68361c7f4c6945b0d956e725a9881f Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 20 Sep 2016 18:05:10 -0400 Subject: [PATCH] deps: cherry-pick 34880eb3dc from V8 upstream Revert of Put RegExp js code in strict mode (patchset #2 id:20001 of https://codereview.chromium.org/1776883005/ ) Reason for revert: Found to break SAP Web IDE, and these semantics are not shipped in any other browser. Revert to legacy semantics while assessing web compatibility. BUG=chromium:624318 Original issue's description: > Put RegExp js code in strict mode > > src/js/regexp.js was one of the few files that was left in sloppy > mode. The ES2017 draft specification requires that writes to > lastIndex throw when the property is non-writable, and test262 > tests enforce this behavior. This patch puts that file in strict > mode. > > BUG=v8:4504 > R=yangguo@chromium.org > LOG=Y > > Committed: https://crrev.com/80b1b2a45bbd9bf3d08e4e6516acfaaa8f438213 > Cr-Commit-Position: refs/heads/master@{#34801} TBR=yangguo@chromium.org,adamk@chromium.org Review-Url: https://codereview.chromium.org/2112713003 Cr-Commit-Position: refs/heads/master@{#37449} --- deps/v8/src/js/regexp.js | 2 -- deps/v8/test/mjsunit/regexp-lastIndex.js | 18 ------------------ deps/v8/test/test262/test262.status | 16 ++++++++++++++++ .../webkit/fast/regex/lastIndex-expected.txt | 6 +++--- 4 files changed, 19 insertions(+), 23 deletions(-) delete mode 100644 deps/v8/test/mjsunit/regexp-lastIndex.js diff --git a/deps/v8/src/js/regexp.js b/deps/v8/src/js/regexp.js index cc8cb41de18098..dea0de663040ea 100644 --- a/deps/v8/src/js/regexp.js +++ b/deps/v8/src/js/regexp.js @@ -4,8 +4,6 @@ (function(global, utils) { -'use strict'; - %CheckIsBootstrapping(); // ------------------------------------------------------------------- diff --git a/deps/v8/test/mjsunit/regexp-lastIndex.js b/deps/v8/test/mjsunit/regexp-lastIndex.js deleted file mode 100644 index 1445b9b2ae610e..00000000000000 --- a/deps/v8/test/mjsunit/regexp-lastIndex.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// lastIndex is set according to funny rules. It is typically set only -// for global or sticky RegExps, but on a failure to find a match, it is -// set unconditionally. If a set fails, then it acts as if in strict mode -// and throws. - -var re = /x/; -Object.defineProperty(re, 'lastIndex', {writable: false}); -assertThrows(() => re.exec(""), TypeError); -assertEquals(["x"], re.exec("x")); - -var re = /x/y; -Object.defineProperty(re, 'lastIndex', {writable: false}); -assertThrows(() => re.exec(""), TypeError); -assertThrows(() => re.exec("x"), TypeError); diff --git a/deps/v8/test/test262/test262.status b/deps/v8/test/test262/test262.status index b1bdd0adb07971..487bafc63fa704 100644 --- a/deps/v8/test/test262/test262.status +++ b/deps/v8/test/test262/test262.status @@ -131,6 +131,22 @@ 'built-ins/RegExp/prototype/Symbol.replace/y-init-lastindex': [FAIL], 'built-ins/RegExp/prototype/Symbol.replace/y-set-lastindex': [FAIL], + # https://code.google.com/p/v8/issues/detail?id=4504 + # https://bugs.chromium.org/p/chromium/issues/detail?id=624318 + 'built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex-err': [PASS, FAIL], + 'built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex-err': [PASS, FAIL], + 'built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex-err': [SKIP], + 'built-ins/RegExp/prototype/Symbol.match/builtin-success-y-set-lastindex-err': [PASS, FAIL], + 'built-ins/RegExp/prototype/Symbol.match/g-init-lastindex-err': [PASS, FAIL], + 'built-ins/RegExp/prototype/Symbol.match/g-match-empty-set-lastindex-err': [PASS, FAIL], + 'built-ins/RegExp/prototype/Symbol.match/y-fail-lastindex-no-write': [PASS, FAIL], + 'built-ins/RegExp/prototype/Symbol.replace/g-init-lastindex-err': [PASS, FAIL], + 'built-ins/RegExp/prototype/Symbol.replace/y-fail-lastindex-no-write': [PASS, FAIL], + 'built-ins/RegExp/prototype/Symbol.search/set-lastindex-init-err': [PASS, FAIL], + 'built-ins/RegExp/prototype/Symbol.search/set-lastindex-restore-err': [PASS, FAIL], + 'built-ins/RegExp/prototype/exec/y-fail-lastindex-no-write': [PASS, FAIL], + 'built-ins/RegExp/prototype/test/y-fail-lastindex-no-write': [PASS, FAIL], + # SKIP rather than FAIL, as the test checks for an exception which # happens to be thrown for some other reason. 'built-ins/RegExp/prototype/Symbol.split/str-result-get-length-err': [SKIP], diff --git a/deps/v8/test/webkit/fast/regex/lastIndex-expected.txt b/deps/v8/test/webkit/fast/regex/lastIndex-expected.txt index 71292c77b15288..1e0959c3f986cb 100644 --- a/deps/v8/test/webkit/fast/regex/lastIndex-expected.txt +++ b/deps/v8/test/webkit/fast/regex/lastIndex-expected.txt @@ -42,10 +42,10 @@ PASS var re = Object.defineProperty(/x/, 'lastIndex', {value:42}); re.lastIndex PASS Object.defineProperty(Object.defineProperty(/x/, 'lastIndex', {writable:false}), 'lastIndex', {writable:true}); true threw exception TypeError: Cannot redefine property: lastIndex. PASS Object.defineProperty(Object.defineProperty(/x/, 'lastIndex', {writable:false}), 'lastIndex', {value:42}); true threw exception TypeError: Cannot redefine property: lastIndex. PASS Object.defineProperty(Object.defineProperty(/x/, 'lastIndex', {writable:false}), 'lastIndex', {value:0}); true is true -FAIL Object.defineProperty(/x/, 'lastIndex', {writable:false}).exec('') should be null. Threw exception TypeError: Cannot assign to read only property 'lastIndex' of object '[object RegExp]' +PASS Object.defineProperty(/x/, 'lastIndex', {writable:false}).exec('') is null PASS Object.defineProperty(/x/, 'lastIndex', {writable:false}).exec('x') is ["x"] -PASS Object.defineProperty(/x/g, 'lastIndex', {writable:false}).exec('') threw exception TypeError: Cannot assign to read only property 'lastIndex' of object '[object RegExp]'. -PASS Object.defineProperty(/x/g, 'lastIndex', {writable:false}).exec('x') threw exception TypeError: Cannot assign to read only property 'lastIndex' of object '[object RegExp]'. +FAIL Object.defineProperty(/x/g, 'lastIndex', {writable:false}).exec('') should throw an exception. Was null. +FAIL Object.defineProperty(/x/g, 'lastIndex', {writable:false}).exec('x') should throw an exception. Was x. PASS var re = /x/; Object.freeze(re); Object.isFrozen(re); is true PASS successfullyParsed is true