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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-scopes.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/cctest/cctest.h" 5 #include "test/cctest/cctest.h"
6 6
7 #include "include/v8-experimental.h" 7 #include "include/v8-experimental.h"
8 #include "include/v8.h" 8 #include "include/v8.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 // Reset hidden property. 241 // Reset hidden property.
242 CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 789)) 242 CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 789))
243 .FromJust()); 243 .FromJust());
244 244
245 // Test non-global access in Crankshaft. 245 // Test non-global access in Crankshaft.
246 CompileRun("%OptimizeFunctionOnNextCall(g);"); 246 CompileRun("%OptimizeFunctionOnNextCall(g);");
247 247
248 ExpectInt32("g()", 789); 248 ExpectInt32("g()", 789);
249 } 249 }
250
251 namespace {
252
253 static void Setter(v8::Local<v8::String> name, v8::Local<v8::Value> value,
254 const v8::PropertyCallbackInfo<void>& info) {}
255 }
256
257 // Re-declaration of non-configurable accessors should throw.
258 TEST(RedeclareAccessor) {
259 v8::HandleScope scope(CcTest::isolate());
260 LocalContext env;
261
262 v8::Local<v8::FunctionTemplate> templ =
263 v8::FunctionTemplate::New(CcTest::isolate());
264
265 v8::Local<v8::ObjectTemplate> object_template = templ->InstanceTemplate();
266 object_template->SetAccessor(
267 v8_str("foo"), NULL, Setter, v8::Local<v8::Value>(),
268 v8::AccessControl::DEFAULT, v8::PropertyAttribute::DontDelete);
269
270 v8::Local<v8::Context> ctx =
271 v8::Context::New(CcTest::isolate(), nullptr, object_template);
272
273 // Declare function.
274 v8::Local<v8::String> code = v8_str("function foo() {};");
275
276 v8::TryCatch try_catch(CcTest::isolate());
277 v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).IsEmpty();
278 CHECK(try_catch.HasCaught());
279 }
OLDNEW
« 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