Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Unified Diff: test/unittests/api/v8-object-unittest.cc

Issue 2680353004: Fixes Object::SetAccessor to return false if the prop is unconfigurable. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/api/v8-object-unittest.cc
diff --git a/test/unittests/api/v8-object-unittest.cc b/test/unittests/api/v8-object-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5d6ca804ad0303e994194e83d2cd90ef18a2b4bc
--- /dev/null
+++ b/test/unittests/api/v8-object-unittest.cc
@@ -0,0 +1,39 @@
+// 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 ObjectTest = TestWithContext;
+
+void accessor_name_getter_callback(Local<Name>,
+ const PropertyCallbackInfo<Value>&) {}
+
+TEST_F(ObjectTest, SetAccessorWhenUnconfigurablePropAlreadyDefined) {
+ Context::Scope context_scope(context());
+
+ TryCatch try_catch(isolate());
+
+ Local<Object> global = context()->Global();
+ Local<String> property_name =
+ String::NewFromUtf8(isolate(), "foo", NewStringType::kNormal)
+ .ToLocalChecked();
+
+ PropertyDescriptor prop_desc;
+ prop_desc.set_configurable(false);
+ global->DefineProperty(context(), property_name, prop_desc).ToChecked();
+
+ Maybe<bool> result = global->SetAccessor(context(), property_name,
+ accessor_name_getter_callback);
+ ASSERT_TRUE(result.IsJust());
+ ASSERT_FALSE(result.FromJust());
+ ASSERT_FALSE(try_catch.HasCaught());
+}
+
+} // namespace
+} // namespace v8
« no previous file with comments | « test/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698