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

Side by Side Diff: test/cctest/test-debug.cc

Issue 124943004: Prepare removal of ObjectTemplate::New without Isolate parameter. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Do not remove ObjectTemplate::New() yet. Created 6 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-assembler-x64.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4337 matching lines...) Expand 10 before | Expand all | Expand 10 after
4348 4348
4349 static void IndexedGetter(uint32_t index, 4349 static void IndexedGetter(uint32_t index,
4350 const v8::PropertyCallbackInfo<v8::Value>& info) { 4350 const v8::PropertyCallbackInfo<v8::Value>& info) {
4351 info.GetReturnValue().Set(static_cast<double>(index + 1)); 4351 info.GetReturnValue().Set(static_cast<double>(index + 1));
4352 } 4352 }
4353 4353
4354 4354
4355 TEST(InterceptorPropertyMirror) { 4355 TEST(InterceptorPropertyMirror) {
4356 // Create a V8 environment with debug access. 4356 // Create a V8 environment with debug access.
4357 DebugLocalContext env; 4357 DebugLocalContext env;
4358 v8::HandleScope scope(env->GetIsolate()); 4358 v8::Isolate* isolate = env->GetIsolate();
4359 v8::HandleScope scope(isolate);
4359 env.ExposeDebug(); 4360 env.ExposeDebug();
4360 4361
4361 // Create object with named interceptor. 4362 // Create object with named interceptor.
4362 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 4363 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
4363 named->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); 4364 named->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum);
4364 env->Global()->Set( 4365 env->Global()->Set(
4365 v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_named"), 4366 v8::String::NewFromUtf8(isolate, "intercepted_named"),
4366 named->NewInstance()); 4367 named->NewInstance());
4367 4368
4368 // Create object with indexed interceptor. 4369 // Create object with indexed interceptor.
4369 v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(); 4370 v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(isolate);
4370 indexed->SetIndexedPropertyHandler(IndexedGetter, 4371 indexed->SetIndexedPropertyHandler(IndexedGetter,
4371 NULL, 4372 NULL,
4372 NULL, 4373 NULL,
4373 NULL, 4374 NULL,
4374 IndexedEnum); 4375 IndexedEnum);
4375 env->Global()->Set( 4376 env->Global()->Set(
4376 v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_indexed"), 4377 v8::String::NewFromUtf8(isolate, "intercepted_indexed"),
4377 indexed->NewInstance()); 4378 indexed->NewInstance());
4378 4379
4379 // Create object with both named and indexed interceptor. 4380 // Create object with both named and indexed interceptor.
4380 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(); 4381 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(isolate);
4381 both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); 4382 both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum);
4382 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum); 4383 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum);
4383 env->Global()->Set( 4384 env->Global()->Set(
4384 v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_both"), 4385 v8::String::NewFromUtf8(isolate, "intercepted_both"),
4385 both->NewInstance()); 4386 both->NewInstance());
4386 4387
4387 // Get mirrors for the three objects with interceptor. 4388 // Get mirrors for the three objects with interceptor.
4388 CompileRun( 4389 CompileRun(
4389 "var named_mirror = debug.MakeMirror(intercepted_named);" 4390 "var named_mirror = debug.MakeMirror(intercepted_named);"
4390 "var indexed_mirror = debug.MakeMirror(intercepted_indexed);" 4391 "var indexed_mirror = debug.MakeMirror(intercepted_indexed);"
4391 "var both_mirror = debug.MakeMirror(intercepted_both)"); 4392 "var both_mirror = debug.MakeMirror(intercepted_both)");
4392 CHECK(CompileRun( 4393 CHECK(CompileRun(
4393 "named_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4394 "named_mirror instanceof debug.ObjectMirror")->BooleanValue());
4394 CHECK(CompileRun( 4395 CHECK(CompileRun(
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
4590 static void ProtperyXNativeGetter( 4591 static void ProtperyXNativeGetter(
4591 v8::Local<v8::String> property, 4592 v8::Local<v8::String> property,
4592 const v8::PropertyCallbackInfo<v8::Value>& info) { 4593 const v8::PropertyCallbackInfo<v8::Value>& info) {
4593 info.GetReturnValue().Set(10); 4594 info.GetReturnValue().Set(10);
4594 } 4595 }
4595 4596
4596 4597
4597 TEST(NativeGetterPropertyMirror) { 4598 TEST(NativeGetterPropertyMirror) {
4598 // Create a V8 environment with debug access. 4599 // Create a V8 environment with debug access.
4599 DebugLocalContext env; 4600 DebugLocalContext env;
4600 v8::HandleScope scope(env->GetIsolate()); 4601 v8::Isolate* isolate = env->GetIsolate();
4602 v8::HandleScope scope(isolate);
4601 env.ExposeDebug(); 4603 env.ExposeDebug();
4602 4604
4603 v8::Handle<v8::String> name = v8::String::NewFromUtf8(env->GetIsolate(), "x"); 4605 v8::Handle<v8::String> name = v8::String::NewFromUtf8(isolate, "x");
4604 // Create object with named accessor. 4606 // Create object with named accessor.
4605 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 4607 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
4606 named->SetAccessor(name, &ProtperyXNativeGetter, NULL, 4608 named->SetAccessor(name, &ProtperyXNativeGetter, NULL,
4607 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); 4609 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
4608 4610
4609 // Create object with named property getter. 4611 // Create object with named property getter.
4610 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 4612 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
4611 named->NewInstance()); 4613 named->NewInstance());
4612 CHECK_EQ(10, CompileRun("instance.x")->Int32Value()); 4614 CHECK_EQ(10, CompileRun("instance.x")->Int32Value());
4613 4615
4614 // Get mirror for the object with property getter. 4616 // Get mirror for the object with property getter.
4615 CompileRun("var instance_mirror = debug.MakeMirror(instance);"); 4617 CompileRun("var instance_mirror = debug.MakeMirror(instance);");
4616 CHECK(CompileRun( 4618 CHECK(CompileRun(
4617 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4619 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
4618 4620
4619 CompileRun("var named_names = instance_mirror.propertyNames();"); 4621 CompileRun("var named_names = instance_mirror.propertyNames();");
4620 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); 4622 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
4621 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); 4623 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
4622 CHECK(CompileRun( 4624 CHECK(CompileRun(
4623 "instance_mirror.property('x').value().isNumber()")->BooleanValue()); 4625 "instance_mirror.property('x').value().isNumber()")->BooleanValue());
4624 CHECK(CompileRun( 4626 CHECK(CompileRun(
4625 "instance_mirror.property('x').value().value() == 10")->BooleanValue()); 4627 "instance_mirror.property('x').value().value() == 10")->BooleanValue());
4626 } 4628 }
4627 4629
4628 4630
4629 static void ProtperyXNativeGetterThrowingError( 4631 static void ProtperyXNativeGetterThrowingError(
4630 v8::Local<v8::String> property, 4632 v8::Local<v8::String> property,
4631 const v8::PropertyCallbackInfo<v8::Value>& info) { 4633 const v8::PropertyCallbackInfo<v8::Value>& info) {
4632 CompileRun("throw new Error('Error message');"); 4634 CompileRun("throw new Error('Error message');");
4633 } 4635 }
4634 4636
4635 4637
4636 TEST(NativeGetterThrowingErrorPropertyMirror) { 4638 TEST(NativeGetterThrowingErrorPropertyMirror) {
4637 // Create a V8 environment with debug access. 4639 // Create a V8 environment with debug access.
4638 DebugLocalContext env; 4640 DebugLocalContext env;
4639 v8::HandleScope scope(env->GetIsolate()); 4641 v8::Isolate* isolate = env->GetIsolate();
4642 v8::HandleScope scope(isolate);
4640 env.ExposeDebug(); 4643 env.ExposeDebug();
4641 4644
4642 v8::Handle<v8::String> name = v8::String::NewFromUtf8(env->GetIsolate(), "x"); 4645 v8::Handle<v8::String> name = v8::String::NewFromUtf8(isolate, "x");
4643 // Create object with named accessor. 4646 // Create object with named accessor.
4644 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 4647 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
4645 named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL, 4648 named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL,
4646 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); 4649 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
4647 4650
4648 // Create object with named property getter. 4651 // Create object with named property getter.
4649 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 4652 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
4650 named->NewInstance()); 4653 named->NewInstance());
4651 4654
4652 // Get mirror for the object with property getter. 4655 // Get mirror for the object with property getter.
4653 CompileRun("var instance_mirror = debug.MakeMirror(instance);"); 4656 CompileRun("var instance_mirror = debug.MakeMirror(instance);");
4654 CHECK(CompileRun( 4657 CHECK(CompileRun(
4655 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4658 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
4656 CompileRun("named_names = instance_mirror.propertyNames();"); 4659 CompileRun("named_names = instance_mirror.propertyNames();");
4657 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); 4660 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
4658 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); 4661 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
4659 CHECK(CompileRun( 4662 CHECK(CompileRun(
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
5209 " while ( flag == true ) {\n" 5212 " while ( flag == true ) {\n"
5210 " if ( x == 1 ) {\n" 5213 " if ( x == 1 ) {\n"
5211 " ThreadedAtBarrier1();\n" 5214 " ThreadedAtBarrier1();\n"
5212 " }\n" 5215 " }\n"
5213 " x = x + 1;\n" 5216 " x = x + 1;\n"
5214 " }\n" 5217 " }\n"
5215 "}\n" 5218 "}\n"
5216 "\n" 5219 "\n"
5217 "foo();\n"; 5220 "foo();\n";
5218 5221
5219 v8::Isolate::Scope isolate_scope(CcTest::isolate()); 5222 v8::Isolate* isolate = CcTest::isolate();
5223 v8::Isolate::Scope isolate_scope(isolate);
5220 DebugLocalContext env; 5224 DebugLocalContext env;
5221 v8::HandleScope scope(env->GetIsolate()); 5225 v8::HandleScope scope(env->GetIsolate());
5222 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); 5226 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler);
5223 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 5227 v8::Handle<v8::ObjectTemplate> global_template =
5228 v8::ObjectTemplate::New(env->GetIsolate());
5224 global_template->Set( 5229 global_template->Set(
5225 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), 5230 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
5226 v8::FunctionTemplate::New(CcTest::isolate(), ThreadedAtBarrier1)); 5231 v8::FunctionTemplate::New(isolate, ThreadedAtBarrier1));
5227 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), 5232 v8::Handle<v8::Context> context = v8::Context::New(isolate,
5228 NULL, 5233 NULL,
5229 global_template); 5234 global_template);
5230 v8::Context::Scope context_scope(context); 5235 v8::Context::Scope context_scope(context);
5231 5236
5232 CompileRun(source); 5237 CompileRun(source);
5233 } 5238 }
5234 5239
5235 5240
5236 void DebuggerThread::Run() { 5241 void DebuggerThread::Run() {
5237 const int kBufSize = 1000; 5242 const int kBufSize = 1000;
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
5573 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) { 5578 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) {
5574 CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber()); 5579 CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber());
5575 CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value()); 5580 CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value());
5576 } 5581 }
5577 5582
5578 5583
5579 // Test functions called through the debugger. 5584 // Test functions called through the debugger.
5580 TEST(CallFunctionInDebugger) { 5585 TEST(CallFunctionInDebugger) {
5581 // Create and enter a context with the functions CheckFrameCount, 5586 // Create and enter a context with the functions CheckFrameCount,
5582 // CheckSourceLine and CheckDataParameter installed. 5587 // CheckSourceLine and CheckDataParameter installed.
5583 v8::HandleScope scope(CcTest::isolate()); 5588 v8::Isolate* isolate = CcTest::isolate();
5584 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 5589 v8::HandleScope scope(isolate);
5590 v8::Handle<v8::ObjectTemplate> global_template =
5591 v8::ObjectTemplate::New(isolate);
5585 global_template->Set( 5592 global_template->Set(
5586 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"), 5593 v8::String::NewFromUtf8(isolate, "CheckFrameCount"),
5587 v8::FunctionTemplate::New(CcTest::isolate(), CheckFrameCount)); 5594 v8::FunctionTemplate::New(isolate, CheckFrameCount));
5588 global_template->Set( 5595 global_template->Set(
5589 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"), 5596 v8::String::NewFromUtf8(isolate, "CheckSourceLine"),
5590 v8::FunctionTemplate::New(CcTest::isolate(), CheckSourceLine)); 5597 v8::FunctionTemplate::New(isolate, CheckSourceLine));
5591 global_template->Set( 5598 global_template->Set(
5592 v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"), 5599 v8::String::NewFromUtf8(isolate, "CheckDataParameter"),
5593 v8::FunctionTemplate::New(CcTest::isolate(), CheckDataParameter)); 5600 v8::FunctionTemplate::New(isolate, CheckDataParameter));
5594 global_template->Set( 5601 global_template->Set(
5595 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"), 5602 v8::String::NewFromUtf8(isolate, "CheckClosure"),
5596 v8::FunctionTemplate::New(CcTest::isolate(), CheckClosure)); 5603 v8::FunctionTemplate::New(isolate, CheckClosure));
5597 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), 5604 v8::Handle<v8::Context> context = v8::Context::New(isolate,
5598 NULL, 5605 NULL,
5599 global_template); 5606 global_template);
5600 v8::Context::Scope context_scope(context); 5607 v8::Context::Scope context_scope(context);
5601 5608
5602 // Compile a function for checking the number of JavaScript frames. 5609 // Compile a function for checking the number of JavaScript frames.
5603 v8::Script::Compile( 5610 v8::Script::Compile(
5604 v8::String::NewFromUtf8(CcTest::isolate(), frame_count_source))->Run(); 5611 v8::String::NewFromUtf8(isolate, frame_count_source))->Run();
5605 frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get( 5612 frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get(
5606 v8::String::NewFromUtf8(CcTest::isolate(), "frame_count"))); 5613 v8::String::NewFromUtf8(isolate, "frame_count")));
5607 5614
5608 // Compile a function for returning the source line for the top frame. 5615 // Compile a function for returning the source line for the top frame.
5609 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5616 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5610 frame_source_line_source))->Run(); 5617 frame_source_line_source))->Run();
5611 frame_source_line = v8::Local<v8::Function>::Cast(context->Global()->Get( 5618 frame_source_line = v8::Local<v8::Function>::Cast(context->Global()->Get(
5612 v8::String::NewFromUtf8(CcTest::isolate(), "frame_source_line"))); 5619 v8::String::NewFromUtf8(isolate, "frame_source_line")));
5613 5620
5614 // Compile a function returning the data parameter. 5621 // Compile a function returning the data parameter.
5615 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5622 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5616 debugger_call_with_data_source)) 5623 debugger_call_with_data_source))
5617 ->Run(); 5624 ->Run();
5618 debugger_call_with_data = v8::Local<v8::Function>::Cast( 5625 debugger_call_with_data = v8::Local<v8::Function>::Cast(
5619 context->Global()->Get(v8::String::NewFromUtf8( 5626 context->Global()->Get(v8::String::NewFromUtf8(
5620 CcTest::isolate(), "debugger_call_with_data"))); 5627 isolate, "debugger_call_with_data")));
5621 5628
5622 // Compile a function capturing closure. 5629 // Compile a function capturing closure.
5623 debugger_call_with_closure = 5630 debugger_call_with_closure =
5624 v8::Local<v8::Function>::Cast(v8::Script::Compile( 5631 v8::Local<v8::Function>::Cast(v8::Script::Compile(
5625 v8::String::NewFromUtf8(CcTest::isolate(), 5632 v8::String::NewFromUtf8(isolate,
5626 debugger_call_with_closure_source))->Run()); 5633 debugger_call_with_closure_source))->Run());
5627 5634
5628 // Calling a function through the debugger returns 0 frames if there are 5635 // Calling a function through the debugger returns 0 frames if there are
5629 // no JavaScript frames. 5636 // no JavaScript frames.
5630 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 0), 5637 CHECK_EQ(v8::Integer::New(isolate, 0),
5631 v8::Debug::Call(frame_count)); 5638 v8::Debug::Call(frame_count));
5632 5639
5633 // Test that the number of frames can be retrieved. 5640 // Test that the number of frames can be retrieved.
5634 v8::Script::Compile( 5641 v8::Script::Compile(
5635 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount(1)"))->Run(); 5642 v8::String::NewFromUtf8(isolate, "CheckFrameCount(1)"))->Run();
5636 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5643 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5637 "function f() {" 5644 "function f() {"
5638 " CheckFrameCount(2);" 5645 " CheckFrameCount(2);"
5639 "}; f()"))->Run(); 5646 "}; f()"))->Run();
5640 5647
5641 // Test that the source line can be retrieved. 5648 // Test that the source line can be retrieved.
5642 v8::Script::Compile( 5649 v8::Script::Compile(
5643 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(0)"))->Run(); 5650 v8::String::NewFromUtf8(isolate, "CheckSourceLine(0)"))->Run();
5644 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5651 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5645 "function f() {\n" 5652 "function f() {\n"
5646 " CheckSourceLine(1)\n" 5653 " CheckSourceLine(1)\n"
5647 " CheckSourceLine(2)\n" 5654 " CheckSourceLine(2)\n"
5648 " CheckSourceLine(3)\n" 5655 " CheckSourceLine(3)\n"
5649 "}; f()"))->Run(); 5656 "}; f()"))->Run();
5650 5657
5651 // Test that a parameter can be passed to a function called in the debugger. 5658 // Test that a parameter can be passed to a function called in the debugger.
5652 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5659 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5653 "CheckDataParameter()"))->Run(); 5660 "CheckDataParameter()"))->Run();
5654 5661
5655 // Test that a function with closure can be run in the debugger. 5662 // Test that a function with closure can be run in the debugger.
5656 v8::Script::Compile( 5663 v8::Script::Compile(
5657 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure()"))->Run(); 5664 v8::String::NewFromUtf8(isolate, "CheckClosure()"))->Run();
5658 5665
5659 // Test that the source line is correct when there is a line offset. 5666 // Test that the source line is correct when there is a line offset.
5660 v8::ScriptOrigin origin(v8::String::NewFromUtf8(CcTest::isolate(), "test"), 5667 v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, "test"),
5661 v8::Integer::New(CcTest::isolate(), 7)); 5668 v8::Integer::New(isolate, 7));
5662 v8::Script::Compile( 5669 v8::Script::Compile(
5663 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(7)"), &origin) 5670 v8::String::NewFromUtf8(isolate, "CheckSourceLine(7)"), &origin)
5664 ->Run(); 5671 ->Run();
5665 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5672 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5666 "function f() {\n" 5673 "function f() {\n"
5667 " CheckSourceLine(8)\n" 5674 " CheckSourceLine(8)\n"
5668 " CheckSourceLine(9)\n" 5675 " CheckSourceLine(9)\n"
5669 " CheckSourceLine(10)\n" 5676 " CheckSourceLine(10)\n"
5670 "}; f()"), 5677 "}; f()"),
5671 &origin)->Run(); 5678 &origin)->Run();
5672 } 5679 }
5673 5680
5674 5681
5675 // Debugger message handler which counts the number of breaks. 5682 // Debugger message handler which counts the number of breaks.
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
7160 v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv); 7167 v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv);
7161 CHECK(result->IsTrue()); 7168 CHECK(result->IsTrue());
7162 } 7169 }
7163 } 7170 }
7164 7171
7165 7172
7166 TEST(CallingContextIsNotDebugContext) { 7173 TEST(CallingContextIsNotDebugContext) {
7167 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 7174 v8::internal::Debug* debug = CcTest::i_isolate()->debug();
7168 // Create and enter a debugee context. 7175 // Create and enter a debugee context.
7169 DebugLocalContext env; 7176 DebugLocalContext env;
7170 v8::HandleScope scope(env->GetIsolate()); 7177 v8::Isolate* isolate = env->GetIsolate();
7178 v8::HandleScope scope(isolate);
7171 env.ExposeDebug(); 7179 env.ExposeDebug();
7172 7180
7173 // Save handles to the debugger and debugee contexts to be used in 7181 // Save handles to the debugger and debugee contexts to be used in
7174 // NamedGetterWithCallingContextCheck. 7182 // NamedGetterWithCallingContextCheck.
7175 debugee_context = env.context(); 7183 debugee_context = env.context();
7176 debugger_context = v8::Utils::ToLocal(debug->debug_context()); 7184 debugger_context = v8::Utils::ToLocal(debug->debug_context());
7177 7185
7178 // Create object with 'a' property accessor. 7186 // Create object with 'a' property accessor.
7179 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 7187 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
7180 named->SetAccessor(v8::String::NewFromUtf8(env->GetIsolate(), "a"), 7188 named->SetAccessor(v8::String::NewFromUtf8(isolate, "a"),
7181 NamedGetterWithCallingContextCheck); 7189 NamedGetterWithCallingContextCheck);
7182 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "obj"), 7190 env->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"),
7183 named->NewInstance()); 7191 named->NewInstance());
7184 7192
7185 // Register the debug event listener 7193 // Register the debug event listener
7186 v8::Debug::SetDebugEventListener2(DebugEventGetAtgumentPropertyValue); 7194 v8::Debug::SetDebugEventListener2(DebugEventGetAtgumentPropertyValue);
7187 7195
7188 // Create a function that invokes debugger. 7196 // Create a function that invokes debugger.
7189 v8::Local<v8::Function> foo = CompileFunction( 7197 v8::Local<v8::Function> foo = CompileFunction(
7190 &env, 7198 &env,
7191 "function bar(x) { debugger; }" 7199 "function bar(x) { debugger; }"
7192 "function foo(){ bar(obj); }", 7200 "function foo(){ bar(obj); }",
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
7691 TEST(LiveEditDisabled) { 7699 TEST(LiveEditDisabled) {
7692 v8::internal::FLAG_allow_natives_syntax = true; 7700 v8::internal::FLAG_allow_natives_syntax = true;
7693 LocalContext env; 7701 LocalContext env;
7694 v8::HandleScope scope(env->GetIsolate()); 7702 v8::HandleScope scope(env->GetIsolate());
7695 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate()); 7703 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate());
7696 CompileRun("%LiveEditCompareStrings('', '')"); 7704 CompileRun("%LiveEditCompareStrings('', '')");
7697 } 7705 }
7698 7706
7699 7707
7700 #endif // ENABLE_DEBUGGER_SUPPORT 7708 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-x64.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698