v8/test/unittests/api/interceptor-unittest.cc
Jochen Eisinger f8deca1c86 Never freeze/seal/preventExtensions objects with interceptors
BUG=v8:6163
R=verwaest@chromium.org

Change-Id: Ieaec78c806cc3d459488a8491e77b7b5a8047079
Reviewed-on: https://chromium-review.googlesource.com/461903
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44228}
2017-03-29 13:04:58 +00:00

33 lines
1016 B
C++

// Copyright 2017 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.
#include "include/v8.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace {
using InterceptorTest = TestWithContext;
void NamedGetter(Local<Name> property,
const PropertyCallbackInfo<Value>& info) {}
TEST_F(InterceptorTest, FreezeApiObjectWithInterceptor) {
TryCatch try_catch(isolate());
Local<FunctionTemplate> tmpl = FunctionTemplate::New(isolate());
tmpl->InstanceTemplate()->SetHandler(
NamedPropertyHandlerConfiguration(NamedGetter));
Local<Function> ctor = tmpl->GetFunction(context()).ToLocalChecked();
Local<Object> obj = ctor->NewInstance(context()).ToLocalChecked();
ASSERT_TRUE(
obj->SetIntegrityLevel(context(), IntegrityLevel::kFrozen).IsNothing());
ASSERT_TRUE(try_catch.HasCaught());
}
} // namespace
} // namespace v8