diff --git a/src/js/harmony-unicode-regexps.js b/src/js/harmony-unicode-regexps.js index aa8fc76bd5..b24bbdf2c5 100644 --- a/src/js/harmony-unicode-regexps.js +++ b/src/js/harmony-unicode-regexps.js @@ -24,8 +24,10 @@ utils.Import(function(from) { // ES6 21.2.5.15. function RegExpGetUnicode() { if (!IS_REGEXP(this)) { + // TODO(littledan): Remove this RegExp compat workaround if (this === GlobalRegExpPrototype) { %IncrementUseCounter(kRegExpPrototypeUnicodeGetter); + return UNDEFINED; } throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode"); } diff --git a/src/js/regexp.js b/src/js/regexp.js index d5e55ef3bc..e80d0190f4 100644 --- a/src/js/regexp.js +++ b/src/js/regexp.js @@ -642,6 +642,10 @@ function RegExpMakeCaptureGetter(n) { // ES6 21.2.5.4. function RegExpGetGlobal() { if (!IS_REGEXP(this)) { + // TODO(littledan): Remove this RegExp compat workaround + if (this === GlobalRegExpPrototype) { + return UNDEFINED; + } throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.global"); } return !!REGEXP_GLOBAL(this); @@ -653,6 +657,10 @@ function RegExpGetGlobal() { // ES6 21.2.5.5. function RegExpGetIgnoreCase() { if (!IS_REGEXP(this)) { + // TODO(littledan): Remove this RegExp compat workaround + if (this === GlobalRegExpPrototype) { + return UNDEFINED; + } throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.ignoreCase"); } return !!REGEXP_IGNORE_CASE(this); @@ -664,6 +672,10 @@ function RegExpGetIgnoreCase() { // ES6 21.2.5.7. function RegExpGetMultiline() { if (!IS_REGEXP(this)) { + // TODO(littledan): Remove this RegExp compat workaround + if (this === GlobalRegExpPrototype) { + return UNDEFINED; + } throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.multiline"); } return !!REGEXP_MULTILINE(this); @@ -675,6 +687,10 @@ function RegExpGetMultiline() { // ES6 21.2.5.10. function RegExpGetSource() { if (!IS_REGEXP(this)) { + // TODO(littledan): Remove this RegExp compat workaround + if (this === GlobalRegExpPrototype) { + return UNDEFINED; + } throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.source"); } return REGEXP_SOURCE(this); diff --git a/test/mjsunit/es6/regexp-flags.js b/test/mjsunit/es6/regexp-flags.js index 2f1222197d..79b0197e91 100644 --- a/test/mjsunit/es6/regexp-flags.js +++ b/test/mjsunit/es6/regexp-flags.js @@ -50,11 +50,9 @@ assertEquals(4, get_count); function testName(name) { - if (name === "sticky") { - assertEquals(undefined, RegExp.prototype[name]); - } else { - assertThrows(() => RegExp.prototype[name], TypeError); - } + // TODO(littledan): For web compatibility, we don't throw an exception, + // but ES2015 expects an exception to be thrown from this getter. + assertEquals(undefined, RegExp.prototype[name]); assertEquals( "get " + name, Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name); diff --git a/test/mjsunit/regress/regress-crbug-581577.js b/test/mjsunit/regress/regress-crbug-581577.js new file mode 100644 index 0000000000..d95ada5f5a --- /dev/null +++ b/test/mjsunit/regress/regress-crbug-581577.js @@ -0,0 +1,5 @@ +// Copyright 2015 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. + +assertEquals("", RegExp.prototype.flags); diff --git a/test/test262/test262.status b/test/test262/test262.status index 7c2e9cbf4f..a926bcc92d 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -252,6 +252,12 @@ 'built-ins/Object/entries/*': [SKIP], 'built-ins/Object/values/*': [SKIP], + # https://code.google.com/p/chromium/issues/detail?id=581577 + 'built-ins/RegExp/prototype/source/15.10.7.1-1': [FAIL], + 'built-ins/RegExp/prototype/global/15.10.7.2-1': [FAIL], + 'built-ins/RegExp/prototype/ignoreCase/15.10.7.3-1': [FAIL], + 'built-ins/RegExp/prototype/multiline/15.10.7.4-1': [FAIL], + ######################## NEEDS INVESTIGATION ########################### # These test failures are specific to the intl402 suite and need investigation diff --git a/test/webkit/fast/regex/toString-expected.txt b/test/webkit/fast/regex/toString-expected.txt index 3b1fd12e3b..08852f9543 100644 --- a/test/webkit/fast/regex/toString-expected.txt +++ b/test/webkit/fast/regex/toString-expected.txt @@ -28,7 +28,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE PASS RegExp('/').source is "\\/" PASS RegExp('').source is "(?:)" -FAIL RegExp.prototype.source should be (?:). Threw exception TypeError: RegExp.prototype.source getter called on non-RegExp object +FAIL RegExp.prototype.source should be (?:) (of type string). Was undefined (of type undefined). PASS RegExp('/').toString() is "/\\//" PASS RegExp('').toString() is "/(?:)/" PASS RegExp.prototype.toString() is "/(?:)/"