[runtime] Fix use of attributes if intercepted.
The property details of a LookupIterator are not accessible,
if the iterator state is interceptor. Instead, use the
property attributes.
Fixes a crash in Node.js tests in Debug mode, see
c2c6ae52ea
BUG=
Review-Url: https://codereview.chromium.org/2675993002
Cr-Commit-Position: refs/heads/master@{#42941}
This commit is contained in:
parent
22a6785eb6
commit
29e8d49f56
@ -86,8 +86,7 @@ Object* DeclareGlobal(
|
||||
|
||||
// Check whether we can reconfigure the existing property into a
|
||||
// function.
|
||||
PropertyDetails old_details = it.property_details();
|
||||
if (old_details.IsReadOnly() || old_details.IsDontEnum() ||
|
||||
if (old_attributes & READ_ONLY || old_attributes & DONT_ENUM ||
|
||||
(it.state() == LookupIterator::ACCESSOR)) {
|
||||
// ECMA-262 section 15.1.11 GlobalDeclarationInstantiation 5.d:
|
||||
// If hasRestrictedGlobal is true, throw a SyntaxError exception.
|
||||
|
@ -568,6 +568,34 @@ THREADED_TEST(SetterCallbackFunctionDeclarationInterceptor) {
|
||||
CHECK_EQ(set_was_called_counter, 3);
|
||||
}
|
||||
|
||||
namespace {
|
||||
void QueryCallbackSetDontDelete(
|
||||
Local<Name> property, const v8::PropertyCallbackInfo<v8::Integer>& info) {
|
||||
info.GetReturnValue().Set(v8::PropertyAttribute::DontDelete);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Regression for a Node.js test that fails in debug mode.
|
||||
THREADED_TEST(InterceptorFunctionRedeclareWithQueryCallback) {
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
LocalContext env;
|
||||
v8::Local<v8::FunctionTemplate> templ =
|
||||
v8::FunctionTemplate::New(CcTest::isolate());
|
||||
|
||||
v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate();
|
||||
object_template->SetHandler(v8::NamedPropertyHandlerConfiguration(
|
||||
nullptr, nullptr, QueryCallbackSetDontDelete));
|
||||
v8::Local<v8::Context> ctx =
|
||||
v8::Context::New(CcTest::isolate(), nullptr, object_template);
|
||||
|
||||
// Declare and redeclare function.
|
||||
v8::Local<v8::String> code = v8_str(
|
||||
"function x() {return 42;};"
|
||||
"function x() {return 43;};");
|
||||
v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).ToLocalChecked();
|
||||
}
|
||||
|
||||
// Check that function re-declarations throw if they are read-only.
|
||||
THREADED_TEST(SetterCallbackFunctionDeclarationInterceptorThrow) {
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
|
Loading…
Reference in New Issue
Block a user