aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/test-debug.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/test-debug.cc')
-rw-r--r--deps/v8/test/cctest/test-debug.cc3323
1 files changed, 1863 insertions, 1460 deletions
diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc
index e1e928f43a..e35227ab23 100644
--- a/deps/v8/test/cctest/test-debug.cc
+++ b/deps/v8/test/cctest/test-debug.cc
@@ -73,9 +73,9 @@ class DebugLocalContext {
public:
inline DebugLocalContext(
v8::Isolate* isolate, v8::ExtensionConfiguration* extensions = 0,
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::Handle<v8::ObjectTemplate>(),
- v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
+ v8::Local<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate>(),
+ v8::Local<v8::Value> global_object = v8::Local<v8::Value>())
: scope_(isolate),
context_(v8::Context::New(isolate, extensions, global_template,
global_object)) {
@@ -83,9 +83,9 @@ class DebugLocalContext {
}
inline DebugLocalContext(
v8::ExtensionConfiguration* extensions = 0,
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::Handle<v8::ObjectTemplate>(),
- v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
+ v8::Local<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate>(),
+ v8::Local<v8::Value> global_object = v8::Local<v8::Value>())
: scope_(CcTest::isolate()),
context_(v8::Context::New(CcTest::isolate(), extensions,
global_template, global_object)) {
@@ -115,7 +115,8 @@ class DebugLocalContext {
Handle<v8::internal::String> debug_string =
factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("debug"));
v8::internal::JSObject::SetOwnPropertyIgnoreAttributes(
- global, debug_string, handle(debug_context->global_proxy()), DONT_ENUM)
+ global, debug_string, handle(debug_context->global_proxy()),
+ v8::internal::DONT_ENUM)
.Check();
}
@@ -127,31 +128,29 @@ class DebugLocalContext {
// --- H e l p e r F u n c t i o n s
-
-// Compile and run the supplied source and return the fequested function.
-static v8::Local<v8::Function> CompileFunction(DebugLocalContext* env,
+// Compile and run the supplied source and return the requested function.
+static v8::Local<v8::Function> CompileFunction(v8::Isolate* isolate,
const char* source,
const char* function_name) {
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source))
- ->Run();
- return v8::Local<v8::Function>::Cast((*env)->Global()->Get(
- v8::String::NewFromUtf8(env->GetIsolate(), function_name)));
+ CompileRunChecked(isolate, source);
+ v8::Local<v8::String> name = v8_str(isolate, function_name);
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::MaybeLocal<v8::Value> maybe_function =
+ context->Global()->Get(context, name);
+ return v8::Local<v8::Function>::Cast(maybe_function.ToLocalChecked());
}
// Compile and run the supplied source and return the requested function.
-static v8::Local<v8::Function> CompileFunction(v8::Isolate* isolate,
+static v8::Local<v8::Function> CompileFunction(DebugLocalContext* env,
const char* source,
const char* function_name) {
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))->Run();
- v8::Local<v8::Object> global = isolate->GetCurrentContext()->Global();
- return v8::Local<v8::Function>::Cast(
- global->Get(v8::String::NewFromUtf8(isolate, function_name)));
+ return CompileFunction(env->GetIsolate(), source, function_name);
}
// Is there any debug info for the function?
-static bool HasDebugInfo(v8::Handle<v8::Function> fun) {
+static bool HasDebugInfo(v8::Local<v8::Function> fun) {
Handle<v8::internal::JSFunction> f =
Handle<v8::internal::JSFunction>::cast(v8::Utils::OpenHandle(*fun));
Handle<v8::internal::SharedFunctionInfo> shared(f->shared());
@@ -175,7 +174,7 @@ static int SetBreakPoint(Handle<v8::internal::JSFunction> fun, int position) {
// Set a break point in a function and return the associated break point
// number.
-static int SetBreakPoint(v8::Handle<v8::Function> fun, int position) {
+static int SetBreakPoint(v8::Local<v8::Function> fun, int position) {
return SetBreakPoint(
i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*fun)), position);
}
@@ -191,8 +190,8 @@ static int SetBreakPointFromJS(v8::Isolate* isolate,
"debug.Debug.setBreakPoint(%s,%d,%d)",
function_name, line, position);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Handle<v8::String> str = v8::String::NewFromUtf8(isolate, buffer.start());
- return v8::Script::Compile(str)->Run()->Int32Value();
+ v8::Local<v8::Value> value = CompileRunChecked(isolate, buffer.start());
+ return value->Int32Value(isolate->GetCurrentContext()).FromJust();
}
@@ -214,11 +213,9 @@ static int SetScriptBreakPointByIdFromJS(v8::Isolate* isolate, int script_id,
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
v8::TryCatch try_catch(isolate);
- v8::Handle<v8::String> str =
- v8::String::NewFromUtf8(isolate, buffer.start());
- v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
+ v8::Local<v8::Value> value = CompileRunChecked(isolate, buffer.start());
CHECK(!try_catch.HasCaught());
- return value->Int32Value();
+ return value->Int32Value(isolate->GetCurrentContext()).FromJust();
}
}
@@ -243,11 +240,9 @@ static int SetScriptBreakPointByNameFromJS(v8::Isolate* isolate,
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
v8::TryCatch try_catch(isolate);
- v8::Handle<v8::String> str =
- v8::String::NewFromUtf8(isolate, buffer.start());
- v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
+ v8::Local<v8::Value> value = CompileRunChecked(isolate, buffer.start());
CHECK(!try_catch.HasCaught());
- return value->Int32Value();
+ return value->Int32Value(isolate->GetCurrentContext()).FromJust();
}
}
@@ -269,7 +264,7 @@ static void ClearBreakPointFromJS(v8::Isolate* isolate,
"debug.Debug.clearBreakPoint(%d)",
break_point_number);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
+ CompileRunChecked(isolate, buffer.start());
}
@@ -280,7 +275,7 @@ static void EnableScriptBreakPointFromJS(v8::Isolate* isolate,
"debug.Debug.enableScriptBreakPoint(%d)",
break_point_number);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
+ CompileRunChecked(isolate, buffer.start());
}
@@ -291,7 +286,7 @@ static void DisableScriptBreakPointFromJS(v8::Isolate* isolate,
"debug.Debug.disableScriptBreakPoint(%d)",
break_point_number);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
+ CompileRunChecked(isolate, buffer.start());
}
@@ -303,7 +298,7 @@ static void ChangeScriptBreakPointConditionFromJS(v8::Isolate* isolate,
"debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")",
break_point_number, condition);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
+ CompileRunChecked(isolate, buffer.start());
}
@@ -315,7 +310,7 @@ static void ChangeScriptBreakPointIgnoreCountFromJS(v8::Isolate* isolate,
"debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)",
break_point_number, ignoreCount);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
+ CompileRunChecked(isolate, buffer.start());
}
@@ -331,22 +326,14 @@ static void ChangeBreakOnException(bool caught, bool uncaught) {
static void ChangeBreakOnExceptionFromJS(v8::Isolate* isolate, bool caught,
bool uncaught) {
if (caught) {
- v8::Script::Compile(
- v8::String::NewFromUtf8(isolate, "debug.Debug.setBreakOnException()"))
- ->Run();
+ CompileRunChecked(isolate, "debug.Debug.setBreakOnException()");
} else {
- v8::Script::Compile(
- v8::String::NewFromUtf8(isolate, "debug.Debug.clearBreakOnException()"))
- ->Run();
+ CompileRunChecked(isolate, "debug.Debug.clearBreakOnException()");
}
if (uncaught) {
- v8::Script::Compile(
- v8::String::NewFromUtf8(
- isolate, "debug.Debug.setBreakOnUncaughtException()"))->Run();
+ CompileRunChecked(isolate, "debug.Debug.setBreakOnUncaughtException()");
} else {
- v8::Script::Compile(
- v8::String::NewFromUtf8(
- isolate, "debug.Debug.clearBreakOnUncaughtException()"))->Run();
+ CompileRunChecked(isolate, "debug.Debug.clearBreakOnUncaughtException()");
}
}
@@ -354,10 +341,13 @@ static void ChangeBreakOnExceptionFromJS(v8::Isolate* isolate, bool caught,
// Prepare to step to next break location.
static void PrepareStep(StepAction step_action) {
v8::internal::Debug* debug = CcTest::i_isolate()->debug();
- debug->PrepareStep(step_action, 1, StackFrame::NO_ID);
+ debug->PrepareStep(step_action);
}
+static void ClearStepping() { CcTest::i_isolate()->debug()->ClearStepping(); }
+
+
// This function is in namespace v8::internal to be friend with class
// v8::internal::Debug.
namespace v8 {
@@ -429,9 +419,10 @@ void CheckDebuggerUnloaded(bool check_functions) {
// Check that the debugger has been fully unloaded.
-static void CheckDebuggerUnloaded(bool check_functions = false) {
+static void CheckDebuggerUnloaded(v8::Isolate* isolate,
+ bool check_functions = false) {
// Let debugger to unload itself synchronously
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
v8::internal::CheckDebuggerUnloaded(check_functions);
}
@@ -520,7 +511,7 @@ static const char* frame_count_source =
"function frame_count(exec_state) {"
" return exec_state.frameCount();"
"}";
-v8::Handle<v8::Function> frame_count;
+v8::Local<v8::Function> frame_count;
// Global variable to store the last function hit - used by some tests.
@@ -539,7 +530,8 @@ int break_point_hit_count_deoptimize = 0;
static void DebugEventBreakPointHitCount(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
v8::internal::Isolate* isolate = CcTest::i_isolate();
Debug* debug = isolate->debug();
// When hitting a debug event listener there must be a break set.
@@ -551,16 +543,16 @@ static void DebugEventBreakPointHitCount(
if (!frame_function_name.IsEmpty()) {
// Get the name of the function.
const int argc = 2;
- v8::Handle<v8::Value> argv[argc] = {
- exec_state, v8::Integer::New(CcTest::isolate(), 0)
- };
- v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
- argc, argv);
+ v8::Local<v8::Value> argv[argc] = {
+ exec_state, v8::Integer::New(CcTest::isolate(), 0)};
+ v8::Local<v8::Value> result =
+ frame_function_name->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
if (result->IsUndefined()) {
last_function_hit[0] = '\0';
} else {
CHECK(result->IsString());
- v8::Handle<v8::String> function_name(result.As<v8::String>());
+ v8::Local<v8::String> function_name(result.As<v8::String>());
function_name->WriteUtf8(last_function_hit);
}
}
@@ -568,34 +560,37 @@ static void DebugEventBreakPointHitCount(
if (!frame_source_line.IsEmpty()) {
// Get the source line.
const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = { exec_state };
- v8::Handle<v8::Value> result = frame_source_line->Call(exec_state,
- argc, argv);
+ v8::Local<v8::Value> argv[argc] = {exec_state};
+ v8::Local<v8::Value> result =
+ frame_source_line->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
CHECK(result->IsNumber());
- last_source_line = result->Int32Value();
+ last_source_line = result->Int32Value(context).FromJust();
}
if (!frame_source_column.IsEmpty()) {
// Get the source column.
const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = { exec_state };
- v8::Handle<v8::Value> result = frame_source_column->Call(exec_state,
- argc, argv);
+ v8::Local<v8::Value> argv[argc] = {exec_state};
+ v8::Local<v8::Value> result =
+ frame_source_column->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
CHECK(result->IsNumber());
- last_source_column = result->Int32Value();
+ last_source_column = result->Int32Value(context).FromJust();
}
if (!frame_script_name.IsEmpty()) {
// Get the script name of the function script.
const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = { exec_state };
- v8::Handle<v8::Value> result = frame_script_name->Call(exec_state,
- argc, argv);
+ v8::Local<v8::Value> argv[argc] = {exec_state};
+ v8::Local<v8::Value> result =
+ frame_script_name->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
if (result->IsUndefined()) {
last_script_name_hit[0] = '\0';
} else {
CHECK(result->IsString());
- v8::Handle<v8::String> script_name(result.As<v8::String>());
+ v8::Local<v8::String> script_name(result.As<v8::String>());
script_name->WriteUtf8(last_script_name_hit);
}
}
@@ -614,7 +609,7 @@ static void DebugEventBreakPointHitCount(
int exception_hit_count = 0;
int uncaught_exception_hit_count = 0;
int last_js_stack_height = -1;
-v8::Handle<v8::Function> debug_event_listener_callback;
+v8::Local<v8::Function> debug_event_listener_callback;
int debug_event_listener_callback_result;
static void DebugEventCounterClear() {
@@ -626,8 +621,9 @@ static void DebugEventCounterClear() {
static void DebugEventCounter(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
- v8::Handle<v8::Object> event_data = event_details.GetEventData();
+ v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Object> event_data = event_details.GetEventData();
+ v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
v8::internal::Debug* debug = CcTest::i_isolate()->debug();
// When hitting a debug event listener there must be a break set.
@@ -640,11 +636,11 @@ static void DebugEventCounter(
exception_hit_count++;
// Check whether the exception was uncaught.
- v8::Local<v8::String> fun_name =
- v8::String::NewFromUtf8(CcTest::isolate(), "uncaught");
- v8::Local<v8::Function> fun =
- v8::Local<v8::Function>::Cast(event_data->Get(fun_name));
- v8::Local<v8::Value> result = fun->Call(event_data, 0, NULL);
+ v8::Local<v8::String> fun_name = v8_str(CcTest::isolate(), "uncaught");
+ v8::Local<v8::Function> fun = v8::Local<v8::Function>::Cast(
+ event_data->Get(context, fun_name).ToLocalChecked());
+ v8::Local<v8::Value> result =
+ fun->Call(context, event_data, 0, NULL).ToLocalChecked();
if (result->IsTrue()) {
uncaught_exception_hit_count++;
}
@@ -654,18 +650,21 @@ static void DebugEventCounter(
// compiled.
if (!frame_count.IsEmpty()) {
static const int kArgc = 1;
- v8::Handle<v8::Value> argv[kArgc] = { exec_state };
+ v8::Local<v8::Value> argv[kArgc] = {exec_state};
// Using exec_state as receiver is just to have a receiver.
- v8::Handle<v8::Value> result = frame_count->Call(exec_state, kArgc, argv);
- last_js_stack_height = result->Int32Value();
+ v8::Local<v8::Value> result =
+ frame_count->Call(context, exec_state, kArgc, argv).ToLocalChecked();
+ last_js_stack_height = result->Int32Value(context).FromJust();
}
// Run callback from DebugEventListener and check the result.
if (!debug_event_listener_callback.IsEmpty()) {
- v8::Handle<v8::Value> result =
- debug_event_listener_callback->Call(event_data, 0, NULL);
+ v8::Local<v8::Value> result =
+ debug_event_listener_callback->Call(context, event_data, 0, NULL)
+ .ToLocalChecked();
CHECK(!result.IsEmpty());
- CHECK_EQ(debug_event_listener_callback_result, result->Int32Value());
+ CHECK_EQ(debug_event_listener_callback_result,
+ result->Int32Value(context).FromJust());
}
}
@@ -680,7 +679,7 @@ static void DebugEventCounter(
// Structure for holding checks to do.
struct EvaluateCheck {
const char* expr; // An expression to evaluate when a break point is hit.
- v8::Handle<v8::Value> expected; // The expected result.
+ v8::Local<v8::Value> expected; // The expected result.
};
@@ -698,7 +697,9 @@ v8::Local<v8::Function> evaluate_check_function;
static void DebugEventEvaluate(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::internal::Debug* debug = CcTest::i_isolate()->debug();
// When hitting a debug event listener there must be a break set.
CHECK_NE(debug->break_id(), 0);
@@ -707,12 +708,12 @@ static void DebugEventEvaluate(
break_point_hit_count++;
for (int i = 0; checks[i].expr != NULL; i++) {
const int argc = 3;
- v8::Handle<v8::Value> argv[argc] = {
- exec_state,
- v8::String::NewFromUtf8(CcTest::isolate(), checks[i].expr),
- checks[i].expected};
- v8::Handle<v8::Value> result =
- evaluate_check_function->Call(exec_state, argc, argv);
+ v8::Local<v8::String> string = v8_str(isolate, checks[i].expr);
+ v8::Local<v8::Value> argv[argc] = {exec_state, string,
+ checks[i].expected};
+ v8::Local<v8::Value> result =
+ evaluate_check_function->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
if (!result->IsTrue()) {
v8::String::Utf8Value utf8(checks[i].expected);
V8_Fatal(__FILE__, __LINE__, "%s != %s", checks[i].expr, *utf8);
@@ -727,7 +728,7 @@ int debug_event_remove_break_point = 0;
static void DebugEventRemoveBreakPoint(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Value> data = event_details.GetCallbackData();
+ v8::Local<v8::Value> data = event_details.GetCallbackData();
v8::internal::Debug* debug = CcTest::i_isolate()->debug();
// When hitting a debug event listener there must be a break set.
CHECK_NE(debug->break_id(), 0);
@@ -772,7 +773,7 @@ const char* expected_step_sequence = NULL;
static void DebugEventStepSequence(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
v8::internal::Debug* debug = CcTest::i_isolate()->debug();
// When hitting a debug event listener there must be a break set.
CHECK_NE(debug->break_id(), 0);
@@ -782,13 +783,15 @@ static void DebugEventStepSequence(
CHECK(break_point_hit_count <
StrLength(expected_step_sequence));
const int argc = 2;
- v8::Handle<v8::Value> argv[argc] = {
- exec_state, v8::Integer::New(CcTest::isolate(), 0)
- };
- v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
- argc, argv);
+ v8::Local<v8::Value> argv[argc] = {exec_state,
+ v8::Integer::New(CcTest::isolate(), 0)};
+ v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
+ v8::Local<v8::Value> result =
+ frame_function_name->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
CHECK(result->IsString());
- v8::String::Utf8Value function_name(result->ToString(CcTest::isolate()));
+ v8::String::Utf8Value function_name(
+ result->ToString(context).ToLocalChecked());
CHECK_EQ(1, StrLength(*function_name));
CHECK_EQ((*function_name)[0],
expected_step_sequence[break_point_hit_count]);
@@ -870,7 +873,7 @@ static void DebugEventBreakMax(
} else if (terminate_after_max_break_point_hit) {
// Terminate execution after the last break if requested.
- v8::V8::TerminateExecution(v8_isolate);
+ v8_isolate->TerminateExecution();
}
// Perform a full deoptimization when the specified number of
@@ -892,8 +895,8 @@ static void MessageCallbackCountClear() {
message_callback_count = 0;
}
-static void MessageCallbackCount(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
+static void MessageCallbackCount(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
message_callback_count++;
}
@@ -914,7 +917,7 @@ TEST(DebugInfo) {
CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length());
CHECK(!HasDebugInfo(foo));
CHECK(!HasDebugInfo(bar));
- EnableDebugger();
+ EnableDebugger(env->GetIsolate());
// One function (foo) is debugged.
int bp1 = SetBreakPoint(foo, 0);
CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length());
@@ -932,7 +935,7 @@ TEST(DebugInfo) {
CHECK(HasDebugInfo(bar));
// No functions are debugged.
ClearBreakPoint(bp2);
- DisableDebugger();
+ DisableDebugger(env->GetIsolate());
CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length());
CHECK(!HasDebugInfo(foo));
CHECK(!HasDebugInfo(bar));
@@ -945,30 +948,29 @@ TEST(BreakPointICStore) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){bar=0;}"))->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){bar=0;}", "foo");
// Run without breakpoints.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint
int bp = SetBreakPoint(foo, 0);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -977,33 +979,31 @@ TEST(BreakPointICLoad) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar=1"))
- ->Run();
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){var x=bar;}"))
- ->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+
+ CompileRunChecked(env->GetIsolate(), "bar=1");
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){var x=bar;}", "foo");
// Run without breakpoints.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint.
int bp = SetBreakPoint(foo, 0);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1012,32 +1012,30 @@ TEST(BreakPointICCall) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){bar();}"))->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ CompileRunChecked(env->GetIsolate(), "function bar(){}");
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){bar();}", "foo");
// Run without breakpoints.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint
int bp = SetBreakPoint(foo, 0);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1046,34 +1044,40 @@ TEST(BreakPointICCallWithGC) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){return 1;}"))
- ->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){return bar();}"))
- ->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointCollectGarbage);
+ CompileRunChecked(env->GetIsolate(), "function bar(){return 1;}");
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){return bar();}", "foo");
+ v8::Local<v8::Context> context = env.context();
// Run without breakpoints.
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint.
int bp = SetBreakPoint(foo, 0);
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(1, break_point_hit_count);
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1082,34 +1086,40 @@ TEST(BreakPointConstructCallWithGC) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function bar(){ this.x = 1;}"))
- ->Run();
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){return new bar(1).x;}"))->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointCollectGarbage);
+ CompileRunChecked(env->GetIsolate(), "function bar(){ this.x = 1;}");
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){return new bar(1).x;}", "foo");
+ v8::Local<v8::Context> context = env.context();
// Run without breakpoints.
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint.
int bp = SetBreakPoint(foo, 0);
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(1, break_point_hit_count);
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1129,44 +1139,44 @@ TEST(BreakPointReturn) {
"frame_source_column");
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){}"))->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){}", "foo");
+ v8::Local<v8::Context> context = env.context();
// Run without breakpoints.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint
int bp = SetBreakPoint(foo, 0);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
CHECK_EQ(0, last_source_line);
CHECK_EQ(15, last_source_column);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
CHECK_EQ(0, last_source_line);
CHECK_EQ(15, last_source_column);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
-static void CallWithBreakPoints(v8::Local<v8::Object> recv,
+static void CallWithBreakPoints(v8::Local<v8::Context> context,
+ v8::Local<v8::Object> recv,
v8::Local<v8::Function> f,
- int break_point_count,
- int call_count) {
+ int break_point_count, int call_count) {
break_point_hit_count = 0;
for (int i = 0; i < call_count; i++) {
- f->Call(recv, 0, NULL);
+ f->Call(context, recv, 0, NULL).ToLocalChecked();
CHECK_EQ((i + 1) * break_point_count, break_point_hit_count);
}
}
@@ -1177,59 +1187,61 @@ TEST(GCDuringBreakPointProcessing) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointCollectGarbage);
v8::Local<v8::Function> foo;
// Test IC store break point with garbage collection.
foo = CompileFunction(&env, "function foo(){bar=0;}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 10);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 10);
// Test IC load break point with garbage collection.
foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 10);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 10);
// Test IC call break point with garbage collection.
foo = CompileFunction(&env, "function bar(){};function foo(){bar();}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 10);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 10);
// Test return break point with garbage collection.
foo = CompileFunction(&env, "function foo(){}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 25);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 25);
// Test debug break slot break point with garbage collection.
foo = CompileFunction(&env, "function foo(){var a;}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 25);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 25);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
// Call the function three times with different garbage collections in between
// and make sure that the break point survives.
-static void CallAndGC(v8::Local<v8::Object> recv,
- v8::Local<v8::Function> f) {
+static void CallAndGC(v8::Local<v8::Context> context,
+ v8::Local<v8::Object> recv, v8::Local<v8::Function> f) {
break_point_hit_count = 0;
for (int i = 0; i < 3; i++) {
// Call function.
- f->Call(recv, 0, NULL);
+ f->Call(context, recv, 0, NULL).ToLocalChecked();
CHECK_EQ(1 + i * 3, break_point_hit_count);
// Scavenge and call function.
CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
- f->Call(recv, 0, NULL);
+ f->Call(context, recv, 0, NULL).ToLocalChecked();
CHECK_EQ(2 + i * 3, break_point_hit_count);
// Mark sweep (and perhaps compact) and call function.
CcTest::heap()->CollectAllGarbage();
- f->Call(recv, 0, NULL);
+ f->Call(context, recv, 0, NULL).ToLocalChecked();
CHECK_EQ(3 + i * 3, break_point_hit_count);
}
}
@@ -1240,8 +1252,10 @@ TEST(BreakPointSurviveGC) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
v8::Local<v8::Function> foo;
// Test IC store break point with garbage collection.
@@ -1250,7 +1264,7 @@ TEST(BreakPointSurviveGC) {
foo = CompileFunction(&env, "function foo(){bar=0;}", "foo");
SetBreakPoint(foo, 0);
}
- CallAndGC(env->Global(), foo);
+ CallAndGC(context, env->Global(), foo);
// Test IC load break point with garbage collection.
{
@@ -1258,7 +1272,7 @@ TEST(BreakPointSurviveGC) {
foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo");
SetBreakPoint(foo, 0);
}
- CallAndGC(env->Global(), foo);
+ CallAndGC(context, env->Global(), foo);
// Test IC call break point with garbage collection.
{
@@ -1268,7 +1282,7 @@ TEST(BreakPointSurviveGC) {
"foo");
SetBreakPoint(foo, 0);
}
- CallAndGC(env->Global(), foo);
+ CallAndGC(context, env->Global(), foo);
// Test return break point with garbage collection.
{
@@ -1276,7 +1290,7 @@ TEST(BreakPointSurviveGC) {
foo = CompileFunction(&env, "function foo(){}", "foo");
SetBreakPoint(foo, 0);
}
- CallAndGC(env->Global(), foo);
+ CallAndGC(context, env->Global(), foo);
// Test non IC break point with garbage collection.
{
@@ -1284,11 +1298,11 @@ TEST(BreakPointSurviveGC) {
foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo");
SetBreakPoint(foo, 0);
}
- CallAndGC(env->Global(), foo);
+ CallAndGC(context, env->Global(), foo);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1296,53 +1310,51 @@ TEST(BreakPointSurviveGC) {
TEST(BreakPointThroughJavaScript) {
break_point_hit_count = 0;
DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){bar();bar();}"))
- ->Run();
- // 012345678901234567890
- // 1 2
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
+ CompileRunChecked(isolate, "function bar(){}");
+ CompileFunction(isolate, "function foo(){bar();bar();}", "foo");
+ // 012345678901234567890
+ // 1 2
// Break points are set at position 3 and 9
+ v8::Local<v8::String> source = v8_str(env->GetIsolate(), "foo()");
v8::Local<v8::Script> foo =
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "foo()"));
+ v8::Script::Compile(context, source).ToLocalChecked();
- // Run without breakpoints.
- foo->Run();
CHECK_EQ(0, break_point_hit_count);
// Run with one breakpoint
int bp1 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 3);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Run with two breakpoints
int bp2 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 9);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Run with one breakpoint
ClearBreakPointFromJS(env->GetIsolate(), bp2);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(7, break_point_hit_count);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(8, break_point_hit_count);
// Run without breakpoints.
ClearBreakPointFromJS(env->GetIsolate(), bp1);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(8, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
// Make sure that the break point numbers are consecutive.
CHECK_EQ(1, bp1);
@@ -1355,96 +1367,99 @@ TEST(BreakPointThroughJavaScript) {
TEST(ScriptBreakPointByNameThroughJavaScript) {
break_point_hit_count = 0;
DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
-
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " function h() {\n"
- " a = 0; // line 2\n"
- " }\n"
- " b = 1; // line 4\n"
- " return h();\n"
- "}\n"
- "\n"
- "function g() {\n"
- " function h() {\n"
- " a = 0;\n"
- " }\n"
- " b = 2; // line 12\n"
- " h();\n"
- " b = 3; // line 14\n"
- " f(); // line 15\n"
- "}");
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
+
+ v8::Local<v8::String> script = v8_str(isolate,
+ "function f() {\n"
+ " function h() {\n"
+ " a = 0; // line 2\n"
+ " }\n"
+ " b = 1; // line 4\n"
+ " return h();\n"
+ "}\n"
+ "\n"
+ "function g() {\n"
+ " function h() {\n"
+ " a = 0;\n"
+ " }\n"
+ " b = 2; // line 12\n"
+ " h();\n"
+ " b = 3; // line 14\n"
+ " f(); // line 15\n"
+ "}");
// Compile the script and get the two functions.
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Script::Compile(script, &origin)->Run();
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(isolate, "test"));
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()->Get(context, v8_str(isolate, "f")).ToLocalChecked());
v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
+ env->Global()->Get(context, v8_str(isolate, "g")).ToLocalChecked());
// Call f and g without break points.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Call f and g with break point on line 12.
- int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 12, 0);
+ int sbp1 = SetScriptBreakPointByNameFromJS(isolate, "test", 12, 0);
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
// Remove the break point again.
break_point_hit_count = 0;
ClearBreakPointFromJS(env->GetIsolate(), sbp1);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Call f and g with break point on line 2.
int sbp2 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 2, 0);
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Call f and g with break point on line 2, 4, 12, 14 and 15.
- int sbp3 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 4, 0);
- int sbp4 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 12, 0);
- int sbp5 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 14, 0);
- int sbp6 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 15, 0);
+ int sbp3 = SetScriptBreakPointByNameFromJS(isolate, "test", 4, 0);
+ int sbp4 = SetScriptBreakPointByNameFromJS(isolate, "test", 12, 0);
+ int sbp5 = SetScriptBreakPointByNameFromJS(isolate, "test", 14, 0);
+ int sbp6 = SetScriptBreakPointByNameFromJS(isolate, "test", 15, 0);
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(7, break_point_hit_count);
// Remove all the break points again.
break_point_hit_count = 0;
- ClearBreakPointFromJS(env->GetIsolate(), sbp2);
- ClearBreakPointFromJS(env->GetIsolate(), sbp3);
- ClearBreakPointFromJS(env->GetIsolate(), sbp4);
- ClearBreakPointFromJS(env->GetIsolate(), sbp5);
- ClearBreakPointFromJS(env->GetIsolate(), sbp6);
- f->Call(env->Global(), 0, NULL);
+ ClearBreakPointFromJS(isolate, sbp2);
+ ClearBreakPointFromJS(isolate, sbp3);
+ ClearBreakPointFromJS(isolate, sbp4);
+ ClearBreakPointFromJS(isolate, sbp5);
+ ClearBreakPointFromJS(isolate, sbp6);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
// Make sure that the break point numbers are consecutive.
CHECK_EQ(1, sbp1);
@@ -1459,73 +1474,74 @@ TEST(ScriptBreakPointByNameThroughJavaScript) {
TEST(ScriptBreakPointByIdThroughJavaScript) {
break_point_hit_count = 0;
DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
-
- v8::Local<v8::String> source = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " function h() {\n"
- " a = 0; // line 2\n"
- " }\n"
- " b = 1; // line 4\n"
- " return h();\n"
- "}\n"
- "\n"
- "function g() {\n"
- " function h() {\n"
- " a = 0;\n"
- " }\n"
- " b = 2; // line 12\n"
- " h();\n"
- " b = 3; // line 14\n"
- " f(); // line 15\n"
- "}");
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
+
+ v8::Local<v8::String> source = v8_str(isolate,
+ "function f() {\n"
+ " function h() {\n"
+ " a = 0; // line 2\n"
+ " }\n"
+ " b = 1; // line 4\n"
+ " return h();\n"
+ "}\n"
+ "\n"
+ "function g() {\n"
+ " function h() {\n"
+ " a = 0;\n"
+ " }\n"
+ " b = 2; // line 12\n"
+ " h();\n"
+ " b = 3; // line 14\n"
+ " f(); // line 15\n"
+ "}");
// Compile the script and get the two functions.
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Local<v8::Script> script = v8::Script::Compile(source, &origin);
- script->Run();
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(isolate, "test"));
+ v8::Local<v8::Script> script =
+ v8::Script::Compile(context, source, &origin).ToLocalChecked();
+ script->Run(context).ToLocalChecked();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()->Get(context, v8_str(isolate, "f")).ToLocalChecked());
v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
+ env->Global()->Get(context, v8_str(isolate, "g")).ToLocalChecked());
// Get the script id knowing that internally it is a 32 integer.
int script_id = script->GetUnboundScript()->GetId();
// Call f and g without break points.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Call f and g with break point on line 12.
int sbp1 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 12, 0);
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
// Remove the break point again.
break_point_hit_count = 0;
ClearBreakPointFromJS(env->GetIsolate(), sbp1);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Call f and g with break point on line 2.
int sbp2 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 2, 0);
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Call f and g with break point on line 2, 4, 12, 14 and 15.
@@ -1534,9 +1550,9 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
int sbp5 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 14, 0);
int sbp6 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 15, 0);
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(7, break_point_hit_count);
// Remove all the break points again.
@@ -1546,13 +1562,13 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
ClearBreakPointFromJS(env->GetIsolate(), sbp4);
ClearBreakPointFromJS(env->GetIsolate(), sbp5);
ClearBreakPointFromJS(env->GetIsolate(), sbp6);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
// Make sure that the break point numbers are consecutive.
CHECK_EQ(1, sbp1);
@@ -1568,57 +1584,63 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
TEST(EnableDisableScriptBreakPoint) {
break_point_hit_count = 0;
DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " a = 0; // line 1\n"
- "};");
+ v8::Local<v8::String> script = v8_str(isolate,
+ "function f() {\n"
+ " a = 0; // line 1\n"
+ "};");
// Compile the script and get function f.
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Script::Compile(script, &origin)->Run();
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(isolate, "test"));
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()->Get(context, v8_str(isolate, "f")).ToLocalChecked());
// Set script break point on line 1 (in function f).
- int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
+ int sbp = SetScriptBreakPointByNameFromJS(isolate, "test", 1, 0);
// Call f while enabeling and disabling the script break point.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- DisableScriptBreakPointFromJS(env->GetIsolate(), sbp);
- f->Call(env->Global(), 0, NULL);
+ DisableScriptBreakPointFromJS(isolate, sbp);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- EnableScriptBreakPointFromJS(env->GetIsolate(), sbp);
- f->Call(env->Global(), 0, NULL);
+ EnableScriptBreakPointFromJS(isolate, sbp);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- DisableScriptBreakPointFromJS(env->GetIsolate(), sbp);
- f->Call(env->Global(), 0, NULL);
+ DisableScriptBreakPointFromJS(isolate, sbp);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- // Reload the script and get f again checking that the disabeling survives.
- v8::Script::Compile(script, &origin)->Run();
+ // Reload the script and get f again checking that the disabling survives.
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- f->Call(env->Global(), 0, NULL);
+ env->Global()->Get(context, v8_str(isolate, "f")).ToLocalChecked());
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- EnableScriptBreakPointFromJS(env->GetIsolate(), sbp);
- f->Call(env->Global(), 0, NULL);
+ EnableScriptBreakPointFromJS(isolate, sbp);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(3, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -1629,24 +1651,29 @@ TEST(ConditionalScriptBreakPoint) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "count = 0;\n"
- "function f() {\n"
- " g(count++); // line 2\n"
- "};\n"
- "function g(x) {\n"
- " var a=x; // line 5\n"
- "};");
+ v8::Local<v8::String> script = v8_str(env->GetIsolate(),
+ "count = 0;\n"
+ "function f() {\n"
+ " g(count++); // line 2\n"
+ "};\n"
+ "function g(x) {\n"
+ " var a=x; // line 5\n"
+ "};");
// Compile the script and get function f.
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Script::Compile(script, &origin)->Run();
+ v8::Local<v8::Context> context = env.context();
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(env->GetIsolate(), "test"));
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Set script break point on line 5 (in function g).
int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 5, 0);
@@ -1654,34 +1681,39 @@ TEST(ConditionalScriptBreakPoint) {
// Call f with different conditions on the script break point.
break_point_hit_count = 0;
ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "false");
- f->Call(env->Global(), 0, NULL);
+ f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "true");
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "x % 2 == 0");
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
- f->Call(env->Global(), 0, NULL);
+ f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
// Reload the script and get f again checking that the condition survives.
- v8::Script::Compile(script, &origin)->Run();
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
- f->Call(env->Global(), 0, NULL);
+ f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1692,20 +1724,25 @@ TEST(ScriptBreakPointIgnoreCount) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " a = 0; // line 1\n"
- "};");
+ v8::Local<v8::String> script = v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " a = 0; // line 1\n"
+ "};");
// Compile the script and get function f.
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Script::Compile(script, &origin)->Run();
+ v8::Local<v8::Context> context = env.context();
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(env->GetIsolate(), "test"));
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Set script break point on line 1 (in function f).
int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
@@ -1713,31 +1750,36 @@ TEST(ScriptBreakPointIgnoreCount) {
// Call f with different ignores on the script break point.
break_point_hit_count = 0;
ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 1);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 5);
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
// Reload the script and get f again checking that the ignore survives.
- v8::Script::Compile(script, &origin)->Run();
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1748,60 +1790,74 @@ TEST(ScriptBreakPointReload) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> f;
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " function h() {\n"
- " a = 0; // line 2\n"
- " }\n"
- " b = 1; // line 4\n"
- " return h();\n"
- "}");
-
- v8::ScriptOrigin origin_1 =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "1"));
- v8::ScriptOrigin origin_2 =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "2"));
+ v8::Local<v8::String> script = v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " function h() {\n"
+ " a = 0; // line 2\n"
+ " }\n"
+ " b = 1; // line 4\n"
+ " return h();\n"
+ "}");
+
+ v8::ScriptOrigin origin_1 = v8::ScriptOrigin(v8_str(env->GetIsolate(), "1"));
+ v8::ScriptOrigin origin_2 = v8::ScriptOrigin(v8_str(env->GetIsolate(), "2"));
// Set a script break point before the script is loaded.
SetScriptBreakPointByNameFromJS(env->GetIsolate(), "1", 2, 0);
// Compile the script and get the function.
- v8::Script::Compile(script, &origin_1)->Run();
+ v8::Script::Compile(context, script, &origin_1)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Call f and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
// Compile the script again with a different script data and get the
// function.
- v8::Script::Compile(script, &origin_2)->Run();
+ v8::Script::Compile(context, script, &origin_2)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Call f and check that no break points are set.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Compile the script again and get the function.
- v8::Script::Compile(script, &origin_1)->Run();
+ v8::Script::Compile(context, script, &origin_1)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Call f and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1812,41 +1868,50 @@ TEST(ScriptBreakPointMultiple) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> f;
- v8::Local<v8::String> script_f =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function f() {\n"
- " a = 0; // line 1\n"
- "}");
+ v8::Local<v8::String> script_f = v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " a = 0; // line 1\n"
+ "}");
v8::Local<v8::Function> g;
- v8::Local<v8::String> script_g =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function g() {\n"
- " b = 0; // line 1\n"
- "}");
+ v8::Local<v8::String> script_g = v8_str(env->GetIsolate(),
+ "function g() {\n"
+ " b = 0; // line 1\n"
+ "}");
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(env->GetIsolate(), "test"));
// Set a script break point before the scripts are loaded.
int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
// Compile the scripts with same script data and get the functions.
- v8::Script::Compile(script_f, &origin)->Run();
+ v8::Script::Compile(context, script_f, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- v8::Script::Compile(script_g, &origin)->Run();
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
+ v8::Script::Compile(context, script_g, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
g = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "g"))
+ .ToLocalChecked());
// Call f and g and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Clear the script break point.
@@ -1854,9 +1919,9 @@ TEST(ScriptBreakPointMultiple) {
// Call f and g and check that the script break point is no longer active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Set script break point with the scripts loaded.
@@ -1864,13 +1929,13 @@ TEST(ScriptBreakPointMultiple) {
// Call f and g and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1881,20 +1946,21 @@ TEST(ScriptBreakPointLineOffset) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> f;
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " a = 0; // line 8 as this script has line offset 7\n"
- " b = 0; // line 9 as this script has line offset 7\n"
- "}");
+ v8::Local<v8::String> script =
+ v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " a = 0; // line 8 as this script has line offset 7\n"
+ " b = 0; // line 9 as this script has line offset 7\n"
+ "}");
// Create script origin both name and line offset.
- v8::ScriptOrigin origin(
- v8::String::NewFromUtf8(env->GetIsolate(), "test.html"),
- v8::Integer::New(env->GetIsolate(), 7));
+ v8::ScriptOrigin origin(v8_str(env->GetIsolate(), "test.html"),
+ v8::Integer::New(env->GetIsolate(), 7));
// Set two script break points before the script is loaded.
int sbp1 =
@@ -1903,13 +1969,18 @@ TEST(ScriptBreakPointLineOffset) {
SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0);
// Compile the script and get the function.
- v8::Script::Compile(script, &origin)->Run();
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Call f and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Clear the script break points.
@@ -1918,7 +1989,7 @@ TEST(ScriptBreakPointLineOffset) {
// Call f and check that no script break points are active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Set a script break point with the script loaded.
@@ -1926,11 +1997,11 @@ TEST(ScriptBreakPointLineOffset) {
// Call f and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1945,25 +2016,27 @@ TEST(ScriptBreakPointLine) {
frame_function_name_source,
"frame_function_name");
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> f;
v8::Local<v8::Function> g;
v8::Local<v8::String> script =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "a = 0 // line 0\n"
- "function f() {\n"
- " a = 1; // line 2\n"
- "}\n"
- " a = 2; // line 4\n"
- " /* xx */ function g() { // line 5\n"
- " function h() { // line 6\n"
- " a = 3; // line 7\n"
- " }\n"
- " h(); // line 9\n"
- " a = 4; // line 10\n"
- " }\n"
- " a=5; // line 12");
+ v8_str(env->GetIsolate(),
+ "a = 0 // line 0\n"
+ "function f() {\n"
+ " a = 1; // line 2\n"
+ "}\n"
+ " a = 2; // line 4\n"
+ " /* xx */ function g() { // line 5\n"
+ " function h() { // line 6\n"
+ " a = 3; // line 7\n"
+ " }\n"
+ " h(); // line 9\n"
+ " a = 4; // line 10\n"
+ " }\n"
+ " a=5; // line 12");
// Set a couple script break point before the script is loaded.
int sbp1 =
@@ -1975,26 +2048,32 @@ TEST(ScriptBreakPointLine) {
// Compile the script and get the function.
break_point_hit_count = 0;
- v8::ScriptOrigin origin(
- v8::String::NewFromUtf8(env->GetIsolate(), "test.html"),
- v8::Integer::New(env->GetIsolate(), 0));
- v8::Script::Compile(script, &origin)->Run();
+ v8::ScriptOrigin origin(v8_str(env->GetIsolate(), "test.html"),
+ v8::Integer::New(env->GetIsolate(), 0));
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
g = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "g"))
+ .ToLocalChecked());
// Check that a break point was hit when the script was run.
CHECK_EQ(1, break_point_hit_count);
CHECK_EQ(0, StrLength(last_function_hit));
// Call f and check that the script break point.
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
CHECK_EQ(0, strcmp("f", last_function_hit));
// Call g and check that the script break point.
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(3, break_point_hit_count);
CHECK_EQ(0, strcmp("g", last_function_hit));
@@ -2004,7 +2083,7 @@ TEST(ScriptBreakPointLine) {
SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 6, -1);
// Call g and check that the script break point in h is hit.
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
CHECK_EQ(0, strcmp("h", last_function_hit));
@@ -2016,13 +2095,16 @@ TEST(ScriptBreakPointLine) {
int sbp5 =
SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 4, -1);
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
- g->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Reload the script which should hit two break points.
break_point_hit_count = 0;
- v8::Script::Compile(script, &origin)->Run();
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
CHECK_EQ(0, StrLength(last_function_hit));
@@ -2032,7 +2114,10 @@ TEST(ScriptBreakPointLine) {
// Reload the script which should hit three break points.
break_point_hit_count = 0;
- v8::Script::Compile(script, &origin)->Run();
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
CHECK_EQ(3, break_point_hit_count);
CHECK_EQ(0, StrLength(last_function_hit));
@@ -2042,11 +2127,14 @@ TEST(ScriptBreakPointLine) {
ClearBreakPointFromJS(env->GetIsolate(), sbp5);
ClearBreakPointFromJS(env->GetIsolate(), sbp6);
break_point_hit_count = 0;
- v8::Script::Compile(script, &origin)->Run();
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2056,21 +2144,25 @@ TEST(ScriptBreakPointLineTopLevel) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::String> script =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function f() {\n"
- " a = 1; // line 1\n"
- "}\n"
- "a = 2; // line 3\n");
+ v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " a = 1; // line 1\n"
+ "}\n"
+ "a = 2; // line 3\n");
v8::Local<v8::Function> f;
{
v8::HandleScope scope(env->GetIsolate());
CompileRunWithOrigin(script, "test.html");
}
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
CcTest::heap()->CollectAllGarbage();
@@ -2078,7 +2170,7 @@ TEST(ScriptBreakPointLineTopLevel) {
// Call f and check that there was no break points.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Recompile and run script and check that break point was hit.
@@ -2089,11 +2181,13 @@ TEST(ScriptBreakPointLineTopLevel) {
// Call f and check that there are still no break points.
break_point_hit_count = 0;
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2104,14 +2198,14 @@ TEST(ScriptBreakPointTopLevelCrash) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
- v8::Local<v8::String> script_source =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function f() {\n"
- " return 0;\n"
- "}\n"
- "f()");
+ v8::Local<v8::String> script_source = v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " return 0;\n"
+ "}\n"
+ "f()");
int sbp1 =
SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
@@ -2127,8 +2221,8 @@ TEST(ScriptBreakPointTopLevelCrash) {
ClearBreakPointFromJS(env->GetIsolate(), sbp1);
ClearBreakPointFromJS(env->GetIsolate(), sbp2);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2138,24 +2232,26 @@ TEST(RemoveBreakPointInBreak) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> foo =
CompileFunction(&env, "function foo(){a=1;}", "foo");
// Register the debug event listener pasing the function
- v8::Debug::SetDebugEventListener(DebugEventRemoveBreakPoint, foo);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventRemoveBreakPoint, foo);
debug_event_remove_break_point = SetBreakPoint(foo, 0);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2164,28 +2260,38 @@ TEST(DebuggerStatement) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){debugger}"))
- ->Run();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
+ v8::Script::Compile(context,
+ v8_str(env->GetIsolate(), "function bar(){debugger}"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){debugger;debugger;}"))->Run();
+ context, v8_str(env->GetIsolate(), "function foo(){debugger;debugger;}"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "foo"))
+ .ToLocalChecked());
v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "bar"))
+ .ToLocalChecked());
// Run function with debugger statement
- bar->Call(env->Global(), 0, NULL);
+ bar->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
// Run function with two debugger statement
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(3, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2194,26 +2300,32 @@ TEST(DebuggerStatementBreakpoint) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){debugger;}"))
- ->Run();
+ v8::Local<v8::Context> context = env.context();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Script::Compile(context,
+ v8_str(env->GetIsolate(), "function foo(){debugger;}"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "foo"))
+ .ToLocalChecked());
// The debugger statement triggers breakpoint hit
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
int bp = SetBreakPoint(foo, 0);
// Set breakpoint does not duplicate hits
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
ClearBreakPoint(bp);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2230,25 +2342,21 @@ TEST(DebugEvaluate) {
evaluate_check_source,
"evaluate_check");
// Register the debug event listener
- v8::Debug::SetDebugEventListener(DebugEventEvaluate);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventEvaluate);
// Different expected vaules of x and a when in a break point (u = undefined,
// d = Hello, world!).
- struct EvaluateCheck checks_uu[] = {
- {"x", v8::Undefined(isolate)},
- {"a", v8::Undefined(isolate)},
- {NULL, v8::Handle<v8::Value>()}
- };
+ struct EvaluateCheck checks_uu[] = {{"x", v8::Undefined(isolate)},
+ {"a", v8::Undefined(isolate)},
+ {NULL, v8::Local<v8::Value>()}};
struct EvaluateCheck checks_hu[] = {
- {"x", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")},
- {"a", v8::Undefined(isolate)},
- {NULL, v8::Handle<v8::Value>()}
- };
+ {"x", v8_str(env->GetIsolate(), "Hello, world!")},
+ {"a", v8::Undefined(isolate)},
+ {NULL, v8::Local<v8::Value>()}};
struct EvaluateCheck checks_hh[] = {
- {"x", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")},
- {"a", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")},
- {NULL, v8::Handle<v8::Value>()}
- };
+ {"x", v8_str(env->GetIsolate(), "Hello, world!")},
+ {"a", v8_str(env->GetIsolate(), "Hello, world!")},
+ {NULL, v8::Local<v8::Value>()}};
// Simple test function. The "y=0" is in the function foo to provide a break
// location. For "y=0" the "y" is at position 15 in the foo function
@@ -2265,24 +2373,25 @@ TEST(DebugEvaluate) {
const int foo_break_position_1 = 15;
const int foo_break_position_2 = 29;
+ v8::Local<v8::Context> context = env.context();
// Arguments with one parameter "Hello, world!"
- v8::Handle<v8::Value> argv_foo[1] = {
- v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")};
+ v8::Local<v8::Value> argv_foo[1] = {
+ v8_str(env->GetIsolate(), "Hello, world!")};
// Call foo with breakpoint set before a=x and undefined as parameter.
int bp = SetBreakPoint(foo, foo_break_position_1);
checks = checks_uu;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Call foo with breakpoint set before a=x and parameter "Hello, world!".
checks = checks_hu;
- foo->Call(env->Global(), 1, argv_foo);
+ foo->Call(context, env->Global(), 1, argv_foo).ToLocalChecked();
// Call foo with breakpoint set after a=x and parameter "Hello, world!".
ClearBreakPoint(bp);
SetBreakPoint(foo, foo_break_position_2);
checks = checks_hh;
- foo->Call(env->Global(), 1, argv_foo);
+ foo->Call(context, env->Global(), 1, argv_foo).ToLocalChecked();
// Test that overriding Object.prototype will not interfere into evaluation
// on call frame.
@@ -2301,14 +2410,14 @@ TEST(DebugEvaluate) {
const int zoo_break_position = 50;
// Arguments with one parameter "Hello, world!"
- v8::Handle<v8::Value> argv_zoo[1] = {
- v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")};
+ v8::Local<v8::Value> argv_zoo[1] = {
+ v8_str(env->GetIsolate(), "Hello, world!")};
// Call zoo with breakpoint set at y=0.
DebugEventCounterClear();
bp = SetBreakPoint(zoo, zoo_break_position);
checks = checks_hu;
- zoo->Call(env->Global(), 1, argv_zoo);
+ zoo->Call(context, env->Global(), 1, argv_zoo).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
ClearBreakPoint(bp);
@@ -2335,32 +2444,28 @@ TEST(DebugEvaluate) {
// Call bar setting breakpoint before a=x in barbar and undefined as
// parameter.
checks = checks_uu;
- v8::Handle<v8::Value> argv_bar_1[2] = {
- v8::Undefined(isolate),
- v8::Number::New(isolate, barbar_break_position)
- };
- bar->Call(env->Global(), 2, argv_bar_1);
+ v8::Local<v8::Value> argv_bar_1[2] = {
+ v8::Undefined(isolate), v8::Number::New(isolate, barbar_break_position)};
+ bar->Call(context, env->Global(), 2, argv_bar_1).ToLocalChecked();
// Call bar setting breakpoint before a=x in barbar and parameter
// "Hello, world!".
checks = checks_hu;
- v8::Handle<v8::Value> argv_bar_2[2] = {
- v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
- v8::Number::New(env->GetIsolate(), barbar_break_position)
- };
- bar->Call(env->Global(), 2, argv_bar_2);
+ v8::Local<v8::Value> argv_bar_2[2] = {
+ v8_str(env->GetIsolate(), "Hello, world!"),
+ v8::Number::New(env->GetIsolate(), barbar_break_position)};
+ bar->Call(context, env->Global(), 2, argv_bar_2).ToLocalChecked();
// Call bar setting breakpoint after a=x in barbar and parameter
// "Hello, world!".
checks = checks_hh;
- v8::Handle<v8::Value> argv_bar_3[2] = {
- v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
- v8::Number::New(env->GetIsolate(), barbar_break_position + 1)
- };
- bar->Call(env->Global(), 2, argv_bar_3);
+ v8::Local<v8::Value> argv_bar_3[2] = {
+ v8_str(env->GetIsolate(), "Hello, world!"),
+ v8::Number::New(env->GetIsolate(), barbar_break_position + 1)};
+ bar->Call(context, env->Global(), 2, argv_bar_3).ToLocalChecked();
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -2377,8 +2482,9 @@ TEST(ConditionalBreakpointWithCodeGenerationDisallowed) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(CheckDebugEvent);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), CheckDebugEvent);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> foo = CompileFunction(&env,
"function foo(x) {\n"
" var s = 'String value2';\n"
@@ -2391,27 +2497,34 @@ TEST(ConditionalBreakpointWithCodeGenerationDisallowed) {
debugEventCount = 0;
env->AllowCodeGenerationFromStrings(false);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, debugEventCount);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
bool checkedDebugEvals = true;
-v8::Handle<v8::Function> checkGlobalEvalFunction;
-v8::Handle<v8::Function> checkFrameEvalFunction;
+v8::Local<v8::Function> checkGlobalEvalFunction;
+v8::Local<v8::Function> checkFrameEvalFunction;
static void CheckDebugEval(const v8::Debug::EventDetails& eventDetails) {
if (eventDetails.GetEvent() == v8::Break) {
++debugEventCount;
v8::HandleScope handleScope(CcTest::isolate());
- v8::Handle<v8::Value> args[] = { eventDetails.GetExecutionState() };
- CHECK(checkGlobalEvalFunction->Call(
- eventDetails.GetEventContext()->Global(), 1, args)->IsTrue());
- CHECK(checkFrameEvalFunction->Call(
- eventDetails.GetEventContext()->Global(), 1, args)->IsTrue());
+ v8::Local<v8::Value> args[] = {eventDetails.GetExecutionState()};
+ CHECK(
+ checkGlobalEvalFunction->Call(eventDetails.GetEventContext(),
+ eventDetails.GetEventContext()->Global(),
+ 1, args)
+ .ToLocalChecked()
+ ->IsTrue());
+ CHECK(checkFrameEvalFunction->Call(eventDetails.GetEventContext(),
+ eventDetails.GetEventContext()->Global(),
+ 1, args)
+ .ToLocalChecked()
+ ->IsTrue());
}
}
@@ -2424,8 +2537,9 @@ TEST(DebugEvaluateWithCodeGenerationDisallowed) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(CheckDebugEval);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), CheckDebugEval);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> foo = CompileFunction(&env,
"var global = 'Global';\n"
"function foo(x) {\n"
@@ -2447,13 +2561,13 @@ TEST(DebugEvaluateWithCodeGenerationDisallowed) {
"checkFrameEval");
debugEventCount = 0;
env->AllowCodeGenerationFromStrings(false);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, debugEventCount);
checkGlobalEvalFunction.Clear();
checkFrameEvalFunction.Clear();
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2541,7 +2655,7 @@ DebugProcessDebugMessagesData process_debug_messages_data;
static void DebugProcessDebugMessagesHandler(
const v8::Debug::Message& message) {
- v8::Handle<v8::String> json = message.GetJSON();
+ v8::Local<v8::String> json = message.GetJSON();
v8::String::Utf8Value utf8(json);
EvaluateResult* array_item = process_debug_messages_data.current();
@@ -2557,18 +2671,21 @@ static void DebugProcessDebugMessagesHandler(
// Test that the evaluation of expressions works even from ProcessDebugMessages
// i.e. with empty stack.
TEST(DebugEvaluateWithoutStack) {
- v8::Debug::SetMessageHandler(DebugProcessDebugMessagesHandler);
-
DebugLocalContext env;
+ v8::Debug::SetMessageHandler(env->GetIsolate(),
+ DebugProcessDebugMessagesHandler);
v8::HandleScope scope(env->GetIsolate());
const char* source =
"var v1 = 'Pinguin';\n function getAnimal() { return 'Capy' + 'bara'; }";
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source))
- ->Run();
+ v8::Local<v8::Context> context = env.context();
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), source))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(env->GetIsolate());
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -2604,7 +2721,7 @@ TEST(DebugEvaluateWithoutStack) {
v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_113, buffer));
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
CHECK_EQ(3, process_debug_messages_data.counter);
@@ -2613,9 +2730,9 @@ TEST(DebugEvaluateWithoutStack) {
0);
CHECK_EQ(strcmp("805", process_debug_messages_data.results[2].buffer), 0);
- v8::Debug::SetMessageHandler(NULL);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2633,32 +2750,34 @@ TEST(DebugStepLinear) {
CompileRun("a=0; b=0; c=0; foo();");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
SetBreakPoint(foo, 3);
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ v8::Local<v8::Context> context = env.context();
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(4, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
SetBreakPoint(foo, 3);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only active break points are hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2668,7 +2787,7 @@ TEST(DebugStepKeyedLoadLoop) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
// Create a function for testing stepping of keyed load. The statement 'y=1'
// is there to have more than one breakable statement in the loop, TODO(315).
@@ -2685,29 +2804,31 @@ TEST(DebugStepKeyedLoadLoop) {
"y=0\n",
"foo");
+ v8::Local<v8::Context> context = env.context();
// Create array [0,1,2,3,4,5,6,7,8,9]
v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
for (int i = 0; i < 10; i++) {
- a->Set(v8::Number::New(env->GetIsolate(), i),
- v8::Number::New(env->GetIsolate(), i));
+ CHECK(a->Set(context, v8::Number::New(env->GetIsolate(), i),
+ v8::Number::New(env->GetIsolate(), i))
+ .FromJust());
}
// Call function without any break points to ensure inlining is in place.
const int kArgc = 1;
- v8::Handle<v8::Value> args[kArgc] = { a };
- foo->Call(env->Global(), kArgc, args);
+ v8::Local<v8::Value> args[kArgc] = {a};
+ foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
// Set up break point and step through the function.
SetBreakPoint(foo, 3);
step_action = StepNext;
break_point_hit_count = 0;
- foo->Call(env->Global(), kArgc, args);
+ foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(45, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2717,7 +2838,7 @@ TEST(DebugStepKeyedStoreLoop) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
// Create a function for testing stepping of keyed store. The statement 'y=1'
// is there to have more than one breakable statement in the loop, TODO(315).
@@ -2733,29 +2854,31 @@ TEST(DebugStepKeyedStoreLoop) {
"y=0\n",
"foo");
+ v8::Local<v8::Context> context = env.context();
// Create array [0,1,2,3,4,5,6,7,8,9]
v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
for (int i = 0; i < 10; i++) {
- a->Set(v8::Number::New(env->GetIsolate(), i),
- v8::Number::New(env->GetIsolate(), i));
+ CHECK(a->Set(context, v8::Number::New(env->GetIsolate(), i),
+ v8::Number::New(env->GetIsolate(), i))
+ .FromJust());
}
// Call function without any break points to ensure inlining is in place.
const int kArgc = 1;
- v8::Handle<v8::Value> args[kArgc] = { a };
- foo->Call(env->Global(), kArgc, args);
+ v8::Local<v8::Value> args[kArgc] = {a};
+ foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
// Set up break point and step through the function.
SetBreakPoint(foo, 3);
step_action = StepNext;
break_point_hit_count = 0;
- foo->Call(env->Global(), kArgc, args);
+ foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(44, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2765,8 +2888,9 @@ TEST(DebugStepNamedLoadLoop) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping of named load.
v8::Local<v8::Function> foo = CompileFunction(
&env,
@@ -2787,19 +2911,19 @@ TEST(DebugStepNamedLoadLoop) {
"foo");
// Call function without any break points to ensure inlining is in place.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Set up break point and step through the function.
SetBreakPoint(foo, 4);
step_action = StepNext;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(65, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2808,9 +2932,10 @@ static void DoDebugStepNamedStoreLoop(int expected) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
// Create a function for testing stepping of named store.
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> foo = CompileFunction(
&env,
"function foo() {\n"
@@ -2822,19 +2947,19 @@ static void DoDebugStepNamedStoreLoop(int expected) {
"foo");
// Call function without any break points to ensure inlining is in place.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Set up break point and step through the function.
SetBreakPoint(foo, 3);
step_action = StepNext;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all expected break locations are hit.
CHECK_EQ(expected, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2848,8 +2973,9 @@ TEST(DebugStepLinearMixedICs) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping.
v8::Local<v8::Function> foo = CompileFunction(&env,
"function bar() {};"
@@ -2866,26 +2992,27 @@ TEST(DebugStepLinearMixedICs) {
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(11, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
SetBreakPoint(foo, 0);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only active break points are hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2894,8 +3021,9 @@ TEST(DebugStepDeclarations) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function foo() { "
@@ -2913,12 +3041,12 @@ TEST(DebugStepDeclarations) {
// Stepping through the declarations.
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2927,8 +3055,9 @@ TEST(DebugStepLocals) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function foo() { "
@@ -2946,12 +3075,12 @@ TEST(DebugStepLocals) {
// Stepping through the declarations.
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2961,8 +3090,9 @@ TEST(DebugStepIf) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -2982,20 +3112,20 @@ TEST(DebugStepIf) {
// Stepping through the true part.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_true[argc] = { v8::True(isolate) };
- foo->Call(env->Global(), argc, argv_true);
+ v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)};
+ foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
// Stepping through the false part.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_false[argc] = { v8::False(isolate) };
- foo->Call(env->Global(), argc, argv_false);
+ v8::Local<v8::Value> argv_false[argc] = {v8::False(isolate)};
+ foo->Call(context, env->Global(), argc, argv_false).ToLocalChecked();
CHECK_EQ(5, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3005,8 +3135,9 @@ TEST(DebugStepSwitch) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3032,27 +3163,27 @@ TEST(DebugStepSwitch) {
// One case with fall-through.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_1[argc] = { v8::Number::New(isolate, 1) };
- foo->Call(env->Global(), argc, argv_1);
+ v8::Local<v8::Value> argv_1[argc] = {v8::Number::New(isolate, 1)};
+ foo->Call(context, env->Global(), argc, argv_1).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Another case.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_2[argc] = { v8::Number::New(isolate, 2) };
- foo->Call(env->Global(), argc, argv_2);
+ v8::Local<v8::Value> argv_2[argc] = {v8::Number::New(isolate, 2)};
+ foo->Call(context, env->Global(), argc, argv_2).ToLocalChecked();
CHECK_EQ(5, break_point_hit_count);
// Last case.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_3[argc] = { v8::Number::New(isolate, 3) };
- foo->Call(env->Global(), argc, argv_3);
+ v8::Local<v8::Value> argv_3[argc] = {v8::Number::New(isolate, 3)};
+ foo->Call(context, env->Global(), argc, argv_3).ToLocalChecked();
CHECK_EQ(7, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3062,8 +3193,9 @@ TEST(DebugStepWhile) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3080,27 +3212,27 @@ TEST(DebugStepWhile) {
// Looping 0 times. We still should break at the while-condition once.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_0[argc] = { v8::Number::New(isolate, 0) };
- foo->Call(env->Global(), argc, argv_0);
+ v8::Local<v8::Value> argv_0[argc] = {v8::Number::New(isolate, 0)};
+ foo->Call(context, env->Global(), argc, argv_0).ToLocalChecked();
CHECK_EQ(3, break_point_hit_count);
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
- foo->Call(env->Global(), argc, argv_10);
+ v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)};
+ foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked();
CHECK_EQ(23, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
- foo->Call(env->Global(), argc, argv_100);
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
CHECK_EQ(203, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3110,8 +3242,9 @@ TEST(DebugStepDoWhile) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3128,27 +3261,27 @@ TEST(DebugStepDoWhile) {
// Looping 0 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_0[argc] = {v8::Number::New(isolate, 0)};
- foo->Call(env->Global(), argc, argv_0);
+ v8::Local<v8::Value> argv_0[argc] = {v8::Number::New(isolate, 0)};
+ foo->Call(context, env->Global(), argc, argv_0).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
- foo->Call(env->Global(), argc, argv_10);
+ v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)};
+ foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked();
CHECK_EQ(22, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
- foo->Call(env->Global(), argc, argv_100);
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
CHECK_EQ(202, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3158,8 +3291,9 @@ TEST(DebugStepFor) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3177,27 +3311,27 @@ TEST(DebugStepFor) {
// Looping 0 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_0[argc] = {v8::Number::New(isolate, 0)};
- foo->Call(env->Global(), argc, argv_0);
+ v8::Local<v8::Value> argv_0[argc] = {v8::Number::New(isolate, 0)};
+ foo->Call(context, env->Global(), argc, argv_0).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
- foo->Call(env->Global(), argc, argv_10);
+ v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)};
+ foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked();
CHECK_EQ(34, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
- foo->Call(env->Global(), argc, argv_100);
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
CHECK_EQ(304, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3207,8 +3341,9 @@ TEST(DebugStepForContinue) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3226,7 +3361,7 @@ TEST(DebugStepForContinue) {
"}"
"foo()";
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
- v8::Handle<v8::Value> result;
+ v8::Local<v8::Value> result;
SetBreakPoint(foo, 8); // "var a = 0;"
// Each loop generates 4 or 5 steps depending on whether a is equal.
@@ -3234,22 +3369,22 @@ TEST(DebugStepForContinue) {
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
- result = foo->Call(env->Global(), argc, argv_10);
- CHECK_EQ(5, result->Int32Value());
+ v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)};
+ result = foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked();
+ CHECK_EQ(5, result->Int32Value(context).FromJust());
CHECK_EQ(62, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
- result = foo->Call(env->Global(), argc, argv_100);
- CHECK_EQ(50, result->Int32Value());
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
+ CHECK_EQ(50, result->Int32Value(context).FromJust());
CHECK_EQ(557, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3259,8 +3394,9 @@ TEST(DebugStepForBreak) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3278,7 +3414,7 @@ TEST(DebugStepForBreak) {
"}"
"foo()";
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
- v8::Handle<v8::Value> result;
+ v8::Local<v8::Value> result;
SetBreakPoint(foo, 8); // "var a = 0;"
// Each loop generates 5 steps except for the last (when break is executed)
@@ -3287,22 +3423,22 @@ TEST(DebugStepForBreak) {
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
- result = foo->Call(env->Global(), argc, argv_10);
- CHECK_EQ(9, result->Int32Value());
+ v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)};
+ result = foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked();
+ CHECK_EQ(9, result->Int32Value(context).FromJust());
CHECK_EQ(64, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
- result = foo->Call(env->Global(), argc, argv_100);
- CHECK_EQ(99, result->Int32Value());
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
+ CHECK_EQ(99, result->Int32Value(context).FromJust());
CHECK_EQ(604, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3311,8 +3447,9 @@ TEST(DebugStepForIn) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
v8::Local<v8::Function> foo;
@@ -3328,7 +3465,7 @@ TEST(DebugStepForIn) {
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(8, break_point_hit_count);
// Create a function for testing stepping. Run it to allow it to get
@@ -3345,12 +3482,12 @@ TEST(DebugStepForIn) {
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(10, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3359,8 +3496,9 @@ TEST(DebugStepWith) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function foo(x) { "
@@ -3369,20 +3507,22 @@ TEST(DebugStepWith) {
" with (b) {}"
"}"
"foo()";
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"),
- v8::Object::New(env->GetIsolate()));
+ CHECK(env->Global()
+ ->Set(context, v8_str(env->GetIsolate(), "b"),
+ v8::Object::New(env->GetIsolate()))
+ .FromJust());
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
- v8::Handle<v8::Value> result;
+ v8::Local<v8::Value> result;
SetBreakPoint(foo, 8); // "var a = {};"
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3392,8 +3532,9 @@ TEST(DebugConditional) {
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function foo(x) { "
@@ -3407,19 +3548,19 @@ TEST(DebugConditional) {
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
step_action = StepIn;
break_point_hit_count = 0;
const int argc = 1;
- v8::Handle<v8::Value> argv_true[argc] = { v8::True(isolate) };
- foo->Call(env->Global(), argc, argv_true);
+ v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)};
+ foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3433,8 +3574,9 @@ TEST(StepInOutSimple) {
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function a() {b();c();}; "
@@ -3448,7 +3590,7 @@ TEST(StepInOutSimple) {
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "abcbaca";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -3456,7 +3598,7 @@ TEST(StepInOutSimple) {
step_action = StepNext;
break_point_hit_count = 0;
expected_step_sequence = "aaa";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -3464,13 +3606,13 @@ TEST(StepInOutSimple) {
step_action = StepOut;
break_point_hit_count = 0;
expected_step_sequence = "a";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3484,8 +3626,9 @@ TEST(StepInOutTree) {
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function a() {b(c(d()),d());c(d());d()}; "
@@ -3500,7 +3643,7 @@ TEST(StepInOutTree) {
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "adacadabcbadacada";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -3508,7 +3651,7 @@ TEST(StepInOutTree) {
step_action = StepNext;
break_point_hit_count = 0;
expected_step_sequence = "aaaa";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -3516,13 +3659,13 @@ TEST(StepInOutTree) {
step_action = StepOut;
break_point_hit_count = 0;
expected_step_sequence = "a";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded(true);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
}
@@ -3536,8 +3679,9 @@ TEST(StepInOutBranch) {
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function a() {b(false);c();}; "
@@ -3551,13 +3695,13 @@ TEST(StepInOutBranch) {
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "abbaca";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3573,29 +3717,31 @@ TEST(DebugStepNatives) {
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(3, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only active break points are hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3612,29 +3758,31 @@ TEST(DebugStepFunctionApply) {
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(7, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only the debugger statement is hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3644,6 +3792,7 @@ TEST(DebugStepFunctionCall) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping.
v8::Local<v8::Function> foo = CompileFunction(
&env,
@@ -3658,35 +3807,35 @@ TEST(DebugStepFunctionCall) {
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
step_action = StepIn;
// Check stepping where the if condition in bar is false.
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Check stepping where the if condition in bar is true.
break_point_hit_count = 0;
const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = { v8::True(isolate) };
- foo->Call(env->Global(), argc, argv);
+ v8::Local<v8::Value> argv[argc] = {v8::True(isolate)};
+ foo->Call(context, env->Global(), argc, argv).ToLocalChecked();
CHECK_EQ(8, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only the debugger statement is hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3696,6 +3845,7 @@ TEST(DebugStepFunctionCallApply) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping.
v8::Local<v8::Function> foo =
CompileFunction(&env,
@@ -3708,27 +3858,27 @@ TEST(DebugStepFunctionCallApply) {
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
- CHECK_EQ(5, break_point_hit_count);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ CHECK_EQ(6, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only the debugger statement is hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3739,8 +3889,9 @@ TEST(PauseInScript) {
env.ExposeDebug();
// Register a debug event listener which counts.
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
+ v8::Local<v8::Context> context = env.context();
// Create a script that returns a function.
const char* src = "(function (evt) {})";
const char* script_name = "StepInHandlerTest";
@@ -3749,19 +3900,19 @@ TEST(PauseInScript) {
SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1);
break_point_hit_count = 0;
- v8::ScriptOrigin origin(
- v8::String::NewFromUtf8(env->GetIsolate(), script_name),
- v8::Integer::New(env->GetIsolate(), 0));
- v8::Handle<v8::Script> script = v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), src), &origin);
- v8::Local<v8::Value> r = script->Run();
+ v8::ScriptOrigin origin(v8_str(env->GetIsolate(), script_name),
+ v8::Integer::New(env->GetIsolate(), 0));
+ v8::Local<v8::Script> script =
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), src), &origin)
+ .ToLocalChecked();
+ v8::Local<v8::Value> r = script->Run(context).ToLocalChecked();
CHECK(r->IsFunction());
CHECK_EQ(1, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3783,6 +3934,7 @@ TEST(BreakOnException) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
+ v8::Local<v8::Context> context = env.context();
// Create functions for testing break on exception.
CompileFunction(&env, "function throws(){throw 1;}", "throws");
v8::Local<v8::Function> caught =
@@ -3801,135 +3953,136 @@ TEST(BreakOnException) {
&env, "function caughtFinally(){L:try{throws();}finally{break L;}}",
"caughtFinally");
- v8::V8::AddMessageListener(MessageCallbackCount);
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ env->GetIsolate()->AddMessageListener(MessageCallbackCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
// Initial state should be no break on exceptions.
DebugEventCounterClear();
MessageCallbackCountClear();
- caught->Call(env->Global(), 0, NULL);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(0, 0, 0);
- notCaught->Call(env->Global(), 0, NULL);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(0, 0, 1);
- notCaughtFinally->Call(env->Global(), 0, NULL);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(0, 0, 2);
- edgeCaseFinally->Call(env->Global(), 0, NULL);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(0, 0, 2);
// No break on exception
DebugEventCounterClear();
MessageCallbackCountClear();
ChangeBreakOnException(false, false);
- caught->Call(env->Global(), 0, NULL);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(0, 0, 0);
- notCaught->Call(env->Global(), 0, NULL);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(0, 0, 1);
- notCaughtFinally->Call(env->Global(), 0, NULL);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(0, 0, 2);
- edgeCaseFinally->Call(env->Global(), 0, NULL);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(0, 0, 2);
// Break on uncaught exception
DebugEventCounterClear();
MessageCallbackCountClear();
ChangeBreakOnException(false, true);
- caught->Call(env->Global(), 0, NULL);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(0, 0, 0);
- notCaught->Call(env->Global(), 0, NULL);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(1, 1, 1);
- notCaughtFinally->Call(env->Global(), 0, NULL);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(2, 2, 2);
- edgeCaseFinally->Call(env->Global(), 0, NULL);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(3, 3, 2);
// Break on exception and uncaught exception
DebugEventCounterClear();
MessageCallbackCountClear();
ChangeBreakOnException(true, true);
- caught->Call(env->Global(), 0, NULL);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(1, 0, 0);
- notCaught->Call(env->Global(), 0, NULL);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(2, 1, 1);
- notCaughtFinally->Call(env->Global(), 0, NULL);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(3, 2, 2);
- edgeCaseFinally->Call(env->Global(), 0, NULL);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(4, 3, 2);
// Break on exception
DebugEventCounterClear();
MessageCallbackCountClear();
ChangeBreakOnException(true, false);
- caught->Call(env->Global(), 0, NULL);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(1, 0, 0);
- notCaught->Call(env->Global(), 0, NULL);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(2, 1, 1);
- notCaughtFinally->Call(env->Global(), 0, NULL);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(3, 2, 2);
- edgeCaseFinally->Call(env->Global(), 0, NULL);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(4, 3, 2);
// No break on exception using JavaScript
DebugEventCounterClear();
MessageCallbackCountClear();
ChangeBreakOnExceptionFromJS(env->GetIsolate(), false, false);
- caught->Call(env->Global(), 0, NULL);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(0, 0, 0);
- notCaught->Call(env->Global(), 0, NULL);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(0, 0, 1);
- notCaughtFinally->Call(env->Global(), 0, NULL);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(0, 0, 2);
- edgeCaseFinally->Call(env->Global(), 0, NULL);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(0, 0, 2);
// Break on uncaught exception using JavaScript
DebugEventCounterClear();
MessageCallbackCountClear();
ChangeBreakOnExceptionFromJS(env->GetIsolate(), false, true);
- caught->Call(env->Global(), 0, NULL);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(0, 0, 0);
- notCaught->Call(env->Global(), 0, NULL);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(1, 1, 1);
- notCaughtFinally->Call(env->Global(), 0, NULL);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(2, 2, 2);
- edgeCaseFinally->Call(env->Global(), 0, NULL);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(3, 3, 2);
// Break on exception and uncaught exception using JavaScript
DebugEventCounterClear();
MessageCallbackCountClear();
ChangeBreakOnExceptionFromJS(env->GetIsolate(), true, true);
- caught->Call(env->Global(), 0, NULL);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(1, 0, 0);
- notCaught->Call(env->Global(), 0, NULL);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(2, 1, 1);
- notCaughtFinally->Call(env->Global(), 0, NULL);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(3, 2, 2);
- edgeCaseFinally->Call(env->Global(), 0, NULL);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(4, 3, 2);
// Break on exception using JavaScript
DebugEventCounterClear();
MessageCallbackCountClear();
ChangeBreakOnExceptionFromJS(env->GetIsolate(), true, false);
- caught->Call(env->Global(), 0, NULL);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(1, 0, 0);
- notCaught->Call(env->Global(), 0, NULL);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(2, 1, 1);
- notCaughtFinally->Call(env->Global(), 0, NULL);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
DebugEventCounterCheck(3, 2, 2);
- edgeCaseFinally->Call(env->Global(), 0, NULL);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
DebugEventCounterCheck(4, 3, 2);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
- v8::V8::RemoveMessageListeners(MessageCallbackCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
+ env->GetIsolate()->RemoveMessageListeners(MessageCallbackCount);
}
-static void try_finally_original_message(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
- CHECK_EQ(2, message->GetLineNumber());
- CHECK_EQ(2, message->GetStartColumn());
+static void try_finally_original_message(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
+ v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
+ CHECK_EQ(2, message->GetLineNumber(context).FromJust());
+ CHECK_EQ(2, message->GetStartColumn(context).FromJust());
message_callback_count++;
}
@@ -3938,11 +4091,11 @@ TEST(TryFinallyOriginalMessage) {
// Test that the debugger plays nicely with the pending message.
message_callback_count = 0;
DebugEventCounterClear();
- v8::V8::AddMessageListener(try_finally_original_message);
- v8::Debug::SetDebugEventListener(DebugEventCounter);
- ChangeBreakOnException(true, true);
DebugLocalContext env;
v8::Isolate* isolate = CcTest::isolate();
+ isolate->AddMessageListener(try_finally_original_message);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventCounter);
+ ChangeBreakOnException(true, true);
v8::HandleScope scope(isolate);
CompileRun(
"try {\n"
@@ -3950,8 +4103,8 @@ TEST(TryFinallyOriginalMessage) {
"} finally {\n"
"}\n");
DebugEventCounterCheck(1, 1, 1);
- v8::Debug::SetDebugEventListener(NULL);
- v8::V8::RemoveMessageListeners(try_finally_original_message);
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ isolate->RemoveMessageListeners(try_finally_original_message);
}
@@ -3968,8 +4121,8 @@ TEST(EvalJSInDebugEventListenerOnNativeReThrownException) {
debug_event_listener_callback = noThrowJS;
debug_event_listener_callback_result = 2;
- v8::V8::AddMessageListener(MessageCallbackCount);
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ env->GetIsolate()->AddMessageListener(MessageCallbackCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
// Break on uncaught exception
ChangeBreakOnException(false, true);
DebugEventCounterClear();
@@ -3978,8 +4131,8 @@ TEST(EvalJSInDebugEventListenerOnNativeReThrownException) {
// ReThrow native error
{
v8::TryCatch tryCatch(env->GetIsolate());
- env->GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(env->GetIsolate(), "Type error")));
+ env->GetIsolate()->ThrowException(
+ v8::Exception::TypeError(v8_str(env->GetIsolate(), "Type error")));
CHECK(tryCatch.HasCaught());
tryCatch.ReThrow();
}
@@ -3999,14 +4152,15 @@ TEST(BreakOnCompileException) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
// For this test, we want to break on uncaught exceptions:
ChangeBreakOnException(false, true);
// Create a function for checking the function when hitting a break point.
frame_count = CompileFunction(&env, frame_count_source, "frame_count");
- v8::V8::AddMessageListener(MessageCallbackCount);
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ env->GetIsolate()->AddMessageListener(MessageCallbackCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
DebugEventCounterClear();
MessageCallbackCountClear();
@@ -4018,30 +4172,36 @@ TEST(BreakOnCompileException) {
CHECK_EQ(-1, last_js_stack_height);
// Throws SyntaxError: Unexpected end of input
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "+++"));
+ CHECK(
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), "+++")).IsEmpty());
CHECK_EQ(1, exception_hit_count);
CHECK_EQ(1, uncaught_exception_hit_count);
CHECK_EQ(1, message_callback_count);
CHECK_EQ(0, last_js_stack_height); // No JavaScript stack.
// Throws SyntaxError: Unexpected identifier
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "x x"));
+ CHECK(
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), "x x")).IsEmpty());
CHECK_EQ(2, exception_hit_count);
CHECK_EQ(2, uncaught_exception_hit_count);
CHECK_EQ(2, message_callback_count);
CHECK_EQ(0, last_js_stack_height); // No JavaScript stack.
// Throws SyntaxError: Unexpected end of input
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "eval('+++')"))
- ->Run();
+ CHECK(v8::Script::Compile(context, v8_str(env->GetIsolate(), "eval('+++')"))
+ .ToLocalChecked()
+ ->Run(context)
+ .IsEmpty());
CHECK_EQ(3, exception_hit_count);
CHECK_EQ(3, uncaught_exception_hit_count);
CHECK_EQ(3, message_callback_count);
CHECK_EQ(1, last_js_stack_height);
// Throws SyntaxError: Unexpected identifier
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "eval('x x')"))
- ->Run();
+ CHECK(v8::Script::Compile(context, v8_str(env->GetIsolate(), "eval('x x')"))
+ .ToLocalChecked()
+ ->Run(context)
+ .IsEmpty());
CHECK_EQ(4, exception_hit_count);
CHECK_EQ(4, uncaught_exception_hit_count);
CHECK_EQ(4, message_callback_count);
@@ -4062,8 +4222,9 @@ TEST(StepWithException) {
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
+ v8::Local<v8::Context> context = env.context();
// Create functions for testing stepping.
const char* src = "function a() { n(); }; "
"function b() { c(); }; "
@@ -4075,32 +4236,36 @@ TEST(StepWithException) {
"function h() { x = 1; throw 1; }; ";
// Step through invocation of a.
+ ClearStepping();
v8::Local<v8::Function> a = CompileFunction(&env, src, "a");
SetBreakPoint(a, 0);
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "aa";
- a->Call(env->Global(), 0, NULL);
+ CHECK(a->Call(context, env->Global(), 0, NULL).IsEmpty());
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Step through invocation of b + c.
+ ClearStepping();
v8::Local<v8::Function> b = CompileFunction(&env, src, "b");
SetBreakPoint(b, 0);
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "bcc";
- b->Call(env->Global(), 0, NULL);
+ CHECK(b->Call(context, env->Global(), 0, NULL).IsEmpty());
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
+
// Step through invocation of d + e.
+ ClearStepping();
v8::Local<v8::Function> d = CompileFunction(&env, src, "d");
SetBreakPoint(d, 0);
ChangeBreakOnException(false, true);
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "ddedd";
- d->Call(env->Global(), 0, NULL);
+ d->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -4109,18 +4274,19 @@ TEST(StepWithException) {
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "ddeedd";
- d->Call(env->Global(), 0, NULL);
+ d->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Step through invocation of f + g + h.
+ ClearStepping();
v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
SetBreakPoint(f, 0);
ChangeBreakOnException(false, true);
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "ffghhff";
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -4129,13 +4295,13 @@ TEST(StepWithException) {
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "ffghhhff";
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -4149,8 +4315,9 @@ TEST(DebugBreak) {
v8::HandleScope scope(isolate);
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener(DebugEventBreak);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreak);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping.
const char* src = "function f0() {}"
"function f1(x1) {}"
@@ -4162,16 +4329,15 @@ TEST(DebugBreak) {
v8::Local<v8::Function> f3 = CompileFunction(&env, src, "f3");
// Call the function to make sure it is compiled.
- v8::Handle<v8::Value> argv[] = { v8::Number::New(isolate, 1),
- v8::Number::New(isolate, 1),
- v8::Number::New(isolate, 1),
- v8::Number::New(isolate, 1) };
+ v8::Local<v8::Value> argv[] = {
+ v8::Number::New(isolate, 1), v8::Number::New(isolate, 1),
+ v8::Number::New(isolate, 1), v8::Number::New(isolate, 1)};
// Call all functions to make sure that they are compiled.
- f0->Call(env->Global(), 0, NULL);
- f1->Call(env->Global(), 0, NULL);
- f2->Call(env->Global(), 0, NULL);
- f3->Call(env->Global(), 0, NULL);
+ f0->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ f1->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ f2->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ f3->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Set the debug break flag.
v8::Debug::DebugBreak(env->GetIsolate());
@@ -4180,18 +4346,18 @@ TEST(DebugBreak) {
// Call all functions with different argument count.
break_point_hit_count = 0;
for (unsigned int i = 0; i < arraysize(argv); i++) {
- f0->Call(env->Global(), i, argv);
- f1->Call(env->Global(), i, argv);
- f2->Call(env->Global(), i, argv);
- f3->Call(env->Global(), i, argv);
+ f0->Call(context, env->Global(), i, argv).ToLocalChecked();
+ f1->Call(context, env->Global(), i, argv).ToLocalChecked();
+ f2->Call(context, env->Global(), i, argv).ToLocalChecked();
+ f3->Call(context, env->Global(), i, argv).ToLocalChecked();
}
// One break for each function called.
CHECK(4 * arraysize(argv) == break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -4202,8 +4368,9 @@ TEST(DisableBreak) {
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping.
const char* src = "function f() {g()};function g(){i=0; while(i<10){i++}}";
v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
@@ -4219,23 +4386,23 @@ TEST(DisableBreak) {
// Call all functions with different argument count.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
{
v8::Debug::DebugBreak(env->GetIsolate());
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate());
v8::internal::DisableBreak disable_break(isolate->debug(), true);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
}
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
static const char* kSimpleExtensionSource =
@@ -4250,7 +4417,7 @@ TEST(NoBreakWhenBootstrapping) {
v8::HandleScope scope(isolate);
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventCounter);
// Set the debug break flag.
v8::Debug::DebugBreak(isolate);
@@ -4269,28 +4436,37 @@ TEST(NoBreakWhenBootstrapping) {
CHECK_EQ(0, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
- v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
- result->Set(v8::Integer::New(info.GetIsolate(), 0),
- v8::String::NewFromUtf8(info.GetIsolate(), "a"));
- result->Set(v8::Integer::New(info.GetIsolate(), 1),
- v8::String::NewFromUtf8(info.GetIsolate(), "b"));
- result->Set(v8::Integer::New(info.GetIsolate(), 2),
- v8::String::NewFromUtf8(info.GetIsolate(), "c"));
+ v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 0),
+ v8_str(info.GetIsolate(), "a"))
+ .FromJust());
+ CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 1),
+ v8_str(info.GetIsolate(), "b"))
+ .FromJust());
+ CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 2),
+ v8_str(info.GetIsolate(), "c"))
+ .FromJust());
info.GetReturnValue().Set(result);
}
static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
v8::Isolate* isolate = info.GetIsolate();
- v8::Handle<v8::Array> result = v8::Array::New(isolate, 2);
- result->Set(v8::Integer::New(isolate, 0), v8::Number::New(isolate, 1));
- result->Set(v8::Integer::New(isolate, 1), v8::Number::New(isolate, 10));
+ v8::Local<v8::Array> result = v8::Array::New(isolate, 2);
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ CHECK(result->Set(context, v8::Integer::New(isolate, 0),
+ v8::Number::New(isolate, 1))
+ .FromJust());
+ CHECK(result->Set(context, v8::Integer::New(isolate, 1),
+ v8::Number::New(isolate, 10))
+ .FromJust());
info.GetReturnValue().Set(result);
}
@@ -4300,13 +4476,13 @@ static void NamedGetter(v8::Local<v8::Name> name,
if (name->IsSymbol()) return;
v8::String::Utf8Value n(v8::Local<v8::String>::Cast(name));
if (strcmp(*n, "a") == 0) {
- info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "AA"));
+ info.GetReturnValue().Set(v8_str(info.GetIsolate(), "AA"));
return;
} else if (strcmp(*n, "b") == 0) {
- info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "BB"));
+ info.GetReturnValue().Set(v8_str(info.GetIsolate(), "BB"));
return;
} else if (strcmp(*n, "c") == 0) {
- info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "CC"));
+ info.GetReturnValue().Set(v8_str(info.GetIsolate(), "CC"));
return;
} else {
info.GetReturnValue().SetUndefined();
@@ -4329,75 +4505,71 @@ TEST(InterceptorPropertyMirror) {
v8::HandleScope scope(isolate);
env.ExposeDebug();
+ v8::Local<v8::Context> context = env.context();
// Create object with named interceptor.
- v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
named->SetHandler(v8::NamedPropertyHandlerConfiguration(
NamedGetter, NULL, NULL, NULL, NamedEnum));
- env->Global()->Set(
- v8::String::NewFromUtf8(isolate, "intercepted_named"),
- named->NewInstance());
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "intercepted_named"),
+ named->NewInstance(context).ToLocalChecked())
+ .FromJust());
// Create object with indexed interceptor.
- v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(isolate);
indexed->SetHandler(v8::IndexedPropertyHandlerConfiguration(
IndexedGetter, NULL, NULL, NULL, IndexedEnum));
- env->Global()->Set(
- v8::String::NewFromUtf8(isolate, "intercepted_indexed"),
- indexed->NewInstance());
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "intercepted_indexed"),
+ indexed->NewInstance(context).ToLocalChecked())
+ .FromJust());
// Create object with both named and indexed interceptor.
- v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> both = v8::ObjectTemplate::New(isolate);
both->SetHandler(v8::NamedPropertyHandlerConfiguration(
NamedGetter, NULL, NULL, NULL, NamedEnum));
both->SetHandler(v8::IndexedPropertyHandlerConfiguration(
IndexedGetter, NULL, NULL, NULL, IndexedEnum));
- env->Global()->Set(
- v8::String::NewFromUtf8(isolate, "intercepted_both"),
- both->NewInstance());
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "intercepted_both"),
+ both->NewInstance(context).ToLocalChecked())
+ .FromJust());
// Get mirrors for the three objects with interceptor.
CompileRun(
"var named_mirror = debug.MakeMirror(intercepted_named);"
"var indexed_mirror = debug.MakeMirror(intercepted_indexed);"
"var both_mirror = debug.MakeMirror(intercepted_both)");
- CHECK(CompileRun(
- "named_mirror instanceof debug.ObjectMirror")->BooleanValue());
- CHECK(CompileRun(
- "indexed_mirror instanceof debug.ObjectMirror")->BooleanValue());
- CHECK(CompileRun(
- "both_mirror instanceof debug.ObjectMirror")->BooleanValue());
+ CHECK(CompileRun("named_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("indexed_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("both_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
// Get the property names from the interceptors
CompileRun(
"named_names = named_mirror.propertyNames();"
"indexed_names = indexed_mirror.propertyNames();"
"both_names = both_mirror.propertyNames()");
- CHECK_EQ(3, CompileRun("named_names.length")->Int32Value());
- CHECK_EQ(2, CompileRun("indexed_names.length")->Int32Value());
- CHECK_EQ(5, CompileRun("both_names.length")->Int32Value());
+ CHECK_EQ(3, CompileRun("named_names.length")->Int32Value(context).FromJust());
+ CHECK_EQ(2,
+ CompileRun("indexed_names.length")->Int32Value(context).FromJust());
+ CHECK_EQ(5, CompileRun("both_names.length")->Int32Value(context).FromJust());
// Check the expected number of properties.
const char* source;
source = "named_mirror.properties().length";
- CHECK_EQ(3, CompileRun(source)->Int32Value());
+ CHECK_EQ(3, CompileRun(source)->Int32Value(context).FromJust());
source = "indexed_mirror.properties().length";
- CHECK_EQ(2, CompileRun(source)->Int32Value());
+ CHECK_EQ(2, CompileRun(source)->Int32Value(context).FromJust());
source = "both_mirror.properties().length";
- CHECK_EQ(5, CompileRun(source)->Int32Value());
-
- // 1 is PropertyKind.Named;
- source = "both_mirror.properties(1).length";
- CHECK_EQ(3, CompileRun(source)->Int32Value());
-
- // 2 is PropertyKind.Indexed;
- source = "both_mirror.properties(2).length";
- CHECK_EQ(2, CompileRun(source)->Int32Value());
-
- // 3 is PropertyKind.Named | PropertyKind.Indexed;
- source = "both_mirror.properties(3).length";
- CHECK_EQ(5, CompileRun(source)->Int32Value());
+ CHECK_EQ(5, CompileRun(source)->Int32Value(context).FromJust());
// Get the interceptor properties for the object with only named interceptor.
CompileRun("var named_values = named_mirror.properties()");
@@ -4407,10 +4579,10 @@ TEST(InterceptorPropertyMirror) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
SNPrintF(buffer,
"named_values[%d] instanceof debug.PropertyMirror", i);
- CHECK(CompileRun(buffer.start())->BooleanValue());
+ CHECK(CompileRun(buffer.start())->BooleanValue(context).FromJust());
SNPrintF(buffer, "named_values[%d].isNative()", i);
- CHECK(CompileRun(buffer.start())->BooleanValue());
+ CHECK(CompileRun(buffer.start())->BooleanValue(context).FromJust());
}
// Get the interceptor properties for the object with only indexed
@@ -4422,7 +4594,7 @@ TEST(InterceptorPropertyMirror) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
SNPrintF(buffer,
"indexed_values[%d] instanceof debug.PropertyMirror", i);
- CHECK(CompileRun(buffer.start())->BooleanValue());
+ CHECK(CompileRun(buffer.start())->BooleanValue(context).FromJust());
}
// Get the interceptor properties for the object with both types of
@@ -4433,24 +4605,24 @@ TEST(InterceptorPropertyMirror) {
for (int i = 0; i < 5; i++) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
SNPrintF(buffer, "both_values[%d] instanceof debug.PropertyMirror", i);
- CHECK(CompileRun(buffer.start())->BooleanValue());
+ CHECK(CompileRun(buffer.start())->BooleanValue(context).FromJust());
}
// Check the property names.
- source = "both_values[0].name() == 'a'";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[0].name() == '1'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
- source = "both_values[1].name() == 'b'";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[1].name() == '10'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
- source = "both_values[2].name() == 'c'";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[2].name() == 'a'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
- source = "both_values[3].name() == 1";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[3].name() == 'b'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
- source = "both_values[4].name() == 10";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[4].name() == 'c'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
}
@@ -4461,30 +4633,43 @@ TEST(HiddenPrototypePropertyMirror) {
v8::HandleScope scope(isolate);
env.ExposeDebug();
- v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
- t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"),
+ v8::Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
+ t0->InstanceTemplate()->Set(v8_str(isolate, "x"),
v8::Number::New(isolate, 0));
- v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->SetHiddenPrototype(true);
- t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"),
+ t1->InstanceTemplate()->Set(v8_str(isolate, "y"),
v8::Number::New(isolate, 1));
- v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
t2->SetHiddenPrototype(true);
- t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"),
+ t2->InstanceTemplate()->Set(v8_str(isolate, "z"),
v8::Number::New(isolate, 2));
- v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
- t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"),
+ v8::Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
+ t3->InstanceTemplate()->Set(v8_str(isolate, "u"),
v8::Number::New(isolate, 3));
+ v8::Local<v8::Context> context = env.context();
// Create object and set them on the global object.
- v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0);
- v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1);
- v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2);
- v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3);
+ v8::Local<v8::Object> o0 = t0->GetFunction(context)
+ .ToLocalChecked()
+ ->NewInstance(context)
+ .ToLocalChecked();
+ CHECK(env->Global()->Set(context, v8_str(isolate, "o0"), o0).FromJust());
+ v8::Local<v8::Object> o1 = t1->GetFunction(context)
+ .ToLocalChecked()
+ ->NewInstance(context)
+ .ToLocalChecked();
+ CHECK(env->Global()->Set(context, v8_str(isolate, "o1"), o1).FromJust());
+ v8::Local<v8::Object> o2 = t2->GetFunction(context)
+ .ToLocalChecked()
+ ->NewInstance(context)
+ .ToLocalChecked();
+ CHECK(env->Global()->Set(context, v8_str(isolate, "o2"), o2).FromJust());
+ v8::Local<v8::Object> o3 = t3->GetFunction(context)
+ .ToLocalChecked()
+ ->NewInstance(context)
+ .ToLocalChecked();
+ CHECK(env->Global()->Set(context, v8_str(isolate, "o3"), o3).FromJust());
// Get mirrors for the four objects.
CompileRun(
@@ -4492,43 +4677,62 @@ TEST(HiddenPrototypePropertyMirror) {
"var o1_mirror = debug.MakeMirror(o1);"
"var o2_mirror = debug.MakeMirror(o2);"
"var o3_mirror = debug.MakeMirror(o3)");
- CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue());
- CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue());
- CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue());
- CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue());
+ CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
// Check that each object has one property.
- CHECK_EQ(1, CompileRun(
- "o0_mirror.propertyNames().length")->Int32Value());
- CHECK_EQ(1, CompileRun(
- "o1_mirror.propertyNames().length")->Int32Value());
- CHECK_EQ(1, CompileRun(
- "o2_mirror.propertyNames().length")->Int32Value());
- CHECK_EQ(1, CompileRun(
- "o3_mirror.propertyNames().length")->Int32Value());
+ CHECK_EQ(1, CompileRun("o0_mirror.propertyNames().length")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(1, CompileRun("o1_mirror.propertyNames().length")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(1, CompileRun("o2_mirror.propertyNames().length")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(1, CompileRun("o3_mirror.propertyNames().length")
+ ->Int32Value(context)
+ .FromJust());
// Set o1 as prototype for o0. o1 has the hidden prototype flag so all
// properties on o1 should be seen on o0.
- o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o1);
- CHECK_EQ(2, CompileRun(
- "o0_mirror.propertyNames().length")->Int32Value());
- CHECK_EQ(0, CompileRun(
- "o0_mirror.property('x').value().value()")->Int32Value());
- CHECK_EQ(1, CompileRun(
- "o0_mirror.property('y').value().value()")->Int32Value());
+ CHECK(o0->Set(context, v8_str(isolate, "__proto__"), o1).FromJust());
+ CHECK_EQ(2, CompileRun("o0_mirror.propertyNames().length")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(0, CompileRun("o0_mirror.property('x').value().value()")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(1, CompileRun("o0_mirror.property('y').value().value()")
+ ->Int32Value(context)
+ .FromJust());
// Set o2 as prototype for o0 (it will end up after o1 as o1 has the hidden
// prototype flag. o2 also has the hidden prototype flag so all properties
// on o2 should be seen on o0 as well as properties on o1.
- o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o2);
- CHECK_EQ(3, CompileRun(
- "o0_mirror.propertyNames().length")->Int32Value());
- CHECK_EQ(0, CompileRun(
- "o0_mirror.property('x').value().value()")->Int32Value());
- CHECK_EQ(1, CompileRun(
- "o0_mirror.property('y').value().value()")->Int32Value());
- CHECK_EQ(2, CompileRun(
- "o0_mirror.property('z').value().value()")->Int32Value());
+ CHECK(o0->Set(context, v8_str(isolate, "__proto__"), o2).FromJust());
+ CHECK_EQ(3, CompileRun("o0_mirror.propertyNames().length")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(0, CompileRun("o0_mirror.property('x').value().value()")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(1, CompileRun("o0_mirror.property('y').value().value()")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(2, CompileRun("o0_mirror.property('z').value().value()")
+ ->Int32Value(context)
+ .FromJust());
// Set o3 as prototype for o0 (it will end up after o1 and o2 as both o1 and
// o2 has the hidden prototype flag. o3 does not have the hidden prototype
@@ -4536,21 +4740,30 @@ TEST(HiddenPrototypePropertyMirror) {
// from o1 and o2 should still be seen on o0.
// Final prototype chain: o0 -> o1 -> o2 -> o3
// Hidden prototypes: ^^ ^^
- o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o3);
- CHECK_EQ(3, CompileRun(
- "o0_mirror.propertyNames().length")->Int32Value());
- CHECK_EQ(1, CompileRun(
- "o3_mirror.propertyNames().length")->Int32Value());
- CHECK_EQ(0, CompileRun(
- "o0_mirror.property('x').value().value()")->Int32Value());
- CHECK_EQ(1, CompileRun(
- "o0_mirror.property('y').value().value()")->Int32Value());
- CHECK_EQ(2, CompileRun(
- "o0_mirror.property('z').value().value()")->Int32Value());
- CHECK(CompileRun("o0_mirror.property('u').isUndefined()")->BooleanValue());
+ CHECK(o0->Set(context, v8_str(isolate, "__proto__"), o3).FromJust());
+ CHECK_EQ(3, CompileRun("o0_mirror.propertyNames().length")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(1, CompileRun("o3_mirror.propertyNames().length")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(0, CompileRun("o0_mirror.property('x').value().value()")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(1, CompileRun("o0_mirror.property('y').value().value()")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(2, CompileRun("o0_mirror.property('z').value().value()")
+ ->Int32Value(context)
+ .FromJust());
+ CHECK(CompileRun("o0_mirror.property('u').isUndefined()")
+ ->BooleanValue(context)
+ .FromJust());
// The prototype (__proto__) for o0 should be o3 as o1 and o2 are hidden.
- CHECK(CompileRun("o0_mirror.protoObject() == o3_mirror")->BooleanValue());
+ CHECK(CompileRun("o0_mirror.protoObject() == o3_mirror")
+ ->BooleanValue(context)
+ .FromJust());
}
@@ -4568,29 +4781,35 @@ TEST(NativeGetterPropertyMirror) {
v8::HandleScope scope(isolate);
env.ExposeDebug();
- v8::Handle<v8::String> name = v8::String::NewFromUtf8(isolate, "x");
+ v8::Local<v8::Context> context = env.context();
+ v8::Local<v8::String> name = v8_str(isolate, "x");
// Create object with named accessor.
- v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
- named->SetAccessor(name, &ProtperyXNativeGetter, NULL,
- v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
+ v8::Local<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
+ named->SetAccessor(name, &ProtperyXNativeGetter, NULL, v8::Local<v8::Value>(),
+ v8::DEFAULT, v8::None);
// Create object with named property getter.
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
- named->NewInstance());
- CHECK_EQ(10, CompileRun("instance.x")->Int32Value());
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "instance"),
+ named->NewInstance(context).ToLocalChecked())
+ .FromJust());
+ CHECK_EQ(10, CompileRun("instance.x")->Int32Value(context).FromJust());
// Get mirror for the object with property getter.
CompileRun("var instance_mirror = debug.MakeMirror(instance);");
- CHECK(CompileRun(
- "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
+ CHECK(CompileRun("instance_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
CompileRun("var named_names = instance_mirror.propertyNames();");
- CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
- CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
- CHECK(CompileRun(
- "instance_mirror.property('x').value().isNumber()")->BooleanValue());
- CHECK(CompileRun(
- "instance_mirror.property('x').value().value() == 10")->BooleanValue());
+ CHECK_EQ(1, CompileRun("named_names.length")->Int32Value(context).FromJust());
+ CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue(context).FromJust());
+ CHECK(CompileRun("instance_mirror.property('x').value().isNumber()")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("instance_mirror.property('x').value().value() == 10")
+ ->BooleanValue(context)
+ .FromJust());
}
@@ -4608,30 +4827,37 @@ TEST(NativeGetterThrowingErrorPropertyMirror) {
v8::HandleScope scope(isolate);
env.ExposeDebug();
- v8::Handle<v8::String> name = v8::String::NewFromUtf8(isolate, "x");
+ v8::Local<v8::Context> context = env.context();
+ v8::Local<v8::String> name = v8_str(isolate, "x");
// Create object with named accessor.
- v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL,
- v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
+ v8::Local<v8::Value>(), v8::DEFAULT, v8::None);
// Create object with named property getter.
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
- named->NewInstance());
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "instance"),
+ named->NewInstance(context).ToLocalChecked())
+ .FromJust());
// Get mirror for the object with property getter.
CompileRun("var instance_mirror = debug.MakeMirror(instance);");
- CHECK(CompileRun(
- "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
+ CHECK(CompileRun("instance_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
CompileRun("named_names = instance_mirror.propertyNames();");
- CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
- CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
- CHECK(CompileRun(
- "instance_mirror.property('x').value().isError()")->BooleanValue());
+ CHECK_EQ(1, CompileRun("named_names.length")->Int32Value(context).FromJust());
+ CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue(context).FromJust());
+ CHECK(CompileRun("instance_mirror.property('x').value().isError()")
+ ->BooleanValue(context)
+ .FromJust());
// Check that the message is that passed to the Error constructor.
- CHECK(CompileRun(
- "instance_mirror.property('x').value().message() == 'Error message'")->
- BooleanValue());
+ CHECK(
+ CompileRun(
+ "instance_mirror.property('x').value().message() == 'Error message'")
+ ->BooleanValue(context)
+ .FromJust());
}
@@ -4645,81 +4871,97 @@ TEST(NoHiddenProperties) {
v8::HandleScope scope(isolate);
env.ExposeDebug();
+ v8::Local<v8::Context> context = env.context();
// Create an object in the global scope.
const char* source = "var obj = {a: 1};";
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))
- ->Run();
+ v8::Script::Compile(context, v8_str(isolate, source))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj")));
+ env->Global()->Get(context, v8_str(isolate, "obj")).ToLocalChecked());
// Set a hidden property on the object.
- obj->SetPrivate(env.context(),
- v8::Private::New(isolate, v8::String::NewFromUtf8(
- isolate, "v8::test-debug::a")),
- v8::Int32::New(isolate, 11))
+ obj->SetPrivate(
+ env.context(),
+ v8::Private::New(isolate, v8_str(isolate, "v8::test-debug::a")),
+ v8::Int32::New(isolate, 11))
.FromJust();
// Get mirror for the object with property getter.
CompileRun("var obj_mirror = debug.MakeMirror(obj);");
- CHECK(CompileRun(
- "obj_mirror instanceof debug.ObjectMirror")->BooleanValue());
+ CHECK(CompileRun("obj_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
CompileRun("var named_names = obj_mirror.propertyNames();");
// There should be exactly one property. But there is also an unnamed
// property whose value is hidden properties dictionary. The latter
// property should not be in the list of reguar properties.
- CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
- CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue());
- CHECK(CompileRun(
- "obj_mirror.property('a').value().value() == 1")->BooleanValue());
+ CHECK_EQ(1, CompileRun("named_names.length")->Int32Value(context).FromJust());
+ CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue(context).FromJust());
+ CHECK(CompileRun("obj_mirror.property('a').value().value() == 1")
+ ->BooleanValue(context)
+ .FromJust());
// Object created by t0 will become hidden prototype of object 'obj'.
- v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
- t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"),
+ v8::Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
+ t0->InstanceTemplate()->Set(v8_str(isolate, "b"),
v8::Number::New(isolate, 2));
t0->SetHiddenPrototype(true);
- v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
- t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"),
+ v8::Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
+ t1->InstanceTemplate()->Set(v8_str(isolate, "c"),
v8::Number::New(isolate, 3));
// Create proto objects, add hidden properties to them and set them on
// the global object.
- v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance();
+ v8::Local<v8::Object> protoObj = t0->GetFunction(context)
+ .ToLocalChecked()
+ ->NewInstance(context)
+ .ToLocalChecked();
protoObj->SetPrivate(
env.context(),
- v8::Private::New(isolate, v8::String::NewFromUtf8(
- isolate, "v8::test-debug::b")),
+ v8::Private::New(isolate, v8_str(isolate, "v8::test-debug::b")),
v8::Int32::New(isolate, 12))
.FromJust();
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"),
- protoObj);
- v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
- grandProtoObj->SetPrivate(
- env.context(),
- v8::Private::New(isolate, v8::String::NewFromUtf8(
- isolate, "v8::test-debug::c")),
- v8::Int32::New(isolate, 13))
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "protoObj"), protoObj)
+ .FromJust());
+ v8::Local<v8::Object> grandProtoObj = t1->GetFunction(context)
+ .ToLocalChecked()
+ ->NewInstance(context)
+ .ToLocalChecked();
+ grandProtoObj->SetPrivate(env.context(),
+ v8::Private::New(
+ isolate, v8_str(isolate, "v8::test-debug::c")),
+ v8::Int32::New(isolate, 13))
.FromJust();
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "grandProtoObj"),
- grandProtoObj);
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "grandProtoObj"), grandProtoObj)
+ .FromJust());
// Setting prototypes: obj->protoObj->grandProtoObj
- protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"),
- grandProtoObj);
- obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj);
+ CHECK(protoObj->Set(context, v8_str(isolate, "__proto__"), grandProtoObj)
+ .FromJust());
+ CHECK(obj->Set(context, v8_str(isolate, "__proto__"), protoObj).FromJust());
// Get mirror for the object with property getter.
CompileRun("var obj_mirror = debug.MakeMirror(obj);");
- CHECK(CompileRun(
- "obj_mirror instanceof debug.ObjectMirror")->BooleanValue());
+ CHECK(CompileRun("obj_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
CompileRun("var named_names = obj_mirror.propertyNames();");
// There should be exactly two properties - one from the object itself and
// another from its hidden prototype.
- CHECK_EQ(2, CompileRun("named_names.length")->Int32Value());
+ CHECK_EQ(2, CompileRun("named_names.length")->Int32Value(context).FromJust());
CHECK(CompileRun("named_names.sort(); named_names[0] == 'a' &&"
- "named_names[1] == 'b'")->BooleanValue());
- CHECK(CompileRun(
- "obj_mirror.property('a').value().value() == 1")->BooleanValue());
- CHECK(CompileRun(
- "obj_mirror.property('b').value().value() == 2")->BooleanValue());
+ "named_names[1] == 'b'")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("obj_mirror.property('a').value().value() == 1")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("obj_mirror.property('b').value().value() == 2")
+ ->BooleanValue(context)
+ .FromJust());
}
@@ -4889,7 +5131,7 @@ class MessageQueueDebuggerThread : public v8::base::Thread {
static void MessageHandler(const v8::Debug::Message& message) {
- v8::Handle<v8::String> json = message.GetJSON();
+ v8::Local<v8::String> json = message.GetJSON();
v8::String::Utf8Value utf8(json);
if (IsBreakEventMessage(*utf8)) {
// Lets test script wait until break occurs to send commands.
@@ -4995,7 +5237,7 @@ TEST(MessageQueues) {
// Create a V8 environment
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetMessageHandler(MessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), MessageHandler);
message_queue_debugger_thread.Start();
const char* source_1 = "a = 3; b = 4; c = new Object(); c.d = 5;";
@@ -5089,7 +5331,7 @@ TEST(SendClientDataToHandler) {
v8::HandleScope scope(isolate);
TestClientData::ResetCounters();
handled_client_data_instances_count = 0;
- v8::Debug::SetMessageHandler(MessageHandlerCountingClientData);
+ v8::Debug::SetMessageHandler(isolate, MessageHandlerCountingClientData);
const char* source_1 = "a = 3; b = 4; c = new Object(); c.d = 5;";
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -5171,7 +5413,7 @@ static void ThreadedMessageHandler(const v8::Debug::Message& message) {
if (IsBreakEventMessage(print_buffer)) {
// Check that we are inside the while loop.
int source_line = GetSourceLineFromBreakEventMessage(print_buffer);
- CHECK(8 <= source_line && source_line <= 13);
+ CHECK(4 <= source_line && source_line <= 10);
threaded_debugging_barriers.barrier_2.Wait();
}
}
@@ -5180,10 +5422,6 @@ static void ThreadedMessageHandler(const v8::Debug::Message& message) {
void V8Thread::Run() {
const char* source =
"flag = true;\n"
- "function bar( new_value ) {\n"
- " flag = new_value;\n"
- " return \"Return from bar(\" + new_value + \")\";\n"
- "}\n"
"\n"
"function foo() {\n"
" var x = 1;\n"
@@ -5205,13 +5443,13 @@ void V8Thread::Run() {
v8::Isolate::Scope isolate_scope(isolate_);
DebugLocalContext env(isolate_);
v8::HandleScope scope(isolate_);
- v8::Debug::SetMessageHandler(&ThreadedMessageHandler);
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Debug::SetMessageHandler(isolate_, &ThreadedMessageHandler);
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(env->GetIsolate());
global_template->Set(
- v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
+ v8_str(env->GetIsolate(), "ThreadedAtBarrier1"),
v8::FunctionTemplate::New(isolate_, ThreadedAtBarrier1));
- v8::Handle<v8::Context> context =
+ v8::Local<v8::Context> context =
v8::Context::New(isolate_, NULL, global_template);
v8::Context::Scope context_scope(context);
@@ -5226,10 +5464,11 @@ void DebuggerThread::Run() {
const int kBufSize = 1000;
uint16_t buffer[kBufSize];
- const char* command_1 = "{\"seq\":102,"
+ const char* command_1 =
+ "{\"seq\":102,"
"\"type\":\"request\","
"\"command\":\"evaluate\","
- "\"arguments\":{\"expression\":\"bar(false)\"}}";
+ "\"arguments\":{\"expression\":\"flag = false\"}}";
const char* command_2 = "{\"seq\":103,"
"\"type\":\"request\","
"\"command\":\"continue\"}";
@@ -5338,7 +5577,7 @@ void BreakpointsV8Thread::Run() {
v8::Isolate::Scope isolate_scope(isolate_);
DebugLocalContext env(isolate_);
v8::HandleScope scope(isolate_);
- v8::Debug::SetMessageHandler(&BreakpointsMessageHandler);
+ v8::Debug::SetMessageHandler(isolate_, &BreakpointsMessageHandler);
CompileRun(source_1);
breakpoints_barriers->barrier_1.Wait();
@@ -5494,7 +5733,7 @@ TEST(RecursiveBreakpointsGlobal) {
TEST(SetDebugEventListenerOnUninitializedVM) {
- v8::Debug::SetDebugEventListener(DummyDebugEventListener);
+ v8::Debug::SetDebugEventListener(CcTest::isolate(), DummyDebugEventListener);
}
@@ -5503,7 +5742,7 @@ static void DummyMessageHandler(const v8::Debug::Message& message) {
TEST(SetMessageHandlerOnUninitializedVM) {
- v8::Debug::SetMessageHandler(DummyMessageHandler);
+ v8::Debug::SetMessageHandler(CcTest::isolate(), DummyMessageHandler);
}
@@ -5515,7 +5754,7 @@ static const char* debugger_call_with_data_source =
" if (data) return data;"
" throw 'No data!'"
"}";
-v8::Handle<v8::Function> debugger_call_with_data;
+v8::Local<v8::Function> debugger_call_with_data;
// Source for a JavaScript function which returns the data parameter of a
@@ -5528,23 +5767,32 @@ static const char* debugger_call_with_closure_source =
" exec_state.y = x;"
" return exec_state.y"
"})";
-v8::Handle<v8::Function> debugger_call_with_closure;
+v8::Local<v8::Function> debugger_call_with_closure;
// Function to retrieve the number of JavaScript frames by calling a JavaScript
// in the debugger.
static void CheckFrameCount(const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK(v8::Debug::Call(frame_count)->IsNumber());
- CHECK_EQ(args[0]->Int32Value(),
- v8::Debug::Call(frame_count)->Int32Value());
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ CHECK(v8::Debug::Call(context, frame_count).ToLocalChecked()->IsNumber());
+ CHECK_EQ(args[0]->Int32Value(context).FromJust(),
+ v8::Debug::Call(context, frame_count)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
}
// Function to retrieve the source line of the top JavaScript frame by calling a
// JavaScript function in the debugger.
static void CheckSourceLine(const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK(v8::Debug::Call(frame_source_line)->IsNumber());
- CHECK_EQ(args[0]->Int32Value(),
- v8::Debug::Call(frame_source_line)->Int32Value());
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ CHECK(
+ v8::Debug::Call(context, frame_source_line).ToLocalChecked()->IsNumber());
+ CHECK_EQ(args[0]->Int32Value(context).FromJust(),
+ v8::Debug::Call(context, frame_source_line)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
}
@@ -5553,13 +5801,15 @@ static void CheckSourceLine(const v8::FunctionCallbackInfo<v8::Value>& args) {
// can throw exceptions.
static void CheckDataParameter(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::Handle<v8::String> data =
- v8::String::NewFromUtf8(args.GetIsolate(), "Test");
- CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString());
+ v8::Local<v8::String> data = v8_str(args.GetIsolate(), "Test");
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ CHECK(v8::Debug::Call(context, debugger_call_with_data, data)
+ .ToLocalChecked()
+ ->IsString());
for (int i = 0; i < 3; i++) {
v8::TryCatch catcher(args.GetIsolate());
- CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
+ CHECK(v8::Debug::Call(context, debugger_call_with_data).IsEmpty());
CHECK(catcher.HasCaught());
CHECK(catcher.Exception()->IsString());
}
@@ -5568,8 +5818,14 @@ static void CheckDataParameter(
// Function to test using a JavaScript with closure in the debugger.
static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber());
- CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value());
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ CHECK(v8::Debug::Call(context, debugger_call_with_closure)
+ .ToLocalChecked()
+ ->IsNumber());
+ CHECK_EQ(3, v8::Debug::Call(context, debugger_call_with_closure)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
}
@@ -5579,94 +5835,122 @@ TEST(CallFunctionInDebugger) {
// CheckSourceLine and CheckDataParameter installed.
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
- global_template->Set(
- v8::String::NewFromUtf8(isolate, "CheckFrameCount"),
- v8::FunctionTemplate::New(isolate, CheckFrameCount));
- global_template->Set(
- v8::String::NewFromUtf8(isolate, "CheckSourceLine"),
- v8::FunctionTemplate::New(isolate, CheckSourceLine));
- global_template->Set(
- v8::String::NewFromUtf8(isolate, "CheckDataParameter"),
- v8::FunctionTemplate::New(isolate, CheckDataParameter));
- global_template->Set(
- v8::String::NewFromUtf8(isolate, "CheckClosure"),
- v8::FunctionTemplate::New(isolate, CheckClosure));
- v8::Handle<v8::Context> context = v8::Context::New(isolate,
- NULL,
- global_template);
+ global_template->Set(v8_str(isolate, "CheckFrameCount"),
+ v8::FunctionTemplate::New(isolate, CheckFrameCount));
+ global_template->Set(v8_str(isolate, "CheckSourceLine"),
+ v8::FunctionTemplate::New(isolate, CheckSourceLine));
+ global_template->Set(v8_str(isolate, "CheckDataParameter"),
+ v8::FunctionTemplate::New(isolate, CheckDataParameter));
+ global_template->Set(v8_str(isolate, "CheckClosure"),
+ v8::FunctionTemplate::New(isolate, CheckClosure));
+ v8::Local<v8::Context> context =
+ v8::Context::New(isolate, NULL, global_template);
v8::Context::Scope context_scope(context);
// Compile a function for checking the number of JavaScript frames.
- v8::Script::Compile(
- v8::String::NewFromUtf8(isolate, frame_count_source))->Run();
- frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get(
- v8::String::NewFromUtf8(isolate, "frame_count")));
+ v8::Script::Compile(context, v8_str(isolate, frame_count_source))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ frame_count = v8::Local<v8::Function>::Cast(
+ context->Global()
+ ->Get(context, v8_str(isolate, "frame_count"))
+ .ToLocalChecked());
// Compile a function for returning the source line for the top frame.
- v8::Script::Compile(v8::String::NewFromUtf8(isolate,
- frame_source_line_source))->Run();
- frame_source_line = v8::Local<v8::Function>::Cast(context->Global()->Get(
- v8::String::NewFromUtf8(isolate, "frame_source_line")));
+ v8::Script::Compile(context, v8_str(isolate, frame_source_line_source))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ frame_source_line = v8::Local<v8::Function>::Cast(
+ context->Global()
+ ->Get(context, v8_str(isolate, "frame_source_line"))
+ .ToLocalChecked());
// Compile a function returning the data parameter.
- v8::Script::Compile(v8::String::NewFromUtf8(isolate,
- debugger_call_with_data_source))
- ->Run();
+ v8::Script::Compile(context, v8_str(isolate, debugger_call_with_data_source))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
debugger_call_with_data = v8::Local<v8::Function>::Cast(
- context->Global()->Get(v8::String::NewFromUtf8(
- isolate, "debugger_call_with_data")));
+ context->Global()
+ ->Get(context, v8_str(isolate, "debugger_call_with_data"))
+ .ToLocalChecked());
// Compile a function capturing closure.
- debugger_call_with_closure =
- v8::Local<v8::Function>::Cast(v8::Script::Compile(
- v8::String::NewFromUtf8(isolate,
- debugger_call_with_closure_source))->Run());
+ debugger_call_with_closure = v8::Local<v8::Function>::Cast(
+ v8::Script::Compile(context,
+ v8_str(isolate, debugger_call_with_closure_source))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked());
// Calling a function through the debugger returns 0 frames if there are
// no JavaScript frames.
- CHECK(v8::Integer::New(isolate, 0)->Equals(v8::Debug::Call(frame_count)));
+ CHECK(v8::Integer::New(isolate, 0)
+ ->Equals(context,
+ v8::Debug::Call(context, frame_count).ToLocalChecked())
+ .FromJust());
// Test that the number of frames can be retrieved.
- v8::Script::Compile(
- v8::String::NewFromUtf8(isolate, "CheckFrameCount(1)"))->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(isolate,
- "function f() {"
- " CheckFrameCount(2);"
- "}; f()"))->Run();
+ v8::Script::Compile(context, v8_str(isolate, "CheckFrameCount(1)"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ v8::Script::Compile(context, v8_str(isolate,
+ "function f() {"
+ " CheckFrameCount(2);"
+ "}; f()"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
// Test that the source line can be retrieved.
- v8::Script::Compile(
- v8::String::NewFromUtf8(isolate, "CheckSourceLine(0)"))->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(isolate,
- "function f() {\n"
- " CheckSourceLine(1)\n"
- " CheckSourceLine(2)\n"
- " CheckSourceLine(3)\n"
- "}; f()"))->Run();
+ v8::Script::Compile(context, v8_str(isolate, "CheckSourceLine(0)"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ v8::Script::Compile(context, v8_str(isolate,
+ "function f() {\n"
+ " CheckSourceLine(1)\n"
+ " CheckSourceLine(2)\n"
+ " CheckSourceLine(3)\n"
+ "}; f()"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
// Test that a parameter can be passed to a function called in the debugger.
- v8::Script::Compile(v8::String::NewFromUtf8(isolate,
- "CheckDataParameter()"))->Run();
+ v8::Script::Compile(context, v8_str(isolate, "CheckDataParameter()"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
// Test that a function with closure can be run in the debugger.
- v8::Script::Compile(
- v8::String::NewFromUtf8(isolate, "CheckClosure()"))->Run();
+ v8::Script::Compile(context, v8_str(isolate, "CheckClosure()"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
// Test that the source line is correct when there is a line offset.
- v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, "test"),
+ v8::ScriptOrigin origin(v8_str(isolate, "test"),
v8::Integer::New(isolate, 7));
- v8::Script::Compile(
- v8::String::NewFromUtf8(isolate, "CheckSourceLine(7)"), &origin)
- ->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(isolate,
- "function f() {\n"
- " CheckSourceLine(8)\n"
- " CheckSourceLine(9)\n"
- " CheckSourceLine(10)\n"
- "}; f()"),
- &origin)->Run();
+ v8::Script::Compile(context, v8_str(isolate, "CheckSourceLine(7)"), &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ v8::Script::Compile(context, v8_str(isolate,
+ "function f() {\n"
+ " CheckSourceLine(8)\n"
+ " CheckSourceLine(9)\n"
+ " CheckSourceLine(10)\n"
+ "}; f()"),
+ &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
}
@@ -5689,11 +5973,13 @@ TEST(DebuggerUnload) {
DebugLocalContext env;
// Check debugger is unloaded before it is used.
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(env->GetIsolate());
// Set a debug event listener.
break_point_hit_count = 0;
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
{
v8::HandleScope scope(env->GetIsolate());
// Create a couple of functions for the test.
@@ -5710,41 +5996,44 @@ TEST(DebuggerUnload) {
// Make sure that the break points are there.
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- bar->Call(env->Global(), 0, NULL);
+ bar->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
}
// Remove the debug event listener without clearing breakpoints. Do this
// outside a handle scope.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded(true);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
// Now set a debug message handler.
break_point_hit_count = 0;
- v8::Debug::SetMessageHandler(MessageHandlerBreakPointHitCount);
+ v8::Debug::SetMessageHandler(env->GetIsolate(),
+ MessageHandlerBreakPointHitCount);
{
v8::HandleScope scope(env->GetIsolate());
// Get the test functions again.
v8::Local<v8::Function> foo(v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "foo"))
+ .ToLocalChecked()));
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Set break points and run again.
SetBreakPoint(foo, 0);
SetBreakPoint(foo, 4);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
}
// Remove the debug message handler without clearing breakpoints. Do this
// outside a handle scope.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded(true);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
}
@@ -5783,10 +6072,10 @@ TEST(DebuggerClearMessageHandler) {
v8::HandleScope scope(env->GetIsolate());
// Check debugger is unloaded before it is used.
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(env->GetIsolate());
// Set a debug message handler.
- v8::Debug::SetMessageHandler(MessageHandlerHitCount);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), MessageHandlerHitCount);
// Run code to throw a unhandled exception. This should end up in the message
// handler.
@@ -5797,7 +6086,7 @@ TEST(DebuggerClearMessageHandler) {
// Clear debug message handler.
message_handler_hit_count = 0;
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
// Run code to throw a unhandled exception. This should end up in the message
// handler.
@@ -5806,7 +6095,7 @@ TEST(DebuggerClearMessageHandler) {
// The message handler should not be called more.
CHECK_EQ(0, message_handler_hit_count);
- CheckDebuggerUnloaded(true);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
}
@@ -5816,7 +6105,7 @@ static void MessageHandlerClearingMessageHandler(
message_handler_hit_count++;
// Clear debug message handler.
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(message.GetIsolate(), nullptr);
}
@@ -5826,10 +6115,11 @@ TEST(DebuggerClearMessageHandlerWhileActive) {
v8::HandleScope scope(env->GetIsolate());
// Check debugger is unloaded before it is used.
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(env->GetIsolate());
// Set a debug message handler.
- v8::Debug::SetMessageHandler(MessageHandlerClearingMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(),
+ MessageHandlerClearingMessageHandler);
// Run code to throw a unhandled exception. This should end up in the message
// handler.
@@ -5838,7 +6128,7 @@ TEST(DebuggerClearMessageHandlerWhileActive) {
// The message handler should be called.
CHECK_EQ(1, message_handler_hit_count);
- CheckDebuggerUnloaded(true);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
}
@@ -5861,12 +6151,12 @@ TEST(DebugGetLoadedScripts) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
+ v8::Local<v8::Context> context = env.context();
EmptyExternalStringResource source_ext_str;
v8::Local<v8::String> source =
- v8::String::NewExternal(env->GetIsolate(), &source_ext_str);
- v8::Handle<v8::Script> evil_script(v8::Script::Compile(source));
- // "use" evil_script to make the compiler happy.
- USE(evil_script);
+ v8::String::NewExternalTwoByte(env->GetIsolate(), &source_ext_str)
+ .ToLocalChecked();
+ CHECK(v8::Script::Compile(context, source).IsEmpty());
Handle<i::ExternalTwoByteString> i_source(
i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source)));
// This situation can happen if source was an external string disposed
@@ -5875,7 +6165,7 @@ TEST(DebugGetLoadedScripts) {
bool allow_natives_syntax = i::FLAG_allow_natives_syntax;
i::FLAG_allow_natives_syntax = true;
- EnableDebugger();
+ EnableDebugger(env->GetIsolate());
v8::MaybeLocal<v8::Value> result =
CompileRun(env.context(),
"var scripts = %DebugGetLoadedScripts();"
@@ -5891,15 +6181,16 @@ TEST(DebugGetLoadedScripts) {
" }"
"}");
CHECK(!result.IsEmpty());
- DisableDebugger();
+ DisableDebugger(env->GetIsolate());
// Must not crash while accessing line_ends.
i::FLAG_allow_natives_syntax = allow_natives_syntax;
// Some scripts are retrieved - at least the number of native scripts.
- CHECK_GT((*env)
- ->Global()
- ->Get(v8::String::NewFromUtf8(env->GetIsolate(), "count"))
- ->Int32Value(),
+ CHECK_GT(env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "count"))
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust(),
8);
}
@@ -5916,63 +6207,82 @@ TEST(ScriptNameAndData) {
frame_script_name_source,
"frame_script_name");
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
// Test function source.
- v8::Local<v8::String> script = v8::String::NewFromUtf8(env->GetIsolate(),
- "function f() {\n"
- " debugger;\n"
- "}\n");
+ v8::Local<v8::String> script = v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " debugger;\n"
+ "}\n");
v8::ScriptOrigin origin1 =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "name"));
- v8::Handle<v8::Script> script1 = v8::Script::Compile(script, &origin1);
- script1->Run();
+ v8::ScriptOrigin(v8_str(env->GetIsolate(), "name"));
+ v8::Local<v8::Script> script1 =
+ v8::Script::Compile(context, script, &origin1).ToLocalChecked();
+ script1->Run(context).ToLocalChecked();
v8::Local<v8::Function> f;
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
CHECK_EQ(0, strcmp("name", last_script_name_hit));
// Compile the same script again without setting data. As the compilation
// cache is disabled when debugging expect the data to be missing.
- v8::Script::Compile(script, &origin1)->Run();
+ v8::Script::Compile(context, script, &origin1)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- f->Call(env->Global(), 0, NULL);
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
CHECK_EQ(0, strcmp("name", last_script_name_hit));
- v8::Local<v8::String> data_obj_source = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "({ a: 'abc',\n"
- " b: 123,\n"
- " toString: function() { return this.a + ' ' + this.b; }\n"
- "})\n");
- v8::Script::Compile(data_obj_source)->Run();
+ v8::Local<v8::String> data_obj_source =
+ v8_str(env->GetIsolate(),
+ "({ a: 'abc',\n"
+ " b: 123,\n"
+ " toString: function() { return this.a + ' ' + this.b; }\n"
+ "})\n");
+ v8::Script::Compile(context, data_obj_source)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::ScriptOrigin origin2 =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "new name"));
- v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2);
- script2->Run();
+ v8::ScriptOrigin(v8_str(env->GetIsolate(), "new name"));
+ v8::Local<v8::Script> script2 =
+ v8::Script::Compile(context, script, &origin2).ToLocalChecked();
+ script2->Run(context).ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- f->Call(env->Global(), 0, NULL);
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(3, break_point_hit_count);
CHECK_EQ(0, strcmp("new name", last_script_name_hit));
- v8::Handle<v8::Script> script3 = v8::Script::Compile(script, &origin2);
- script3->Run();
+ v8::Local<v8::Script> script3 =
+ v8::Script::Compile(context, script, &origin2).ToLocalChecked();
+ script3->Run(context).ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- f->Call(env->Global(), 0, NULL);
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
}
-static v8::Handle<v8::Context> expected_context;
-static v8::Handle<v8::Value> expected_context_data;
+static v8::Local<v8::Context> expected_context;
+static v8::Local<v8::Value> expected_context_data;
// Check that the expected context is the one generating the debug event.
@@ -6001,23 +6311,23 @@ TEST(ContextData) {
v8::HandleScope scope(isolate);
// Create two contexts.
- v8::Handle<v8::Context> context_1;
- v8::Handle<v8::Context> context_2;
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::Handle<v8::ObjectTemplate>();
- v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>();
+ v8::Local<v8::Context> context_1;
+ v8::Local<v8::Context> context_2;
+ v8::Local<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate>();
+ v8::Local<v8::Value> global_object = v8::Local<v8::Value>();
context_1 = v8::Context::New(isolate, NULL, global_template, global_object);
context_2 = v8::Context::New(isolate, NULL, global_template, global_object);
- v8::Debug::SetMessageHandler(ContextCheckMessageHandler);
+ v8::Debug::SetMessageHandler(isolate, ContextCheckMessageHandler);
// Default data value is undefined.
CHECK(context_1->GetEmbedderData(0)->IsUndefined());
CHECK(context_2->GetEmbedderData(0)->IsUndefined());
// Set and check different data values.
- v8::Handle<v8::String> data_1 = v8::String::NewFromUtf8(isolate, "1");
- v8::Handle<v8::String> data_2 = v8::String::NewFromUtf8(isolate, "2");
+ v8::Local<v8::String> data_1 = v8_str(isolate, "1");
+ v8::Local<v8::String> data_2 = v8_str(isolate, "2");
context_1->SetEmbedderData(0, data_1);
context_2->SetEmbedderData(0, data_2);
CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1));
@@ -6032,7 +6342,7 @@ TEST(ContextData) {
expected_context = context_1;
expected_context_data = data_1;
v8::Local<v8::Function> f = CompileFunction(isolate, source, "f");
- f->Call(context_1->Global(), 0, NULL);
+ f->Call(context_1, context_1->Global(), 0, NULL).ToLocalChecked();
}
@@ -6042,14 +6352,14 @@ TEST(ContextData) {
expected_context = context_2;
expected_context_data = data_2;
v8::Local<v8::Function> f = CompileFunction(isolate, source, "f");
- f->Call(context_2->Global(), 0, NULL);
+ f->Call(context_2, context_2->Global(), 0, NULL).ToLocalChecked();
}
// Two times compile event and two times break event.
CHECK_GT(message_handler_hit_count, 4);
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -6078,22 +6388,27 @@ TEST(DebugBreakInMessageHandler) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetMessageHandler(DebugBreakMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), DebugBreakMessageHandler);
+ v8::Local<v8::Context> context = env.context();
// Test functions.
const char* script = "function f() { debugger; g(); } function g() { }";
CompileRun(script);
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "g"))
+ .ToLocalChecked());
// Call f then g. The debugger statement in f will cause a break which will
// cause another break.
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, message_handler_break_hit_count);
// Calling g will not cause any additional breaks.
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, message_handler_break_hit_count);
}
@@ -6104,8 +6419,8 @@ TEST(DebugBreakInMessageHandler) {
static void DebugEventDebugBreak(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
-
+ v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
if (event == v8::Break) {
break_point_hit_count++;
@@ -6113,17 +6428,17 @@ static void DebugEventDebugBreak(
if (!frame_function_name.IsEmpty()) {
// Get the name of the function.
const int argc = 2;
- v8::Handle<v8::Value> argv[argc] = {
- exec_state, v8::Integer::New(CcTest::isolate(), 0)
- };
- v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
- argc, argv);
+ v8::Local<v8::Value> argv[argc] = {
+ exec_state, v8::Integer::New(CcTest::isolate(), 0)};
+ v8::Local<v8::Value> result =
+ frame_function_name->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
if (result->IsUndefined()) {
last_function_hit[0] = '\0';
} else {
CHECK(result->IsString());
- v8::Handle<v8::String> function_name(
- result->ToString(CcTest::isolate()));
+ v8::Local<v8::String> function_name(
+ result->ToString(context).ToLocalChecked());
function_name->WriteUtf8(last_function_hit);
}
}
@@ -6140,7 +6455,7 @@ TEST(RegExpDebugBreak) {
// This test only applies to native regexps.
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
-
+ v8::Local<v8::Context> context = env.context();
// Create a function for checking the function when hitting a break point.
frame_function_name = CompileFunction(&env,
frame_function_name_source,
@@ -6154,14 +6469,15 @@ TEST(RegExpDebugBreak) {
v8::Local<v8::Function> f = CompileFunction(env->GetIsolate(), script, "f");
const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = {
- v8::String::NewFromUtf8(env->GetIsolate(), " /* xxx */ a=0;")};
- v8::Local<v8::Value> result = f->Call(env->Global(), argc, argv);
- CHECK_EQ(12, result->Int32Value());
+ v8::Local<v8::Value> argv[argc] = {
+ v8_str(env->GetIsolate(), " /* xxx */ a=0;")};
+ v8::Local<v8::Value> result =
+ f->Call(context, env->Global(), argc, argv).ToLocalChecked();
+ CHECK_EQ(12, result->Int32Value(context).FromJust());
- v8::Debug::SetDebugEventListener(DebugEventDebugBreak);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventDebugBreak);
v8::Debug::DebugBreak(env->GetIsolate());
- result = f->Call(env->Global(), argc, argv);
+ result = f->Call(context, env->Global(), argc, argv).ToLocalChecked();
// Check that there was only one break event. Matching RegExp should not
// cause Break events.
@@ -6175,20 +6491,19 @@ TEST(RegExpDebugBreak) {
static void ExecuteScriptForContextCheck(
v8::Debug::MessageHandler message_handler) {
// Create a context.
- v8::Handle<v8::Context> context_1;
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::Handle<v8::ObjectTemplate>();
+ v8::Local<v8::Context> context_1;
+ v8::Local<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate>();
context_1 =
v8::Context::New(CcTest::isolate(), NULL, global_template);
- v8::Debug::SetMessageHandler(message_handler);
+ v8::Debug::SetMessageHandler(CcTest::isolate(), message_handler);
// Default data value is undefined.
CHECK(context_1->GetEmbedderData(0)->IsUndefined());
// Set and check a data value.
- v8::Handle<v8::String> data_1 =
- v8::String::NewFromUtf8(CcTest::isolate(), "1");
+ v8::Local<v8::String> data_1 = v8_str(CcTest::isolate(), "1");
context_1->SetEmbedderData(0, data_1);
CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1));
@@ -6201,10 +6516,10 @@ static void ExecuteScriptForContextCheck(
expected_context = context_1;
expected_context_data = data_1;
v8::Local<v8::Function> f = CompileFunction(CcTest::isolate(), source, "f");
- f->Call(context_1->Global(), 0, NULL);
+ f->Call(context_1, context_1->Global(), 0, NULL).ToLocalChecked();
}
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(CcTest::isolate(), nullptr);
}
@@ -6219,7 +6534,7 @@ TEST(EvalContextData) {
// One time compile event and one time break event.
CHECK_GT(message_handler_hit_count, 2);
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(CcTest::isolate());
}
@@ -6287,7 +6602,7 @@ TEST(NestedBreakEventContextData) {
// One break from the source and another from the evaluate request.
CHECK_EQ(break_count, 2);
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(CcTest::isolate());
}
@@ -6310,22 +6625,27 @@ static void AfterCompileMessageHandler(const v8::Debug::Message& message) {
TEST(AfterCompileMessageWhenMessageHandlerIsReset) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
after_compile_message_count = 0;
const char* script = "var a=1";
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
- ->Run();
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
v8::Debug::DebugBreak(env->GetIsolate());
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
- ->Run();
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
// Setting listener to NULL should cause debugger unload.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Compilation cache should be disabled when debugger is active.
CHECK_EQ(2, after_compile_message_count);
@@ -6358,7 +6678,8 @@ TEST(SyntaxErrorMessageOnSyntaxException) {
// For this test, we want to break on uncaught exceptions:
ChangeBreakOnException(false, true);
- v8::Debug::SetDebugEventListener(CompileErrorEventCounter);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), CompileErrorEventCounter);
+ v8::Local<v8::Context> context = env.context();
CompileErrorEventCounterClear();
@@ -6366,24 +6687,29 @@ TEST(SyntaxErrorMessageOnSyntaxException) {
CHECK_EQ(0, compile_error_event_count);
// Throws SyntaxError: Unexpected end of input
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "+++"));
+ CHECK(
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), "+++")).IsEmpty());
CHECK_EQ(1, compile_error_event_count);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "/sel\\/: \\"));
+ CHECK(v8::Script::Compile(context, v8_str(env->GetIsolate(), "/sel\\/: \\"))
+ .IsEmpty());
CHECK_EQ(2, compile_error_event_count);
- v8::Local<v8::Script> script = v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "JSON.parse('1234:')"));
+ v8::Local<v8::Script> script =
+ v8::Script::Compile(context,
+ v8_str(env->GetIsolate(), "JSON.parse('1234:')"))
+ .ToLocalChecked();
CHECK_EQ(2, compile_error_event_count);
- script->Run();
+ CHECK(script->Run(context).IsEmpty());
CHECK_EQ(3, compile_error_event_count);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "new RegExp('/\\/\\\\');"));
+ v8::Script::Compile(context,
+ v8_str(env->GetIsolate(), "new RegExp('/\\/\\\\');"))
+ .ToLocalChecked();
CHECK_EQ(3, compile_error_event_count);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "throw 1;"));
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), "throw 1;"))
+ .ToLocalChecked();
CHECK_EQ(3, compile_error_event_count);
}
@@ -6392,23 +6718,28 @@ TEST(SyntaxErrorMessageOnSyntaxException) {
TEST(BreakMessageWhenMessageHandlerIsReset) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
after_compile_message_count = 0;
const char* script = "function f() {};";
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
- ->Run();
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
v8::Debug::DebugBreak(env->GetIsolate());
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- f->Call(env->Global(), 0, NULL);
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Setting message handler to NULL should cause debugger unload.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Compilation cache should be disabled when debugger is active.
CHECK_EQ(1, after_compile_message_count);
@@ -6429,25 +6760,30 @@ TEST(ExceptionMessageWhenMessageHandlerIsReset) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
// For this test, we want to break on uncaught exceptions:
ChangeBreakOnException(false, true);
exception_event_count = 0;
const char* script = "function f() {throw new Error()};";
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
- ->Run();
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
- v8::Debug::SetMessageHandler(ExceptionMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), ExceptionMessageHandler);
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- f->Call(env->Global(), 0, NULL);
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
+ CHECK(f->Call(context, env->Global(), 0, NULL).IsEmpty());
// Setting message handler to NULL should cause debugger unload.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
CHECK_EQ(1, exception_event_count);
}
@@ -6462,7 +6798,8 @@ TEST(ProvisionalBreakpointOnLineOutOfRange) {
const char* script = "function f() {};";
const char* resource_name = "test_resource";
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
+ v8::Local<v8::Context> context = env.context();
// Set a couple of provisional breakpoint on lines out of the script lines
// range.
@@ -6473,14 +6810,15 @@ TEST(ProvisionalBreakpointOnLineOutOfRange) {
after_compile_message_count = 0;
- v8::ScriptOrigin origin(
- v8::String::NewFromUtf8(env->GetIsolate(), resource_name),
- v8::Integer::New(env->GetIsolate(), 10),
- v8::Integer::New(env->GetIsolate(), 1));
+ v8::ScriptOrigin origin(v8_str(env->GetIsolate(), resource_name),
+ v8::Integer::New(env->GetIsolate(), 10),
+ v8::Integer::New(env->GetIsolate(), 1));
// Compile a script whose first line number is greater than the breakpoints'
// lines.
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script),
- &origin)->Run();
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), script), &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
// If the script is compiled successfully there is exactly one after compile
// event. In case of an exception in debugger code after compile event is not
@@ -6489,7 +6827,7 @@ TEST(ProvisionalBreakpointOnLineOutOfRange) {
ClearBreakPointFromJS(env->GetIsolate(), sbp1);
ClearBreakPointFromJS(env->GetIsolate(), sbp2);
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
}
@@ -6521,9 +6859,10 @@ static void BreakMessageHandler(const v8::Debug::Message& message) {
TEST(NoDebugBreakInAfterCompileMessageHandler) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetMessageHandler(BreakMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), BreakMessageHandler);
// Set the debug break flag.
v8::Debug::DebugBreak(env->GetIsolate());
@@ -6537,13 +6876,13 @@ TEST(NoDebugBreakInAfterCompileMessageHandler) {
// Set the debug break flag again.
v8::Debug::DebugBreak(env->GetIsolate());
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// There should be one more break event when the script is evaluated in 'f'.
CHECK_EQ(2, break_point_hit_count);
// Get rid of the debug message handler.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -6562,7 +6901,7 @@ TEST(ProcessDebugMessages) {
counting_message_handler_counter = 0;
- v8::Debug::SetMessageHandler(CountingMessageHandler);
+ v8::Debug::SetMessageHandler(isolate, CountingMessageHandler);
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -6576,7 +6915,7 @@ TEST(ProcessDebugMessages) {
isolate, buffer, AsciiToUtf16(scripts_command, buffer));
CHECK_EQ(0, counting_message_handler_counter);
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
// At least one message should come
CHECK_GE(counting_message_handler_counter, 1);
@@ -6587,13 +6926,13 @@ TEST(ProcessDebugMessages) {
v8::Debug::SendCommand(
isolate, buffer, AsciiToUtf16(scripts_command, buffer));
CHECK_EQ(0, counting_message_handler_counter);
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
// At least two messages should come
CHECK_GE(counting_message_handler_counter, 2);
// Get rid of the debug message handler.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -6639,7 +6978,7 @@ class SendCommandThread : public v8::base::Thread {
timer.Elapsed().InMillisecondsF());
}
- v8::V8::TerminateExecution(isolate_);
+ isolate_->TerminateExecution();
}
void StartSending() { semaphore_.Signal(); }
@@ -6660,24 +6999,28 @@ TEST(ProcessDebugMessagesThreaded) {
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
counting_message_handler_counter = 0;
v8::Debug::SetMessageHandler(
- SendCommandThread::CountingAndSignallingMessageHandler);
+ isolate, SendCommandThread::CountingAndSignallingMessageHandler);
send_command_thread_ = new SendCommandThread(isolate);
send_command_thread_->Start();
- v8::Handle<v8::FunctionTemplate> start =
+ v8::Local<v8::FunctionTemplate> start =
v8::FunctionTemplate::New(isolate, StartSendingCommands);
- env->Global()->Set(v8_str("start"), start->GetFunction());
+ CHECK(env->Global()
+ ->Set(context, v8_str("start"),
+ start->GetFunction(context).ToLocalChecked())
+ .FromJust());
CompileRun("start(); while (true) { }");
CHECK_EQ(20, counting_message_handler_counter);
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -6703,8 +7046,9 @@ TEST(Backtrace) {
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
- v8::Debug::SetMessageHandler(BacktraceData::MessageHandler);
+ v8::Debug::SetMessageHandler(isolate, BacktraceData::MessageHandler);
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -6720,12 +7064,11 @@ TEST(Backtrace) {
buffer,
AsciiToUtf16(scripts_command, buffer),
NULL);
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
CHECK_EQ(BacktraceData::frame_counter, 0);
- v8::Handle<v8::String> void0 =
- v8::String::NewFromUtf8(env->GetIsolate(), "void(0)");
- v8::Handle<v8::Script> script = CompileWithOrigin(void0, void0);
+ v8::Local<v8::String> void0 = v8_str(env->GetIsolate(), "void(0)");
+ v8::Local<v8::Script> script = CompileWithOrigin(void0, void0);
// Check backtrace from "void(0)" script.
BacktraceData::frame_counter = -10;
@@ -6734,12 +7077,12 @@ TEST(Backtrace) {
buffer,
AsciiToUtf16(scripts_command, buffer),
NULL);
- script->Run();
+ script->Run(context).ToLocalChecked();
CHECK_EQ(BacktraceData::frame_counter, 1);
// Get rid of the debug message handler.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -6747,19 +7090,23 @@ TEST(GetMirror) {
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::Value> obj =
- v8::Debug::GetMirror(v8::String::NewFromUtf8(isolate, "hodja"));
+ v8::Local<v8::Context> context = env.context();
+ v8::Local<v8::Value> obj =
+ v8::Debug::GetMirror(context, v8_str(isolate, "hodja")).ToLocalChecked();
v8::ScriptCompiler::Source source(v8_str(
"function runTest(mirror) {"
" return mirror.isString() && (mirror.length() == 5);"
"}"
""
"runTest;"));
- v8::Handle<v8::Function> run_test = v8::Handle<v8::Function>::Cast(
- v8::ScriptCompiler::CompileUnbound(isolate, &source)
+ v8::Local<v8::Function> run_test = v8::Local<v8::Function>::Cast(
+ v8::ScriptCompiler::CompileUnboundScript(isolate, &source)
+ .ToLocalChecked()
->BindToCurrentContext()
- ->Run());
- v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj);
+ ->Run(context)
+ .ToLocalChecked());
+ v8::Local<v8::Value> result =
+ run_test->Call(context, env->Global(), 1, &obj).ToLocalChecked();
CHECK(result->IsTrue());
}
@@ -6768,6 +7115,7 @@ TEST(GetMirror) {
TEST(DebugBreakFunctionApply) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing breaking in apply.
v8::Local<v8::Function> foo = CompileFunction(
@@ -6778,7 +7126,7 @@ TEST(DebugBreakFunctionApply) {
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakMax);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax);
// Set the debug break flag before calling the code using function.apply.
v8::Debug::DebugBreak(env->GetIsolate());
@@ -6787,18 +7135,18 @@ TEST(DebugBreakFunctionApply) {
// where this test would enter an infinite loop.
break_point_hit_count = 0;
max_break_point_hit_count = 10000; // 10000 => infinite loop.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// When keeping the debug break several break will happen.
CHECK_GT(break_point_hit_count, 1);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
-v8::Handle<v8::Context> debugee_context;
-v8::Handle<v8::Context> debugger_context;
+v8::Local<v8::Context> debugee_context;
+v8::Local<v8::Context> debugger_context;
// Property getter that checks that current and calling contexts
@@ -6807,7 +7155,7 @@ static void NamedGetterWithCallingContextCheck(
v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK_EQ(0, strcmp(*v8::String::Utf8Value(name), "a"));
- v8::Handle<v8::Context> current = info.GetIsolate()->GetCurrentContext();
+ v8::Local<v8::Context> current = info.GetIsolate()->GetCurrentContext();
CHECK(current == debugee_context);
CHECK(current != debugger_context);
info.GetReturnValue().Set(1);
@@ -6820,18 +7168,19 @@ static void NamedGetterWithCallingContextCheck(
static void DebugEventGetAtgumentPropertyValue(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
if (event == v8::Break) {
break_point_hit_count++;
CHECK(debugger_context == CcTest::isolate()->GetCurrentContext());
- v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(CompileRun(
+ v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(CompileRun(
"(function(exec_state) {\n"
" return (exec_state.frame(0).argumentValue(0).property('a').\n"
" value().value() == 1);\n"
"})"));
const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = { exec_state };
- v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv);
+ v8::Local<v8::Value> argv[argc] = {exec_state};
+ v8::Local<v8::Value> result =
+ func->Call(debugger_context, exec_state, argc, argv).ToLocalChecked();
CHECK(result->IsTrue());
}
}
@@ -6851,14 +7200,15 @@ TEST(CallingContextIsNotDebugContext) {
debugger_context = v8::Utils::ToLocal(debug->debug_context());
// Create object with 'a' property accessor.
- v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
- named->SetAccessor(v8::String::NewFromUtf8(isolate, "a"),
- NamedGetterWithCallingContextCheck);
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"),
- named->NewInstance());
+ v8::Local<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
+ named->SetAccessor(v8_str(isolate, "a"), NamedGetterWithCallingContextCheck);
+ CHECK(env->Global()
+ ->Set(debugee_context, v8_str(isolate, "obj"),
+ named->NewInstance(debugee_context).ToLocalChecked())
+ .FromJust());
// Register the debug event listener
- v8::Debug::SetDebugEventListener(DebugEventGetAtgumentPropertyValue);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventGetAtgumentPropertyValue);
// Create a function that invokes debugger.
v8::Local<v8::Function> foo = CompileFunction(
@@ -6868,38 +7218,44 @@ TEST(CallingContextIsNotDebugContext) {
"foo");
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(debugee_context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- debugee_context = v8::Handle<v8::Context>();
- debugger_context = v8::Handle<v8::Context>();
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ debugee_context = v8::Local<v8::Context>();
+ debugger_context = v8::Local<v8::Context>();
+ CheckDebuggerUnloaded(isolate);
}
TEST(DebugContextIsPreservedBetweenAccesses) {
v8::HandleScope scope(CcTest::isolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext();
- v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext();
+ v8::Debug::SetDebugEventListener(CcTest::isolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context1 =
+ v8::Debug::GetDebugContext(CcTest::isolate());
+ v8::Local<v8::Context> context2 =
+ v8::Debug::GetDebugContext(CcTest::isolate());
CHECK(v8::Utils::OpenHandle(*context1).is_identical_to(
v8::Utils::OpenHandle(*context2)));
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr);
}
TEST(NoDebugContextWhenDebuggerDisabled) {
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Context> context = v8::Debug::GetDebugContext();
+ v8::Local<v8::Context> context =
+ v8::Debug::GetDebugContext(CcTest::isolate());
CHECK(context.IsEmpty());
}
-static v8::Handle<v8::Value> expected_callback_data;
+static v8::Local<v8::Value> expected_callback_data;
static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
CHECK(details.GetEventContext() == expected_context);
- CHECK(expected_callback_data->Equals(details.GetCallbackData()));
+ CHECK(expected_callback_data->Equals(details.GetEventContext(),
+ details.GetCallbackData())
+ .FromJust());
}
@@ -6909,15 +7265,18 @@ TEST(DebugEventContext) {
v8::HandleScope scope(isolate);
expected_context = v8::Context::New(isolate);
expected_callback_data = v8::Int32::New(isolate, 2010);
- v8::Debug::SetDebugEventListener(DebugEventContextChecker,
- expected_callback_data);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventContextChecker,
+ expected_callback_data);
v8::Context::Scope context_scope(expected_context);
- v8::Script::Compile(
- v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run();
+ v8::Script::Compile(expected_context,
+ v8_str(isolate, "(function(){debugger;})();"))
+ .ToLocalChecked()
+ ->Run(expected_context)
+ .ToLocalChecked();
expected_context.Clear();
- v8::Debug::SetDebugEventListener(NULL);
- expected_context_data = v8::Handle<v8::Value>();
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ expected_context_data = v8::Local<v8::Value>();
+ CheckDebuggerUnloaded(isolate);
}
@@ -6926,21 +7285,22 @@ static bool debug_event_break_deoptimize_done = false;
static void DebugEventBreakDeoptimize(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
if (event == v8::Break) {
if (!frame_function_name.IsEmpty()) {
// Get the name of the function.
const int argc = 2;
- v8::Handle<v8::Value> argv[argc] = {
- exec_state, v8::Integer::New(CcTest::isolate(), 0)
- };
- v8::Handle<v8::Value> result =
- frame_function_name->Call(exec_state, argc, argv);
+ v8::Local<v8::Value> argv[argc] = {
+ exec_state, v8::Integer::New(CcTest::isolate(), 0)};
+ v8::Local<v8::Value> result =
+ frame_function_name->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
if (!result->IsUndefined()) {
char fn[80];
CHECK(result->IsString());
- v8::Handle<v8::String> function_name(
- result->ToString(CcTest::isolate()));
+ v8::Local<v8::String> function_name(
+ result->ToString(context).ToLocalChecked());
function_name->WriteUtf8(fn);
if (strcmp(fn, "bar") == 0) {
i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate());
@@ -6960,6 +7320,7 @@ TEST(DeoptimizeDuringDebugBreak) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
+ v8::Local<v8::Context> context = env.context();
// Create a function for checking the function when hitting a break point.
frame_function_name = CompileFunction(&env,
@@ -6971,19 +7332,20 @@ TEST(DeoptimizeDuringDebugBreak) {
// This tests lazy deoptimization bailout for the stack check, as the first
// time in function bar when using debug break and no break points will be at
// the initial stack check.
- v8::Debug::SetDebugEventListener(DebugEventBreakDeoptimize);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakDeoptimize);
// Compile and run function bar which will optimize it for some flag settings.
v8::Local<v8::Function> f = CompileFunction(&env, "function bar(){}", "bar");
- f->Call(v8::Undefined(env->GetIsolate()), 0, NULL);
+ f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked();
// Set debug break and call bar again.
v8::Debug::DebugBreak(env->GetIsolate());
- f->Call(v8::Undefined(env->GetIsolate()), 0, NULL);
+ f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked();
CHECK(debug_event_break_deoptimize_done);
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
}
@@ -6991,46 +7353,58 @@ static void DebugEventBreakWithOptimizedStack(
const v8::Debug::EventDetails& event_details) {
v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate();
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (event == v8::Break) {
if (!frame_function_name.IsEmpty()) {
for (int i = 0; i < 2; i++) {
const int argc = 2;
- v8::Handle<v8::Value> argv[argc] = {
- exec_state, v8::Integer::New(isolate, i)
- };
+ v8::Local<v8::Value> argv[argc] = {exec_state,
+ v8::Integer::New(isolate, i)};
// Get the name of the function in frame i.
- v8::Handle<v8::Value> result =
- frame_function_name->Call(exec_state, argc, argv);
+ v8::Local<v8::Value> result =
+ frame_function_name->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
CHECK(result->IsString());
- v8::Handle<v8::String> function_name(result->ToString(isolate));
- CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop")));
+ v8::Local<v8::String> function_name(
+ result->ToString(context).ToLocalChecked());
+ CHECK(
+ function_name->Equals(context, v8_str(isolate, "loop")).FromJust());
// Get the name of the first argument in frame i.
- result = frame_argument_name->Call(exec_state, argc, argv);
+ result = frame_argument_name->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
CHECK(result->IsString());
- v8::Handle<v8::String> argument_name(result->ToString(isolate));
- CHECK(argument_name->Equals(v8::String::NewFromUtf8(isolate, "count")));
+ v8::Local<v8::String> argument_name(
+ result->ToString(context).ToLocalChecked());
+ CHECK(argument_name->Equals(context, v8_str(isolate, "count"))
+ .FromJust());
// Get the value of the first argument in frame i. If the
// funtion is optimized the value will be undefined, otherwise
// the value will be '1 - i'.
//
// TODO(3141533): We should be able to get the real value for
// optimized frames.
- result = frame_argument_value->Call(exec_state, argc, argv);
- CHECK(result->IsUndefined() || (result->Int32Value() == 1 - i));
+ result = frame_argument_value->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
+ CHECK(result->IsUndefined() ||
+ (result->Int32Value(context).FromJust() == 1 - i));
// Get the name of the first local variable.
- result = frame_local_name->Call(exec_state, argc, argv);
+ result = frame_local_name->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
CHECK(result->IsString());
- v8::Handle<v8::String> local_name(result->ToString(isolate));
- CHECK(local_name->Equals(v8::String::NewFromUtf8(isolate, "local")));
+ v8::Local<v8::String> local_name(
+ result->ToString(context).ToLocalChecked());
+ CHECK(local_name->Equals(context, v8_str(isolate, "local")).FromJust());
// Get the value of the first local variable. If the function
// is optimized the value will be undefined, otherwise it will
// be 42.
//
// TODO(3141533): We should be able to get the real value for
// optimized frames.
- result = frame_local_value->Call(exec_state, argc, argv);
- CHECK(result->IsUndefined() || (result->Int32Value() == 42));
+ result = frame_local_value->Call(context, exec_state, argc, argv)
+ .ToLocalChecked();
+ CHECK(result->IsUndefined() ||
+ (result->Int32Value(context).FromJust() == 42));
}
}
}
@@ -7038,7 +7412,8 @@ static void DebugEventBreakWithOptimizedStack(
static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::Debug::SetDebugEventListener(DebugEventBreakWithOptimizedStack);
+ v8::Debug::SetDebugEventListener(args.GetIsolate(),
+ DebugEventBreakWithOptimizedStack);
v8::Debug::DebugBreak(args.GetIsolate());
}
@@ -7046,6 +7421,7 @@ static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(DebugBreakStackInspection) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
frame_function_name =
CompileFunction(&env, frame_function_name_source, "frame_function_name");
@@ -7059,11 +7435,13 @@ TEST(DebugBreakStackInspection) {
frame_local_value =
CompileFunction(&env, frame_local_value_source, "frame_local_value");
- v8::Handle<v8::FunctionTemplate> schedule_break_template =
+ v8::Local<v8::FunctionTemplate> schedule_break_template =
v8::FunctionTemplate::New(env->GetIsolate(), ScheduleBreak);
- v8::Handle<v8::Function> schedule_break =
- schedule_break_template->GetFunction();
- env->Global()->Set(v8_str("scheduleBreak"), schedule_break);
+ v8::Local<v8::Function> schedule_break =
+ schedule_break_template->GetFunction(context).ToLocalChecked();
+ CHECK(env->Global()
+ ->Set(context, v8_str("scheduleBreak"), schedule_break)
+ .FromJust());
const char* src =
"function loop(count) {"
@@ -7071,7 +7449,10 @@ TEST(DebugBreakStackInspection) {
" if (count < 1) { scheduleBreak(); loop(count + 1); }"
"}"
"loop(0);";
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), src))->Run();
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), src))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
}
@@ -7112,7 +7493,7 @@ static void TestDebugBreakInLoop(const char* loop_head,
CompileRun("f();");
CHECK_EQ(kBreaksPerTest, break_point_hit_count);
- CHECK(!v8::V8::IsExecutionTerminating());
+ CHECK(!CcTest::isolate()->IsExecutionTerminating());
}
}
}
@@ -7142,7 +7523,7 @@ void DebugBreakLoop(const char* loop_header, const char** loop_bodies,
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakMax);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax);
CompileRun(
"var a = 1;\n"
@@ -7152,8 +7533,8 @@ void DebugBreakLoop(const char* loop_header, const char** loop_bodies,
TestDebugBreakInLoop(loop_header, loop_bodies, loop_footer);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -7218,6 +7599,7 @@ v8::Local<v8::Script> inline_script;
static void DebugBreakInlineListener(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
+ v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
if (event != v8::Break) return;
int expected_frame_count = 4;
@@ -7233,7 +7615,7 @@ static void DebugBreakInlineListener(
SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id);
v8::Local<v8::Value> result = CompileRun(script);
- int frame_count = result->Int32Value();
+ int frame_count = result->Int32Value(context).FromJust();
CHECK_EQ(expected_frame_count, frame_count);
for (int i = 0; i < frame_count; i++) {
@@ -7242,10 +7624,11 @@ static void DebugBreakInlineListener(
SNPrintF(script_vector, "%%GetFrameDetails(%d, %d)[5]", break_id, i);
v8::Local<v8::Value> result = CompileRun(script);
CHECK_EQ(expected_line_number[i],
- i::Script::GetLineNumber(source_script, result->Int32Value()));
+ i::Script::GetLineNumber(source_script,
+ result->Int32Value(context).FromJust()));
}
- v8::Debug::SetDebugEventListener(NULL);
- v8::V8::TerminateExecution(CcTest::isolate());
+ v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr);
+ CcTest::isolate()->TerminateExecution();
}
@@ -7253,6 +7636,7 @@ TEST(DebugBreakInline) {
i::FLAG_allow_natives_syntax = true;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
const char* source =
"function debug(b) { \n"
" if (b) debugger; \n"
@@ -7267,10 +7651,11 @@ TEST(DebugBreakInline) {
"g(false); \n"
"%OptimizeFunctionOnNextCall(g); \n"
"g(true);";
- v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugBreakInlineListener);
inline_script =
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source));
- inline_script->Run();
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), source))
+ .ToLocalChecked();
+ inline_script->Run(context).ToLocalChecked();
}
@@ -7301,7 +7686,7 @@ TEST(Regress131642) {
// on the stack.
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventStepNext);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepNext);
// We step through the first script. It exits through an exception. We run
// this inside a new frame to record a different FP than the second script
@@ -7313,7 +7698,7 @@ TEST(Regress131642) {
const char* script_2 = "[0].forEach(function() { });";
CompileRun(script_2);
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
}
@@ -7335,15 +7720,15 @@ TEST(DebuggerCreatesContextIffActive) {
v8::HandleScope scope(env->GetIsolate());
CHECK_EQ(1, v8::internal::CountNativeContexts());
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
CompileRun("debugger;");
CHECK_EQ(1, v8::internal::CountNativeContexts());
- v8::Debug::SetDebugEventListener(NopListener);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), NopListener);
CompileRun("debugger;");
CHECK_EQ(2, v8::internal::CountNativeContexts());
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
}
@@ -7373,7 +7758,7 @@ TEST(PrecompiledFunction) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugBreakInlineListener);
v8::Local<v8::Function> break_here =
CompileFunction(&env, "function break_here(){}", "break_here");
@@ -7395,8 +7780,8 @@ TEST(PrecompiledFunction) {
v8::String::Utf8Value utf8(result);
CHECK_EQ(0, strcmp("bar", *utf8));
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -7414,12 +7799,16 @@ static void AddDebugBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(DebugBreakStackTrace) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugBreakStackTraceListener);
- v8::Handle<v8::FunctionTemplate> add_debug_break_template =
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugBreakStackTraceListener);
+ v8::Local<v8::Context> context = env.context();
+ v8::Local<v8::FunctionTemplate> add_debug_break_template =
v8::FunctionTemplate::New(env->GetIsolate(), AddDebugBreak);
- v8::Handle<v8::Function> add_debug_break =
- add_debug_break_template->GetFunction();
- env->Global()->Set(v8_str("add_debug_break"), add_debug_break);
+ v8::Local<v8::Function> add_debug_break =
+ add_debug_break_template->GetFunction(context).ToLocalChecked();
+ CHECK(env->Global()
+ ->Set(context, v8_str("add_debug_break"), add_debug_break)
+ .FromJust());
CompileRun("(function loop() {"
" for (var j = 0; j < 1000; j++) {"
@@ -7453,7 +7842,7 @@ class TerminationThread : public v8::base::Thread {
virtual void Run() {
terminate_requested_semaphore.Wait();
- v8::V8::TerminateExecution(isolate_);
+ isolate_->TerminateExecution();
terminate_fired_semaphore.Signal();
}
@@ -7466,7 +7855,7 @@ TEST(DebugBreakOffThreadTerminate) {
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate);
+ v8::Debug::SetDebugEventListener(isolate, DebugBreakTriggerTerminate);
TerminationThread terminator(isolate);
terminator.Start();
v8::TryCatch try_catch(env->GetIsolate());
@@ -7495,19 +7884,23 @@ TEST(DebugPromiseInterceptedByTryCatch) {
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(&DebugEventExpectNoException);
+ v8::Debug::SetDebugEventListener(isolate, &DebugEventExpectNoException);
+ v8::Local<v8::Context> context = env.context();
ChangeBreakOnException(false, true);
- v8::Handle<v8::FunctionTemplate> fun =
+ v8::Local<v8::FunctionTemplate> fun =
v8::FunctionTemplate::New(isolate, TryCatchWrappedThrowCallback);
- env->Global()->Set(v8_str("fun"), fun->GetFunction());
+ CHECK(env->Global()
+ ->Set(context, v8_str("fun"),
+ fun->GetFunction(context).ToLocalChecked())
+ .FromJust());
CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });");
CompileRun(
"var r;"
"p.chain(function() { r = 'resolved'; },"
" function() { r = 'rejected'; });");
- CHECK(CompileRun("r")->Equals(v8_str("resolved")));
+ CHECK(CompileRun("r")->Equals(context, v8_str("resolved")).FromJust());
}
@@ -7530,36 +7923,46 @@ TEST(DebugPromiseRejectedByCallback) {
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(&DebugEventCountException);
+ v8::Debug::SetDebugEventListener(isolate, &DebugEventCountException);
+ v8::Local<v8::Context> context = env.context();
ChangeBreakOnException(false, true);
exception_event_counter = 0;
- v8::Handle<v8::FunctionTemplate> fun =
+ v8::Local<v8::FunctionTemplate> fun =
v8::FunctionTemplate::New(isolate, ThrowCallback);
- env->Global()->Set(v8_str("fun"), fun->GetFunction());
+ CHECK(env->Global()
+ ->Set(context, v8_str("fun"),
+ fun->GetFunction(context).ToLocalChecked())
+ .FromJust());
CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });");
CompileRun(
"var r;"
"p.chain(function() { r = 'resolved'; },"
" function(e) { r = 'rejected' + e; });");
- CHECK(CompileRun("r")->Equals(v8_str("rejectedrejection")));
+ CHECK(
+ CompileRun("r")->Equals(context, v8_str("rejectedrejection")).FromJust());
CHECK_EQ(1, exception_event_counter);
}
TEST(DebugBreakOnExceptionInObserveCallback) {
+ i::FLAG_harmony_object_observe = true;
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(&DebugEventCountException);
+ v8::Debug::SetDebugEventListener(isolate, &DebugEventCountException);
+ v8::Local<v8::Context> context = env.context();
// Break on uncaught exception
ChangeBreakOnException(false, true);
exception_event_counter = 0;
- v8::Handle<v8::FunctionTemplate> fun =
+ v8::Local<v8::FunctionTemplate> fun =
v8::FunctionTemplate::New(isolate, ThrowCallback);
- env->Global()->Set(v8_str("fun"), fun->GetFunction());
+ CHECK(env->Global()
+ ->Set(context, v8_str("fun"),
+ fun->GetFunction(context).ToLocalChecked())
+ .FromJust());
CompileRun(
"var obj = {};"
@@ -7569,7 +7972,7 @@ TEST(DebugBreakOnExceptionInObserveCallback) {
" throw Error('foo');"
"});"
"obj.prop = 1");
- CHECK(CompileRun("callbackRan")->BooleanValue());
+ CHECK(CompileRun("callbackRan")->BooleanValue(context).FromJust());
CHECK_EQ(1, exception_event_counter);
}
@@ -7612,7 +8015,7 @@ TEST(DebugBreakInLexicalScopes) {
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(DebugHarmonyScopingListener);
+ v8::Debug::SetDebugEventListener(isolate, DebugHarmonyScopingListener);
CompileRun(
"'use strict'; \n"
@@ -7650,6 +8053,6 @@ static void NoInterruptsOnDebugEvent(
TEST(NoInterruptsInDebugListener) {
DebugLocalContext env;
- v8::Debug::SetDebugEventListener(NoInterruptsOnDebugEvent);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), NoInterruptsOnDebugEvent);
CompileRun("void(0);");
}