OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |