Commit 88c5a300 authored by jgruber's avatar jgruber Committed by Commit bot

[regexp] Set static property attributes as in spec proposal

'[...] accessor properties who have the attributes { [[Enumerable]]:
false, [[Configurable]]: true } [...]'

BUG=v8:5566

Review-Url: https://codereview.chromium.org/2452913002
Cr-Commit-Position: refs/heads/master@{#40609}
parent 7d383be9
......@@ -1874,14 +1874,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{
// RegExp getters and setters.
// TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE.
// However, that currently breaks layout test expectations. Note that
// Firefox sets a couple of these as enumerable.
// On the other hand, installing attributes as DONT_ENUM matches the draft
// specification at
// https://github.com/claudepache/es-regexp-legacy-static-properties.
const PropertyAttributes no_enum = DONT_ENUM;
SimpleInstallGetter(regexp_fun,
factory->InternalizeUtf8String("[Symbol.species]"),
factory->species_symbol(),
......@@ -1889,9 +1881,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
// Static properties set by a successful match.
const PropertyAttributes no_enum = DONT_ENUM;
SimpleInstallGetterSetter(regexp_fun, factory->input_string(),
Builtins::kRegExpInputGetter,
Builtins::kRegExpInputSetter, DONT_DELETE);
Builtins::kRegExpInputSetter, no_enum);
SimpleInstallGetterSetter(
regexp_fun, factory->InternalizeUtf8String("$_"),
Builtins::kRegExpInputGetter, Builtins::kRegExpInputSetter, no_enum);
......@@ -1928,11 +1921,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kRegExpRightContextGetter,
Builtins::kEmptyFunction, no_enum);
#define INSTALL_CAPTURE_GETTER(i) \
SimpleInstallGetterSetter(regexp_fun, \
factory->InternalizeUtf8String("$" #i), \
Builtins::kRegExpCapture##i##Getter, \
Builtins::kEmptyFunction, DONT_DELETE)
#define INSTALL_CAPTURE_GETTER(i) \
SimpleInstallGetterSetter( \
regexp_fun, factory->InternalizeUtf8String("$" #i), \
Builtins::kRegExpCapture##i##Getter, Builtins::kEmptyFunction, no_enum)
INSTALL_CAPTURE_GETTER(1);
INSTALL_CAPTURE_GETTER(2);
INSTALL_CAPTURE_GETTER(3);
......
// 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.
// https://github.com/tc39/proposal-regexp-legacy-features#additional-properties-of-the-regexp-constructor
const props = [ "input", "$_"
, "lastMatch", "$&"
, "lastParen", "$+"
, "leftContext", "$`"
, "rightContext", "$'"
, "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9"
];
for (let i = 0; i < props.length; i++) {
const prop = props[i];
const desc = Object.getOwnPropertyDescriptor(RegExp, prop);
assertTrue(desc.configurable, prop);
assertFalse(desc.enumerable, prop);
assertTrue(desc.get !== undefined, prop);
// TODO(jgruber): Although the spec proposal specifies setting setters to
// undefined, we are not sure that this change would be web-compatible, and
// we are intentionally sticking with the old behavior for now.
assertTrue(desc.set !== undefined, prop);
}
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