Commit 9c304f1e authored by littledan's avatar littledan Committed by Commit bot

Guard the property RegExp.prototype.unicode behind --harmony-regexp-unicode

When the 'y' flag was shipped, the property RegExp.prototype.unicode was
accidentally also shipped. However, the existence of this property should
be a usable feature testing point. This patch adds the 'unicode' getter on
RegExp.prototype only if the --harmony-regexp-unicode flag is turned on.

R=cbruni
CC=yangguo
BUG=v8:4644
LOG=Y

Review URL: https://codereview.chromium.org/1550713002

Cr-Commit-Position: refs/heads/master@{#33049}
parent 7b42c6cf
......@@ -286,6 +286,7 @@ action("js2c_experimental") {
"src/js/harmony-object-observe.js",
"src/js/harmony-sharedarraybuffer.js",
"src/js/harmony-simd.js",
"src/js/harmony-unicode-regexps.js",
"src/js/promise-extra.js"
]
......
......@@ -2665,7 +2665,8 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_sloppy_natives[] = {nullptr};
static const char* harmony_sloppy_function_natives[] = {nullptr};
static const char* harmony_sloppy_let_natives[] = {nullptr};
static const char* harmony_unicode_regexps_natives[] = {nullptr};
static const char* harmony_unicode_regexps_natives[] = {
"native harmony-unicode-regexps.js", nullptr};
static const char* harmony_default_parameters_natives[] = {nullptr};
static const char* harmony_reflect_natives[] = {"native harmony-reflect.js",
nullptr};
......
......@@ -56,19 +56,7 @@ function RegExpGetSticky() {
%FunctionSetName(RegExpGetSticky, "RegExp.prototype.sticky");
%SetNativeFlag(RegExpGetSticky);
// ES6 21.2.5.15.
function RegExpGetUnicode() {
if (!IS_REGEXP(this)) {
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode");
}
return !!REGEXP_UNICODE(this);
}
%FunctionSetName(RegExpGetUnicode, "RegExp.prototype.unicode");
%SetNativeFlag(RegExpGetUnicode);
utils.InstallGetter(GlobalRegExp.prototype, 'flags', RegExpGetFlags);
utils.InstallGetter(GlobalRegExp.prototype, 'sticky', RegExpGetSticky);
utils.InstallGetter(GlobalRegExp.prototype, 'unicode', RegExpGetUnicode);
})
// Copyright 2014 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.
(function(global, utils) {
'use strict';
%CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalRegExp = global.RegExp;
var GlobalRegExpPrototype = GlobalRegExp.prototype;
var MakeTypeError;
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
// ES6 21.2.5.15.
function RegExpGetUnicode() {
if (!IS_REGEXP(this)) {
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode");
}
return !!REGEXP_UNICODE(this);
}
%FunctionSetName(RegExpGetUnicode, "RegExp.prototype.unicode");
%SetNativeFlag(RegExpGetUnicode);
utils.InstallGetter(GlobalRegExp.prototype, 'unicode', RegExpGetUnicode);
})
// 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.
// Before Unicode RegExps are shipped, we shouldn't have the 'unicode'
// property on RegExp.prototype, or read it from 'flags'.
// mjsunit/es6/regexp-flags tests that the property is there when the
// flag is on.
// Flags: --harmony-regexp
'use strict';
assertFalse(RegExp.prototype.hasOwnProperty('unicode'));
// If we were going to be really strict, we could have a test like this,
// with the assertTrue replaced by assertFalse, since flags shouldn't
// Get the 'unicode' property. However, it is probably OK to omit this
// detailed fix.
var x = /a/;
var y = false;
Object.defineProperty(x, 'unicode', { get() { y = true; } });
assertEquals("", x.flags);
assertTrue(y);
......@@ -316,6 +316,11 @@
'language/literals/regexp/u-case-mapping': [FAIL],
'language/literals/regexp/u-astral': [FAIL],
'built-ins/RegExp/valid-flags-y': [FAIL],
'built-ins/RegExp/prototype/unicode/length': [FAIL],
'built-ins/RegExp/prototype/unicode/name': [FAIL],
'built-ins/RegExp/prototype/unicode/prop-desc': [FAIL],
'built-ins/RegExp/prototype/unicode/this-invald-obj': [FAIL],
'built-ins/RegExp/prototype/unicode/this-non-obj': [FAIL],
# https://code.google.com/p/v8/issues/detail?id=4602
'built-ins/RegExp/prototype/exec/get-sticky-coerce': [FAIL],
......
......@@ -1927,6 +1927,7 @@
'../../src/js/harmony-object-observe.js',
'../../src/js/harmony-sharedarraybuffer.js',
'../../src/js/harmony-simd.js',
'../../src/js/harmony-unicode-regexps.js',
'../../src/js/promise-extra.js',
],
'libraries_bin_file': '<(SHARED_INTERMEDIATE_DIR)/libraries.bin',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment