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

Unified Diff: test/cctest/test-api-accessors.cc

Issue 2582493002: [runtime] Throw if attempting to re-declaring an accessor. (Closed)
Patch Set: Add test. Created 4 years 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 | « src/runtime/runtime-scopes.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api-accessors.cc
diff --git a/test/cctest/test-api-accessors.cc b/test/cctest/test-api-accessors.cc
index e9773e918df6284be78e0473b585617bd46aa2f1..cbe0692455a3f87dbbb1dcf184c332313be04268 100644
--- a/test/cctest/test-api-accessors.cc
+++ b/test/cctest/test-api-accessors.cc
@@ -247,3 +247,33 @@ TEST(CachedAccessorCrankshaft) {
ExpectInt32("g()", 789);
}
+
+namespace {
+
+static void Setter(v8::Local<v8::String> name, v8::Local<v8::Value> value,
+ const v8::PropertyCallbackInfo<void>& info) {}
+}
+
+// Re-declaration of non-configurable accessors should throw.
+TEST(RedeclareAccessor) {
+ v8::HandleScope scope(CcTest::isolate());
+ LocalContext env;
+
+ v8::Local<v8::FunctionTemplate> templ =
+ v8::FunctionTemplate::New(CcTest::isolate());
+
+ v8::Local<v8::ObjectTemplate> object_template = templ->InstanceTemplate();
+ object_template->SetAccessor(
+ v8_str("foo"), NULL, Setter, v8::Local<v8::Value>(),
+ v8::AccessControl::DEFAULT, v8::PropertyAttribute::DontDelete);
+
+ v8::Local<v8::Context> ctx =
+ v8::Context::New(CcTest::isolate(), nullptr, object_template);
+
+ // Declare function.
+ v8::Local<v8::String> code = v8_str("function foo() {};");
+
+ v8::TryCatch try_catch(CcTest::isolate());
+ v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).IsEmpty();
+ CHECK(try_catch.HasCaught());
+}
« no previous file with comments | « src/runtime/runtime-scopes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698