| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 using ::v8::internal::StepAction; | 63 using ::v8::internal::StepAction; |
| 64 using ::v8::internal::StepIn; // From StepAction enum | 64 using ::v8::internal::StepIn; // From StepAction enum |
| 65 using ::v8::internal::StepNext; // From StepAction enum | 65 using ::v8::internal::StepNext; // From StepAction enum |
| 66 using ::v8::internal::StepOut; // From StepAction enum | 66 using ::v8::internal::StepOut; // From StepAction enum |
| 67 using ::v8::internal::Vector; | 67 using ::v8::internal::Vector; |
| 68 using ::v8::internal::StrLength; | 68 using ::v8::internal::StrLength; |
| 69 | 69 |
| 70 // Size of temp buffer for formatting small strings. | 70 // Size of temp buffer for formatting small strings. |
| 71 #define SMALL_STRING_BUFFER_SIZE 80 | 71 #define SMALL_STRING_BUFFER_SIZE 80 |
| 72 | 72 |
| 73 // --- A d d i t i o n a l C h e c k H e l p e r s | |
| 74 | |
| 75 | |
| 76 // Helper function used by the CHECK_EQ function when given Address | |
| 77 // arguments. Should not be called directly. | |
| 78 static inline void CheckEqualsHelper(const char* file, int line, | |
| 79 const char* expected_source, | |
| 80 ::v8::internal::Address expected, | |
| 81 const char* value_source, | |
| 82 ::v8::internal::Address value) { | |
| 83 if (expected != value) { | |
| 84 V8_Fatal(file, line, "CHECK_EQ(%s, %s) failed\n# " | |
| 85 "Expected: %i\n# Found: %i", | |
| 86 expected_source, value_source, expected, value); | |
| 87 } | |
| 88 } | |
| 89 | |
| 90 | |
| 91 // Helper function used by the CHECK_NE function when given Address | |
| 92 // arguments. Should not be called directly. | |
| 93 static inline void CheckNonEqualsHelper(const char* file, int line, | |
| 94 const char* unexpected_source, | |
| 95 ::v8::internal::Address unexpected, | |
| 96 const char* value_source, | |
| 97 ::v8::internal::Address value) { | |
| 98 if (unexpected == value) { | |
| 99 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %i", | |
| 100 unexpected_source, value_source, value); | |
| 101 } | |
| 102 } | |
| 103 | |
| 104 | |
| 105 // Helper function used by the CHECK function when given code | |
| 106 // arguments. Should not be called directly. | |
| 107 static inline void CheckEqualsHelper(const char* file, int line, | |
| 108 const char* expected_source, | |
| 109 const Code* expected, | |
| 110 const char* value_source, | |
| 111 const Code* value) { | |
| 112 if (expected != value) { | |
| 113 V8_Fatal(file, line, "CHECK_EQ(%s, %s) failed\n# " | |
| 114 "Expected: %p\n# Found: %p", | |
| 115 expected_source, value_source, expected, value); | |
| 116 } | |
| 117 } | |
| 118 | |
| 119 | |
| 120 static inline void CheckNonEqualsHelper(const char* file, int line, | |
| 121 const char* expected_source, | |
| 122 const Code* expected, | |
| 123 const char* value_source, | |
| 124 const Code* value) { | |
| 125 if (expected == value) { | |
| 126 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %p", | |
| 127 expected_source, value_source, value); | |
| 128 } | |
| 129 } | |
| 130 | |
| 131 | |
| 132 // --- H e l p e r C l a s s e s | 73 // --- H e l p e r C l a s s e s |
| 133 | 74 |
| 134 | 75 |
| 135 // Helper class for creating a V8 enviromnent for running tests | 76 // Helper class for creating a V8 enviromnent for running tests |
| 136 class DebugLocalContext { | 77 class DebugLocalContext { |
| 137 public: | 78 public: |
| 138 inline DebugLocalContext( | 79 inline DebugLocalContext( |
| 139 v8::ExtensionConfiguration* extensions = 0, | 80 v8::ExtensionConfiguration* extensions = 0, |
| 140 v8::Handle<v8::ObjectTemplate> global_template = | 81 v8::Handle<v8::ObjectTemplate> global_template = |
| 141 v8::Handle<v8::ObjectTemplate>(), | 82 v8::Handle<v8::ObjectTemplate>(), |
| (...skipping 4386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4528 CHECK(CompileRun(source)->BooleanValue()); | 4469 CHECK(CompileRun(source)->BooleanValue()); |
| 4529 | 4470 |
| 4530 source = "both_values[4].name() == 10"; | 4471 source = "both_values[4].name() == 10"; |
| 4531 CHECK(CompileRun(source)->BooleanValue()); | 4472 CHECK(CompileRun(source)->BooleanValue()); |
| 4532 } | 4473 } |
| 4533 | 4474 |
| 4534 | 4475 |
| 4535 TEST(HiddenPrototypePropertyMirror) { | 4476 TEST(HiddenPrototypePropertyMirror) { |
| 4536 // Create a V8 environment with debug access. | 4477 // Create a V8 environment with debug access. |
| 4537 DebugLocalContext env; | 4478 DebugLocalContext env; |
| 4538 v8::HandleScope scope(env->GetIsolate()); | 4479 v8::Isolate* isolate = env->GetIsolate(); |
| 4480 v8::HandleScope scope(isolate); |
| 4539 env.ExposeDebug(); | 4481 env.ExposeDebug(); |
| 4540 | 4482 |
| 4541 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | 4483 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); |
| 4542 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "x"), | 4484 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"), |
| 4543 v8::Number::New(0)); | 4485 v8::Number::New(0)); |
| 4544 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 4486 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 4545 t1->SetHiddenPrototype(true); | 4487 t1->SetHiddenPrototype(true); |
| 4546 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "y"), | 4488 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"), |
| 4547 v8::Number::New(1)); | 4489 v8::Number::New(1)); |
| 4548 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); | 4490 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
| 4549 t2->SetHiddenPrototype(true); | 4491 t2->SetHiddenPrototype(true); |
| 4550 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "z"), | 4492 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"), |
| 4551 v8::Number::New(2)); | 4493 v8::Number::New(2)); |
| 4552 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(); | 4494 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); |
| 4553 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "u"), | 4495 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"), |
| 4554 v8::Number::New(3)); | 4496 v8::Number::New(3)); |
| 4555 | 4497 |
| 4556 // Create object and set them on the global object. | 4498 // Create object and set them on the global object. |
| 4557 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance(); | 4499 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance(); |
| 4558 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o0"), o0); | 4500 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0); |
| 4559 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); | 4501 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); |
| 4560 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o1"), o1); | 4502 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1); |
| 4561 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); | 4503 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); |
| 4562 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o2"), o2); | 4504 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2); |
| 4563 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); | 4505 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); |
| 4564 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o3"), o3); | 4506 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3); |
| 4565 | 4507 |
| 4566 // Get mirrors for the four objects. | 4508 // Get mirrors for the four objects. |
| 4567 CompileRun( | 4509 CompileRun( |
| 4568 "var o0_mirror = debug.MakeMirror(o0);" | 4510 "var o0_mirror = debug.MakeMirror(o0);" |
| 4569 "var o1_mirror = debug.MakeMirror(o1);" | 4511 "var o1_mirror = debug.MakeMirror(o1);" |
| 4570 "var o2_mirror = debug.MakeMirror(o2);" | 4512 "var o2_mirror = debug.MakeMirror(o2);" |
| 4571 "var o3_mirror = debug.MakeMirror(o3)"); | 4513 "var o3_mirror = debug.MakeMirror(o3)"); |
| 4572 CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4514 CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
| 4573 CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4515 CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
| 4574 CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4516 CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
| 4575 CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4517 CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
| 4576 | 4518 |
| 4577 // Check that each object has one property. | 4519 // Check that each object has one property. |
| 4578 CHECK_EQ(1, CompileRun( | 4520 CHECK_EQ(1, CompileRun( |
| 4579 "o0_mirror.propertyNames().length")->Int32Value()); | 4521 "o0_mirror.propertyNames().length")->Int32Value()); |
| 4580 CHECK_EQ(1, CompileRun( | 4522 CHECK_EQ(1, CompileRun( |
| 4581 "o1_mirror.propertyNames().length")->Int32Value()); | 4523 "o1_mirror.propertyNames().length")->Int32Value()); |
| 4582 CHECK_EQ(1, CompileRun( | 4524 CHECK_EQ(1, CompileRun( |
| 4583 "o2_mirror.propertyNames().length")->Int32Value()); | 4525 "o2_mirror.propertyNames().length")->Int32Value()); |
| 4584 CHECK_EQ(1, CompileRun( | 4526 CHECK_EQ(1, CompileRun( |
| 4585 "o3_mirror.propertyNames().length")->Int32Value()); | 4527 "o3_mirror.propertyNames().length")->Int32Value()); |
| 4586 | 4528 |
| 4587 // 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 |
| 4588 // properties on o1 should be seen on o0. | 4530 // properties on o1 should be seen on o0. |
| 4589 o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o1); | 4531 o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o1); |
| 4590 CHECK_EQ(2, CompileRun( | 4532 CHECK_EQ(2, CompileRun( |
| 4591 "o0_mirror.propertyNames().length")->Int32Value()); | 4533 "o0_mirror.propertyNames().length")->Int32Value()); |
| 4592 CHECK_EQ(0, CompileRun( | 4534 CHECK_EQ(0, CompileRun( |
| 4593 "o0_mirror.property('x').value().value()")->Int32Value()); | 4535 "o0_mirror.property('x').value().value()")->Int32Value()); |
| 4594 CHECK_EQ(1, CompileRun( | 4536 CHECK_EQ(1, CompileRun( |
| 4595 "o0_mirror.property('y').value().value()")->Int32Value()); | 4537 "o0_mirror.property('y').value().value()")->Int32Value()); |
| 4596 | 4538 |
| 4597 // 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 |
| 4598 // 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 |
| 4599 // 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. |
| 4600 o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o2); | 4542 o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o2); |
| 4601 CHECK_EQ(3, CompileRun( | 4543 CHECK_EQ(3, CompileRun( |
| 4602 "o0_mirror.propertyNames().length")->Int32Value()); | 4544 "o0_mirror.propertyNames().length")->Int32Value()); |
| 4603 CHECK_EQ(0, CompileRun( | 4545 CHECK_EQ(0, CompileRun( |
| 4604 "o0_mirror.property('x').value().value()")->Int32Value()); | 4546 "o0_mirror.property('x').value().value()")->Int32Value()); |
| 4605 CHECK_EQ(1, CompileRun( | 4547 CHECK_EQ(1, CompileRun( |
| 4606 "o0_mirror.property('y').value().value()")->Int32Value()); | 4548 "o0_mirror.property('y').value().value()")->Int32Value()); |
| 4607 CHECK_EQ(2, CompileRun( | 4549 CHECK_EQ(2, CompileRun( |
| 4608 "o0_mirror.property('z').value().value()")->Int32Value()); | 4550 "o0_mirror.property('z').value().value()")->Int32Value()); |
| 4609 | 4551 |
| 4610 // 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 |
| 4611 // 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 |
| 4612 // 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 |
| 4613 // from o1 and o2 should still be seen on o0. | 4555 // from o1 and o2 should still be seen on o0. |
| 4614 // Final prototype chain: o0 -> o1 -> o2 -> o3 | 4556 // Final prototype chain: o0 -> o1 -> o2 -> o3 |
| 4615 // Hidden prototypes: ^^ ^^ | 4557 // Hidden prototypes: ^^ ^^ |
| 4616 o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o3); | 4558 o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o3); |
| 4617 CHECK_EQ(3, CompileRun( | 4559 CHECK_EQ(3, CompileRun( |
| 4618 "o0_mirror.propertyNames().length")->Int32Value()); | 4560 "o0_mirror.propertyNames().length")->Int32Value()); |
| 4619 CHECK_EQ(1, CompileRun( | 4561 CHECK_EQ(1, CompileRun( |
| 4620 "o3_mirror.propertyNames().length")->Int32Value()); | 4562 "o3_mirror.propertyNames().length")->Int32Value()); |
| 4621 CHECK_EQ(0, CompileRun( | 4563 CHECK_EQ(0, CompileRun( |
| 4622 "o0_mirror.property('x').value().value()")->Int32Value()); | 4564 "o0_mirror.property('x').value().value()")->Int32Value()); |
| 4623 CHECK_EQ(1, CompileRun( | 4565 CHECK_EQ(1, CompileRun( |
| 4624 "o0_mirror.property('y').value().value()")->Int32Value()); | 4566 "o0_mirror.property('y').value().value()")->Int32Value()); |
| 4625 CHECK_EQ(2, CompileRun( | 4567 CHECK_EQ(2, CompileRun( |
| 4626 "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... |
| 4709 BooleanValue()); | 4651 BooleanValue()); |
| 4710 } | 4652 } |
| 4711 | 4653 |
| 4712 | 4654 |
| 4713 // 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 |
| 4714 // among regular properties. | 4656 // among regular properties. |
| 4715 // See http://crbug.com/26491 | 4657 // See http://crbug.com/26491 |
| 4716 TEST(NoHiddenProperties) { | 4658 TEST(NoHiddenProperties) { |
| 4717 // Create a V8 environment with debug access. | 4659 // Create a V8 environment with debug access. |
| 4718 DebugLocalContext env; | 4660 DebugLocalContext env; |
| 4719 v8::HandleScope scope(env->GetIsolate()); | 4661 v8::Isolate* isolate = env->GetIsolate(); |
| 4662 v8::HandleScope scope(isolate); |
| 4720 env.ExposeDebug(); | 4663 env.ExposeDebug(); |
| 4721 | 4664 |
| 4722 // Create an object in the global scope. | 4665 // Create an object in the global scope. |
| 4723 const char* source = "var obj = {a: 1};"; | 4666 const char* source = "var obj = {a: 1};"; |
| 4724 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source)) | 4667 v8::Script::Compile(v8::String::NewFromUtf8(isolate, source)) |
| 4725 ->Run(); | 4668 ->Run(); |
| 4726 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( | 4669 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( |
| 4727 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "obj"))); | 4670 env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj"))); |
| 4728 // Set a hidden property on the object. | 4671 // Set a hidden property on the object. |
| 4729 obj->SetHiddenValue( | 4672 obj->SetHiddenValue( |
| 4730 v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::a"), | 4673 v8::String::NewFromUtf8(isolate, "v8::test-debug::a"), |
| 4731 v8::Int32::New(11)); | 4674 v8::Int32::New(11)); |
| 4732 | 4675 |
| 4733 // Get mirror for the object with property getter. | 4676 // Get mirror for the object with property getter. |
| 4734 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); | 4677 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); |
| 4735 CHECK(CompileRun( | 4678 CHECK(CompileRun( |
| 4736 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4679 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
| 4737 CompileRun("var named_names = obj_mirror.propertyNames();"); | 4680 CompileRun("var named_names = obj_mirror.propertyNames();"); |
| 4738 // 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 |
| 4739 // property whose value is hidden properties dictionary. The latter | 4682 // property whose value is hidden properties dictionary. The latter |
| 4740 // property should not be in the list of reguar properties. | 4683 // property should not be in the list of reguar properties. |
| 4741 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); | 4684 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); |
| 4742 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); | 4685 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); |
| 4743 CHECK(CompileRun( | 4686 CHECK(CompileRun( |
| 4744 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); | 4687 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); |
| 4745 | 4688 |
| 4746 // Object created by t0 will become hidden prototype of object 'obj'. | 4689 // Object created by t0 will become hidden prototype of object 'obj'. |
| 4747 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | 4690 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); |
| 4748 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"), | 4691 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"), |
| 4749 v8::Number::New(2)); | 4692 v8::Number::New(2)); |
| 4750 t0->SetHiddenPrototype(true); | 4693 t0->SetHiddenPrototype(true); |
| 4751 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 4694 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 4752 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "c"), | 4695 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"), |
| 4753 v8::Number::New(3)); | 4696 v8::Number::New(3)); |
| 4754 | 4697 |
| 4755 // 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 |
| 4756 // the global object. | 4699 // the global object. |
| 4757 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); | 4700 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); |
| 4758 protoObj->SetHiddenValue( | 4701 protoObj->SetHiddenValue( |
| 4759 v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::b"), | 4702 v8::String::NewFromUtf8(isolate, "v8::test-debug::b"), |
| 4760 v8::Int32::New(12)); | 4703 v8::Int32::New(12)); |
| 4761 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "protoObj"), | 4704 env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"), |
| 4762 protoObj); | 4705 protoObj); |
| 4763 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); | 4706 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); |
| 4764 grandProtoObj->SetHiddenValue( | 4707 grandProtoObj->SetHiddenValue( |
| 4765 v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::c"), | 4708 v8::String::NewFromUtf8(isolate, "v8::test-debug::c"), |
| 4766 v8::Int32::New(13)); | 4709 v8::Int32::New(13)); |
| 4767 env->Global()->Set( | 4710 env->Global()->Set( |
| 4768 v8::String::NewFromUtf8(env->GetIsolate(), "grandProtoObj"), | 4711 v8::String::NewFromUtf8(isolate, "grandProtoObj"), |
| 4769 grandProtoObj); | 4712 grandProtoObj); |
| 4770 | 4713 |
| 4771 // Setting prototypes: obj->protoObj->grandProtoObj | 4714 // Setting prototypes: obj->protoObj->grandProtoObj |
| 4772 protoObj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), | 4715 protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), |
| 4773 grandProtoObj); | 4716 grandProtoObj); |
| 4774 obj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), protoObj); | 4717 obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj); |
| 4775 | 4718 |
| 4776 // Get mirror for the object with property getter. | 4719 // Get mirror for the object with property getter. |
| 4777 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); | 4720 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); |
| 4778 CHECK(CompileRun( | 4721 CHECK(CompileRun( |
| 4779 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4722 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
| 4780 CompileRun("var named_names = obj_mirror.propertyNames();"); | 4723 CompileRun("var named_names = obj_mirror.propertyNames();"); |
| 4781 // 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 |
| 4782 // another from its hidden prototype. | 4725 // another from its hidden prototype. |
| 4783 CHECK_EQ(2, CompileRun("named_names.length")->Int32Value()); | 4726 CHECK_EQ(2, CompileRun("named_names.length")->Int32Value()); |
| 4784 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... |
| 5259 "\n" | 5202 "\n" |
| 5260 "foo();\n"; | 5203 "foo();\n"; |
| 5261 | 5204 |
| 5262 v8::Isolate::Scope isolate_scope(CcTest::isolate()); | 5205 v8::Isolate::Scope isolate_scope(CcTest::isolate()); |
| 5263 DebugLocalContext env; | 5206 DebugLocalContext env; |
| 5264 v8::HandleScope scope(env->GetIsolate()); | 5207 v8::HandleScope scope(env->GetIsolate()); |
| 5265 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); | 5208 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); |
| 5266 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5209 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 5267 global_template->Set( | 5210 global_template->Set( |
| 5268 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), | 5211 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), |
| 5269 v8::FunctionTemplate::New(ThreadedAtBarrier1)); | 5212 v8::FunctionTemplate::New(CcTest::isolate(), ThreadedAtBarrier1)); |
| 5270 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), | 5213 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), |
| 5271 NULL, | 5214 NULL, |
| 5272 global_template); | 5215 global_template); |
| 5273 v8::Context::Scope context_scope(context); | 5216 v8::Context::Scope context_scope(context); |
| 5274 | 5217 |
| 5275 CompileRun(source); | 5218 CompileRun(source); |
| 5276 } | 5219 } |
| 5277 | 5220 |
| 5278 | 5221 |
| 5279 void DebuggerThread::Run() { | 5222 void DebuggerThread::Run() { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5620 | 5563 |
| 5621 | 5564 |
| 5622 // Test functions called through the debugger. | 5565 // Test functions called through the debugger. |
| 5623 TEST(CallFunctionInDebugger) { | 5566 TEST(CallFunctionInDebugger) { |
| 5624 // Create and enter a context with the functions CheckFrameCount, | 5567 // Create and enter a context with the functions CheckFrameCount, |
| 5625 // CheckSourceLine and CheckDataParameter installed. | 5568 // CheckSourceLine and CheckDataParameter installed. |
| 5626 v8::HandleScope scope(CcTest::isolate()); | 5569 v8::HandleScope scope(CcTest::isolate()); |
| 5627 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5570 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 5628 global_template->Set( | 5571 global_template->Set( |
| 5629 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"), | 5572 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"), |
| 5630 v8::FunctionTemplate::New(CheckFrameCount)); | 5573 v8::FunctionTemplate::New(CcTest::isolate(), CheckFrameCount)); |
| 5631 global_template->Set( | 5574 global_template->Set( |
| 5632 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"), | 5575 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"), |
| 5633 v8::FunctionTemplate::New(CheckSourceLine)); | 5576 v8::FunctionTemplate::New(CcTest::isolate(), CheckSourceLine)); |
| 5634 global_template->Set( | 5577 global_template->Set( |
| 5635 v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"), | 5578 v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"), |
| 5636 v8::FunctionTemplate::New(CheckDataParameter)); | 5579 v8::FunctionTemplate::New(CcTest::isolate(), CheckDataParameter)); |
| 5637 global_template->Set( | 5580 global_template->Set( |
| 5638 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"), | 5581 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"), |
| 5639 v8::FunctionTemplate::New(CheckClosure)); | 5582 v8::FunctionTemplate::New(CcTest::isolate(), CheckClosure)); |
| 5640 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), | 5583 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), |
| 5641 NULL, | 5584 NULL, |
| 5642 global_template); | 5585 global_template); |
| 5643 v8::Context::Scope context_scope(context); | 5586 v8::Context::Scope context_scope(context); |
| 5644 | 5587 |
| 5645 // Compile a function for checking the number of JavaScript frames. | 5588 // Compile a function for checking the number of JavaScript frames. |
| 5646 v8::Script::Compile( | 5589 v8::Script::Compile( |
| 5647 v8::String::NewFromUtf8(CcTest::isolate(), frame_count_source))->Run(); | 5590 v8::String::NewFromUtf8(CcTest::isolate(), frame_count_source))->Run(); |
| 5648 frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get( | 5591 frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get( |
| 5649 v8::String::NewFromUtf8(CcTest::isolate(), "frame_count"))); | 5592 v8::String::NewFromUtf8(CcTest::isolate(), "frame_count"))); |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6116 listening_(0) { | 6059 listening_(0) { |
| 6117 } | 6060 } |
| 6118 ~DebuggerAgentProtocolServerThread() { | 6061 ~DebuggerAgentProtocolServerThread() { |
| 6119 // Close both sockets. | 6062 // Close both sockets. |
| 6120 delete client_; | 6063 delete client_; |
| 6121 delete server_; | 6064 delete server_; |
| 6122 } | 6065 } |
| 6123 | 6066 |
| 6124 void Run(); | 6067 void Run(); |
| 6125 void WaitForListening() { listening_.Wait(); } | 6068 void WaitForListening() { listening_.Wait(); } |
| 6126 char* body() { return *body_; } | 6069 char* body() { return body_.get(); } |
| 6127 | 6070 |
| 6128 private: | 6071 private: |
| 6129 int port_; | 6072 int port_; |
| 6130 i::SmartArrayPointer<char> body_; | 6073 i::SmartArrayPointer<char> body_; |
| 6131 i::Socket* server_; // Server socket used for bind/accept. | 6074 i::Socket* server_; // Server socket used for bind/accept. |
| 6132 i::Socket* client_; // Single client connection used by the test. | 6075 i::Socket* client_; // Single client connection used by the test. |
| 6133 i::Semaphore listening_; // Signalled when the server is in listen mode. | 6076 i::Semaphore listening_; // Signalled when the server is in listen mode. |
| 6134 }; | 6077 }; |
| 6135 | 6078 |
| 6136 | 6079 |
| (...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7479 CompileFunction(&env, frame_argument_name_source, "frame_argument_name"); | 7422 CompileFunction(&env, frame_argument_name_source, "frame_argument_name"); |
| 7480 frame_argument_value = CompileFunction(&env, | 7423 frame_argument_value = CompileFunction(&env, |
| 7481 frame_argument_value_source, | 7424 frame_argument_value_source, |
| 7482 "frame_argument_value"); | 7425 "frame_argument_value"); |
| 7483 frame_local_name = | 7426 frame_local_name = |
| 7484 CompileFunction(&env, frame_local_name_source, "frame_local_name"); | 7427 CompileFunction(&env, frame_local_name_source, "frame_local_name"); |
| 7485 frame_local_value = | 7428 frame_local_value = |
| 7486 CompileFunction(&env, frame_local_value_source, "frame_local_value"); | 7429 CompileFunction(&env, frame_local_value_source, "frame_local_value"); |
| 7487 | 7430 |
| 7488 v8::Handle<v8::FunctionTemplate> schedule_break_template = | 7431 v8::Handle<v8::FunctionTemplate> schedule_break_template = |
| 7489 v8::FunctionTemplate::New(ScheduleBreak); | 7432 v8::FunctionTemplate::New(env->GetIsolate(), ScheduleBreak); |
| 7490 v8::Handle<v8::Function> schedule_break = | 7433 v8::Handle<v8::Function> schedule_break = |
| 7491 schedule_break_template->GetFunction(); | 7434 schedule_break_template->GetFunction(); |
| 7492 env->Global()->Set(v8_str("scheduleBreak"), schedule_break); | 7435 env->Global()->Set(v8_str("scheduleBreak"), schedule_break); |
| 7493 | 7436 |
| 7494 const char* src = | 7437 const char* src = |
| 7495 "function loop(count) {" | 7438 "function loop(count) {" |
| 7496 " var local = 42;" | 7439 " var local = 42;" |
| 7497 " if (count < 1) { scheduleBreak(); loop(count + 1); }" | 7440 " if (count < 1) { scheduleBreak(); loop(count + 1); }" |
| 7498 "}" | 7441 "}" |
| 7499 "loop(0);"; | 7442 "loop(0);"; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7727 TEST(LiveEditDisabled) { | 7670 TEST(LiveEditDisabled) { |
| 7728 v8::internal::FLAG_allow_natives_syntax = true; | 7671 v8::internal::FLAG_allow_natives_syntax = true; |
| 7729 LocalContext env; | 7672 LocalContext env; |
| 7730 v8::HandleScope scope(env->GetIsolate()); | 7673 v8::HandleScope scope(env->GetIsolate()); |
| 7731 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate()); | 7674 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate()); |
| 7732 CompileRun("%LiveEditCompareStrings('', '')"); | 7675 CompileRun("%LiveEditCompareStrings('', '')"); |
| 7733 } | 7676 } |
| 7734 | 7677 |
| 7735 | 7678 |
| 7736 #endif // ENABLE_DEBUGGER_SUPPORT | 7679 #endif // ENABLE_DEBUGGER_SUPPORT |
| OLD | NEW |