Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index c3c65fd..914bda1 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -33,7 +33,7 @@
#include "src/base/platform/condition-variable.h"
#include "src/base/platform/platform.h"
#include "src/compilation-cache.h"
-#include "src/debug.h"
+#include "src/debug/debug.h"
#include "src/deoptimizer.h"
#include "src/frames.h"
#include "src/utils.h"
@@ -52,7 +52,6 @@
using ::v8::internal::JSGlobalProxy;
using ::v8::internal::Code;
using ::v8::internal::Debug;
-using ::v8::internal::Debugger;
using ::v8::internal::CommandMessage;
using ::v8::internal::CommandMessageQueue;
using ::v8::internal::StackFrame;
@@ -74,9 +73,9 @@
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)) {
@@ -84,9 +83,9 @@
}
inline DebugLocalContext(
v8::ExtensionConfiguration* extensions = 0,
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::Handle<v8::ObjectTemplate>(),
- v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
+ v8::Local<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate>(),
+ v8::Local<v8::Value> global_object = v8::Local<v8::Value>())
: scope_(CcTest::isolate()),
context_(v8::Context::New(CcTest::isolate(), extensions,
global_template, global_object)) {
@@ -115,8 +114,10 @@
v8::Utils::OpenHandle(*context_->Global())));
Handle<v8::internal::String> debug_string =
factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("debug"));
- v8::internal::Runtime::DefineObjectProperty(global, debug_string,
- handle(debug_context->global_proxy(), isolate), DONT_ENUM).Check();
+ v8::internal::JSObject::SetOwnPropertyIgnoreAttributes(
+ global, debug_string, handle(debug_context->global_proxy()),
+ v8::internal::DONT_ENUM)
+ .Check();
}
private:
@@ -127,34 +128,33 @@
// --- 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,
- 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)));
-}
-
-
// 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(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)));
+ 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(DebugLocalContext* env,
+ const char* source,
+ const char* 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) {
- Handle<v8::internal::JSFunction> f = v8::Utils::OpenHandle(*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());
- return Debug::HasDebugInfo(shared);
+ return shared->HasDebugInfo();
}
@@ -174,8 +174,9 @@
// Set a break point in a function and return the associated break point
// number.
-static int SetBreakPoint(v8::Handle<v8::Function> fun, int position) {
- return SetBreakPoint(v8::Utils::OpenHandle(*fun), position);
+static int SetBreakPoint(v8::Local<v8::Function> fun, int position) {
+ return SetBreakPoint(
+ i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*fun)), position);
}
@@ -189,8 +190,8 @@
"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();
}
@@ -211,12 +212,10 @@
}
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
- v8::TryCatch try_catch;
- v8::Handle<v8::String> str =
- v8::String::NewFromUtf8(isolate, buffer.start());
- v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
+ v8::TryCatch try_catch(isolate);
+ v8::Local<v8::Value> value = CompileRunChecked(isolate, buffer.start());
CHECK(!try_catch.HasCaught());
- return value->Int32Value();
+ return value->Int32Value(isolate->GetCurrentContext()).FromJust();
}
}
@@ -240,12 +239,10 @@
}
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
- v8::TryCatch try_catch;
- v8::Handle<v8::String> str =
- v8::String::NewFromUtf8(isolate, buffer.start());
- v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
+ v8::TryCatch try_catch(isolate);
+ v8::Local<v8::Value> value = CompileRunChecked(isolate, buffer.start());
CHECK(!try_catch.HasCaught());
- return value->Int32Value();
+ return value->Int32Value(isolate->GetCurrentContext()).FromJust();
}
}
@@ -267,7 +264,7 @@
"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());
}
@@ -278,7 +275,7 @@
"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());
}
@@ -289,7 +286,7 @@
"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());
}
@@ -301,7 +298,7 @@
"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());
}
@@ -313,7 +310,7 @@
"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());
}
@@ -329,22 +326,14 @@
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()");
}
}
@@ -352,10 +341,13 @@
// Prepare to step to next break location.
static void PrepareStep(StepAction step_action) {
v8::internal::Debug* debug = CcTest::i_isolate()->debug();
- debug->PrepareStep(step_action, 1, StackFrame::NO_ID);
+ debug->PrepareStep(step_action);
}
+static void ClearStepping() { CcTest::i_isolate()->debug()->ClearStepping(); }
+
+
// This function is in namespace v8::internal to be friend with class
// v8::internal::Debug.
namespace v8 {
@@ -394,10 +386,10 @@
// Check that the debugger context is cleared and that there is no debug
// information stored for the debugger.
CHECK(CcTest::i_isolate()->debug()->debug_context().is_null());
- CHECK_EQ(NULL, CcTest::i_isolate()->debug()->debug_info_list_);
+ CHECK(!CcTest::i_isolate()->debug()->debug_info_list_);
// Collect garbage to ensure weak handles are cleared.
- CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
+ CcTest::heap()->CollectAllGarbage();
CcTest::heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask);
// Iterate the head and check that there are no debugger related objects left.
@@ -411,13 +403,10 @@
if (check_functions) {
if (obj->IsJSFunction()) {
JSFunction* fun = JSFunction::cast(obj);
- for (RelocIterator it(fun->shared()->code()); !it.done(); it.next()) {
- RelocInfo::Mode rmode = it.rinfo()->rmode();
- if (RelocInfo::IsCodeTarget(rmode)) {
- CHECK(!Debug::IsDebugBreak(it.rinfo()->target_address()));
- } else if (RelocInfo::IsJSReturn(rmode)) {
- CHECK(!Debug::IsDebugBreakAtReturn(it.rinfo()));
- }
+ for (RelocIterator it(fun->shared()->code(),
+ RelocInfo::kDebugBreakSlotMask);
+ !it.done(); it.next()) {
+ CHECK(!it.rinfo()->IsPatchedDebugBreakSlotSequence());
}
}
}
@@ -425,79 +414,20 @@
}
-} } // namespace v8::internal
+} // namespace internal
+} // namespace v8
// Check that the debugger has been fully unloaded.
-static void CheckDebuggerUnloaded(bool check_functions = false) {
+static void CheckDebuggerUnloaded(v8::Isolate* isolate,
+ bool check_functions = false) {
// Let debugger to unload itself synchronously
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
v8::internal::CheckDebuggerUnloaded(check_functions);
}
-// Inherit from BreakLocationIterator to get access to protected parts for
-// testing.
-class TestBreakLocationIterator: public v8::internal::BreakLocationIterator {
- public:
- explicit TestBreakLocationIterator(Handle<v8::internal::DebugInfo> debug_info)
- : BreakLocationIterator(debug_info, v8::internal::SOURCE_BREAK_LOCATIONS) {}
- v8::internal::RelocIterator* it() { return reloc_iterator_; }
- v8::internal::RelocIterator* it_original() {
- return reloc_iterator_original_;
- }
-};
-
-
-// Compile a function, set a break point and check that the call at the break
-// location in the code is the expected debug_break function.
-void CheckDebugBreakFunction(DebugLocalContext* env,
- const char* source, const char* name,
- int position, v8::internal::RelocInfo::Mode mode,
- Code* debug_break) {
- v8::internal::Debug* debug = CcTest::i_isolate()->debug();
-
- // Create function and set the break point.
- Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle(
- *CompileFunction(env, source, name));
- int bp = SetBreakPoint(fun, position);
-
- // Check that the debug break function is as expected.
- Handle<v8::internal::SharedFunctionInfo> shared(fun->shared());
- CHECK(Debug::HasDebugInfo(shared));
- TestBreakLocationIterator it1(Debug::GetDebugInfo(shared));
- it1.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED);
- v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode();
- if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
- actual_mode = v8::internal::RelocInfo::CODE_TARGET;
- }
- CHECK_EQ(mode, actual_mode);
- if (mode != v8::internal::RelocInfo::JS_RETURN) {
- CHECK_EQ(debug_break,
- Code::GetCodeFromTargetAddress(it1.it()->rinfo()->target_address()));
- } else {
- CHECK(Debug::IsDebugBreakAtReturn(it1.it()->rinfo()));
- }
-
- // Clear the break point and check that the debug break function is no longer
- // there
- ClearBreakPoint(bp);
- CHECK(!debug->HasDebugInfo(shared));
- CHECK(debug->EnsureDebugInfo(shared, fun));
- TestBreakLocationIterator it2(Debug::GetDebugInfo(shared));
- it2.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED);
- actual_mode = it2.it()->rinfo()->rmode();
- if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
- actual_mode = v8::internal::RelocInfo::CODE_TARGET;
- }
- CHECK_EQ(mode, actual_mode);
- if (mode == v8::internal::RelocInfo::JS_RETURN) {
- CHECK(!Debug::IsDebugBreakAtReturn(it2.it()->rinfo()));
- }
-}
-
-
// --- D e b u g E v e n t H a n d l e r s
// ---
// --- The different tests uses a number of debug event handlers.
@@ -581,7 +511,7 @@
"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.
@@ -600,7 +530,8 @@
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.
@@ -612,16 +543,16 @@
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);
}
}
@@ -629,34 +560,37 @@
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);
}
}
@@ -675,7 +609,7 @@
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() {
@@ -687,8 +621,9 @@
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.
@@ -701,11 +636,11 @@
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++;
}
@@ -715,18 +650,21 @@
// 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());
}
}
@@ -741,7 +679,7 @@
// 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.
};
@@ -759,7 +697,9 @@
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);
@@ -768,12 +708,12 @@
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);
@@ -788,7 +728,7 @@
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);
@@ -833,7 +773,7 @@
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);
@@ -843,13 +783,15 @@
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]);
@@ -879,7 +821,7 @@
CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
} else {
// Mark sweep compact.
- CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
+ CcTest::heap()->CollectAllGarbage();
}
}
}
@@ -915,7 +857,6 @@
static void DebugEventBreakMax(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
- v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
v8::Isolate* v8_isolate = CcTest::isolate();
v8::internal::Isolate* isolate = CcTest::i_isolate();
v8::internal::Debug* debug = isolate->debug();
@@ -927,23 +868,12 @@
// Count the number of breaks.
break_point_hit_count++;
- // Collect the JavsScript stack height if the function frame_count is
- // compiled.
- if (!frame_count.IsEmpty()) {
- static const int kArgc = 1;
- v8::Handle<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();
- }
-
// Set the break flag again to come back here as soon as possible.
v8::Debug::DebugBreak(v8_isolate);
} 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
@@ -965,100 +895,14 @@
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++;
}
// --- T h e A c t u a l T e s t s
-
-// Test that the debug break function is the expected one for different kinds
-// of break locations.
-TEST(DebugStub) {
- using ::v8::internal::Builtins;
- using ::v8::internal::Isolate;
- DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
-
- CheckDebugBreakFunction(&env,
- "function f1(){}", "f1",
- 0,
- v8::internal::RelocInfo::JS_RETURN,
- NULL);
- CheckDebugBreakFunction(&env,
- "function f2(){x=1;}", "f2",
- 0,
- v8::internal::RelocInfo::CODE_TARGET,
- CcTest::i_isolate()->builtins()->builtin(
- Builtins::kStoreIC_DebugBreak));
- CheckDebugBreakFunction(&env,
- "function f3(){var a=x;}", "f3",
- 0,
- v8::internal::RelocInfo::CODE_TARGET,
- CcTest::i_isolate()->builtins()->builtin(
- Builtins::kLoadIC_DebugBreak));
-
-// TODO(1240753): Make the test architecture independent or split
-// parts of the debugger into architecture dependent files. This
-// part currently disabled as it is not portable between IA32/ARM.
-// Currently on ICs for keyed store/load on ARM.
-#if !defined (__arm__) && !defined(__thumb__)
- CheckDebugBreakFunction(
- &env,
- "function f4(){var index='propertyName'; var a={}; a[index] = 'x';}",
- "f4",
- 0,
- v8::internal::RelocInfo::CODE_TARGET,
- CcTest::i_isolate()->builtins()->builtin(
- Builtins::kKeyedStoreIC_DebugBreak));
- CheckDebugBreakFunction(
- &env,
- "function f5(){var index='propertyName'; var a={}; return a[index];}",
- "f5",
- 0,
- v8::internal::RelocInfo::CODE_TARGET,
- CcTest::i_isolate()->builtins()->builtin(
- Builtins::kKeyedLoadIC_DebugBreak));
-#endif
-
- CheckDebugBreakFunction(
- &env,
- "function f6(a){return a==null;}",
- "f6",
- 0,
- v8::internal::RelocInfo::CODE_TARGET,
- CcTest::i_isolate()->builtins()->builtin(
- Builtins::kCompareNilIC_DebugBreak));
-
- // Check the debug break code stubs for call ICs with different number of
- // parameters.
- // TODO(verwaest): XXX update test.
- // Handle<Code> debug_break_0 = v8::internal::ComputeCallDebugBreak(0);
- // Handle<Code> debug_break_1 = v8::internal::ComputeCallDebugBreak(1);
- // Handle<Code> debug_break_4 = v8::internal::ComputeCallDebugBreak(4);
-
- // CheckDebugBreakFunction(&env,
- // "function f4_0(){x();}", "f4_0",
- // 0,
- // v8::internal::RelocInfo::CODE_TARGET,
- // *debug_break_0);
-
- // CheckDebugBreakFunction(&env,
- // "function f4_1(){x(1);}", "f4_1",
- // 0,
- // v8::internal::RelocInfo::CODE_TARGET,
- // *debug_break_1);
-
- // CheckDebugBreakFunction(&env,
- // "function f4_4(){x(1,2,3,4);}", "f4_4",
- // 0,
- // v8::internal::RelocInfo::CODE_TARGET,
- // *debug_break_4);
-}
-
-
// Test that the debug info in the VM is in sync with the functions being
// debugged.
TEST(DebugInfo) {
@@ -1073,6 +917,7 @@
CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length());
CHECK(!HasDebugInfo(foo));
CHECK(!HasDebugInfo(bar));
+ EnableDebugger(env->GetIsolate());
// One function (foo) is debugged.
int bp1 = SetBreakPoint(foo, 0);
CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length());
@@ -1090,6 +935,7 @@
CHECK(HasDebugInfo(bar));
// No functions are debugged.
ClearBreakPoint(bp2);
+ DisableDebugger(env->GetIsolate());
CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length());
CHECK(!HasDebugInfo(foo));
CHECK(!HasDebugInfo(bar));
@@ -1102,30 +948,29 @@
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){bar=0;}"))->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){bar=0;}", "foo");
// Run without breakpoints.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint
int bp = SetBreakPoint(foo, 0);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1134,33 +979,31 @@
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar=1"))
- ->Run();
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){var x=bar;}"))
- ->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+
+ CompileRunChecked(env->GetIsolate(), "bar=1");
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){var x=bar;}", "foo");
// Run without breakpoints.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint.
int bp = SetBreakPoint(foo, 0);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1169,32 +1012,30 @@
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){bar();}"))->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ CompileRunChecked(env->GetIsolate(), "function bar(){}");
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){bar();}", "foo");
// Run without breakpoints.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint
int bp = SetBreakPoint(foo, 0);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1203,34 +1044,40 @@
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){return 1;}"))
- ->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){return bar();}"))
- ->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointCollectGarbage);
+ CompileRunChecked(env->GetIsolate(), "function bar(){return 1;}");
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){return bar();}", "foo");
+ v8::Local<v8::Context> context = env.context();
// Run without breakpoints.
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint.
int bp = SetBreakPoint(foo, 0);
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(1, break_point_hit_count);
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1239,34 +1086,40 @@
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function bar(){ this.x = 1;}"))
- ->Run();
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){return new bar(1).x;}"))->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointCollectGarbage);
+ CompileRunChecked(env->GetIsolate(), "function bar(){ this.x = 1;}");
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){return new bar(1).x;}", "foo");
+ v8::Local<v8::Context> context = env.context();
// Run without breakpoints.
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint.
int bp = SetBreakPoint(foo, 0);
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(1, break_point_hit_count);
- CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
+ CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL)
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust());
CHECK_EQ(2, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1286,44 +1139,44 @@
"frame_source_column");
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){}"))->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){}", "foo");
+ v8::Local<v8::Context> context = env.context();
// Run without breakpoints.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint
int bp = SetBreakPoint(foo, 0);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
CHECK_EQ(0, last_source_line);
CHECK_EQ(15, last_source_column);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
CHECK_EQ(0, last_source_line);
CHECK_EQ(15, last_source_column);
// Run without breakpoints.
ClearBreakPoint(bp);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
-static void CallWithBreakPoints(v8::Local<v8::Object> recv,
+static void CallWithBreakPoints(v8::Local<v8::Context> context,
+ v8::Local<v8::Object> recv,
v8::Local<v8::Function> f,
- int break_point_count,
- int call_count) {
+ int break_point_count, int call_count) {
break_point_hit_count = 0;
for (int i = 0; i < call_count; i++) {
- f->Call(recv, 0, NULL);
+ f->Call(context, recv, 0, NULL).ToLocalChecked();
CHECK_EQ((i + 1) * break_point_count, break_point_hit_count);
}
}
@@ -1334,59 +1187,61 @@
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointCollectGarbage);
v8::Local<v8::Function> foo;
// Test IC store break point with garbage collection.
foo = CompileFunction(&env, "function foo(){bar=0;}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 10);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 10);
// Test IC load break point with garbage collection.
foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 10);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 10);
// Test IC call break point with garbage collection.
foo = CompileFunction(&env, "function bar(){};function foo(){bar();}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 10);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 10);
// Test return break point with garbage collection.
foo = CompileFunction(&env, "function foo(){}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 25);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 25);
// Test debug break slot break point with garbage collection.
foo = CompileFunction(&env, "function foo(){var a;}", "foo");
SetBreakPoint(foo, 0);
- CallWithBreakPoints(env->Global(), foo, 1, 25);
+ CallWithBreakPoints(context, env->Global(), foo, 1, 25);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
// Call the function three times with different garbage collections in between
// and make sure that the break point survives.
-static void CallAndGC(v8::Local<v8::Object> recv,
- v8::Local<v8::Function> f) {
+static void CallAndGC(v8::Local<v8::Context> context,
+ v8::Local<v8::Object> recv, v8::Local<v8::Function> f) {
break_point_hit_count = 0;
for (int i = 0; i < 3; i++) {
// Call function.
- f->Call(recv, 0, NULL);
+ f->Call(context, recv, 0, NULL).ToLocalChecked();
CHECK_EQ(1 + i * 3, break_point_hit_count);
// Scavenge and call function.
CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
- f->Call(recv, 0, NULL);
+ f->Call(context, recv, 0, NULL).ToLocalChecked();
CHECK_EQ(2 + i * 3, break_point_hit_count);
// Mark sweep (and perhaps compact) and call function.
- CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
- f->Call(recv, 0, NULL);
+ CcTest::heap()->CollectAllGarbage();
+ f->Call(context, recv, 0, NULL).ToLocalChecked();
CHECK_EQ(3 + i * 3, break_point_hit_count);
}
}
@@ -1397,8 +1252,10 @@
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
v8::Local<v8::Function> foo;
// Test IC store break point with garbage collection.
@@ -1407,7 +1264,7 @@
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.
{
@@ -1415,7 +1272,7 @@
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.
{
@@ -1425,7 +1282,7 @@
"foo");
SetBreakPoint(foo, 0);
}
- CallAndGC(env->Global(), foo);
+ CallAndGC(context, env->Global(), foo);
// Test return break point with garbage collection.
{
@@ -1433,7 +1290,7 @@
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.
{
@@ -1441,11 +1298,11 @@
foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo");
SetBreakPoint(foo, 0);
}
- CallAndGC(env->Global(), foo);
+ CallAndGC(context, env->Global(), foo);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1453,53 +1310,51 @@
TEST(BreakPointThroughJavaScript) {
break_point_hit_count = 0;
DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run();
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "function foo(){bar();bar();}"))
- ->Run();
- // 012345678901234567890
- // 1 2
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
+ CompileRunChecked(isolate, "function bar(){}");
+ CompileFunction(isolate, "function foo(){bar();bar();}", "foo");
+ // 012345678901234567890
+ // 1 2
// Break points are set at position 3 and 9
+ v8::Local<v8::String> source = v8_str(env->GetIsolate(), "foo()");
v8::Local<v8::Script> foo =
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "foo()"));
+ v8::Script::Compile(context, source).ToLocalChecked();
- // Run without breakpoints.
- foo->Run();
CHECK_EQ(0, break_point_hit_count);
// Run with one breakpoint
int bp1 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 3);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Run with two breakpoints
int bp2 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 9);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Run with one breakpoint
ClearBreakPointFromJS(env->GetIsolate(), bp2);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(7, break_point_hit_count);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(8, break_point_hit_count);
// Run without breakpoints.
ClearBreakPointFromJS(env->GetIsolate(), bp1);
- foo->Run();
+ foo->Run(context).ToLocalChecked();
CHECK_EQ(8, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
// Make sure that the break point numbers are consecutive.
CHECK_EQ(1, bp1);
@@ -1512,96 +1367,99 @@
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::Debug::SetDebugEventListener(isolate, 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);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
// Make sure that the break point numbers are consecutive.
CHECK_EQ(1, sbp1);
@@ -1616,73 +1474,74 @@
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::Debug::SetDebugEventListener(isolate, 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.
@@ -1691,9 +1550,9 @@
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.
@@ -1703,13 +1562,13 @@
ClearBreakPointFromJS(env->GetIsolate(), sbp4);
ClearBreakPointFromJS(env->GetIsolate(), sbp5);
ClearBreakPointFromJS(env->GetIsolate(), sbp6);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
// Make sure that the break point numbers are consecutive.
CHECK_EQ(1, sbp1);
@@ -1725,57 +1584,63 @@
TEST(EnableDisableScriptBreakPoint) {
break_point_hit_count = 0;
DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " a = 0; // line 1\n"
- "};");
+ v8::Local<v8::String> script = v8_str(isolate,
+ "function f() {\n"
+ " a = 0; // line 1\n"
+ "};");
// Compile the script and get function f.
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Script::Compile(script, &origin)->Run();
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(isolate, "test"));
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()->Get(context, v8_str(isolate, "f")).ToLocalChecked());
// Set script break point on line 1 (in function f).
- int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
+ int sbp = SetScriptBreakPointByNameFromJS(isolate, "test", 1, 0);
// Call f while enabeling and disabling the script break point.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- DisableScriptBreakPointFromJS(env->GetIsolate(), sbp);
- f->Call(env->Global(), 0, NULL);
+ DisableScriptBreakPointFromJS(isolate, sbp);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- EnableScriptBreakPointFromJS(env->GetIsolate(), sbp);
- f->Call(env->Global(), 0, NULL);
+ EnableScriptBreakPointFromJS(isolate, sbp);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- DisableScriptBreakPointFromJS(env->GetIsolate(), sbp);
- f->Call(env->Global(), 0, NULL);
+ DisableScriptBreakPointFromJS(isolate, sbp);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- // Reload the script and get f again checking that the disabeling survives.
- v8::Script::Compile(script, &origin)->Run();
+ // Reload the script and get f again checking that the disabling survives.
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- f->Call(env->Global(), 0, NULL);
+ env->Global()->Get(context, v8_str(isolate, "f")).ToLocalChecked());
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- EnableScriptBreakPointFromJS(env->GetIsolate(), sbp);
- f->Call(env->Global(), 0, NULL);
+ EnableScriptBreakPointFromJS(isolate, sbp);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(3, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -1786,24 +1651,29 @@
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "count = 0;\n"
- "function f() {\n"
- " g(count++); // line 2\n"
- "};\n"
- "function g(x) {\n"
- " var a=x; // line 5\n"
- "};");
+ v8::Local<v8::String> script = v8_str(env->GetIsolate(),
+ "count = 0;\n"
+ "function f() {\n"
+ " g(count++); // line 2\n"
+ "};\n"
+ "function g(x) {\n"
+ " var a=x; // line 5\n"
+ "};");
// Compile the script and get function f.
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Script::Compile(script, &origin)->Run();
+ v8::Local<v8::Context> context = env.context();
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(env->GetIsolate(), "test"));
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Set script break point on line 5 (in function g).
int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 5, 0);
@@ -1811,34 +1681,39 @@
// Call f with different conditions on the script break point.
break_point_hit_count = 0;
ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "false");
- f->Call(env->Global(), 0, NULL);
+ f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "true");
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "x % 2 == 0");
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
- f->Call(env->Global(), 0, NULL);
+ f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
// Reload the script and get f again checking that the condition survives.
- v8::Script::Compile(script, &origin)->Run();
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
- f->Call(env->Global(), 0, NULL);
+ f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1849,20 +1724,25 @@
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " a = 0; // line 1\n"
- "};");
+ v8::Local<v8::String> script = v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " a = 0; // line 1\n"
+ "};");
// Compile the script and get function f.
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Script::Compile(script, &origin)->Run();
+ v8::Local<v8::Context> context = env.context();
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(env->GetIsolate(), "test"));
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Set script break point on line 1 (in function f).
int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
@@ -1870,31 +1750,36 @@
// Call f with different ignores on the script break point.
break_point_hit_count = 0;
ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 1);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 5);
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
// Reload the script and get f again checking that the ignore survives.
- v8::Script::Compile(script, &origin)->Run();
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1905,60 +1790,74 @@
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> f;
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " function h() {\n"
- " a = 0; // line 2\n"
- " }\n"
- " b = 1; // line 4\n"
- " return h();\n"
- "}");
+ v8::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::String::NewFromUtf8(env->GetIsolate(), "1"));
- v8::ScriptOrigin origin_2 =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "2"));
+ v8::ScriptOrigin origin_1 = v8::ScriptOrigin(v8_str(env->GetIsolate(), "1"));
+ v8::ScriptOrigin origin_2 = v8::ScriptOrigin(v8_str(env->GetIsolate(), "2"));
// Set a script break point before the script is loaded.
SetScriptBreakPointByNameFromJS(env->GetIsolate(), "1", 2, 0);
// Compile the script and get the function.
- v8::Script::Compile(script, &origin_1)->Run();
+ v8::Script::Compile(context, script, &origin_1)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Call f and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
// Compile the script again with a different script data and get the
// function.
- v8::Script::Compile(script, &origin_2)->Run();
+ v8::Script::Compile(context, script, &origin_2)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Call f and check that no break points are set.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Compile the script again and get the function.
- v8::Script::Compile(script, &origin_1)->Run();
+ v8::Script::Compile(context, script, &origin_1)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
// Call f and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -1969,41 +1868,50 @@
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> f;
- v8::Local<v8::String> script_f =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function f() {\n"
- " a = 0; // line 1\n"
- "}");
+ v8::Local<v8::String> script_f = v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " a = 0; // line 1\n"
+ "}");
v8::Local<v8::Function> g;
- v8::Local<v8::String> script_g =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function g() {\n"
- " b = 0; // line 1\n"
- "}");
+ v8::Local<v8::String> script_g = v8_str(env->GetIsolate(),
+ "function g() {\n"
+ " b = 0; // line 1\n"
+ "}");
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(env->GetIsolate(), "test"));
// Set a script break point before the scripts are loaded.
int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
// Compile the scripts with same script data and get the functions.
- v8::Script::Compile(script_f, &origin)->Run();
+ v8::Script::Compile(context, script_f, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- v8::Script::Compile(script_g, &origin)->Run();
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
+ v8::Script::Compile(context, script_g, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
g = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "g"))
+ .ToLocalChecked());
// Call f and g and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Clear the script break point.
@@ -2011,9 +1919,9 @@
// 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.
@@ -2021,13 +1929,13 @@
// Call f and g and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- g->Call(env->Global(), 0, NULL);
+ g->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2038,20 +1946,21 @@
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> f;
- v8::Local<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "function f() {\n"
- " a = 0; // line 8 as this script has line offset 7\n"
- " b = 0; // line 9 as this script has line offset 7\n"
- "}");
+ v8::Local<v8::String> script =
+ v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " a = 0; // line 8 as this script has line offset 7\n"
+ " b = 0; // line 9 as this script has line offset 7\n"
+ "}");
// Create script origin both name and line offset.
- v8::ScriptOrigin origin(
- v8::String::NewFromUtf8(env->GetIsolate(), "test.html"),
- v8::Integer::New(env->GetIsolate(), 7));
+ v8::ScriptOrigin origin(v8_str(env->GetIsolate(), "test.html"),
+ v8::Integer::New(env->GetIsolate(), 7));
// Set two script break points before the script is loaded.
int sbp1 =
@@ -2060,13 +1969,18 @@
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.
@@ -2075,7 +1989,7 @@
// 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.
@@ -2083,11 +1997,11 @@
// Call f and check that the script break point is active.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2102,25 +2016,27 @@
frame_function_name_source,
"frame_function_name");
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> f;
v8::Local<v8::Function> g;
v8::Local<v8::String> script =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "a = 0 // line 0\n"
- "function f() {\n"
- " a = 1; // line 2\n"
- "}\n"
- " a = 2; // line 4\n"
- " /* xx */ function g() { // line 5\n"
- " function h() { // line 6\n"
- " a = 3; // line 7\n"
- " }\n"
- " h(); // line 9\n"
- " a = 4; // line 10\n"
- " }\n"
- " a=5; // line 12");
+ v8_str(env->GetIsolate(),
+ "a = 0 // line 0\n"
+ "function f() {\n"
+ " a = 1; // line 2\n"
+ "}\n"
+ " a = 2; // line 4\n"
+ " /* xx */ function g() { // line 5\n"
+ " function h() { // line 6\n"
+ " a = 3; // line 7\n"
+ " }\n"
+ " h(); // line 9\n"
+ " a = 4; // line 10\n"
+ " }\n"
+ " a=5; // line 12");
// Set a couple script break point before the script is loaded.
int sbp1 =
@@ -2132,28 +2048,34 @@
// 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("f", last_function_hit);
+ 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("g", last_function_hit);
+ CHECK_EQ(0, strcmp("g", last_function_hit));
// Clear the script break point on g and set one on h.
ClearBreakPointFromJS(env->GetIsolate(), sbp3);
@@ -2161,9 +2083,9 @@
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("h", last_function_hit);
+ CHECK_EQ(0, strcmp("h", last_function_hit));
// Clear break points in f and h. Set a new one in the script between
// functions f and g and test that there is no break points in f and g any
@@ -2173,13 +2095,16 @@
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));
@@ -2189,7 +2114,10 @@
// 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));
@@ -2199,11 +2127,14 @@
ClearBreakPointFromJS(env->GetIsolate(), sbp5);
ClearBreakPointFromJS(env->GetIsolate(), sbp6);
break_point_hit_count = 0;
- v8::Script::Compile(script, &origin)->Run();
+ v8::Script::Compile(context, script, &origin)
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2213,29 +2144,33 @@
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::String> script =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function f() {\n"
- " a = 1; // line 1\n"
- "}\n"
- "a = 2; // line 3\n");
+ v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " a = 1; // line 1\n"
+ "}\n"
+ "a = 2; // line 3\n");
v8::Local<v8::Function> f;
{
v8::HandleScope scope(env->GetIsolate());
CompileRunWithOrigin(script, "test.html");
}
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
- CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
+ CcTest::heap()->CollectAllGarbage();
SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
// 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.
@@ -2246,11 +2181,13 @@
// Call f and check that there are still no break points.
break_point_hit_count = 0;
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2261,14 +2198,14 @@
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
- v8::Local<v8::String> script_source =
- v8::String::NewFromUtf8(env->GetIsolate(),
- "function f() {\n"
- " return 0;\n"
- "}\n"
- "f()");
+ v8::Local<v8::String> script_source = v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " return 0;\n"
+ "}\n"
+ "f()");
int sbp1 =
SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
@@ -2284,8 +2221,8 @@
ClearBreakPointFromJS(env->GetIsolate(), sbp1);
ClearBreakPointFromJS(env->GetIsolate(), sbp2);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2295,23 +2232,26 @@
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");
- debug_event_remove_break_point = SetBreakPoint(foo, 0);
// Register the debug event listener pasing the function
- v8::Debug::SetDebugEventListener(DebugEventRemoveBreakPoint, foo);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventRemoveBreakPoint, foo);
+
+ debug_event_remove_break_point = SetBreakPoint(foo, 0);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2320,28 +2260,38 @@
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
+ v8::Script::Compile(context,
+ v8_str(env->GetIsolate(), "function bar(){debugger}"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function 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);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2350,26 +2300,32 @@
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){debugger;}"))
- ->Run();
+ v8::Local<v8::Context> context = env.context();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Script::Compile(context,
+ v8_str(env->GetIsolate(), "function foo(){debugger;}"))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "foo"))
+ .ToLocalChecked());
- // The debugger statement triggers breakpint hit
- foo->Call(env->Global(), 0, NULL);
+ // The debugger statement triggers breakpoint hit
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
int bp = SetBreakPoint(foo, 0);
// Set breakpoint does not duplicate hits
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
ClearBreakPoint(bp);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2386,25 +2342,21 @@
evaluate_check_source,
"evaluate_check");
// Register the debug event listener
- v8::Debug::SetDebugEventListener(DebugEventEvaluate);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventEvaluate);
// Different expected vaules of x and a when in a break point (u = undefined,
// d = Hello, world!).
- struct EvaluateCheck checks_uu[] = {
- {"x", v8::Undefined(isolate)},
- {"a", v8::Undefined(isolate)},
- {NULL, v8::Handle<v8::Value>()}
- };
+ struct EvaluateCheck checks_uu[] = {{"x", v8::Undefined(isolate)},
+ {"a", v8::Undefined(isolate)},
+ {NULL, v8::Local<v8::Value>()}};
struct EvaluateCheck checks_hu[] = {
- {"x", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")},
- {"a", v8::Undefined(isolate)},
- {NULL, v8::Handle<v8::Value>()}
- };
+ {"x", v8_str(env->GetIsolate(), "Hello, world!")},
+ {"a", v8::Undefined(isolate)},
+ {NULL, v8::Local<v8::Value>()}};
struct EvaluateCheck checks_hh[] = {
- {"x", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")},
- {"a", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")},
- {NULL, v8::Handle<v8::Value>()}
- };
+ {"x", v8_str(env->GetIsolate(), "Hello, world!")},
+ {"a", v8_str(env->GetIsolate(), "Hello, world!")},
+ {NULL, v8::Local<v8::Value>()}};
// Simple test function. The "y=0" is in the function foo to provide a break
// location. For "y=0" the "y" is at position 15 in the foo function
@@ -2421,24 +2373,25 @@
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.
@@ -2457,14 +2410,14 @@
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);
@@ -2491,32 +2444,28 @@
// Call bar setting breakpoint before a=x in barbar and undefined as
// parameter.
checks = checks_uu;
- v8::Handle<v8::Value> argv_bar_1[2] = {
- v8::Undefined(isolate),
- v8::Number::New(isolate, barbar_break_position)
- };
- bar->Call(env->Global(), 2, argv_bar_1);
+ v8::Local<v8::Value> argv_bar_1[2] = {
+ v8::Undefined(isolate), v8::Number::New(isolate, barbar_break_position)};
+ bar->Call(context, env->Global(), 2, argv_bar_1).ToLocalChecked();
// Call bar setting breakpoint before a=x in barbar and parameter
// "Hello, world!".
checks = checks_hu;
- v8::Handle<v8::Value> argv_bar_2[2] = {
- v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
- v8::Number::New(env->GetIsolate(), barbar_break_position)
- };
- bar->Call(env->Global(), 2, argv_bar_2);
+ v8::Local<v8::Value> argv_bar_2[2] = {
+ v8_str(env->GetIsolate(), "Hello, world!"),
+ v8::Number::New(env->GetIsolate(), barbar_break_position)};
+ bar->Call(context, env->Global(), 2, argv_bar_2).ToLocalChecked();
// Call bar setting breakpoint after a=x in barbar and parameter
// "Hello, world!".
checks = checks_hh;
- v8::Handle<v8::Value> argv_bar_3[2] = {
- v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
- v8::Number::New(env->GetIsolate(), barbar_break_position + 1)
- };
- bar->Call(env->Global(), 2, argv_bar_3);
+ v8::Local<v8::Value> argv_bar_3[2] = {
+ v8_str(env->GetIsolate(), "Hello, world!"),
+ v8::Number::New(env->GetIsolate(), barbar_break_position + 1)};
+ bar->Call(context, env->Global(), 2, argv_bar_3).ToLocalChecked();
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -2533,8 +2482,9 @@
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(CheckDebugEvent);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), CheckDebugEvent);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> foo = CompileFunction(&env,
"function foo(x) {\n"
" var s = 'String value2';\n"
@@ -2547,27 +2497,34 @@
debugEventCount = 0;
env->AllowCodeGenerationFromStrings(false);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, debugEventCount);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
bool checkedDebugEvals = true;
-v8::Handle<v8::Function> checkGlobalEvalFunction;
-v8::Handle<v8::Function> checkFrameEvalFunction;
+v8::Local<v8::Function> checkGlobalEvalFunction;
+v8::Local<v8::Function> checkFrameEvalFunction;
static void CheckDebugEval(const v8::Debug::EventDetails& eventDetails) {
if (eventDetails.GetEvent() == v8::Break) {
++debugEventCount;
v8::HandleScope handleScope(CcTest::isolate());
- v8::Handle<v8::Value> args[] = { eventDetails.GetExecutionState() };
- CHECK(checkGlobalEvalFunction->Call(
- eventDetails.GetEventContext()->Global(), 1, args)->IsTrue());
- CHECK(checkFrameEvalFunction->Call(
- eventDetails.GetEventContext()->Global(), 1, args)->IsTrue());
+ v8::Local<v8::Value> args[] = {eventDetails.GetExecutionState()};
+ CHECK(
+ checkGlobalEvalFunction->Call(eventDetails.GetEventContext(),
+ eventDetails.GetEventContext()->Global(),
+ 1, args)
+ .ToLocalChecked()
+ ->IsTrue());
+ CHECK(checkFrameEvalFunction->Call(eventDetails.GetEventContext(),
+ eventDetails.GetEventContext()->Global(),
+ 1, args)
+ .ToLocalChecked()
+ ->IsTrue());
}
}
@@ -2580,8 +2537,9 @@
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(CheckDebugEval);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), CheckDebugEval);
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> foo = CompileFunction(&env,
"var global = 'Global';\n"
"function foo(x) {\n"
@@ -2603,13 +2561,13 @@
"checkFrameEval");
debugEventCount = 0;
env->AllowCodeGenerationFromStrings(false);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, debugEventCount);
checkGlobalEvalFunction.Clear();
checkFrameEvalFunction.Clear();
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2697,7 +2655,7 @@
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();
@@ -2713,18 +2671,21 @@
// Test that the evaluation of expressions works even from ProcessDebugMessages
// i.e. with empty stack.
TEST(DebugEvaluateWithoutStack) {
- v8::Debug::SetMessageHandler(DebugProcessDebugMessagesHandler);
-
DebugLocalContext env;
+ v8::Debug::SetMessageHandler(env->GetIsolate(),
+ DebugProcessDebugMessagesHandler);
v8::HandleScope scope(env->GetIsolate());
const char* source =
"var v1 = 'Pinguin';\n function getAnimal() { return 'Capy' + 'bara'; }";
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source))
- ->Run();
+ v8::Local<v8::Context> context = env.context();
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), source))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(env->GetIsolate());
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -2760,7 +2721,7 @@
v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_113, buffer));
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
CHECK_EQ(3, process_debug_messages_data.counter);
@@ -2769,9 +2730,9 @@
0);
CHECK_EQ(strcmp("805", process_debug_messages_data.results[2].buffer), 0);
- v8::Debug::SetMessageHandler(NULL);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2788,33 +2749,35 @@
// Run foo to allow it to get optimized.
CompileRun("a=0; b=0; c=0; foo();");
- SetBreakPoint(foo, 3);
-
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+
+ SetBreakPoint(foo, 3);
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ v8::Local<v8::Context> context = env.context();
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(4, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
SetBreakPoint(foo, 3);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only active break points are hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2824,7 +2787,7 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
// Create a function for testing stepping of keyed load. The statement 'y=1'
// is there to have more than one breakable statement in the loop, TODO(315).
@@ -2841,29 +2804,31 @@
"y=0\n",
"foo");
+ v8::Local<v8::Context> context = env.context();
// Create array [0,1,2,3,4,5,6,7,8,9]
v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
for (int i = 0; i < 10; i++) {
- a->Set(v8::Number::New(env->GetIsolate(), i),
- v8::Number::New(env->GetIsolate(), i));
+ CHECK(a->Set(context, v8::Number::New(env->GetIsolate(), i),
+ v8::Number::New(env->GetIsolate(), i))
+ .FromJust());
}
// Call function without any break points to ensure inlining is in place.
const int kArgc = 1;
- v8::Handle<v8::Value> args[kArgc] = { a };
- foo->Call(env->Global(), kArgc, args);
+ v8::Local<v8::Value> args[kArgc] = {a};
+ foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
// Set up break point and step through the function.
SetBreakPoint(foo, 3);
step_action = StepNext;
break_point_hit_count = 0;
- foo->Call(env->Global(), kArgc, args);
+ foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(45, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2873,7 +2838,7 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
// Create a function for testing stepping of keyed store. The statement 'y=1'
// is there to have more than one breakable statement in the loop, TODO(315).
@@ -2889,29 +2854,31 @@
"y=0\n",
"foo");
+ v8::Local<v8::Context> context = env.context();
// Create array [0,1,2,3,4,5,6,7,8,9]
v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
for (int i = 0; i < 10; i++) {
- a->Set(v8::Number::New(env->GetIsolate(), i),
- v8::Number::New(env->GetIsolate(), i));
+ CHECK(a->Set(context, v8::Number::New(env->GetIsolate(), i),
+ v8::Number::New(env->GetIsolate(), i))
+ .FromJust());
}
// Call function without any break points to ensure inlining is in place.
const int kArgc = 1;
- v8::Handle<v8::Value> args[kArgc] = { a };
- foo->Call(env->Global(), kArgc, args);
+ v8::Local<v8::Value> args[kArgc] = {a};
+ foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
// Set up break point and step through the function.
SetBreakPoint(foo, 3);
step_action = StepNext;
break_point_hit_count = 0;
- foo->Call(env->Global(), kArgc, args);
+ foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(44, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2921,8 +2888,9 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping of named load.
v8::Local<v8::Function> foo = CompileFunction(
&env,
@@ -2943,19 +2911,19 @@
"foo");
// Call function without any break points to ensure inlining is in place.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Set up break point and step through the function.
SetBreakPoint(foo, 4);
step_action = StepNext;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(65, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -2964,9 +2932,10 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
// Create a function for testing stepping of named store.
+ v8::Local<v8::Context> context = env.context();
v8::Local<v8::Function> foo = CompileFunction(
&env,
"function foo() {\n"
@@ -2978,19 +2947,19 @@
"foo");
// Call function without any break points to ensure inlining is in place.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Set up break point and step through the function.
SetBreakPoint(foo, 3);
step_action = StepNext;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all expected break locations are hit.
CHECK_EQ(expected, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3004,8 +2973,9 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping.
v8::Local<v8::Function> foo = CompileFunction(&env,
"function bar() {};"
@@ -3022,26 +2992,27 @@
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(11, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
SetBreakPoint(foo, 0);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only active break points are hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3050,8 +3021,9 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function foo() { "
@@ -3069,12 +3041,12 @@
// Stepping through the declarations.
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3083,8 +3055,9 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function foo() { "
@@ -3102,12 +3075,12 @@
// Stepping through the declarations.
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3117,8 +3090,9 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3138,20 +3112,20 @@
// Stepping through the true part.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_true[argc] = { v8::True(isolate) };
- foo->Call(env->Global(), argc, argv_true);
+ v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)};
+ foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
// Stepping through the false part.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_false[argc] = { v8::False(isolate) };
- foo->Call(env->Global(), argc, argv_false);
+ v8::Local<v8::Value> argv_false[argc] = {v8::False(isolate)};
+ foo->Call(context, env->Global(), argc, argv_false).ToLocalChecked();
CHECK_EQ(5, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3161,8 +3135,9 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3188,27 +3163,27 @@
// One case with fall-through.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_1[argc] = { v8::Number::New(isolate, 1) };
- foo->Call(env->Global(), argc, argv_1);
+ v8::Local<v8::Value> argv_1[argc] = {v8::Number::New(isolate, 1)};
+ foo->Call(context, env->Global(), argc, argv_1).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Another case.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_2[argc] = { v8::Number::New(isolate, 2) };
- foo->Call(env->Global(), argc, argv_2);
+ v8::Local<v8::Value> argv_2[argc] = {v8::Number::New(isolate, 2)};
+ foo->Call(context, env->Global(), argc, argv_2).ToLocalChecked();
CHECK_EQ(5, break_point_hit_count);
// Last case.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_3[argc] = { v8::Number::New(isolate, 3) };
- foo->Call(env->Global(), argc, argv_3);
+ v8::Local<v8::Value> argv_3[argc] = {v8::Number::New(isolate, 3)};
+ foo->Call(context, env->Global(), argc, argv_3).ToLocalChecked();
CHECK_EQ(7, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3218,8 +3193,9 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3236,27 +3212,27 @@
// Looping 0 times. We still should break at the while-condition once.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_0[argc] = { v8::Number::New(isolate, 0) };
- foo->Call(env->Global(), argc, argv_0);
+ v8::Local<v8::Value> argv_0[argc] = {v8::Number::New(isolate, 0)};
+ foo->Call(context, env->Global(), argc, argv_0).ToLocalChecked();
CHECK_EQ(3, break_point_hit_count);
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
- foo->Call(env->Global(), argc, argv_10);
+ v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)};
+ foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked();
CHECK_EQ(23, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
- foo->Call(env->Global(), argc, argv_100);
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
CHECK_EQ(203, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3266,8 +3242,9 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3281,23 +3258,30 @@
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
SetBreakPoint(foo, 8); // "var a = 0;"
+ // Looping 0 times.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Local<v8::Value> argv_0[argc] = {v8::Number::New(isolate, 0)};
+ foo->Call(context, env->Global(), argc, argv_0).ToLocalChecked();
+ CHECK_EQ(4, break_point_hit_count);
+
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
- foo->Call(env->Global(), argc, argv_10);
+ v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)};
+ foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked();
CHECK_EQ(22, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
- foo->Call(env->Global(), argc, argv_100);
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
CHECK_EQ(202, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3307,8 +3291,9 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3323,23 +3308,30 @@
SetBreakPoint(foo, 8); // "a = 1;"
+ // Looping 0 times.
+ step_action = StepIn;
+ break_point_hit_count = 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);
- CHECK_EQ(45, break_point_hit_count);
+ 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);
- CHECK_EQ(405, break_point_hit_count);
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
+ CHECK_EQ(304, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3349,8 +3341,9 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3368,7 +3361,7 @@
"}"
"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.
@@ -3376,22 +3369,22 @@
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
- result = foo->Call(env->Global(), argc, argv_10);
- CHECK_EQ(5, result->Int32Value());
+ v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)};
+ result = foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked();
+ CHECK_EQ(5, result->Int32Value(context).FromJust());
CHECK_EQ(62, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
- result = foo->Call(env->Global(), argc, argv_100);
- CHECK_EQ(50, result->Int32Value());
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
+ CHECK_EQ(50, result->Int32Value(context).FromJust());
CHECK_EQ(557, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3401,8 +3394,9 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const int argc = 1;
@@ -3420,7 +3414,7 @@
"}"
"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)
@@ -3429,22 +3423,22 @@
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
- result = foo->Call(env->Global(), argc, argv_10);
- CHECK_EQ(9, result->Int32Value());
+ v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)};
+ result = foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked();
+ CHECK_EQ(9, result->Int32Value(context).FromJust());
CHECK_EQ(64, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
- v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
- result = foo->Call(env->Global(), argc, argv_100);
- CHECK_EQ(99, result->Int32Value());
+ v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
+ result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
+ CHECK_EQ(99, result->Int32Value(context).FromJust());
CHECK_EQ(604, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3453,8 +3447,9 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
v8::Local<v8::Function> foo;
@@ -3470,7 +3465,7 @@
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
@@ -3487,12 +3482,12 @@
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(10, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3501,8 +3496,9 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function foo(x) { "
@@ -3511,20 +3507,22 @@
" with (b) {}"
"}"
"foo()";
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"),
- v8::Object::New(env->GetIsolate()));
+ CHECK(env->Global()
+ ->Set(context, v8_str(env->GetIsolate(), "b"),
+ v8::Object::New(env->GetIsolate()))
+ .FromJust());
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
- v8::Handle<v8::Value> result;
+ v8::Local<v8::Value> result;
SetBreakPoint(foo, 8); // "var a = {};"
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3534,8 +3532,9 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function foo(x) { "
@@ -3549,19 +3548,19 @@
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
- CHECK_EQ(5, break_point_hit_count);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ CHECK_EQ(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);
- CHECK_EQ(5, break_point_hit_count);
+ v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)};
+ foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked();
+ CHECK_EQ(4, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3575,8 +3574,9 @@
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function a() {b();c();}; "
@@ -3590,7 +3590,7 @@
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);
@@ -3598,7 +3598,7 @@
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);
@@ -3606,13 +3606,13 @@
step_action = StepOut;
break_point_hit_count = 0;
expected_step_sequence = "a";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3626,8 +3626,9 @@
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function a() {b(c(d()),d());c(d());d()}; "
@@ -3642,7 +3643,7 @@
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);
@@ -3650,7 +3651,7 @@
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);
@@ -3658,13 +3659,13 @@
step_action = StepOut;
break_point_hit_count = 0;
expected_step_sequence = "a";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded(true);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
}
@@ -3678,8 +3679,9 @@
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping. Run it to allow it to get
// optimized.
const char* src = "function a() {b(false);c();}; "
@@ -3693,13 +3695,13 @@
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "abbaca";
- a->Call(env->Global(), 0, NULL);
+ a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3715,29 +3717,31 @@
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(3, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only active break points are hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3754,29 +3758,31 @@
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep);
+ v8::Local<v8::Context> context = env.context();
step_action = StepIn;
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// With stepping all break locations are hit.
CHECK_EQ(7, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only the debugger statement is hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -3786,6 +3792,7 @@
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,
@@ -3800,35 +3807,78 @@
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
step_action = StepIn;
// Check stepping where the if condition in bar is false.
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(6, break_point_hit_count);
// Check stepping where the if condition in bar is true.
break_point_hit_count = 0;
const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = { v8::True(isolate) };
- foo->Call(env->Global(), argc, argv);
+ v8::Local<v8::Value> argv[argc] = {v8::True(isolate)};
+ foo->Call(context, env->Global(), argc, argv).ToLocalChecked();
CHECK_EQ(8, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
// Register a debug event listener which just counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Without stepping only the debugger statement is hit.
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
+}
+
+
+// Test that step in works with Function.call.apply.
+TEST(DebugStepFunctionCallApply) {
+ DebugLocalContext env;
+ 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,
+ "function bar() { }"
+ "function foo(){ debugger;"
+ " Function.call.apply(bar);"
+ " Function.call.apply(Function.call, "
+ "[Function.call, bar]);"
+ "}",
+ "foo");
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(isolate, DebugEventStep);
+ step_action = StepIn;
+
+ break_point_hit_count = 0;
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ CHECK_EQ(6, break_point_hit_count);
+
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
+
+ // Register a debug event listener which just counts.
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
+
+ break_point_hit_count = 0;
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+
+ // Without stepping only the debugger statement is hit.
+ CHECK_EQ(1, break_point_hit_count);
+
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -3839,8 +3889,9 @@
env.ExposeDebug();
// Register a debug event listener which counts.
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
+ v8::Local<v8::Context> context = env.context();
// Create a script that returns a function.
const char* src = "(function (evt) {})";
const char* script_name = "StepInHandlerTest";
@@ -3849,19 +3900,26 @@
SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1);
break_point_hit_count = 0;
- v8::ScriptOrigin origin(
- v8::String::NewFromUtf8(env->GetIsolate(), script_name),
- v8::Integer::New(env->GetIsolate(), 0));
- v8::Handle<v8::Script> script = v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), src), &origin);
- v8::Local<v8::Value> r = script->Run();
+ v8::ScriptOrigin origin(v8_str(env->GetIsolate(), script_name),
+ v8::Integer::New(env->GetIsolate(), 0));
+ v8::Local<v8::Script> script =
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), src), &origin)
+ .ToLocalChecked();
+ v8::Local<v8::Value> r = script->Run(context).ToLocalChecked();
CHECK(r->IsFunction());
CHECK_EQ(1, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
+}
+
+
+static void DebugEventCounterCheck(int caught, int uncaught, int message) {
+ CHECK_EQ(caught, exception_hit_count);
+ CHECK_EQ(uncaught, uncaught_exception_hit_count);
+ CHECK_EQ(message, message_callback_count);
}
@@ -3876,6 +3934,7 @@
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 =
@@ -3884,129 +3943,168 @@
"caught");
v8::Local<v8::Function> notCaught =
CompileFunction(&env, "function notCaught(){throws();}", "notCaught");
+ v8::Local<v8::Function> notCaughtFinally = CompileFunction(
+ &env, "function notCaughtFinally(){try{throws();}finally{}}",
+ "notCaughtFinally");
+ // In this edge case, even though this finally does not propagate the
+ // exception, the debugger considers this uncaught, since we want to break
+ // at the first throw for the general case where finally implicitly rethrows.
+ v8::Local<v8::Function> edgeCaseFinally = CompileFunction(
+ &env, "function caughtFinally(){L:try{throws();}finally{break L;}}",
+ "caughtFinally");
- v8::V8::AddMessageListener(MessageCallbackCount);
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ env->GetIsolate()->AddMessageListener(MessageCallbackCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
// Initial state should be no break on exceptions.
DebugEventCounterClear();
MessageCallbackCountClear();
- caught->Call(env->Global(), 0, NULL);
- CHECK_EQ(0, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(0, message_callback_count);
- notCaught->Call(env->Global(), 0, NULL);
- CHECK_EQ(0, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(1, message_callback_count);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(0, 0, 0);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(0, 0, 1);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(0, 0, 2);
+ 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);
- CHECK_EQ(0, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(0, message_callback_count);
- notCaught->Call(env->Global(), 0, NULL);
- CHECK_EQ(0, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(1, message_callback_count);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(0, 0, 0);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(0, 0, 1);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(0, 0, 2);
+ 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);
- CHECK_EQ(0, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(0, message_callback_count);
- notCaught->Call(env->Global(), 0, NULL);
- CHECK_EQ(1, exception_hit_count);
- CHECK_EQ(1, uncaught_exception_hit_count);
- CHECK_EQ(1, message_callback_count);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(0, 0, 0);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(1, 1, 1);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(2, 2, 2);
+ 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);
- CHECK_EQ(1, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(0, message_callback_count);
- notCaught->Call(env->Global(), 0, NULL);
- CHECK_EQ(2, exception_hit_count);
- CHECK_EQ(1, uncaught_exception_hit_count);
- CHECK_EQ(1, message_callback_count);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(1, 0, 0);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(2, 1, 1);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(3, 2, 2);
+ 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);
- CHECK_EQ(1, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(0, message_callback_count);
- notCaught->Call(env->Global(), 0, NULL);
- CHECK_EQ(2, exception_hit_count);
- CHECK_EQ(1, uncaught_exception_hit_count);
- CHECK_EQ(1, message_callback_count);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(1, 0, 0);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(2, 1, 1);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(3, 2, 2);
+ 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);
- CHECK_EQ(0, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(0, message_callback_count);
- notCaught->Call(env->Global(), 0, NULL);
- CHECK_EQ(0, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(1, message_callback_count);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(0, 0, 0);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(0, 0, 1);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(0, 0, 2);
+ 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);
- CHECK_EQ(0, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(0, message_callback_count);
- notCaught->Call(env->Global(), 0, NULL);
- CHECK_EQ(1, exception_hit_count);
- CHECK_EQ(1, uncaught_exception_hit_count);
- CHECK_EQ(1, message_callback_count);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(0, 0, 0);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(1, 1, 1);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(2, 2, 2);
+ 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);
- CHECK_EQ(1, exception_hit_count);
- CHECK_EQ(0, message_callback_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- notCaught->Call(env->Global(), 0, NULL);
- CHECK_EQ(2, exception_hit_count);
- CHECK_EQ(1, uncaught_exception_hit_count);
- CHECK_EQ(1, message_callback_count);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(1, 0, 0);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(2, 1, 1);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(3, 2, 2);
+ 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);
- CHECK_EQ(1, exception_hit_count);
- CHECK_EQ(0, uncaught_exception_hit_count);
- CHECK_EQ(0, message_callback_count);
- notCaught->Call(env->Global(), 0, NULL);
- CHECK_EQ(2, exception_hit_count);
- CHECK_EQ(1, uncaught_exception_hit_count);
- CHECK_EQ(1, message_callback_count);
+ caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(1, 0, 0);
+ CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(2, 1, 1);
+ CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
+ DebugEventCounterCheck(3, 2, 2);
+ edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
+ DebugEventCounterCheck(4, 3, 2);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
- v8::V8::RemoveMessageListeners(MessageCallbackCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
+ env->GetIsolate()->RemoveMessageListeners(MessageCallbackCount);
+}
+
+
+static void try_finally_original_message(v8::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++;
+}
+
+
+TEST(TryFinallyOriginalMessage) {
+ // Test that the debugger plays nicely with the pending message.
+ message_callback_count = 0;
+ DebugEventCounterClear();
+ DebugLocalContext env;
+ v8::Isolate* isolate = CcTest::isolate();
+ isolate->AddMessageListener(try_finally_original_message);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventCounter);
+ ChangeBreakOnException(true, true);
+ v8::HandleScope scope(isolate);
+ CompileRun(
+ "try {\n"
+ " throw 1;\n"
+ "} finally {\n"
+ "}\n");
+ DebugEventCounterCheck(1, 1, 1);
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ isolate->RemoveMessageListeners(try_finally_original_message);
}
@@ -4023,8 +4121,8 @@
debug_event_listener_callback = noThrowJS;
debug_event_listener_callback_result = 2;
- v8::V8::AddMessageListener(MessageCallbackCount);
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ env->GetIsolate()->AddMessageListener(MessageCallbackCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
// Break on uncaught exception
ChangeBreakOnException(false, true);
DebugEventCounterClear();
@@ -4032,9 +4130,9 @@
// ReThrow native error
{
- v8::TryCatch tryCatch;
- env->GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(env->GetIsolate(), "Type error")));
+ v8::TryCatch tryCatch(env->GetIsolate());
+ env->GetIsolate()->ThrowException(
+ v8::Exception::TypeError(v8_str(env->GetIsolate(), "Type error")));
CHECK(tryCatch.HasCaught());
tryCatch.ReThrow();
}
@@ -4054,14 +4152,15 @@
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
// For this test, we want to break on uncaught exceptions:
ChangeBreakOnException(false, true);
// Create a function for checking the function when hitting a break point.
frame_count = CompileFunction(&env, frame_count_source, "frame_count");
- v8::V8::AddMessageListener(MessageCallbackCount);
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ env->GetIsolate()->AddMessageListener(MessageCallbackCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
DebugEventCounterClear();
MessageCallbackCountClear();
@@ -4073,30 +4172,36 @@
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);
@@ -4117,8 +4222,9 @@
"frame_function_name");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStepSequence);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
+ v8::Local<v8::Context> context = env.context();
// Create functions for testing stepping.
const char* src = "function a() { n(); }; "
"function b() { c(); }; "
@@ -4130,32 +4236,36 @@
"function h() { x = 1; throw 1; }; ";
// Step through invocation of a.
+ ClearStepping();
v8::Local<v8::Function> a = CompileFunction(&env, src, "a");
SetBreakPoint(a, 0);
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "aa";
- a->Call(env->Global(), 0, NULL);
+ CHECK(a->Call(context, env->Global(), 0, NULL).IsEmpty());
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Step through invocation of b + c.
+ ClearStepping();
v8::Local<v8::Function> b = CompileFunction(&env, src, "b");
SetBreakPoint(b, 0);
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "bcc";
- b->Call(env->Global(), 0, NULL);
+ CHECK(b->Call(context, env->Global(), 0, NULL).IsEmpty());
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
+
// Step through invocation of d + e.
+ ClearStepping();
v8::Local<v8::Function> d = CompileFunction(&env, src, "d");
SetBreakPoint(d, 0);
ChangeBreakOnException(false, true);
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "ddedd";
- d->Call(env->Global(), 0, NULL);
+ d->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -4164,18 +4274,19 @@
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "ddeedd";
- d->Call(env->Global(), 0, NULL);
+ d->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Step through invocation of f + g + h.
+ ClearStepping();
v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
SetBreakPoint(f, 0);
ChangeBreakOnException(false, true);
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "ffghhff";
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -4184,13 +4295,13 @@
step_action = StepIn;
break_point_hit_count = 0;
expected_step_sequence = "ffghhhff";
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -4204,8 +4315,9 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener(DebugEventBreak);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventBreak);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping.
const char* src = "function f0() {}"
"function f1(x1) {}"
@@ -4217,16 +4329,15 @@
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());
@@ -4235,18 +4346,18 @@
// Call all functions with different argument count.
break_point_hit_count = 0;
for (unsigned int i = 0; i < arraysize(argv); i++) {
- f0->Call(env->Global(), i, argv);
- f1->Call(env->Global(), i, argv);
- f2->Call(env->Global(), i, argv);
- f3->Call(env->Global(), i, argv);
+ f0->Call(context, env->Global(), i, argv).ToLocalChecked();
+ f1->Call(context, env->Global(), i, argv).ToLocalChecked();
+ f2->Call(context, env->Global(), i, argv).ToLocalChecked();
+ f3->Call(context, env->Global(), i, argv).ToLocalChecked();
}
// One break for each function called.
- CHECK_EQ(4 * arraysize(argv), break_point_hit_count);
+ CHECK(4 * arraysize(argv) == break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -4257,8 +4368,9 @@
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
+ v8::Local<v8::Context> context = env.context();
// Create a function for testing stepping.
const char* src = "function f() {g()};function g(){i=0; while(i<10){i++}}";
v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
@@ -4274,23 +4386,40 @@
// Call all functions with different argument count.
break_point_hit_count = 0;
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
{
v8::Debug::DebugBreak(env->GetIsolate());
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate());
v8::internal::DisableBreak disable_break(isolate->debug(), true);
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
}
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
+}
+
+
+TEST(DisableDebuggerStatement) {
+ DebugLocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+
+ // Register a debug event listener which sets the break flag and counts.
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
+ CompileRun("debugger;");
+ CHECK_EQ(1, break_point_hit_count);
+
+ // Check that we ignore debugger statement when breakpoints aren't active.
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate());
+ isolate->debug()->set_break_points_active(false);
+ CompileRun("debugger;");
+ CHECK_EQ(1, break_point_hit_count);
}
static const char* kSimpleExtensionSource =
@@ -4305,7 +4434,7 @@
v8::HandleScope scope(isolate);
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener(DebugEventCounter);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventCounter);
// Set the debug break flag.
v8::Debug::DebugBreak(isolate);
@@ -4324,28 +4453,37 @@
CHECK_EQ(0, break_point_hit_count);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
- v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
- result->Set(v8::Integer::New(info.GetIsolate(), 0),
- v8::String::NewFromUtf8(info.GetIsolate(), "a"));
- result->Set(v8::Integer::New(info.GetIsolate(), 1),
- v8::String::NewFromUtf8(info.GetIsolate(), "b"));
- result->Set(v8::Integer::New(info.GetIsolate(), 2),
- v8::String::NewFromUtf8(info.GetIsolate(), "c"));
+ v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 0),
+ v8_str(info.GetIsolate(), "a"))
+ .FromJust());
+ CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 1),
+ v8_str(info.GetIsolate(), "b"))
+ .FromJust());
+ CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 2),
+ v8_str(info.GetIsolate(), "c"))
+ .FromJust());
info.GetReturnValue().Set(result);
}
static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
v8::Isolate* isolate = info.GetIsolate();
- v8::Handle<v8::Array> result = v8::Array::New(isolate, 2);
- result->Set(v8::Integer::New(isolate, 0), v8::Number::New(isolate, 1));
- result->Set(v8::Integer::New(isolate, 1), v8::Number::New(isolate, 10));
+ v8::Local<v8::Array> result = v8::Array::New(isolate, 2);
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ CHECK(result->Set(context, v8::Integer::New(isolate, 0),
+ v8::Number::New(isolate, 1))
+ .FromJust());
+ CHECK(result->Set(context, v8::Integer::New(isolate, 1),
+ v8::Number::New(isolate, 10))
+ .FromJust());
info.GetReturnValue().Set(result);
}
@@ -4355,13 +4493,13 @@
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();
@@ -4384,75 +4522,71 @@
v8::HandleScope scope(isolate);
env.ExposeDebug();
+ v8::Local<v8::Context> context = env.context();
// Create object with named interceptor.
- v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
named->SetHandler(v8::NamedPropertyHandlerConfiguration(
NamedGetter, NULL, NULL, NULL, NamedEnum));
- env->Global()->Set(
- v8::String::NewFromUtf8(isolate, "intercepted_named"),
- named->NewInstance());
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "intercepted_named"),
+ named->NewInstance(context).ToLocalChecked())
+ .FromJust());
// Create object with indexed interceptor.
- v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(isolate);
indexed->SetHandler(v8::IndexedPropertyHandlerConfiguration(
IndexedGetter, NULL, NULL, NULL, IndexedEnum));
- env->Global()->Set(
- v8::String::NewFromUtf8(isolate, "intercepted_indexed"),
- indexed->NewInstance());
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "intercepted_indexed"),
+ indexed->NewInstance(context).ToLocalChecked())
+ .FromJust());
// Create object with both named and indexed interceptor.
- v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> both = v8::ObjectTemplate::New(isolate);
both->SetHandler(v8::NamedPropertyHandlerConfiguration(
NamedGetter, NULL, NULL, NULL, NamedEnum));
both->SetHandler(v8::IndexedPropertyHandlerConfiguration(
IndexedGetter, NULL, NULL, NULL, IndexedEnum));
- env->Global()->Set(
- v8::String::NewFromUtf8(isolate, "intercepted_both"),
- both->NewInstance());
+ CHECK(env->Global()
+ ->Set(context, v8_str(isolate, "intercepted_both"),
+ both->NewInstance(context).ToLocalChecked())
+ .FromJust());
// Get mirrors for the three objects with interceptor.
CompileRun(
"var named_mirror = debug.MakeMirror(intercepted_named);"
"var indexed_mirror = debug.MakeMirror(intercepted_indexed);"
"var both_mirror = debug.MakeMirror(intercepted_both)");
- CHECK(CompileRun(
- "named_mirror instanceof debug.ObjectMirror")->BooleanValue());
- CHECK(CompileRun(
- "indexed_mirror instanceof debug.ObjectMirror")->BooleanValue());
- CHECK(CompileRun(
- "both_mirror instanceof debug.ObjectMirror")->BooleanValue());
+ CHECK(CompileRun("named_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("indexed_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
+ CHECK(CompileRun("both_mirror instanceof debug.ObjectMirror")
+ ->BooleanValue(context)
+ .FromJust());
// Get the property names from the interceptors
CompileRun(
"named_names = named_mirror.propertyNames();"
"indexed_names = indexed_mirror.propertyNames();"
"both_names = both_mirror.propertyNames()");
- CHECK_EQ(3, CompileRun("named_names.length")->Int32Value());
- CHECK_EQ(2, CompileRun("indexed_names.length")->Int32Value());
- CHECK_EQ(5, CompileRun("both_names.length")->Int32Value());
+ CHECK_EQ(3, CompileRun("named_names.length")->Int32Value(context).FromJust());
+ CHECK_EQ(2,
+ CompileRun("indexed_names.length")->Int32Value(context).FromJust());
+ CHECK_EQ(5, CompileRun("both_names.length")->Int32Value(context).FromJust());
// Check the expected number of properties.
const char* source;
source = "named_mirror.properties().length";
- CHECK_EQ(3, CompileRun(source)->Int32Value());
+ CHECK_EQ(3, CompileRun(source)->Int32Value(context).FromJust());
source = "indexed_mirror.properties().length";
- CHECK_EQ(2, CompileRun(source)->Int32Value());
+ CHECK_EQ(2, CompileRun(source)->Int32Value(context).FromJust());
source = "both_mirror.properties().length";
- CHECK_EQ(5, CompileRun(source)->Int32Value());
-
- // 1 is PropertyKind.Named;
- source = "both_mirror.properties(1).length";
- CHECK_EQ(3, CompileRun(source)->Int32Value());
-
- // 2 is PropertyKind.Indexed;
- source = "both_mirror.properties(2).length";
- CHECK_EQ(2, CompileRun(source)->Int32Value());
-
- // 3 is PropertyKind.Named | PropertyKind.Indexed;
- source = "both_mirror.properties(3).length";
- CHECK_EQ(5, CompileRun(source)->Int32Value());
+ CHECK_EQ(5, CompileRun(source)->Int32Value(context).FromJust());
// Get the interceptor properties for the object with only named interceptor.
CompileRun("var named_values = named_mirror.properties()");
@@ -4462,10 +4596,10 @@
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
@@ -4477,7 +4611,7 @@
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
@@ -4488,24 +4622,24 @@
for (int i = 0; i < 5; i++) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
SNPrintF(buffer, "both_values[%d] instanceof debug.PropertyMirror", i);
- CHECK(CompileRun(buffer.start())->BooleanValue());
+ CHECK(CompileRun(buffer.start())->BooleanValue(context).FromJust());
}
// Check the property names.
- source = "both_values[0].name() == 'a'";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[0].name() == '1'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
- source = "both_values[1].name() == 'b'";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[1].name() == '10'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
- source = "both_values[2].name() == 'c'";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[2].name() == 'a'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
- source = "both_values[3].name() == 1";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[3].name() == 'b'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
- source = "both_values[4].name() == 10";
- CHECK(CompileRun(source)->BooleanValue());
+ source = "both_values[4].name() == 'c'";
+ CHECK(CompileRun(source)->BooleanValue(context).FromJust());
}
@@ -4516,30 +4650,43 @@
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(
@@ -4547,43 +4694,62 @@
"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
@@ -4591,21 +4757,30 @@
// 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());
}
@@ -4623,29 +4798,35 @@
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());
}
@@ -4663,30 +4844,37 @@
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());
}
@@ -4700,74 +4888,97 @@
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->SetHiddenValue(
- 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();
- protoObj->SetHiddenValue(
- v8::String::NewFromUtf8(isolate, "v8::test-debug::b"),
- v8::Int32::New(isolate, 12));
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"),
- protoObj);
- v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
- grandProtoObj->SetHiddenValue(
- v8::String::NewFromUtf8(isolate, "v8::test-debug::c"),
- v8::Int32::New(isolate, 13));
- env->Global()->Set(
- v8::String::NewFromUtf8(isolate, "grandProtoObj"),
- grandProtoObj);
+ v8::Local<v8::Object> protoObj = t0->GetFunction(context)
+ .ToLocalChecked()
+ ->NewInstance(context)
+ .ToLocalChecked();
+ protoObj->SetPrivate(
+ env.context(),
+ v8::Private::New(isolate, v8_str(isolate, "v8::test-debug::b")),
+ v8::Int32::New(isolate, 12))
+ .FromJust();
+ 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();
+ 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());
}
@@ -4779,7 +4990,7 @@
// The Wait() call blocks a thread until it is called for the Nth time, then all
// calls return. Each ThreadBarrier object can only be used once.
template <int N>
-class ThreadBarrier FINAL {
+class ThreadBarrier final {
public:
ThreadBarrier() : num_blocked_(0) {}
@@ -4937,7 +5148,7 @@
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.
@@ -5043,7 +5254,7 @@
// Create a V8 environment
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetMessageHandler(MessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), MessageHandler);
message_queue_debugger_thread.Start();
const char* source_1 = "a = 3; b = 4; c = new Object(); c.d = 5;";
@@ -5137,7 +5348,7 @@
v8::HandleScope scope(isolate);
TestClientData::ResetCounters();
handled_client_data_instances_count = 0;
- v8::Debug::SetMessageHandler(MessageHandlerCountingClientData);
+ v8::Debug::SetMessageHandler(isolate, MessageHandlerCountingClientData);
const char* source_1 = "a = 3; b = 4; c = new Object(); c.d = 5;";
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -5219,7 +5430,7 @@
if (IsBreakEventMessage(print_buffer)) {
// Check that we are inside the while loop.
int source_line = GetSourceLineFromBreakEventMessage(print_buffer);
- CHECK(8 <= source_line && source_line <= 13);
+ CHECK(4 <= source_line && source_line <= 10);
threaded_debugging_barriers.barrier_2.Wait();
}
}
@@ -5228,10 +5439,6 @@
void V8Thread::Run() {
const char* source =
"flag = true;\n"
- "function bar( new_value ) {\n"
- " flag = new_value;\n"
- " return \"Return from bar(\" + new_value + \")\";\n"
- "}\n"
"\n"
"function foo() {\n"
" var x = 1;\n"
@@ -5245,19 +5452,21 @@
"\n"
"foo();\n";
- isolate_ = v8::Isolate::New();
+ v8::Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
+ isolate_ = v8::Isolate::New(create_params);
threaded_debugging_barriers.barrier_3.Wait();
{
v8::Isolate::Scope isolate_scope(isolate_);
DebugLocalContext env(isolate_);
v8::HandleScope scope(isolate_);
- v8::Debug::SetMessageHandler(&ThreadedMessageHandler);
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Debug::SetMessageHandler(isolate_, &ThreadedMessageHandler);
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(env->GetIsolate());
global_template->Set(
- v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
+ v8_str(env->GetIsolate(), "ThreadedAtBarrier1"),
v8::FunctionTemplate::New(isolate_, ThreadedAtBarrier1));
- v8::Handle<v8::Context> context =
+ v8::Local<v8::Context> context =
v8::Context::New(isolate_, NULL, global_template);
v8::Context::Scope context_scope(context);
@@ -5272,10 +5481,11 @@
const int kBufSize = 1000;
uint16_t buffer[kBufSize];
- const char* command_1 = "{\"seq\":102,"
+ const char* command_1 =
+ "{\"seq\":102,"
"\"type\":\"request\","
"\"command\":\"evaluate\","
- "\"arguments\":{\"expression\":\"bar(false)\"}}";
+ "\"arguments\":{\"expression\":\"flag = false\"}}";
const char* command_2 = "{\"seq\":103,"
"\"type\":\"request\","
"\"command\":\"continue\"}";
@@ -5376,13 +5586,15 @@
const char* source_2 = "cat(17);\n"
"cat(19);\n";
- isolate_ = v8::Isolate::New();
+ v8::Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
+ isolate_ = v8::Isolate::New(create_params);
breakpoints_barriers->barrier_3.Wait();
{
v8::Isolate::Scope isolate_scope(isolate_);
DebugLocalContext env(isolate_);
v8::HandleScope scope(isolate_);
- v8::Debug::SetMessageHandler(&BreakpointsMessageHandler);
+ v8::Debug::SetMessageHandler(isolate_, &BreakpointsMessageHandler);
CompileRun(source_1);
breakpoints_barriers->barrier_1.Wait();
@@ -5537,13 +5749,8 @@
}
-static void DummyDebugEventListener(
- const v8::Debug::EventDetails& event_details) {
-}
-
-
TEST(SetDebugEventListenerOnUninitializedVM) {
- v8::Debug::SetDebugEventListener(DummyDebugEventListener);
+ v8::Debug::SetDebugEventListener(CcTest::isolate(), DummyDebugEventListener);
}
@@ -5552,7 +5759,7 @@
TEST(SetMessageHandlerOnUninitializedVM) {
- v8::Debug::SetMessageHandler(DummyMessageHandler);
+ v8::Debug::SetMessageHandler(CcTest::isolate(), DummyMessageHandler);
}
@@ -5564,7 +5771,7 @@
" 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
@@ -5577,23 +5784,32 @@
" 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());
}
@@ -5602,13 +5818,15 @@
// 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;
- CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
+ v8::TryCatch catcher(args.GetIsolate());
+ CHECK(v8::Debug::Call(context, debugger_call_with_data).IsEmpty());
CHECK(catcher.HasCaught());
CHECK(catcher.Exception()->IsString());
}
@@ -5617,8 +5835,14 @@
// 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());
}
@@ -5628,95 +5852,122 @@
// 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_EQ(v8::Integer::New(isolate, 0),
- 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();
}
@@ -5739,11 +5990,13 @@
DebugLocalContext env;
// Check debugger is unloaded before it is used.
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(env->GetIsolate());
// Set a debug event listener.
break_point_hit_count = 0;
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
{
v8::HandleScope scope(env->GetIsolate());
// Create a couple of functions for the test.
@@ -5760,41 +6013,44 @@
// Make sure that the break points are there.
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
- bar->Call(env->Global(), 0, NULL);
+ bar->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(4, break_point_hit_count);
}
// Remove the debug event listener without clearing breakpoints. Do this
// outside a handle scope.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded(true);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
// Now set a debug message handler.
break_point_hit_count = 0;
- v8::Debug::SetMessageHandler(MessageHandlerBreakPointHitCount);
+ v8::Debug::SetMessageHandler(env->GetIsolate(),
+ MessageHandlerBreakPointHitCount);
{
v8::HandleScope scope(env->GetIsolate());
// Get the test functions again.
v8::Local<v8::Function> foo(v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "foo"))
+ .ToLocalChecked()));
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
// Set break points and run again.
SetBreakPoint(foo, 0);
SetBreakPoint(foo, 4);
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(2, break_point_hit_count);
}
// Remove the debug message handler without clearing breakpoints. Do this
// outside a handle scope.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded(true);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
}
@@ -5833,10 +6089,10 @@
v8::HandleScope scope(env->GetIsolate());
// Check debugger is unloaded before it is used.
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(env->GetIsolate());
// Set a debug message handler.
- v8::Debug::SetMessageHandler(MessageHandlerHitCount);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), MessageHandlerHitCount);
// Run code to throw a unhandled exception. This should end up in the message
// handler.
@@ -5847,7 +6103,7 @@
// Clear debug message handler.
message_handler_hit_count = 0;
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
// Run code to throw a unhandled exception. This should end up in the message
// handler.
@@ -5856,7 +6112,7 @@
// The message handler should not be called more.
CHECK_EQ(0, message_handler_hit_count);
- CheckDebuggerUnloaded(true);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
}
@@ -5866,7 +6122,7 @@
message_handler_hit_count++;
// Clear debug message handler.
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(message.GetIsolate(), nullptr);
}
@@ -5876,10 +6132,11 @@
v8::HandleScope scope(env->GetIsolate());
// Check debugger is unloaded before it is used.
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(env->GetIsolate());
// Set a debug message handler.
- v8::Debug::SetMessageHandler(MessageHandlerClearingMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(),
+ MessageHandlerClearingMessageHandler);
// Run code to throw a unhandled exception. This should end up in the message
// handler.
@@ -5888,7 +6145,7 @@
// The message handler should be called.
CHECK_EQ(1, message_handler_hit_count);
- CheckDebuggerUnloaded(true);
+ CheckDebuggerUnloaded(env->GetIsolate(), true);
}
@@ -5911,12 +6168,12 @@
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.
- (void) 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
@@ -5925,20 +6182,32 @@
bool allow_natives_syntax = i::FLAG_allow_natives_syntax;
i::FLAG_allow_natives_syntax = true;
- CompileRun(
- "var scripts = %DebugGetLoadedScripts();"
- "var count = scripts.length;"
- "for (var i = 0; i < count; ++i) {"
- " scripts[i].line_ends;"
- "}");
+ EnableDebugger(env->GetIsolate());
+ v8::MaybeLocal<v8::Value> result =
+ CompileRun(env.context(),
+ "var scripts = %DebugGetLoadedScripts();"
+ "var count = scripts.length;"
+ "for (var i = 0; i < count; ++i) {"
+ " var lines = scripts[i].lineCount();"
+ " if (lines < 1) throw 'lineCount';"
+ " var last = -1;"
+ " for (var j = 0; j < lines; ++j) {"
+ " var end = scripts[i].lineEnd(j);"
+ " if (last >= end) throw 'lineEnd';"
+ " last = end;"
+ " }"
+ "}");
+ CHECK(!result.IsEmpty());
+ DisableDebugger(env->GetIsolate());
// Must not crash while accessing line_ends.
i::FLAG_allow_natives_syntax = allow_natives_syntax;
// Some scripts are retrieved - at least the number of native scripts.
- CHECK_GT((*env)
- ->Global()
- ->Get(v8::String::NewFromUtf8(env->GetIsolate(), "count"))
- ->Int32Value(),
+ CHECK_GT(env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "count"))
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust(),
8);
}
@@ -5955,63 +6224,82 @@
frame_script_name_source,
"frame_script_name");
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context = env.context();
// Test function source.
- v8::Local<v8::String> script = v8::String::NewFromUtf8(env->GetIsolate(),
- "function f() {\n"
- " debugger;\n"
- "}\n");
+ v8::Local<v8::String> script = v8_str(env->GetIsolate(),
+ "function f() {\n"
+ " debugger;\n"
+ "}\n");
v8::ScriptOrigin origin1 =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "name"));
- v8::Handle<v8::Script> script1 = v8::Script::Compile(script, &origin1);
- script1->Run();
+ v8::ScriptOrigin(v8_str(env->GetIsolate(), "name"));
+ v8::Local<v8::Script> script1 =
+ v8::Script::Compile(context, script, &origin1).ToLocalChecked();
+ script1->Run(context).ToLocalChecked();
v8::Local<v8::Function> f;
f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- CHECK_EQ("name", last_script_name_hit);
+ 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("name", last_script_name_hit);
+ 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("new name", last_script_name_hit);
+ 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.
@@ -6040,23 +6328,23 @@
v8::HandleScope scope(isolate);
// Create two contexts.
- v8::Handle<v8::Context> context_1;
- v8::Handle<v8::Context> context_2;
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::Handle<v8::ObjectTemplate>();
- v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>();
+ v8::Local<v8::Context> context_1;
+ v8::Local<v8::Context> context_2;
+ v8::Local<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate>();
+ v8::Local<v8::Value> global_object = v8::Local<v8::Value>();
context_1 = v8::Context::New(isolate, NULL, global_template, global_object);
context_2 = v8::Context::New(isolate, NULL, global_template, global_object);
- v8::Debug::SetMessageHandler(ContextCheckMessageHandler);
+ v8::Debug::SetMessageHandler(isolate, ContextCheckMessageHandler);
// Default data value is undefined.
CHECK(context_1->GetEmbedderData(0)->IsUndefined());
CHECK(context_2->GetEmbedderData(0)->IsUndefined());
// Set and check different data values.
- v8::Handle<v8::String> data_1 = v8::String::NewFromUtf8(isolate, "1");
- v8::Handle<v8::String> data_2 = v8::String::NewFromUtf8(isolate, "2");
+ v8::Local<v8::String> data_1 = v8_str(isolate, "1");
+ v8::Local<v8::String> data_2 = v8_str(isolate, "2");
context_1->SetEmbedderData(0, data_1);
context_2->SetEmbedderData(0, data_2);
CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1));
@@ -6071,7 +6359,7 @@
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();
}
@@ -6081,14 +6369,14 @@
expected_context = context_2;
expected_context_data = data_2;
v8::Local<v8::Function> f = CompileFunction(isolate, source, "f");
- f->Call(context_2->Global(), 0, NULL);
+ f->Call(context_2, context_2->Global(), 0, NULL).ToLocalChecked();
}
// Two times compile event and two times break event.
CHECK_GT(message_handler_hit_count, 4);
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -6113,25 +6401,31 @@
// Test that a debug break can be scheduled while in a message handler.
TEST(DebugBreakInMessageHandler) {
+ i::FLAG_turbo_inlining = false; // Make sure g is not inlined into f.
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetMessageHandler(DebugBreakMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), DebugBreakMessageHandler);
+ v8::Local<v8::Context> context = env.context();
// Test functions.
const char* script = "function f() { debugger; g(); } function g() { }";
CompileRun(script);
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "g"))
+ .ToLocalChecked());
- // Call f then g. The debugger statement in f will casue a break which will
+ // 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);
}
@@ -6142,8 +6436,8 @@
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++;
@@ -6151,17 +6445,17 @@
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);
}
}
@@ -6178,7 +6472,7 @@
// 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,
@@ -6192,19 +6486,20 @@
v8::Local<v8::Function> f = CompileFunction(env->GetIsolate(), script, "f");
const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = {
- v8::String::NewFromUtf8(env->GetIsolate(), " /* xxx */ a=0;")};
- v8::Local<v8::Value> result = f->Call(env->Global(), argc, argv);
- CHECK_EQ(12, result->Int32Value());
+ v8::Local<v8::Value> argv[argc] = {
+ v8_str(env->GetIsolate(), " /* xxx */ a=0;")};
+ v8::Local<v8::Value> result =
+ f->Call(context, env->Global(), argc, argv).ToLocalChecked();
+ CHECK_EQ(12, result->Int32Value(context).FromJust());
- v8::Debug::SetDebugEventListener(DebugEventDebugBreak);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventDebugBreak);
v8::Debug::DebugBreak(env->GetIsolate());
- result = f->Call(env->Global(), argc, argv);
+ result = f->Call(context, env->Global(), argc, argv).ToLocalChecked();
// Check that there was only one break event. Matching RegExp should not
// cause Break events.
CHECK_EQ(1, break_point_hit_count);
- CHECK_EQ("f", last_function_hit);
+ CHECK_EQ(0, strcmp("f", last_function_hit));
}
#endif // V8_INTERPRETED_REGEXP
@@ -6213,20 +6508,19 @@
static void ExecuteScriptForContextCheck(
v8::Debug::MessageHandler message_handler) {
// Create a context.
- v8::Handle<v8::Context> context_1;
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::Handle<v8::ObjectTemplate>();
+ v8::Local<v8::Context> context_1;
+ v8::Local<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate>();
context_1 =
v8::Context::New(CcTest::isolate(), NULL, global_template);
- v8::Debug::SetMessageHandler(message_handler);
+ v8::Debug::SetMessageHandler(CcTest::isolate(), message_handler);
// Default data value is undefined.
CHECK(context_1->GetEmbedderData(0)->IsUndefined());
// Set and check a data value.
- v8::Handle<v8::String> data_1 =
- v8::String::NewFromUtf8(CcTest::isolate(), "1");
+ v8::Local<v8::String> data_1 = v8_str(CcTest::isolate(), "1");
context_1->SetEmbedderData(0, data_1);
CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1));
@@ -6239,10 +6533,10 @@
expected_context = context_1;
expected_context_data = data_1;
v8::Local<v8::Function> f = CompileFunction(CcTest::isolate(), source, "f");
- f->Call(context_1->Global(), 0, NULL);
+ f->Call(context_1, context_1->Global(), 0, NULL).ToLocalChecked();
}
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(CcTest::isolate(), nullptr);
}
@@ -6257,7 +6551,7 @@
// One time compile event and one time break event.
CHECK_GT(message_handler_hit_count, 2);
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(CcTest::isolate());
}
@@ -6325,7 +6619,7 @@
// One break from the source and another from the evaluate request.
CHECK_EQ(break_count, 2);
- CheckDebuggerUnloaded();
+ CheckDebuggerUnloaded(CcTest::isolate());
}
@@ -6348,22 +6642,27 @@
TEST(AfterCompileMessageWhenMessageHandlerIsReset) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
after_compile_message_count = 0;
const char* script = "var a=1";
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
- ->Run();
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
v8::Debug::DebugBreak(env->GetIsolate());
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
- ->Run();
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
// Setting listener to NULL should cause debugger unload.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Compilation cache should be disabled when debugger is active.
CHECK_EQ(2, after_compile_message_count);
@@ -6396,7 +6695,8 @@
// For this test, we want to break on uncaught exceptions:
ChangeBreakOnException(false, true);
- v8::Debug::SetDebugEventListener(CompileErrorEventCounter);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), CompileErrorEventCounter);
+ v8::Local<v8::Context> context = env.context();
CompileErrorEventCounterClear();
@@ -6404,23 +6704,30 @@
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::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);
+ CHECK(script->Run(context).IsEmpty());
+ CHECK_EQ(3, compile_error_event_count);
- v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "new RegExp('/\\/\\\\');"));
- CHECK_EQ(2, compile_error_event_count);
+ 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;"));
- CHECK_EQ(2, compile_error_event_count);
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), "throw 1;"))
+ .ToLocalChecked();
+ CHECK_EQ(3, compile_error_event_count);
}
@@ -6428,23 +6735,28 @@
TEST(BreakMessageWhenMessageHandlerIsReset) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
after_compile_message_count = 0;
const char* script = "function f() {};";
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
- ->Run();
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
v8::Debug::DebugBreak(env->GetIsolate());
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- f->Call(env->Global(), 0, NULL);
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// Setting message handler to NULL should cause debugger unload.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
// Compilation cache should be disabled when debugger is active.
CHECK_EQ(1, after_compile_message_count);
@@ -6465,25 +6777,30 @@
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
// For this test, we want to break on uncaught exceptions:
ChangeBreakOnException(false, true);
exception_event_count = 0;
const char* script = "function f() {throw new Error()};";
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
- ->Run();
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
+ .ToLocalChecked()
+ ->Run(context)
+ .ToLocalChecked();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
- v8::Debug::SetMessageHandler(ExceptionMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), ExceptionMessageHandler);
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
- f->Call(env->Global(), 0, NULL);
+ env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "f"))
+ .ToLocalChecked());
+ CHECK(f->Call(context, env->Global(), 0, NULL).IsEmpty());
// Setting message handler to NULL should cause debugger unload.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
CHECK_EQ(1, exception_event_count);
}
@@ -6498,6 +6815,9 @@
const char* script = "function f() {};";
const char* resource_name = "test_resource";
+ v8::Debug::SetMessageHandler(env->GetIsolate(), AfterCompileMessageHandler);
+ v8::Local<v8::Context> context = env.context();
+
// Set a couple of provisional breakpoint on lines out of the script lines
// range.
int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name,
@@ -6506,16 +6826,16 @@
SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5);
after_compile_message_count = 0;
- v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
- 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
@@ -6524,7 +6844,7 @@
ClearBreakPointFromJS(env->GetIsolate(), sbp1);
ClearBreakPointFromJS(env->GetIsolate(), sbp2);
- v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
}
@@ -6556,9 +6876,10 @@
TEST(NoDebugBreakInAfterCompileMessageHandler) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
+ v8::Local<v8::Context> context = env.context();
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetMessageHandler(BreakMessageHandler);
+ v8::Debug::SetMessageHandler(env->GetIsolate(), BreakMessageHandler);
// Set the debug break flag.
v8::Debug::DebugBreak(env->GetIsolate());
@@ -6572,13 +6893,13 @@
// Set the debug break flag again.
v8::Debug::DebugBreak(env->GetIsolate());
- f->Call(env->Global(), 0, NULL);
+ f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// There should be one more break event when the script is evaluated in 'f'.
CHECK_EQ(2, break_point_hit_count);
// Get rid of the debug message handler.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -6597,7 +6918,7 @@
counting_message_handler_counter = 0;
- v8::Debug::SetMessageHandler(CountingMessageHandler);
+ v8::Debug::SetMessageHandler(isolate, CountingMessageHandler);
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -6611,7 +6932,7 @@
isolate, buffer, AsciiToUtf16(scripts_command, buffer));
CHECK_EQ(0, counting_message_handler_counter);
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
// At least one message should come
CHECK_GE(counting_message_handler_counter, 1);
@@ -6622,13 +6943,13 @@
v8::Debug::SendCommand(
isolate, buffer, AsciiToUtf16(scripts_command, buffer));
CHECK_EQ(0, counting_message_handler_counter);
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
// At least two messages should come
CHECK_GE(counting_message_handler_counter, 2);
// Get rid of the debug message handler.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -6674,7 +6995,7 @@
timer.Elapsed().InMillisecondsF());
}
- v8::V8::TerminateExecution(isolate_);
+ isolate_->TerminateExecution();
}
void StartSending() { semaphore_.Signal(); }
@@ -6695,24 +7016,28 @@
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
counting_message_handler_counter = 0;
v8::Debug::SetMessageHandler(
- SendCommandThread::CountingAndSignallingMessageHandler);
+ isolate, SendCommandThread::CountingAndSignallingMessageHandler);
send_command_thread_ = new SendCommandThread(isolate);
send_command_thread_->Start();
- v8::Handle<v8::FunctionTemplate> start =
+ v8::Local<v8::FunctionTemplate> start =
v8::FunctionTemplate::New(isolate, StartSendingCommands);
- env->Global()->Set(v8_str("start"), start->GetFunction());
+ CHECK(env->Global()
+ ->Set(context, v8_str("start"),
+ start->GetFunction(context).ToLocalChecked())
+ .FromJust());
CompileRun("start(); while (true) { }");
CHECK_EQ(20, counting_message_handler_counter);
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -6738,8 +7063,9 @@
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = env.context();
- v8::Debug::SetMessageHandler(BacktraceData::MessageHandler);
+ v8::Debug::SetMessageHandler(isolate, BacktraceData::MessageHandler);
const int kBufferSize = 1000;
uint16_t buffer[kBufferSize];
@@ -6755,12 +7081,11 @@
buffer,
AsciiToUtf16(scripts_command, buffer),
NULL);
- v8::Debug::ProcessDebugMessages();
+ v8::Debug::ProcessDebugMessages(isolate);
CHECK_EQ(BacktraceData::frame_counter, 0);
- v8::Handle<v8::String> void0 =
- v8::String::NewFromUtf8(env->GetIsolate(), "void(0)");
- v8::Handle<v8::Script> script = CompileWithOrigin(void0, void0);
+ v8::Local<v8::String> void0 = v8_str(env->GetIsolate(), "void(0)");
+ v8::Local<v8::Script> script = CompileWithOrigin(void0, void0);
// Check backtrace from "void(0)" script.
BacktraceData::frame_counter = -10;
@@ -6769,12 +7094,12 @@
buffer,
AsciiToUtf16(scripts_command, buffer),
NULL);
- script->Run();
+ script->Run(context).ToLocalChecked();
CHECK_EQ(BacktraceData::frame_counter, 1);
// Get rid of the debug message handler.
- v8::Debug::SetMessageHandler(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetMessageHandler(isolate, nullptr);
+ CheckDebuggerUnloaded(isolate);
}
@@ -6782,19 +7107,23 @@
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());
}
@@ -6803,6 +7132,7 @@
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(
@@ -6813,7 +7143,7 @@
"foo");
// Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakMax);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax);
// Set the debug break flag before calling the code using function.apply.
v8::Debug::DebugBreak(env->GetIsolate());
@@ -6822,18 +7152,18 @@
// where this test would enter an infinite loop.
break_point_hit_count = 0;
max_break_point_hit_count = 10000; // 10000 => infinite loop.
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
// When keeping the debug break several break will happen.
CHECK_GT(break_point_hit_count, 1);
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
-v8::Handle<v8::Context> debugee_context;
-v8::Handle<v8::Context> debugger_context;
+v8::Local<v8::Context> debugee_context;
+v8::Local<v8::Context> debugger_context;
// Property getter that checks that current and calling contexts
@@ -6842,12 +7172,9 @@
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);
- v8::Handle<v8::Context> calling = info.GetIsolate()->GetCallingContext();
- CHECK(calling == debugee_context);
- CHECK(calling != debugger_context);
info.GetReturnValue().Set(1);
}
@@ -6858,18 +7185,19 @@
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());
}
}
@@ -6889,14 +7217,15 @@
debugger_context = v8::Utils::ToLocal(debug->debug_context());
// Create object with 'a' property accessor.
- v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
- named->SetAccessor(v8::String::NewFromUtf8(isolate, "a"),
- NamedGetterWithCallingContextCheck);
- env->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"),
- named->NewInstance());
+ v8::Local<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
+ named->SetAccessor(v8_str(isolate, "a"), NamedGetterWithCallingContextCheck);
+ CHECK(env->Global()
+ ->Set(debugee_context, v8_str(isolate, "obj"),
+ named->NewInstance(debugee_context).ToLocalChecked())
+ .FromJust());
// Register the debug event listener
- v8::Debug::SetDebugEventListener(DebugEventGetAtgumentPropertyValue);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventGetAtgumentPropertyValue);
// Create a function that invokes debugger.
v8::Local<v8::Function> foo = CompileFunction(
@@ -6906,31 +7235,44 @@
"foo");
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
+ foo->Call(debugee_context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
- v8::Debug::SetDebugEventListener(NULL);
- debugee_context = v8::Handle<v8::Context>();
- debugger_context = v8::Handle<v8::Context>();
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ debugee_context = v8::Local<v8::Context>();
+ debugger_context = v8::Local<v8::Context>();
+ CheckDebuggerUnloaded(isolate);
}
TEST(DebugContextIsPreservedBetweenAccesses) {
v8::HandleScope scope(CcTest::isolate());
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
- v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext();
- v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext();
+ v8::Debug::SetDebugEventListener(CcTest::isolate(),
+ DebugEventBreakPointHitCount);
+ v8::Local<v8::Context> context1 =
+ v8::Debug::GetDebugContext(CcTest::isolate());
+ v8::Local<v8::Context> context2 =
+ v8::Debug::GetDebugContext(CcTest::isolate());
CHECK(v8::Utils::OpenHandle(*context1).is_identical_to(
v8::Utils::OpenHandle(*context2)));
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr);
}
-static v8::Handle<v8::Value> expected_callback_data;
+TEST(NoDebugContextWhenDebuggerDisabled) {
+ v8::HandleScope scope(CcTest::isolate());
+ v8::Local<v8::Context> context =
+ v8::Debug::GetDebugContext(CcTest::isolate());
+ CHECK(context.IsEmpty());
+}
+
+
+static v8::Local<v8::Value> expected_callback_data;
static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
CHECK(details.GetEventContext() == expected_context);
- CHECK_EQ(expected_callback_data, details.GetCallbackData());
+ CHECK(expected_callback_data->Equals(details.GetEventContext(),
+ details.GetCallbackData())
+ .FromJust());
}
@@ -6940,112 +7282,42 @@
v8::HandleScope scope(isolate);
expected_context = v8::Context::New(isolate);
expected_callback_data = v8::Int32::New(isolate, 2010);
- v8::Debug::SetDebugEventListener(DebugEventContextChecker,
- expected_callback_data);
+ v8::Debug::SetDebugEventListener(isolate, DebugEventContextChecker,
+ expected_callback_data);
v8::Context::Scope context_scope(expected_context);
- v8::Script::Compile(
- v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run();
+ v8::Script::Compile(expected_context,
+ v8_str(isolate, "(function(){debugger;})();"))
+ .ToLocalChecked()
+ ->Run(expected_context)
+ .ToLocalChecked();
expected_context.Clear();
- v8::Debug::SetDebugEventListener(NULL);
- expected_context_data = v8::Handle<v8::Value>();
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(isolate, nullptr);
+ expected_context_data = v8::Local<v8::Value>();
+ CheckDebuggerUnloaded(isolate);
}
-static void* expected_break_data;
-static bool was_debug_break_called;
-static bool was_debug_event_called;
-static void DebugEventBreakDataChecker(const v8::Debug::EventDetails& details) {
- if (details.GetEvent() == v8::BreakForCommand) {
- CHECK_EQ(expected_break_data, details.GetClientData());
- was_debug_event_called = true;
- } else if (details.GetEvent() == v8::Break) {
- was_debug_break_called = true;
- }
-}
-
-
-// Check that event details contain context where debug event occured.
-TEST(DebugEventBreakData) {
- DebugLocalContext env;
- v8::Isolate* isolate = env->GetIsolate();
- v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(DebugEventBreakDataChecker);
-
- TestClientData::constructor_call_counter = 0;
- TestClientData::destructor_call_counter = 0;
-
- expected_break_data = NULL;
- was_debug_event_called = false;
- was_debug_break_called = false;
- v8::Debug::DebugBreakForCommand(isolate, NULL);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "(function(x){return x;})(1);"))
- ->Run();
- CHECK(was_debug_event_called);
- CHECK(!was_debug_break_called);
-
- TestClientData* data1 = new TestClientData();
- expected_break_data = data1;
- was_debug_event_called = false;
- was_debug_break_called = false;
- v8::Debug::DebugBreakForCommand(isolate, data1);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "(function(x){return x+1;})(1);"))
- ->Run();
- CHECK(was_debug_event_called);
- CHECK(!was_debug_break_called);
-
- expected_break_data = NULL;
- was_debug_event_called = false;
- was_debug_break_called = false;
- v8::Debug::DebugBreak(isolate);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "(function(x){return x+2;})(1);"))
- ->Run();
- CHECK(!was_debug_event_called);
- CHECK(was_debug_break_called);
-
- TestClientData* data2 = new TestClientData();
- expected_break_data = data2;
- was_debug_event_called = false;
- was_debug_break_called = false;
- v8::Debug::DebugBreak(isolate);
- v8::Debug::DebugBreakForCommand(isolate, data2);
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
- "(function(x){return x+3;})(1);"))
- ->Run();
- CHECK(was_debug_event_called);
- CHECK(was_debug_break_called);
-
- CHECK_EQ(2, TestClientData::constructor_call_counter);
- CHECK_EQ(TestClientData::constructor_call_counter,
- TestClientData::destructor_call_counter);
-
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
-}
-
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());
@@ -7065,32 +7337,32 @@
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,
frame_function_name_source,
"frame_function_name");
-
// Set a debug event listener which will keep interrupting execution until
// debug break. When inside function bar it will deoptimize all functions.
// This tests lazy deoptimization bailout for the stack check, as the first
// time in function bar when using debug break and no break points will be at
// the initial stack check.
- v8::Debug::SetDebugEventListener(DebugEventBreakDeoptimize);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugEventBreakDeoptimize);
// Compile and run function bar which will optimize it for some flag settings.
- v8::Script::Compile(v8::String::NewFromUtf8(
- env->GetIsolate(), "function bar(){}; bar()"))->Run();
+ v8::Local<v8::Function> f = CompileFunction(&env, "function bar(){}", "bar");
+ f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked();
// Set debug break and call bar again.
v8::Debug::DebugBreak(env->GetIsolate());
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar()"))
- ->Run();
+ f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked();
CHECK(debug_event_break_deoptimize_done);
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
}
@@ -7098,46 +7370,58 @@
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));
}
}
}
@@ -7145,7 +7429,8 @@
static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::Debug::SetDebugEventListener(DebugEventBreakWithOptimizedStack);
+ v8::Debug::SetDebugEventListener(args.GetIsolate(),
+ DebugEventBreakWithOptimizedStack);
v8::Debug::DebugBreak(args.GetIsolate());
}
@@ -7153,6 +7438,7 @@
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");
@@ -7166,11 +7452,13 @@
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) {"
@@ -7178,7 +7466,10 @@
" 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();
}
@@ -7186,15 +7477,22 @@
static void TestDebugBreakInLoop(const char* loop_head,
const char** loop_bodies,
const char* loop_tail) {
- // Receive 100 breaks for each test and then terminate JavaScript execution.
- static const int kBreaksPerTest = 100;
+ // Receive 10 breaks for each test and then terminate JavaScript execution.
+ static const int kBreaksPerTest = 10;
for (int i = 0; loop_bodies[i] != NULL; i++) {
// Perform a lazy deoptimization after various numbers of breaks
// have been hit.
- for (int j = 0; j < 7; j++) {
+
+ EmbeddedVector<char, 1024> buffer;
+ SNPrintF(buffer, "function f() {%s%s%s}", loop_head, loop_bodies[i],
+ loop_tail);
+
+ i::PrintF("%s\n", buffer.start());
+
+ for (int j = 0; j < 3; j++) {
break_point_hit_count_deoptimize = j;
- if (j == 6) {
+ if (j == 2) {
break_point_hit_count_deoptimize = kBreaksPerTest;
}
@@ -7202,11 +7500,6 @@
max_break_point_hit_count = kBreaksPerTest;
terminate_after_max_break_point_hit = true;
- EmbeddedVector<char, 1024> buffer;
- SNPrintF(buffer,
- "function f() {%s%s%s}",
- loop_head, loop_bodies[i], loop_tail);
-
// Function with infinite loop.
CompileRun(buffer.start());
@@ -7217,53 +7510,104 @@
CompileRun("f();");
CHECK_EQ(kBreaksPerTest, break_point_hit_count);
- CHECK(!v8::V8::IsExecutionTerminating());
+ CHECK(!CcTest::isolate()->IsExecutionTerminating());
}
}
}
-TEST(DebugBreakLoop) {
+static const char* loop_bodies_1[] = {"",
+ "g()",
+ "if (a == 0) { g() }",
+ "if (a == 1) { g() }",
+ "if (a == 0) { g() } else { h() }",
+ "if (a == 0) { continue }",
+ NULL};
+
+
+static const char* loop_bodies_2[] = {
+ "if (a == 1) { continue }",
+ "switch (a) { case 1: g(); }",
+ "switch (a) { case 1: continue; }",
+ "switch (a) { case 1: g(); break; default: h() }",
+ "switch (a) { case 1: continue; break; default: h() }",
+ NULL};
+
+
+void DebugBreakLoop(const char* loop_header, const char** loop_bodies,
+ const char* loop_footer) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which sets the break flag and counts.
- v8::Debug::SetDebugEventListener(DebugEventBreakMax);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax);
- // Create a function for getting the frame count when hitting the break.
- frame_count = CompileFunction(&env, frame_count_source, "frame_count");
+ CompileRun(
+ "var a = 1;\n"
+ "function g() { }\n"
+ "function h() { }");
- CompileRun("var a = 1;");
- CompileRun("function g() { }");
- CompileRun("function h() { }");
-
- const char* loop_bodies[] = {
- "",
- "g()",
- "if (a == 0) { g() }",
- "if (a == 1) { g() }",
- "if (a == 0) { g() } else { h() }",
- "if (a == 0) { continue }",
- "if (a == 1) { continue }",
- "switch (a) { case 1: g(); }",
- "switch (a) { case 1: continue; }",
- "switch (a) { case 1: g(); break; default: h() }",
- "switch (a) { case 1: continue; break; default: h() }",
- NULL
- };
-
- TestDebugBreakInLoop("while (true) {", loop_bodies, "}");
- TestDebugBreakInLoop("while (a == 1) {", loop_bodies, "}");
-
- TestDebugBreakInLoop("do {", loop_bodies, "} while (true)");
- TestDebugBreakInLoop("do {", loop_bodies, "} while (a == 1)");
-
- TestDebugBreakInLoop("for (;;) {", loop_bodies, "}");
- TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
+ TestDebugBreakInLoop(loop_header, loop_bodies, loop_footer);
// Get rid of the debug event listener.
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
+}
+
+
+TEST(DebugBreakInWhileTrue1) {
+ DebugBreakLoop("while (true) {", loop_bodies_1, "}");
+}
+
+
+TEST(DebugBreakInWhileTrue2) {
+ DebugBreakLoop("while (true) {", loop_bodies_2, "}");
+}
+
+
+TEST(DebugBreakInWhileCondition1) {
+ DebugBreakLoop("while (a == 1) {", loop_bodies_1, "}");
+}
+
+
+TEST(DebugBreakInWhileCondition2) {
+ DebugBreakLoop("while (a == 1) {", loop_bodies_2, "}");
+}
+
+
+TEST(DebugBreakInDoWhileTrue1) {
+ DebugBreakLoop("do {", loop_bodies_1, "} while (true)");
+}
+
+
+TEST(DebugBreakInDoWhileTrue2) {
+ DebugBreakLoop("do {", loop_bodies_2, "} while (true)");
+}
+
+
+TEST(DebugBreakInDoWhileCondition1) {
+ DebugBreakLoop("do {", loop_bodies_1, "} while (a == 1)");
+}
+
+
+TEST(DebugBreakInDoWhileCondition2) {
+ DebugBreakLoop("do {", loop_bodies_2, "} while (a == 1)");
+}
+
+
+TEST(DebugBreakInFor1) { DebugBreakLoop("for (;;) {", loop_bodies_1, "}"); }
+
+
+TEST(DebugBreakInFor2) { DebugBreakLoop("for (;;) {", loop_bodies_2, "}"); }
+
+
+TEST(DebugBreakInForCondition1) {
+ DebugBreakLoop("for (;a == 1;) {", loop_bodies_1, "}");
+}
+
+
+TEST(DebugBreakInForCondition2) {
+ DebugBreakLoop("for (;a == 1;) {", loop_bodies_2, "}");
}
@@ -7272,6 +7616,7 @@
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;
@@ -7287,7 +7632,7 @@
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++) {
@@ -7296,10 +7641,11 @@
SNPrintF(script_vector, "%%GetFrameDetails(%d, %d)[5]", break_id, i);
v8::Local<v8::Value> result = CompileRun(script);
CHECK_EQ(expected_line_number[i],
- i::Script::GetLineNumber(source_script, result->Int32Value()));
+ i::Script::GetLineNumber(source_script,
+ result->Int32Value(context).FromJust()));
}
- v8::Debug::SetDebugEventListener(NULL);
- v8::V8::TerminateExecution(CcTest::isolate());
+ v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr);
+ CcTest::isolate()->TerminateExecution();
}
@@ -7307,6 +7653,7 @@
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"
@@ -7321,10 +7668,11 @@
"g(false); \n"
"%OptimizeFunctionOnNextCall(g); \n"
"g(true);";
- v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugBreakInlineListener);
inline_script =
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source));
- inline_script->Run();
+ v8::Script::Compile(context, v8_str(env->GetIsolate(), source))
+ .ToLocalChecked();
+ inline_script->Run(context).ToLocalChecked();
}
@@ -7338,7 +7686,7 @@
static void RunScriptInANewCFrame(const char* source) {
- v8::TryCatch try_catch;
+ v8::TryCatch try_catch(CcTest::isolate());
CompileRun(source);
CHECK(try_catch.HasCaught());
}
@@ -7355,7 +7703,7 @@
// on the stack.
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugEventStepNext);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepNext);
// We step through the first script. It exits through an exception. We run
// this inside a new frame to record a different FP than the second script
@@ -7367,12 +7715,17 @@
const char* script_2 = "[0].forEach(function() { });";
CompileRun(script_2);
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
}
// Import from test-heap.cc
+namespace v8 {
+namespace internal {
+
int CountNativeContexts();
+}
+}
static void NopListener(const v8::Debug::EventDetails& event_details) {
@@ -7382,17 +7735,17 @@
TEST(DebuggerCreatesContextIffActive) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- CHECK_EQ(1, CountNativeContexts());
+ CHECK_EQ(1, v8::internal::CountNativeContexts());
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
CompileRun("debugger;");
- CHECK_EQ(1, CountNativeContexts());
+ CHECK_EQ(1, v8::internal::CountNativeContexts());
- v8::Debug::SetDebugEventListener(NopListener);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), NopListener);
CompileRun("debugger;");
- CHECK_EQ(2, CountNativeContexts());
+ CHECK_EQ(2, v8::internal::CountNativeContexts());
- v8::Debug::SetDebugEventListener(NULL);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
}
@@ -7422,7 +7775,7 @@
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugBreakInlineListener);
v8::Local<v8::Function> break_here =
CompileFunction(&env, "function break_here(){}", "break_here");
@@ -7442,10 +7795,10 @@
v8::Local<v8::Value> result = ParserCacheCompileRun(source);
CHECK(result->IsString());
v8::String::Utf8Value utf8(result);
- CHECK_EQ("bar", *utf8);
+ CHECK_EQ(0, strcmp("bar", *utf8));
- v8::Debug::SetDebugEventListener(NULL);
- CheckDebuggerUnloaded();
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
+ CheckDebuggerUnloaded(env->GetIsolate());
}
@@ -7463,12 +7816,16 @@
TEST(DebugBreakStackTrace) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Debug::SetDebugEventListener(DebugBreakStackTraceListener);
- v8::Handle<v8::FunctionTemplate> add_debug_break_template =
+ v8::Debug::SetDebugEventListener(env->GetIsolate(),
+ DebugBreakStackTraceListener);
+ v8::Local<v8::Context> context = env.context();
+ v8::Local<v8::FunctionTemplate> add_debug_break_template =
v8::FunctionTemplate::New(env->GetIsolate(), AddDebugBreak);
- v8::Handle<v8::Function> add_debug_break =
- add_debug_break_template->GetFunction();
- env->Global()->Set(v8_str("add_debug_break"), add_debug_break);
+ v8::Local<v8::Function> add_debug_break =
+ add_debug_break_template->GetFunction(context).ToLocalChecked();
+ CHECK(env->Global()
+ ->Set(context, v8_str("add_debug_break"), add_debug_break)
+ .FromJust());
CompileRun("(function loop() {"
" for (var j = 0; j < 1000; j++) {"
@@ -7502,7 +7859,7 @@
virtual void Run() {
terminate_requested_semaphore.Wait();
- v8::V8::TerminateExecution(isolate_);
+ isolate_->TerminateExecution();
terminate_fired_semaphore.Signal();
}
@@ -7515,10 +7872,10 @@
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate);
+ v8::Debug::SetDebugEventListener(isolate, DebugBreakTriggerTerminate);
TerminationThread terminator(isolate);
terminator.Start();
- v8::TryCatch try_catch;
+ v8::TryCatch try_catch(env->GetIsolate());
v8::Debug::DebugBreak(isolate);
CompileRun("while (true);");
CHECK(try_catch.HasTerminated());
@@ -7534,7 +7891,7 @@
static void TryCatchWrappedThrowCallback(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::TryCatch try_catch;
+ v8::TryCatch try_catch(args.GetIsolate());
CompileRun("throw 'rejection';");
CHECK(try_catch.HasCaught());
}
@@ -7544,19 +7901,23 @@
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(&DebugEventExpectNoException);
+ v8::Debug::SetDebugEventListener(isolate, &DebugEventExpectNoException);
+ v8::Local<v8::Context> context = env.context();
ChangeBreakOnException(false, true);
- v8::Handle<v8::FunctionTemplate> fun =
+ v8::Local<v8::FunctionTemplate> fun =
v8::FunctionTemplate::New(isolate, TryCatchWrappedThrowCallback);
- env->Global()->Set(v8_str("fun"), fun->GetFunction());
+ CHECK(env->Global()
+ ->Set(context, v8_str("fun"),
+ fun->GetFunction(context).ToLocalChecked())
+ .FromJust());
CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });");
CompileRun(
"var r;"
"p.chain(function() { r = 'resolved'; },"
" function() { r = 'rejected'; });");
- CHECK(CompileRun("r")->Equals(v8_str("resolved")));
+ CHECK(CompileRun("r")->Equals(context, v8_str("resolved")).FromJust());
}
@@ -7579,36 +7940,46 @@
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(&DebugEventCountException);
+ v8::Debug::SetDebugEventListener(isolate, &DebugEventCountException);
+ v8::Local<v8::Context> context = env.context();
ChangeBreakOnException(false, true);
exception_event_counter = 0;
- v8::Handle<v8::FunctionTemplate> fun =
+ v8::Local<v8::FunctionTemplate> fun =
v8::FunctionTemplate::New(isolate, ThrowCallback);
- env->Global()->Set(v8_str("fun"), fun->GetFunction());
+ CHECK(env->Global()
+ ->Set(context, v8_str("fun"),
+ fun->GetFunction(context).ToLocalChecked())
+ .FromJust());
CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });");
CompileRun(
"var r;"
"p.chain(function() { r = 'resolved'; },"
" function(e) { r = 'rejected' + e; });");
- CHECK(CompileRun("r")->Equals(v8_str("rejectedrejection")));
+ CHECK(
+ CompileRun("r")->Equals(context, v8_str("rejectedrejection")).FromJust());
CHECK_EQ(1, exception_event_counter);
}
TEST(DebugBreakOnExceptionInObserveCallback) {
+ i::FLAG_harmony_object_observe = true;
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(&DebugEventCountException);
+ v8::Debug::SetDebugEventListener(isolate, &DebugEventCountException);
+ v8::Local<v8::Context> context = env.context();
// Break on uncaught exception
ChangeBreakOnException(false, true);
exception_event_counter = 0;
- v8::Handle<v8::FunctionTemplate> fun =
+ v8::Local<v8::FunctionTemplate> fun =
v8::FunctionTemplate::New(isolate, ThrowCallback);
- env->Global()->Set(v8_str("fun"), fun->GetFunction());
+ CHECK(env->Global()
+ ->Set(context, v8_str("fun"),
+ fun->GetFunction(context).ToLocalChecked())
+ .FromJust());
CompileRun(
"var obj = {};"
@@ -7618,7 +7989,7 @@
" throw Error('foo');"
"});"
"obj.prop = 1");
- CHECK(CompileRun("callbackRan")->BooleanValue());
+ CHECK(CompileRun("callbackRan")->BooleanValue(context).FromJust());
CHECK_EQ(1, exception_event_counter);
}
@@ -7656,13 +8027,12 @@
TEST(DebugBreakInLexicalScopes) {
- i::FLAG_harmony_scoping = true;
i::FLAG_allow_natives_syntax = true;
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Debug::SetDebugEventListener(DebugHarmonyScopingListener);
+ v8::Debug::SetDebugEventListener(isolate, DebugHarmonyScopingListener);
CompileRun(
"'use strict'; \n"
@@ -7679,3 +8049,27 @@
"x * y",
30);
}
+
+static int after_compile_handler_depth = 0;
+static void HandleInterrupt(v8::Isolate* isolate, void* data) {
+ CHECK_EQ(0, after_compile_handler_depth);
+}
+
+static void NoInterruptsOnDebugEvent(
+ const v8::Debug::EventDetails& event_details) {
+ if (event_details.GetEvent() != v8::AfterCompile) return;
+ ++after_compile_handler_depth;
+ // Do not allow nested AfterCompile events.
+ CHECK(after_compile_handler_depth <= 1);
+ v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate();
+ isolate->RequestInterrupt(&HandleInterrupt, nullptr);
+ CompileRun("function foo() {}; foo();");
+ --after_compile_handler_depth;
+}
+
+
+TEST(NoInterruptsInDebugListener) {
+ DebugLocalContext env;
+ v8::Debug::SetDebugEventListener(env->GetIsolate(), NoInterruptsOnDebugEvent);
+ CompileRun("void(0);");
+}