| Index: test/cctest/test-debug.cc
|
| diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
|
| index e1e928f43a9f4785dc37d3f03329e301cec2b1a1..a1a9471e986b61281409010c182fcf5af730af6b 100644
|
| --- a/test/cctest/test-debug.cc
|
| +++ b/test/cctest/test-debug.cc
|
| @@ -25,6 +25,9 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| +// TODO(jochen): Remove this after the setting is turned on globally.
|
| +#define V8_IMMINENT_DEPRECATION_WARNINGS
|
| +
|
| #include <stdlib.h>
|
|
|
| #include "src/v8.h"
|
| @@ -73,9 +76,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 +86,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)) {
|
| @@ -127,31 +130,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 +176,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 +192,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 +215,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 +242,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 +266,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 +277,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 +288,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 +300,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 +312,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 +328,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()");
|
| }
|
| }
|
|
|
| @@ -520,7 +509,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 +528,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 +541,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 +558,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 +607,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 +619,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 +634,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 +648,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 +677,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 +695,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 +706,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 +726,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 +771,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 +781,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 +871,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 +893,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++;
|
| }
|
|
|
| @@ -946,25 +947,23 @@ TEST(BreakPointICStore) {
|
| 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::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);
|
| @@ -978,28 +977,25 @@ TEST(BreakPointICLoad) {
|
| 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")));
|
| +
|
| + 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);
|
| @@ -1013,27 +1009,24 @@ TEST(BreakPointICCall) {
|
| 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")));
|
| + 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);
|
| @@ -1047,29 +1040,34 @@ TEST(BreakPointICCallWithGC) {
|
| 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")));
|
| + 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);
|
| @@ -1083,29 +1081,34 @@ TEST(BreakPointConstructCallWithGC) {
|
| 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")));
|
| + 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);
|
| @@ -1130,29 +1133,28 @@ TEST(BreakPointReturn) {
|
|
|
|
|
| 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::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);
|
| @@ -1160,13 +1162,13 @@ TEST(BreakPointReturn) {
|
| }
|
|
|
|
|
| -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,6 +1179,7 @@ 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::Local<v8::Function> foo;
|
| @@ -1184,27 +1187,27 @@ TEST(GCDuringBreakPointProcessing) {
|
| // 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();
|
| @@ -1213,23 +1216,23 @@ TEST(GCDuringBreakPointProcessing) {
|
|
|
| // 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,6 +1243,7 @@ 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::Local<v8::Function> foo;
|
| @@ -1250,7 +1254,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 +1262,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 +1272,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 +1280,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,7 +1288,7 @@ 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);
|
| @@ -1296,49 +1300,47 @@ 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
|
| + 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);
|
| @@ -1355,92 +1357,95 @@ 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::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);
|
| @@ -1459,73 +1464,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::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 +1540,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,9 +1552,9 @@ 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);
|
| @@ -1568,53 +1574,59 @@ 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::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);
|
| @@ -1631,22 +1643,26 @@ TEST(ConditionalScriptBreakPoint) {
|
|
|
| v8::Debug::SetDebugEventListener(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,29 +1670,34 @@ 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);
|
|
|
| @@ -1694,18 +1715,22 @@ TEST(ScriptBreakPointIgnoreCount) {
|
|
|
| v8::Debug::SetDebugEventListener(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,26 +1738,31 @@ 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);
|
|
|
| @@ -1750,54 +1780,67 @@ TEST(ScriptBreakPointReload) {
|
|
|
| v8::Debug::SetDebugEventListener(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);
|
| @@ -1814,39 +1857,47 @@ TEST(ScriptBreakPointMultiple) {
|
|
|
| v8::Debug::SetDebugEventListener(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 +1905,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,9 +1915,9 @@ 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);
|
| @@ -1883,18 +1934,18 @@ TEST(ScriptBreakPointLineOffset) {
|
|
|
| v8::Debug::SetDebugEventListener(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 +1954,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 +1974,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,7 +1982,7 @@ 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);
|
| @@ -1947,23 +2003,24 @@ TEST(ScriptBreakPointLine) {
|
|
|
| v8::Debug::SetDebugEventListener(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 +2032,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 +2067,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 +2079,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 +2098,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,7 +2111,10 @@ 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);
|
| @@ -2058,19 +2130,22 @@ TEST(ScriptBreakPointLineTopLevel) {
|
|
|
| v8::Debug::SetDebugEventListener(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 +2153,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,7 +2164,9 @@ 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);
|
| @@ -2106,12 +2183,11 @@ TEST(ScriptBreakPointTopLevelCrash) {
|
|
|
| v8::Debug::SetDebugEventListener(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);
|
| @@ -2138,6 +2214,7 @@ 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");
|
|
|
| @@ -2147,11 +2224,11 @@ TEST(RemoveBreakPointInBreak) {
|
| 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);
|
| @@ -2165,23 +2242,32 @@ TEST(DebuggerStatement) {
|
| DebugLocalContext env;
|
| v8::HandleScope scope(env->GetIsolate());
|
| v8::Debug::SetDebugEventListener(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 bar(){debugger}"))
|
| - ->Run();
|
| - 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);
|
| @@ -2194,21 +2280,26 @@ TEST(DebuggerStatementBreakpoint) {
|
| break_point_hit_count = 0;
|
| DebugLocalContext env;
|
| v8::HandleScope scope(env->GetIsolate());
|
| + v8::Local<v8::Context> context = env.context();
|
| v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
|
| - v8::Script::Compile(
|
| - v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){debugger;}"))
|
| - ->Run();
|
| + 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);
|
| @@ -2234,21 +2325,17 @@ TEST(DebugEvaluate) {
|
|
|
| // 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 +2352,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 +2389,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,29 +2423,25 @@ 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();
|
| @@ -2379,6 +2463,7 @@ TEST(ConditionalBreakpointWithCodeGenerationDisallowed) {
|
|
|
| v8::Debug::SetDebugEventListener(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,7 +2476,7 @@ 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);
|
| @@ -2400,18 +2485,25 @@ TEST(ConditionalBreakpointWithCodeGenerationDisallowed) {
|
|
|
|
|
| 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());
|
| }
|
| }
|
|
|
| @@ -2426,6 +2518,7 @@ TEST(DebugEvaluateWithCodeGenerationDisallowed) {
|
|
|
| v8::Debug::SetDebugEventListener(CheckDebugEval);
|
|
|
| + v8::Local<v8::Context> context = env.context();
|
| v8::Local<v8::Function> foo = CompileFunction(&env,
|
| "var global = 'Global';\n"
|
| "function foo(x) {\n"
|
| @@ -2447,7 +2540,7 @@ 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();
|
| @@ -2541,7 +2634,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();
|
|
|
| @@ -2565,8 +2658,11 @@ TEST(DebugEvaluateWithoutStack) {
|
| 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();
|
|
|
| @@ -2639,7 +2735,8 @@ TEST(DebugStepLinear) {
|
|
|
| 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);
|
| @@ -2652,7 +2749,7 @@ TEST(DebugStepLinear) {
|
|
|
| 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);
|
| @@ -2685,23 +2782,25 @@ 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);
|
| @@ -2733,23 +2832,25 @@ 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);
|
| @@ -2767,6 +2868,7 @@ TEST(DebugStepNamedLoadLoop) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,13 +2889,13 @@ 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);
|
| @@ -2811,6 +2913,7 @@ static void DoDebugStepNamedStoreLoop(int expected) {
|
| v8::Debug::SetDebugEventListener(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,13 +2925,13 @@ 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);
|
| @@ -2850,6 +2953,7 @@ TEST(DebugStepLinearMixedICs) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(DebugEventStep);
|
|
|
| + v8::Local<v8::Context> context = env.context();
|
| // Create a function for testing stepping.
|
| v8::Local<v8::Function> foo = CompileFunction(&env,
|
| "function bar() {};"
|
| @@ -2866,7 +2970,7 @@ 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);
|
| @@ -2879,7 +2983,7 @@ TEST(DebugStepLinearMixedICs) {
|
|
|
| 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);
|
| @@ -2896,6 +3000,7 @@ TEST(DebugStepDeclarations) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,7 +3018,7 @@ 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.
|
| @@ -2929,6 +3034,7 @@ TEST(DebugStepLocals) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,7 +3052,7 @@ 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.
|
| @@ -2963,6 +3069,7 @@ TEST(DebugStepIf) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,15 +3089,15 @@ 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.
|
| @@ -3007,6 +3114,7 @@ TEST(DebugStepSwitch) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,22 +3140,22 @@ 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.
|
| @@ -3064,6 +3172,7 @@ TEST(DebugStepWhile) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,22 +3189,22 @@ 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.
|
| @@ -3112,6 +3221,7 @@ TEST(DebugStepDoWhile) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,22 +3238,22 @@ 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.
|
| @@ -3160,6 +3270,7 @@ TEST(DebugStepFor) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,22 +3288,22 @@ 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.
|
| @@ -3209,6 +3320,7 @@ TEST(DebugStepForContinue) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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 +3338,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,17 +3346,17 @@ 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.
|
| @@ -3261,6 +3373,7 @@ TEST(DebugStepForBreak) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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 +3391,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,17 +3400,17 @@ 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.
|
| @@ -3313,6 +3426,7 @@ TEST(DebugStepForIn) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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 +3442,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,7 +3459,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(10, break_point_hit_count);
|
|
|
| // Get rid of the debug event listener.
|
| @@ -3361,6 +3475,7 @@ TEST(DebugStepWith) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,15 +3484,17 @@ 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.
|
| @@ -3394,6 +3511,7 @@ TEST(DebugConditional) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,14 +3525,14 @@ 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.
|
| @@ -3435,6 +3553,7 @@ TEST(StepInOutSimple) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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 +3567,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 +3575,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,7 +3583,7 @@ 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);
|
|
|
| @@ -3486,6 +3605,7 @@ TEST(StepInOutTree) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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 +3620,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 +3628,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,7 +3636,7 @@ 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);
|
|
|
| @@ -3538,6 +3658,7 @@ TEST(StepInOutBranch) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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,7 +3672,7 @@ 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);
|
|
|
| @@ -3575,9 +3696,10 @@ TEST(DebugStepNatives) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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);
|
| @@ -3589,7 +3711,7 @@ TEST(DebugStepNatives) {
|
| v8::Debug::SetDebugEventListener(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);
|
| @@ -3614,9 +3736,10 @@ TEST(DebugStepFunctionApply) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(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);
|
| @@ -3628,7 +3751,7 @@ TEST(DebugStepFunctionApply) {
|
| v8::Debug::SetDebugEventListener(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);
|
| @@ -3644,6 +3767,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,
|
| @@ -3663,14 +3787,14 @@ TEST(DebugStepFunctionCall) {
|
|
|
| // 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);
|
| @@ -3680,7 +3804,7 @@ TEST(DebugStepFunctionCall) {
|
| v8::Debug::SetDebugEventListener(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);
|
| @@ -3696,6 +3820,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,
|
| @@ -3712,7 +3837,7 @@ TEST(DebugStepFunctionCallApply) {
|
| step_action = StepIn;
|
|
|
| break_point_hit_count = 0;
|
| - foo->Call(env->Global(), 0, NULL);
|
| + foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
|
| CHECK_EQ(5, break_point_hit_count);
|
|
|
| v8::Debug::SetDebugEventListener(NULL);
|
| @@ -3722,7 +3847,7 @@ TEST(DebugStepFunctionCallApply) {
|
| v8::Debug::SetDebugEventListener(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);
|
| @@ -3741,6 +3866,7 @@ TEST(PauseInScript) {
|
| // Register a debug event listener which counts.
|
| v8::Debug::SetDebugEventListener(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,12 +3875,12 @@ 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);
|
| @@ -3783,6 +3909,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 +3928,136 @@ TEST(BreakOnException) {
|
| &env, "function caughtFinally(){L:try{throws();}finally{break L;}}",
|
| "caughtFinally");
|
|
|
| - v8::V8::AddMessageListener(MessageCallbackCount);
|
| + env->GetIsolate()->AddMessageListener(MessageCallbackCount);
|
| v8::Debug::SetDebugEventListener(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);
|
| + 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 +4066,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(DebugEventCounter);
|
| + ChangeBreakOnException(true, true);
|
| v8::HandleScope scope(isolate);
|
| CompileRun(
|
| "try {\n"
|
| @@ -3951,7 +4079,7 @@ TEST(TryFinallyOriginalMessage) {
|
| "}\n");
|
| DebugEventCounterCheck(1, 1, 1);
|
| v8::Debug::SetDebugEventListener(NULL);
|
| - v8::V8::RemoveMessageListeners(try_finally_original_message);
|
| + isolate->RemoveMessageListeners(try_finally_original_message);
|
| }
|
|
|
|
|
| @@ -3968,7 +4096,7 @@ TEST(EvalJSInDebugEventListenerOnNativeReThrownException) {
|
| debug_event_listener_callback = noThrowJS;
|
| debug_event_listener_callback_result = 2;
|
|
|
| - v8::V8::AddMessageListener(MessageCallbackCount);
|
| + env->GetIsolate()->AddMessageListener(MessageCallbackCount);
|
| v8::Debug::SetDebugEventListener(DebugEventCounter);
|
| // Break on uncaught exception
|
| ChangeBreakOnException(false, true);
|
| @@ -3978,8 +4106,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,13 +4127,14 @@ 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);
|
| + env->GetIsolate()->AddMessageListener(MessageCallbackCount);
|
| v8::Debug::SetDebugEventListener(DebugEventCounter);
|
|
|
| DebugEventCounterClear();
|
| @@ -4018,30 +4147,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);
|
| @@ -4064,6 +4199,7 @@ TEST(StepWithException) {
|
| // Register a debug event listener which steps and counts.
|
| v8::Debug::SetDebugEventListener(DebugEventStepSequence);
|
|
|
| + v8::Local<v8::Context> context = env.context();
|
| // Create functions for testing stepping.
|
| const char* src = "function a() { n(); }; "
|
| "function b() { c(); }; "
|
| @@ -4080,7 +4216,7 @@ TEST(StepWithException) {
|
| 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);
|
|
|
| @@ -4090,7 +4226,7 @@ TEST(StepWithException) {
|
| 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.
|
| @@ -4100,7 +4236,7 @@ TEST(StepWithException) {
|
| 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,7 +4245,7 @@ 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);
|
|
|
| @@ -4120,7 +4256,7 @@ TEST(StepWithException) {
|
| 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,7 +4265,7 @@ 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);
|
|
|
| @@ -4151,6 +4287,7 @@ TEST(DebugBreak) {
|
| // Register a debug event listener which sets the break flag and counts.
|
| v8::Debug::SetDebugEventListener(DebugEventBreak);
|
|
|
| + v8::Local<v8::Context> context = env.context();
|
| // Create a function for testing stepping.
|
| const char* src = "function f0() {}"
|
| "function f1(x1) {}"
|
| @@ -4162,16 +4299,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,10 +4316,10 @@ 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.
|
| @@ -4204,6 +4340,7 @@ TEST(DisableBreak) {
|
| // Register a debug event listener which sets the break flag and counts.
|
| v8::Debug::SetDebugEventListener(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,18 +4356,18 @@ 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.
|
| @@ -4275,22 +4412,31 @@ TEST(NoBreakWhenBootstrapping) {
|
|
|
|
|
| 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 +4446,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 +4475,83 @@ 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());
|
| + CHECK_EQ(5, CompileRun(source)->Int32Value(context).FromJust());
|
|
|
| // 1 is PropertyKind.Named;
|
| source = "both_mirror.properties(1).length";
|
| - CHECK_EQ(3, CompileRun(source)->Int32Value());
|
| + CHECK_EQ(3, CompileRun(source)->Int32Value(context).FromJust());
|
|
|
| // 2 is PropertyKind.Indexed;
|
| source = "both_mirror.properties(2).length";
|
| - CHECK_EQ(2, CompileRun(source)->Int32Value());
|
| + CHECK_EQ(2, CompileRun(source)->Int32Value(context).FromJust());
|
|
|
| // 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 +4561,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 +4576,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 +4587,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());
|
| + CHECK(CompileRun(source)->BooleanValue(context).FromJust());
|
|
|
| source = "both_values[1].name() == 'b'";
|
| - CHECK(CompileRun(source)->BooleanValue());
|
| + CHECK(CompileRun(source)->BooleanValue(context).FromJust());
|
|
|
| source = "both_values[2].name() == 'c'";
|
| - CHECK(CompileRun(source)->BooleanValue());
|
| + CHECK(CompileRun(source)->BooleanValue(context).FromJust());
|
|
|
| source = "both_values[3].name() == 1";
|
| - CHECK(CompileRun(source)->BooleanValue());
|
| + CHECK(CompileRun(source)->BooleanValue(context).FromJust());
|
|
|
| source = "both_values[4].name() == 10";
|
| - CHECK(CompileRun(source)->BooleanValue());
|
| + CHECK(CompileRun(source)->BooleanValue(context).FromJust());
|
| }
|
|
|
|
|
| @@ -4461,30 +4615,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 +4659,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 +4722,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 +4763,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 +4809,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 +4853,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 +5113,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.
|
| @@ -5206,12 +5430,12 @@ void V8Thread::Run() {
|
| DebugLocalContext env(isolate_);
|
| v8::HandleScope scope(isolate_);
|
| v8::Debug::SetMessageHandler(&ThreadedMessageHandler);
|
| - v8::Handle<v8::ObjectTemplate> global_template =
|
| + 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);
|
|
|
| @@ -5515,7 +5739,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 +5752,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 +5786,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 +5803,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 +5820,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();
|
| }
|
|
|
|
|
| @@ -5694,6 +5963,7 @@ TEST(DebuggerUnload) {
|
| // Set a debug event listener.
|
| break_point_hit_count = 0;
|
| v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
|
| + v8::Local<v8::Context> context = env.context();
|
| {
|
| v8::HandleScope scope(env->GetIsolate());
|
| // Create a couple of functions for the test.
|
| @@ -5710,9 +5980,9 @@ 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);
|
| }
|
|
|
| @@ -5729,15 +5999,17 @@ TEST(DebuggerUnload) {
|
|
|
| // 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);
|
| }
|
|
|
| @@ -5861,12 +6133,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
|
| @@ -5896,10 +6168,11 @@ TEST(DebugGetLoadedScripts) {
|
| 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);
|
| }
|
|
|
| @@ -5918,61 +6191,79 @@ TEST(ScriptNameAndData) {
|
|
|
| v8::Debug::SetDebugEventListener(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,11 +6292,11 @@ 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);
|
|
|
| @@ -6016,8 +6307,8 @@ TEST(ContextData) {
|
| 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 +6323,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,7 +6333,7 @@ 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.
|
| @@ -6080,20 +6371,25 @@ TEST(DebugBreakInMessageHandler) {
|
|
|
| v8::Debug::SetMessageHandler(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 +6400,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 +6409,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 +6436,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 +6450,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::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,9 +6472,9 @@ 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);
|
|
|
| @@ -6187,8 +6484,7 @@ static void ExecuteScriptForContextCheck(
|
| 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,7 +6497,7 @@ 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);
|
| @@ -6310,18 +6606,23 @@ 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::Script::Compile(context, v8_str(env->GetIsolate(), script))
|
| + .ToLocalChecked()
|
| + ->Run(context)
|
| + .ToLocalChecked();
|
| v8::Debug::SetMessageHandler(NULL);
|
|
|
| v8::Debug::SetMessageHandler(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);
|
| @@ -6359,6 +6660,7 @@ TEST(SyntaxErrorMessageOnSyntaxException) {
|
| ChangeBreakOnException(false, true);
|
|
|
| v8::Debug::SetDebugEventListener(CompileErrorEventCounter);
|
| + v8::Local<v8::Context> context = env.context();
|
|
|
| CompileErrorEventCounterClear();
|
|
|
| @@ -6366,24 +6668,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,19 +6699,24 @@ 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::Script::Compile(context, v8_str(env->GetIsolate(), script))
|
| + .ToLocalChecked()
|
| + ->Run(context)
|
| + .ToLocalChecked();
|
| v8::Debug::SetMessageHandler(NULL);
|
|
|
| v8::Debug::SetMessageHandler(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);
|
| @@ -6429,6 +6741,7 @@ 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);
|
|
|
| @@ -6436,14 +6749,18 @@ TEST(ExceptionMessageWhenMessageHandlerIsReset) {
|
| const char* script = "function f() {throw new Error()};";
|
|
|
| v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
|
| - v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
|
| - ->Run();
|
| + v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
|
| + .ToLocalChecked()
|
| + ->Run(context)
|
| + .ToLocalChecked();
|
| v8::Debug::SetMessageHandler(NULL);
|
|
|
| v8::Debug::SetMessageHandler(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);
|
| @@ -6463,6 +6780,7 @@ TEST(ProvisionalBreakpointOnLineOutOfRange) {
|
| const char* resource_name = "test_resource";
|
|
|
| v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
|
| + v8::Local<v8::Context> context = env.context();
|
|
|
| // Set a couple of provisional breakpoint on lines out of the script lines
|
| // range.
|
| @@ -6473,14 +6791,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
|
| @@ -6521,6 +6840,7 @@ 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);
|
| @@ -6537,7 +6857,7 @@ 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);
|
|
|
| @@ -6639,7 +6959,7 @@ class SendCommandThread : public v8::base::Thread {
|
| timer.Elapsed().InMillisecondsF());
|
| }
|
|
|
| - v8::V8::TerminateExecution(isolate_);
|
| + isolate_->TerminateExecution();
|
| }
|
|
|
| void StartSending() { semaphore_.Signal(); }
|
| @@ -6660,6 +6980,7 @@ 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;
|
|
|
| @@ -6668,9 +6989,12 @@ TEST(ProcessDebugMessagesThreaded) {
|
| 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) { }");
|
|
|
| @@ -6703,6 +7027,7 @@ 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);
|
|
|
| @@ -6723,9 +7048,8 @@ TEST(Backtrace) {
|
| v8::Debug::ProcessDebugMessages();
|
| 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,7 +7058,7 @@ 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.
|
| @@ -6747,19 +7071,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 +7096,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(
|
| @@ -6787,7 +7116,7 @@ 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);
|
| @@ -6797,8 +7126,8 @@ TEST(DebugBreakFunctionApply) {
|
| }
|
|
|
|
|
| -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 +7136,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 +7149,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,11 +7181,12 @@ 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);
|
| @@ -6868,12 +7199,12 @@ 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>();
|
| + debugee_context = v8::Local<v8::Context>();
|
| + debugger_context = v8::Local<v8::Context>();
|
| CheckDebuggerUnloaded();
|
| }
|
|
|
| @@ -6896,10 +7227,12 @@ TEST(NoDebugContextWhenDebuggerDisabled) {
|
| }
|
|
|
|
|
| -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());
|
| }
|
|
|
|
|
| @@ -6912,11 +7245,14 @@ TEST(DebugEventContext) {
|
| v8::Debug::SetDebugEventListener(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>();
|
| + expected_context_data = v8::Local<v8::Value>();
|
| CheckDebuggerUnloaded();
|
| }
|
|
|
| @@ -6926,21 +7262,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 +7297,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,
|
| @@ -6975,11 +7313,11 @@ TEST(DeoptimizeDuringDebugBreak) {
|
|
|
| // 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);
|
|
|
| @@ -6991,46 +7329,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));
|
| }
|
| }
|
| }
|
| @@ -7046,6 +7396,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 +7410,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 +7424,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 +7468,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());
|
| }
|
| }
|
| }
|
| @@ -7218,6 +7574,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 +7590,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 +7599,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());
|
| + CcTest::isolate()->TerminateExecution();
|
| }
|
|
|
|
|
| @@ -7253,6 +7611,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"
|
| @@ -7269,8 +7628,9 @@ TEST(DebugBreakInline) {
|
| "g(true);";
|
| v8::Debug::SetDebugEventListener(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();
|
| }
|
|
|
|
|
| @@ -7415,11 +7775,14 @@ TEST(DebugBreakStackTrace) {
|
| DebugLocalContext env;
|
| v8::HandleScope scope(env->GetIsolate());
|
| v8::Debug::SetDebugEventListener(DebugBreakStackTraceListener);
|
| - v8::Handle<v8::FunctionTemplate> add_debug_break_template =
|
| + 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 +7816,7 @@ class TerminationThread : public v8::base::Thread {
|
|
|
| virtual void Run() {
|
| terminate_requested_semaphore.Wait();
|
| - v8::V8::TerminateExecution(isolate_);
|
| + isolate_->TerminateExecution();
|
| terminate_fired_semaphore.Signal();
|
| }
|
|
|
| @@ -7496,18 +7859,22 @@ TEST(DebugPromiseInterceptedByTryCatch) {
|
| v8::Isolate* isolate = env->GetIsolate();
|
| v8::HandleScope scope(isolate);
|
| v8::Debug::SetDebugEventListener(&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());
|
| }
|
|
|
|
|
| @@ -7531,19 +7898,24 @@ TEST(DebugPromiseRejectedByCallback) {
|
| v8::Isolate* isolate = env->GetIsolate();
|
| v8::HandleScope scope(isolate);
|
| v8::Debug::SetDebugEventListener(&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);
|
| }
|
|
|
| @@ -7553,13 +7925,17 @@ TEST(DebugBreakOnExceptionInObserveCallback) {
|
| v8::Isolate* isolate = env->GetIsolate();
|
| v8::HandleScope scope(isolate);
|
| v8::Debug::SetDebugEventListener(&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 +7945,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);
|
| }
|
|
|
|
|