OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4469 CHECK(CompileRun(source)->BooleanValue()); | 4469 CHECK(CompileRun(source)->BooleanValue()); |
4470 | 4470 |
4471 source = "both_values[4].name() == 10"; | 4471 source = "both_values[4].name() == 10"; |
4472 CHECK(CompileRun(source)->BooleanValue()); | 4472 CHECK(CompileRun(source)->BooleanValue()); |
4473 } | 4473 } |
4474 | 4474 |
4475 | 4475 |
4476 TEST(HiddenPrototypePropertyMirror) { | 4476 TEST(HiddenPrototypePropertyMirror) { |
4477 // Create a V8 environment with debug access. | 4477 // Create a V8 environment with debug access. |
4478 DebugLocalContext env; | 4478 DebugLocalContext env; |
4479 v8::HandleScope scope(env->GetIsolate()); | 4479 v8::Isolate* isolate = env->GetIsolate(); |
| 4480 v8::HandleScope scope(isolate); |
4480 env.ExposeDebug(); | 4481 env.ExposeDebug(); |
4481 | 4482 |
4482 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | 4483 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); |
4483 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "x"), | 4484 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"), |
4484 v8::Number::New(0)); | 4485 v8::Number::New(0)); |
4485 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 4486 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
4486 t1->SetHiddenPrototype(true); | 4487 t1->SetHiddenPrototype(true); |
4487 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "y"), | 4488 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"), |
4488 v8::Number::New(1)); | 4489 v8::Number::New(1)); |
4489 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); | 4490 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
4490 t2->SetHiddenPrototype(true); | 4491 t2->SetHiddenPrototype(true); |
4491 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "z"), | 4492 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"), |
4492 v8::Number::New(2)); | 4493 v8::Number::New(2)); |
4493 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(); | 4494 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); |
4494 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "u"), | 4495 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"), |
4495 v8::Number::New(3)); | 4496 v8::Number::New(3)); |
4496 | 4497 |
4497 // Create object and set them on the global object. | 4498 // Create object and set them on the global object. |
4498 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance(); | 4499 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance(); |
4499 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o0"), o0); | 4500 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0); |
4500 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); | 4501 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); |
4501 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o1"), o1); | 4502 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1); |
4502 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); | 4503 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); |
4503 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o2"), o2); | 4504 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2); |
4504 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); | 4505 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); |
4505 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o3"), o3); | 4506 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3); |
4506 | 4507 |
4507 // Get mirrors for the four objects. | 4508 // Get mirrors for the four objects. |
4508 CompileRun( | 4509 CompileRun( |
4509 "var o0_mirror = debug.MakeMirror(o0);" | 4510 "var o0_mirror = debug.MakeMirror(o0);" |
4510 "var o1_mirror = debug.MakeMirror(o1);" | 4511 "var o1_mirror = debug.MakeMirror(o1);" |
4511 "var o2_mirror = debug.MakeMirror(o2);" | 4512 "var o2_mirror = debug.MakeMirror(o2);" |
4512 "var o3_mirror = debug.MakeMirror(o3)"); | 4513 "var o3_mirror = debug.MakeMirror(o3)"); |
4513 CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4514 CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4514 CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4515 CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4515 CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4516 CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4516 CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4517 CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4517 | 4518 |
4518 // Check that each object has one property. | 4519 // Check that each object has one property. |
4519 CHECK_EQ(1, CompileRun( | 4520 CHECK_EQ(1, CompileRun( |
4520 "o0_mirror.propertyNames().length")->Int32Value()); | 4521 "o0_mirror.propertyNames().length")->Int32Value()); |
4521 CHECK_EQ(1, CompileRun( | 4522 CHECK_EQ(1, CompileRun( |
4522 "o1_mirror.propertyNames().length")->Int32Value()); | 4523 "o1_mirror.propertyNames().length")->Int32Value()); |
4523 CHECK_EQ(1, CompileRun( | 4524 CHECK_EQ(1, CompileRun( |
4524 "o2_mirror.propertyNames().length")->Int32Value()); | 4525 "o2_mirror.propertyNames().length")->Int32Value()); |
4525 CHECK_EQ(1, CompileRun( | 4526 CHECK_EQ(1, CompileRun( |
4526 "o3_mirror.propertyNames().length")->Int32Value()); | 4527 "o3_mirror.propertyNames().length")->Int32Value()); |
4527 | 4528 |
4528 // Set o1 as prototype for o0. o1 has the hidden prototype flag so all | 4529 // Set o1 as prototype for o0. o1 has the hidden prototype flag so all |
4529 // properties on o1 should be seen on o0. | 4530 // properties on o1 should be seen on o0. |
4530 o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o1); | 4531 o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o1); |
4531 CHECK_EQ(2, CompileRun( | 4532 CHECK_EQ(2, CompileRun( |
4532 "o0_mirror.propertyNames().length")->Int32Value()); | 4533 "o0_mirror.propertyNames().length")->Int32Value()); |
4533 CHECK_EQ(0, CompileRun( | 4534 CHECK_EQ(0, CompileRun( |
4534 "o0_mirror.property('x').value().value()")->Int32Value()); | 4535 "o0_mirror.property('x').value().value()")->Int32Value()); |
4535 CHECK_EQ(1, CompileRun( | 4536 CHECK_EQ(1, CompileRun( |
4536 "o0_mirror.property('y').value().value()")->Int32Value()); | 4537 "o0_mirror.property('y').value().value()")->Int32Value()); |
4537 | 4538 |
4538 // Set o2 as prototype for o0 (it will end up after o1 as o1 has the hidden | 4539 // Set o2 as prototype for o0 (it will end up after o1 as o1 has the hidden |
4539 // prototype flag. o2 also has the hidden prototype flag so all properties | 4540 // prototype flag. o2 also has the hidden prototype flag so all properties |
4540 // on o2 should be seen on o0 as well as properties on o1. | 4541 // on o2 should be seen on o0 as well as properties on o1. |
4541 o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o2); | 4542 o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o2); |
4542 CHECK_EQ(3, CompileRun( | 4543 CHECK_EQ(3, CompileRun( |
4543 "o0_mirror.propertyNames().length")->Int32Value()); | 4544 "o0_mirror.propertyNames().length")->Int32Value()); |
4544 CHECK_EQ(0, CompileRun( | 4545 CHECK_EQ(0, CompileRun( |
4545 "o0_mirror.property('x').value().value()")->Int32Value()); | 4546 "o0_mirror.property('x').value().value()")->Int32Value()); |
4546 CHECK_EQ(1, CompileRun( | 4547 CHECK_EQ(1, CompileRun( |
4547 "o0_mirror.property('y').value().value()")->Int32Value()); | 4548 "o0_mirror.property('y').value().value()")->Int32Value()); |
4548 CHECK_EQ(2, CompileRun( | 4549 CHECK_EQ(2, CompileRun( |
4549 "o0_mirror.property('z').value().value()")->Int32Value()); | 4550 "o0_mirror.property('z').value().value()")->Int32Value()); |
4550 | 4551 |
4551 // Set o3 as prototype for o0 (it will end up after o1 and o2 as both o1 and | 4552 // Set o3 as prototype for o0 (it will end up after o1 and o2 as both o1 and |
4552 // o2 has the hidden prototype flag. o3 does not have the hidden prototype | 4553 // o2 has the hidden prototype flag. o3 does not have the hidden prototype |
4553 // flag so properties on o3 should not be seen on o0 whereas the properties | 4554 // flag so properties on o3 should not be seen on o0 whereas the properties |
4554 // from o1 and o2 should still be seen on o0. | 4555 // from o1 and o2 should still be seen on o0. |
4555 // Final prototype chain: o0 -> o1 -> o2 -> o3 | 4556 // Final prototype chain: o0 -> o1 -> o2 -> o3 |
4556 // Hidden prototypes: ^^ ^^ | 4557 // Hidden prototypes: ^^ ^^ |
4557 o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o3); | 4558 o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o3); |
4558 CHECK_EQ(3, CompileRun( | 4559 CHECK_EQ(3, CompileRun( |
4559 "o0_mirror.propertyNames().length")->Int32Value()); | 4560 "o0_mirror.propertyNames().length")->Int32Value()); |
4560 CHECK_EQ(1, CompileRun( | 4561 CHECK_EQ(1, CompileRun( |
4561 "o3_mirror.propertyNames().length")->Int32Value()); | 4562 "o3_mirror.propertyNames().length")->Int32Value()); |
4562 CHECK_EQ(0, CompileRun( | 4563 CHECK_EQ(0, CompileRun( |
4563 "o0_mirror.property('x').value().value()")->Int32Value()); | 4564 "o0_mirror.property('x').value().value()")->Int32Value()); |
4564 CHECK_EQ(1, CompileRun( | 4565 CHECK_EQ(1, CompileRun( |
4565 "o0_mirror.property('y').value().value()")->Int32Value()); | 4566 "o0_mirror.property('y').value().value()")->Int32Value()); |
4566 CHECK_EQ(2, CompileRun( | 4567 CHECK_EQ(2, CompileRun( |
4567 "o0_mirror.property('z').value().value()")->Int32Value()); | 4568 "o0_mirror.property('z').value().value()")->Int32Value()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4650 BooleanValue()); | 4651 BooleanValue()); |
4651 } | 4652 } |
4652 | 4653 |
4653 | 4654 |
4654 // Test that hidden properties object is not returned as an unnamed property | 4655 // Test that hidden properties object is not returned as an unnamed property |
4655 // among regular properties. | 4656 // among regular properties. |
4656 // See http://crbug.com/26491 | 4657 // See http://crbug.com/26491 |
4657 TEST(NoHiddenProperties) { | 4658 TEST(NoHiddenProperties) { |
4658 // Create a V8 environment with debug access. | 4659 // Create a V8 environment with debug access. |
4659 DebugLocalContext env; | 4660 DebugLocalContext env; |
4660 v8::HandleScope scope(env->GetIsolate()); | 4661 v8::Isolate* isolate = env->GetIsolate(); |
| 4662 v8::HandleScope scope(isolate); |
4661 env.ExposeDebug(); | 4663 env.ExposeDebug(); |
4662 | 4664 |
4663 // Create an object in the global scope. | 4665 // Create an object in the global scope. |
4664 const char* source = "var obj = {a: 1};"; | 4666 const char* source = "var obj = {a: 1};"; |
4665 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source)) | 4667 v8::Script::Compile(v8::String::NewFromUtf8(isolate, source)) |
4666 ->Run(); | 4668 ->Run(); |
4667 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( | 4669 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( |
4668 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "obj"))); | 4670 env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj"))); |
4669 // Set a hidden property on the object. | 4671 // Set a hidden property on the object. |
4670 obj->SetHiddenValue( | 4672 obj->SetHiddenValue( |
4671 v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::a"), | 4673 v8::String::NewFromUtf8(isolate, "v8::test-debug::a"), |
4672 v8::Int32::New(11)); | 4674 v8::Int32::New(11)); |
4673 | 4675 |
4674 // Get mirror for the object with property getter. | 4676 // Get mirror for the object with property getter. |
4675 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); | 4677 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); |
4676 CHECK(CompileRun( | 4678 CHECK(CompileRun( |
4677 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4679 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4678 CompileRun("var named_names = obj_mirror.propertyNames();"); | 4680 CompileRun("var named_names = obj_mirror.propertyNames();"); |
4679 // There should be exactly one property. But there is also an unnamed | 4681 // There should be exactly one property. But there is also an unnamed |
4680 // property whose value is hidden properties dictionary. The latter | 4682 // property whose value is hidden properties dictionary. The latter |
4681 // property should not be in the list of reguar properties. | 4683 // property should not be in the list of reguar properties. |
4682 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); | 4684 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); |
4683 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); | 4685 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); |
4684 CHECK(CompileRun( | 4686 CHECK(CompileRun( |
4685 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); | 4687 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); |
4686 | 4688 |
4687 // Object created by t0 will become hidden prototype of object 'obj'. | 4689 // Object created by t0 will become hidden prototype of object 'obj'. |
4688 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | 4690 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); |
4689 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"), | 4691 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"), |
4690 v8::Number::New(2)); | 4692 v8::Number::New(2)); |
4691 t0->SetHiddenPrototype(true); | 4693 t0->SetHiddenPrototype(true); |
4692 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 4694 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
4693 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "c"), | 4695 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"), |
4694 v8::Number::New(3)); | 4696 v8::Number::New(3)); |
4695 | 4697 |
4696 // Create proto objects, add hidden properties to them and set them on | 4698 // Create proto objects, add hidden properties to them and set them on |
4697 // the global object. | 4699 // the global object. |
4698 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); | 4700 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); |
4699 protoObj->SetHiddenValue( | 4701 protoObj->SetHiddenValue( |
4700 v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::b"), | 4702 v8::String::NewFromUtf8(isolate, "v8::test-debug::b"), |
4701 v8::Int32::New(12)); | 4703 v8::Int32::New(12)); |
4702 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "protoObj"), | 4704 env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"), |
4703 protoObj); | 4705 protoObj); |
4704 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); | 4706 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); |
4705 grandProtoObj->SetHiddenValue( | 4707 grandProtoObj->SetHiddenValue( |
4706 v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::c"), | 4708 v8::String::NewFromUtf8(isolate, "v8::test-debug::c"), |
4707 v8::Int32::New(13)); | 4709 v8::Int32::New(13)); |
4708 env->Global()->Set( | 4710 env->Global()->Set( |
4709 v8::String::NewFromUtf8(env->GetIsolate(), "grandProtoObj"), | 4711 v8::String::NewFromUtf8(isolate, "grandProtoObj"), |
4710 grandProtoObj); | 4712 grandProtoObj); |
4711 | 4713 |
4712 // Setting prototypes: obj->protoObj->grandProtoObj | 4714 // Setting prototypes: obj->protoObj->grandProtoObj |
4713 protoObj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), | 4715 protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), |
4714 grandProtoObj); | 4716 grandProtoObj); |
4715 obj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), protoObj); | 4717 obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj); |
4716 | 4718 |
4717 // Get mirror for the object with property getter. | 4719 // Get mirror for the object with property getter. |
4718 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); | 4720 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); |
4719 CHECK(CompileRun( | 4721 CHECK(CompileRun( |
4720 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4722 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4721 CompileRun("var named_names = obj_mirror.propertyNames();"); | 4723 CompileRun("var named_names = obj_mirror.propertyNames();"); |
4722 // There should be exactly two properties - one from the object itself and | 4724 // There should be exactly two properties - one from the object itself and |
4723 // another from its hidden prototype. | 4725 // another from its hidden prototype. |
4724 CHECK_EQ(2, CompileRun("named_names.length")->Int32Value()); | 4726 CHECK_EQ(2, CompileRun("named_names.length")->Int32Value()); |
4725 CHECK(CompileRun("named_names.sort(); named_names[0] == 'a' &&" | 4727 CHECK(CompileRun("named_names.sort(); named_names[0] == 'a' &&" |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5200 "\n" | 5202 "\n" |
5201 "foo();\n"; | 5203 "foo();\n"; |
5202 | 5204 |
5203 v8::Isolate::Scope isolate_scope(CcTest::isolate()); | 5205 v8::Isolate::Scope isolate_scope(CcTest::isolate()); |
5204 DebugLocalContext env; | 5206 DebugLocalContext env; |
5205 v8::HandleScope scope(env->GetIsolate()); | 5207 v8::HandleScope scope(env->GetIsolate()); |
5206 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); | 5208 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); |
5207 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5209 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
5208 global_template->Set( | 5210 global_template->Set( |
5209 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), | 5211 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), |
5210 v8::FunctionTemplate::New(ThreadedAtBarrier1)); | 5212 v8::FunctionTemplate::New(CcTest::isolate(), ThreadedAtBarrier1)); |
5211 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), | 5213 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), |
5212 NULL, | 5214 NULL, |
5213 global_template); | 5215 global_template); |
5214 v8::Context::Scope context_scope(context); | 5216 v8::Context::Scope context_scope(context); |
5215 | 5217 |
5216 CompileRun(source); | 5218 CompileRun(source); |
5217 } | 5219 } |
5218 | 5220 |
5219 | 5221 |
5220 void DebuggerThread::Run() { | 5222 void DebuggerThread::Run() { |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5561 | 5563 |
5562 | 5564 |
5563 // Test functions called through the debugger. | 5565 // Test functions called through the debugger. |
5564 TEST(CallFunctionInDebugger) { | 5566 TEST(CallFunctionInDebugger) { |
5565 // Create and enter a context with the functions CheckFrameCount, | 5567 // Create and enter a context with the functions CheckFrameCount, |
5566 // CheckSourceLine and CheckDataParameter installed. | 5568 // CheckSourceLine and CheckDataParameter installed. |
5567 v8::HandleScope scope(CcTest::isolate()); | 5569 v8::HandleScope scope(CcTest::isolate()); |
5568 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5570 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
5569 global_template->Set( | 5571 global_template->Set( |
5570 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"), | 5572 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"), |
5571 v8::FunctionTemplate::New(CheckFrameCount)); | 5573 v8::FunctionTemplate::New(CcTest::isolate(), CheckFrameCount)); |
5572 global_template->Set( | 5574 global_template->Set( |
5573 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"), | 5575 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"), |
5574 v8::FunctionTemplate::New(CheckSourceLine)); | 5576 v8::FunctionTemplate::New(CcTest::isolate(), CheckSourceLine)); |
5575 global_template->Set( | 5577 global_template->Set( |
5576 v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"), | 5578 v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"), |
5577 v8::FunctionTemplate::New(CheckDataParameter)); | 5579 v8::FunctionTemplate::New(CcTest::isolate(), CheckDataParameter)); |
5578 global_template->Set( | 5580 global_template->Set( |
5579 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"), | 5581 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"), |
5580 v8::FunctionTemplate::New(CheckClosure)); | 5582 v8::FunctionTemplate::New(CcTest::isolate(), CheckClosure)); |
5581 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), | 5583 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), |
5582 NULL, | 5584 NULL, |
5583 global_template); | 5585 global_template); |
5584 v8::Context::Scope context_scope(context); | 5586 v8::Context::Scope context_scope(context); |
5585 | 5587 |
5586 // Compile a function for checking the number of JavaScript frames. | 5588 // Compile a function for checking the number of JavaScript frames. |
5587 v8::Script::Compile( | 5589 v8::Script::Compile( |
5588 v8::String::NewFromUtf8(CcTest::isolate(), frame_count_source))->Run(); | 5590 v8::String::NewFromUtf8(CcTest::isolate(), frame_count_source))->Run(); |
5589 frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get( | 5591 frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get( |
5590 v8::String::NewFromUtf8(CcTest::isolate(), "frame_count"))); | 5592 v8::String::NewFromUtf8(CcTest::isolate(), "frame_count"))); |
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7420 CompileFunction(&env, frame_argument_name_source, "frame_argument_name"); | 7422 CompileFunction(&env, frame_argument_name_source, "frame_argument_name"); |
7421 frame_argument_value = CompileFunction(&env, | 7423 frame_argument_value = CompileFunction(&env, |
7422 frame_argument_value_source, | 7424 frame_argument_value_source, |
7423 "frame_argument_value"); | 7425 "frame_argument_value"); |
7424 frame_local_name = | 7426 frame_local_name = |
7425 CompileFunction(&env, frame_local_name_source, "frame_local_name"); | 7427 CompileFunction(&env, frame_local_name_source, "frame_local_name"); |
7426 frame_local_value = | 7428 frame_local_value = |
7427 CompileFunction(&env, frame_local_value_source, "frame_local_value"); | 7429 CompileFunction(&env, frame_local_value_source, "frame_local_value"); |
7428 | 7430 |
7429 v8::Handle<v8::FunctionTemplate> schedule_break_template = | 7431 v8::Handle<v8::FunctionTemplate> schedule_break_template = |
7430 v8::FunctionTemplate::New(ScheduleBreak); | 7432 v8::FunctionTemplate::New(env->GetIsolate(), ScheduleBreak); |
7431 v8::Handle<v8::Function> schedule_break = | 7433 v8::Handle<v8::Function> schedule_break = |
7432 schedule_break_template->GetFunction(); | 7434 schedule_break_template->GetFunction(); |
7433 env->Global()->Set(v8_str("scheduleBreak"), schedule_break); | 7435 env->Global()->Set(v8_str("scheduleBreak"), schedule_break); |
7434 | 7436 |
7435 const char* src = | 7437 const char* src = |
7436 "function loop(count) {" | 7438 "function loop(count) {" |
7437 " var local = 42;" | 7439 " var local = 42;" |
7438 " if (count < 1) { scheduleBreak(); loop(count + 1); }" | 7440 " if (count < 1) { scheduleBreak(); loop(count + 1); }" |
7439 "}" | 7441 "}" |
7440 "loop(0);"; | 7442 "loop(0);"; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7668 TEST(LiveEditDisabled) { | 7670 TEST(LiveEditDisabled) { |
7669 v8::internal::FLAG_allow_natives_syntax = true; | 7671 v8::internal::FLAG_allow_natives_syntax = true; |
7670 LocalContext env; | 7672 LocalContext env; |
7671 v8::HandleScope scope(env->GetIsolate()); | 7673 v8::HandleScope scope(env->GetIsolate()); |
7672 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate()); | 7674 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate()); |
7673 CompileRun("%LiveEditCompareStrings('', '')"); | 7675 CompileRun("%LiveEditCompareStrings('', '')"); |
7674 } | 7676 } |
7675 | 7677 |
7676 | 7678 |
7677 #endif // ENABLE_DEBUGGER_SUPPORT | 7679 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |