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

Unified Diff: test/cctest/test-debug.cc

Issue 83343002: Remove usage of deprecated APIs from cctests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-declarative-accessors.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 0c8a02b0469c7bcafdc9ff66fa7ee65f33c89645..eb9789ab36d211c27c051fff6c46bb1de2f4be00 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -154,6 +154,7 @@ class DebugLocalContext {
inline v8::Local<v8::Context> context() { return context_; }
inline v8::Context* operator->() { return *context_; }
inline v8::Context* operator*() { return *context_; }
+ inline v8::Isolate* GetIsolate() { return context_->GetIsolate(); }
inline bool IsReady() { return !context_.IsEmpty(); }
void ExposeDebug() {
v8::internal::Isolate* isolate =
@@ -188,20 +189,22 @@ class DebugLocalContext {
static v8::Local<v8::Function> CompileFunction(DebugLocalContext* env,
const char* source,
const char* function_name) {
- v8::Script::Compile(v8::String::New(source))->Run();
- return v8::Local<v8::Function>::Cast(
- (*env)->Global()->Get(v8::String::New(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(const char* source,
+static v8::Local<v8::Function> CompileFunction(v8::Isolate* isolate,
+ const char* source,
const char* function_name) {
- v8::Script::Compile(v8::String::New(source))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))->Run();
v8::Local<v8::Object> global =
CcTest::isolate()->GetCurrentContext()->Global();
return v8::Local<v8::Function>::Cast(
- global->Get(v8::String::New(function_name)));
+ global->Get(v8::String::NewFromUtf8(isolate, function_name)));
}
@@ -236,20 +239,22 @@ static int SetBreakPoint(v8::Handle<v8::Function> fun, int position) {
// Set a break point in a function using the Debug object and return the
// associated break point number.
-static int SetBreakPointFromJS(const char* function_name,
+static int SetBreakPointFromJS(v8::Isolate* isolate,
+ const char* function_name,
int line, int position) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
OS::SNPrintF(buffer,
"debug.Debug.setBreakPoint(%s,%d,%d)",
function_name, line, position);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Handle<v8::String> str = v8::String::New(buffer.start());
+ v8::Handle<v8::String> str = v8::String::NewFromUtf8(isolate, buffer.start());
return v8::Script::Compile(str)->Run()->Int32Value();
}
// Set a break point in a script identified by id using the global Debug object.
-static int SetScriptBreakPointByIdFromJS(int script_id, int line, int column) {
+static int SetScriptBreakPointByIdFromJS(v8::Isolate* isolate, int script_id,
+ int line, int column) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
if (column >= 0) {
// Column specified set script break point on precise location.
@@ -265,7 +270,8 @@ static int SetScriptBreakPointByIdFromJS(int script_id, int line, int column) {
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
v8::TryCatch try_catch;
- v8::Handle<v8::String> str = v8::String::New(buffer.start());
+ v8::Handle<v8::String> str =
+ v8::String::NewFromUtf8(isolate, buffer.start());
v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
CHECK(!try_catch.HasCaught());
return value->Int32Value();
@@ -275,8 +281,9 @@ static int SetScriptBreakPointByIdFromJS(int script_id, int line, int column) {
// Set a break point in a script identified by name using the global Debug
// object.
-static int SetScriptBreakPointByNameFromJS(const char* script_name,
- int line, int column) {
+static int SetScriptBreakPointByNameFromJS(v8::Isolate* isolate,
+ const char* script_name, int line,
+ int column) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
if (column >= 0) {
// Column specified set script break point on precise location.
@@ -292,7 +299,8 @@ static int SetScriptBreakPointByNameFromJS(const char* script_name,
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
{
v8::TryCatch try_catch;
- v8::Handle<v8::String> str = v8::String::New(buffer.start());
+ v8::Handle<v8::String> str =
+ v8::String::NewFromUtf8(isolate, buffer.start());
v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run();
CHECK(!try_catch.HasCaught());
return value->Int32Value();
@@ -310,55 +318,60 @@ static void ClearBreakPoint(int break_point) {
// Clear a break point using the global Debug object.
-static void ClearBreakPointFromJS(int break_point_number) {
+static void ClearBreakPointFromJS(v8::Isolate* isolate,
+ int break_point_number) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
OS::SNPrintF(buffer,
"debug.Debug.clearBreakPoint(%d)",
break_point_number);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::New(buffer.start()))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
-static void EnableScriptBreakPointFromJS(int break_point_number) {
+static void EnableScriptBreakPointFromJS(v8::Isolate* isolate,
+ int break_point_number) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
OS::SNPrintF(buffer,
"debug.Debug.enableScriptBreakPoint(%d)",
break_point_number);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::New(buffer.start()))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
-static void DisableScriptBreakPointFromJS(int break_point_number) {
+static void DisableScriptBreakPointFromJS(v8::Isolate* isolate,
+ int break_point_number) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
OS::SNPrintF(buffer,
"debug.Debug.disableScriptBreakPoint(%d)",
break_point_number);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::New(buffer.start()))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
-static void ChangeScriptBreakPointConditionFromJS(int break_point_number,
+static void ChangeScriptBreakPointConditionFromJS(v8::Isolate* isolate,
+ int break_point_number,
const char* condition) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
OS::SNPrintF(buffer,
"debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")",
break_point_number, condition);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::New(buffer.start()))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
-static void ChangeScriptBreakPointIgnoreCountFromJS(int break_point_number,
+static void ChangeScriptBreakPointIgnoreCountFromJS(v8::Isolate* isolate,
+ int break_point_number,
int ignoreCount) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
OS::SNPrintF(buffer,
"debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)",
break_point_number, ignoreCount);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
- v8::Script::Compile(v8::String::New(buffer.start()))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run();
}
@@ -371,20 +384,25 @@ static void ChangeBreakOnException(bool caught, bool uncaught) {
// Change break on exception using the global Debug object.
-static void ChangeBreakOnExceptionFromJS(bool caught, bool uncaught) {
+static void ChangeBreakOnExceptionFromJS(v8::Isolate* isolate, bool caught,
+ bool uncaught) {
if (caught) {
v8::Script::Compile(
- v8::String::New("debug.Debug.setBreakOnException()"))->Run();
+ v8::String::NewFromUtf8(isolate, "debug.Debug.setBreakOnException()"))
+ ->Run();
} else {
v8::Script::Compile(
- v8::String::New("debug.Debug.clearBreakOnException()"))->Run();
+ v8::String::NewFromUtf8(isolate, "debug.Debug.clearBreakOnException()"))
+ ->Run();
}
if (uncaught) {
v8::Script::Compile(
- v8::String::New("debug.Debug.setBreakOnUncaughtException()"))->Run();
+ v8::String::NewFromUtf8(
+ isolate, "debug.Debug.setBreakOnUncaughtException()"))->Run();
} else {
v8::Script::Compile(
- v8::String::New("debug.Debug.clearBreakOnUncaughtException()"))->Run();
+ v8::String::NewFromUtf8(
+ isolate, "debug.Debug.clearBreakOnUncaughtException()"))->Run();
}
}
@@ -799,7 +817,8 @@ static void DebugEventCounter(
exception_hit_count++;
// Check whether the exception was uncaught.
- v8::Local<v8::String> fun_name = v8::String::New("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);
@@ -856,9 +875,10 @@ static void DebugEventEvaluate(
if (event == v8::Break) {
for (int i = 0; checks[i].expr != NULL; i++) {
const int argc = 3;
- v8::Handle<v8::Value> argv[argc] = { exec_state,
- v8::String::New(checks[i].expr),
- checks[i].expected };
+ 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);
if (!result->IsTrue()) {
@@ -1187,9 +1207,10 @@ TEST(BreakPointICStore) {
v8::HandleScope scope(env->GetIsolate());
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::New("function foo(){bar=0;}"))->Run();
- v8::Local<v8::Function> foo =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
+ 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")));
// Run without breakpoints.
foo->Call(env->Global(), 0, NULL);
@@ -1218,10 +1239,13 @@ TEST(BreakPointICLoad) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::New("bar=1"))->Run();
- v8::Script::Compile(v8::String::New("function foo(){var x=bar;}"))->Run();
- v8::Local<v8::Function> foo =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
+ 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")));
// Run without breakpoints.
foo->Call(env->Global(), 0, NULL);
@@ -1250,10 +1274,12 @@ TEST(BreakPointICCall) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::New("function bar(){}"))->Run();
- v8::Script::Compile(v8::String::New("function foo(){bar();}"))->Run();
- v8::Local<v8::Function> foo =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
+ 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")));
// Run without breakpoints.
foo->Call(env->Global(), 0, NULL);
@@ -1282,10 +1308,14 @@ TEST(BreakPointICCallWithGC) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Debug::SetDebugEventListener2(DebugEventBreakPointCollectGarbage);
- v8::Script::Compile(v8::String::New("function bar(){return 1;}"))->Run();
- v8::Script::Compile(v8::String::New("function foo(){return bar();}"))->Run();
- v8::Local<v8::Function> foo =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
+ 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")));
// Run without breakpoints.
CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
@@ -1314,11 +1344,14 @@ TEST(BreakPointConstructCallWithGC) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Debug::SetDebugEventListener2(DebugEventBreakPointCollectGarbage);
- v8::Script::Compile(v8::String::New("function bar(){ this.x = 1;}"))->Run();
- v8::Script::Compile(v8::String::New(
- "function foo(){return new bar(1).x;}"))->Run();
- v8::Local<v8::Function> foo =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
+ 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")));
// Run without breakpoints.
CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
@@ -1358,9 +1391,10 @@ TEST(BreakPointReturn) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::New("function foo(){}"))->Run();
- v8::Local<v8::Function> foo =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
+ 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")));
// Run without breakpoints.
foo->Call(env->Global(), 0, NULL);
@@ -1527,40 +1561,44 @@ TEST(BreakPointThroughJavaScript) {
env.ExposeDebug();
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::New("function bar(){}"))->Run();
- v8::Script::Compile(v8::String::New("function foo(){bar();bar();}"))->Run();
+ 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
// Break points are set at position 3 and 9
- v8::Local<v8::Script> foo = v8::Script::Compile(v8::String::New("foo()"));
+ v8::Local<v8::Script> foo =
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "foo()"));
// Run without breakpoints.
foo->Run();
CHECK_EQ(0, break_point_hit_count);
// Run with one breakpoint
- int bp1 = SetBreakPointFromJS("foo", 0, 3);
+ int bp1 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 3);
foo->Run();
CHECK_EQ(1, break_point_hit_count);
foo->Run();
CHECK_EQ(2, break_point_hit_count);
// Run with two breakpoints
- int bp2 = SetBreakPointFromJS("foo", 0, 9);
+ int bp2 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 9);
foo->Run();
CHECK_EQ(4, break_point_hit_count);
foo->Run();
CHECK_EQ(6, break_point_hit_count);
// Run with one breakpoint
- ClearBreakPointFromJS(bp2);
+ ClearBreakPointFromJS(env->GetIsolate(), bp2);
foo->Run();
CHECK_EQ(7, break_point_hit_count);
foo->Run();
CHECK_EQ(8, break_point_hit_count);
// Run without breakpoints.
- ClearBreakPointFromJS(bp1);
+ ClearBreakPointFromJS(env->GetIsolate(), bp1);
foo->Run();
CHECK_EQ(8, break_point_hit_count);
@@ -1583,7 +1621,8 @@ TEST(ScriptBreakPointByNameThroughJavaScript) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::New(
+ v8::Local<v8::String> script = v8::String::NewFromUtf8(
+ env->GetIsolate(),
"function f() {\n"
" function h() {\n"
" a = 0; // line 2\n"
@@ -1604,12 +1643,12 @@ TEST(ScriptBreakPointByNameThroughJavaScript) {
// Compile the script and get the two functions.
v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::New("test"));
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
v8::Script::Compile(script, &origin)->Run();
- v8::Local<v8::Function> f =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
- v8::Local<v8::Function> g =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
// Call f and g without break points.
break_point_hit_count = 0;
@@ -1619,7 +1658,7 @@ TEST(ScriptBreakPointByNameThroughJavaScript) {
CHECK_EQ(0, break_point_hit_count);
// Call f and g with break point on line 12.
- int sbp1 = SetScriptBreakPointByNameFromJS("test", 12, 0);
+ int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 12, 0);
break_point_hit_count = 0;
f->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
@@ -1628,14 +1667,14 @@ TEST(ScriptBreakPointByNameThroughJavaScript) {
// Remove the break point again.
break_point_hit_count = 0;
- ClearBreakPointFromJS(sbp1);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp1);
f->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
g->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
// Call f and g with break point on line 2.
- int sbp2 = SetScriptBreakPointByNameFromJS("test", 2, 0);
+ int sbp2 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 2, 0);
break_point_hit_count = 0;
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
@@ -1643,10 +1682,10 @@ TEST(ScriptBreakPointByNameThroughJavaScript) {
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("test", 4, 0);
- int sbp4 = SetScriptBreakPointByNameFromJS("test", 12, 0);
- int sbp5 = SetScriptBreakPointByNameFromJS("test", 14, 0);
- int sbp6 = SetScriptBreakPointByNameFromJS("test", 15, 0);
+ 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);
break_point_hit_count = 0;
f->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
@@ -1655,11 +1694,11 @@ TEST(ScriptBreakPointByNameThroughJavaScript) {
// Remove all the break points again.
break_point_hit_count = 0;
- ClearBreakPointFromJS(sbp2);
- ClearBreakPointFromJS(sbp3);
- ClearBreakPointFromJS(sbp4);
- ClearBreakPointFromJS(sbp5);
- ClearBreakPointFromJS(sbp6);
+ 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);
CHECK_EQ(0, break_point_hit_count);
g->Call(env->Global(), 0, NULL);
@@ -1686,7 +1725,8 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Local<v8::String> source = v8::String::New(
+ v8::Local<v8::String> source = v8::String::NewFromUtf8(
+ env->GetIsolate(),
"function f() {\n"
" function h() {\n"
" a = 0; // line 2\n"
@@ -1707,16 +1747,16 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
// Compile the script and get the two functions.
v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::New("test"));
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
v8::Local<v8::Script> script = v8::Script::Compile(source, &origin);
script->Run();
- v8::Local<v8::Function> f =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
- v8::Local<v8::Function> g =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
// Get the script id knowing that internally it is a 32 integer.
- uint32_t script_id = script->Id()->Uint32Value();
+ int script_id = script->GetId();
// Call f and g without break points.
break_point_hit_count = 0;
@@ -1726,7 +1766,7 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
CHECK_EQ(0, break_point_hit_count);
// Call f and g with break point on line 12.
- int sbp1 = SetScriptBreakPointByIdFromJS(script_id, 12, 0);
+ int sbp1 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 12, 0);
break_point_hit_count = 0;
f->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
@@ -1735,14 +1775,14 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
// Remove the break point again.
break_point_hit_count = 0;
- ClearBreakPointFromJS(sbp1);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp1);
f->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
g->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
// Call f and g with break point on line 2.
- int sbp2 = SetScriptBreakPointByIdFromJS(script_id, 2, 0);
+ int sbp2 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 2, 0);
break_point_hit_count = 0;
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
@@ -1750,10 +1790,10 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
CHECK_EQ(2, break_point_hit_count);
// Call f and g with break point on line 2, 4, 12, 14 and 15.
- int sbp3 = SetScriptBreakPointByIdFromJS(script_id, 4, 0);
- int sbp4 = SetScriptBreakPointByIdFromJS(script_id, 12, 0);
- int sbp5 = SetScriptBreakPointByIdFromJS(script_id, 14, 0);
- int sbp6 = SetScriptBreakPointByIdFromJS(script_id, 15, 0);
+ int sbp3 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 4, 0);
+ int sbp4 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 12, 0);
+ 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);
CHECK_EQ(2, break_point_hit_count);
@@ -1762,11 +1802,11 @@ TEST(ScriptBreakPointByIdThroughJavaScript) {
// Remove all the break points again.
break_point_hit_count = 0;
- ClearBreakPointFromJS(sbp2);
- ClearBreakPointFromJS(sbp3);
- ClearBreakPointFromJS(sbp4);
- ClearBreakPointFromJS(sbp5);
- ClearBreakPointFromJS(sbp6);
+ 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);
CHECK_EQ(0, break_point_hit_count);
g->Call(env->Global(), 0, NULL);
@@ -1794,45 +1834,47 @@ TEST(EnableDisableScriptBreakPoint) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::New(
+ v8::Local<v8::String> script = v8::String::NewFromUtf8(
+ env->GetIsolate(),
"function f() {\n"
" a = 0; // line 1\n"
"};");
// Compile the script and get function f.
v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::New("test"));
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
v8::Script::Compile(script, &origin)->Run();
- v8::Local<v8::Function> f =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
// Set script break point on line 1 (in function f).
- int sbp = SetScriptBreakPointByNameFromJS("test", 1, 0);
+ int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
// Call f while enabeling and disabling the script break point.
break_point_hit_count = 0;
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
- DisableScriptBreakPointFromJS(sbp);
+ DisableScriptBreakPointFromJS(env->GetIsolate(), sbp);
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
- EnableScriptBreakPointFromJS(sbp);
+ EnableScriptBreakPointFromJS(env->GetIsolate(), sbp);
f->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
- DisableScriptBreakPointFromJS(sbp);
+ DisableScriptBreakPointFromJS(env->GetIsolate(), sbp);
f->Call(env->Global(), 0, NULL);
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();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
f->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
- EnableScriptBreakPointFromJS(sbp);
+ EnableScriptBreakPointFromJS(env->GetIsolate(), sbp);
f->Call(env->Global(), 0, NULL);
CHECK_EQ(3, break_point_hit_count);
@@ -1850,7 +1892,8 @@ TEST(ConditionalScriptBreakPoint) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::New(
+ v8::Local<v8::String> script = v8::String::NewFromUtf8(
+ env->GetIsolate(),
"count = 0;\n"
"function f() {\n"
" g(count++); // line 2\n"
@@ -1861,26 +1904,26 @@ TEST(ConditionalScriptBreakPoint) {
// Compile the script and get function f.
v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::New("test"));
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
v8::Script::Compile(script, &origin)->Run();
- v8::Local<v8::Function> f =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
// Set script break point on line 5 (in function g).
- int sbp1 = SetScriptBreakPointByNameFromJS("test", 5, 0);
+ int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 5, 0);
// Call f with different conditions on the script break point.
break_point_hit_count = 0;
- ChangeScriptBreakPointConditionFromJS(sbp1, "false");
+ ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "false");
f->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
- ChangeScriptBreakPointConditionFromJS(sbp1, "true");
+ ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "true");
break_point_hit_count = 0;
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
- ChangeScriptBreakPointConditionFromJS(sbp1, "x % 2 == 0");
+ 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);
@@ -1889,7 +1932,8 @@ TEST(ConditionalScriptBreakPoint) {
// Reload the script and get f again checking that the condition survives.
v8::Script::Compile(script, &origin)->Run();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
@@ -1911,30 +1955,31 @@ TEST(ScriptBreakPointIgnoreCount) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::New(
+ v8::Local<v8::String> script = v8::String::NewFromUtf8(
+ env->GetIsolate(),
"function f() {\n"
" a = 0; // line 1\n"
"};");
// Compile the script and get function f.
v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::New("test"));
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
v8::Script::Compile(script, &origin)->Run();
- v8::Local<v8::Function> f =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
// Set script break point on line 1 (in function f).
- int sbp = SetScriptBreakPointByNameFromJS("test", 1, 0);
+ int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
// Call f with different ignores on the script break point.
break_point_hit_count = 0;
- ChangeScriptBreakPointIgnoreCountFromJS(sbp, 1);
+ ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 1);
f->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
- ChangeScriptBreakPointIgnoreCountFromJS(sbp, 5);
+ ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 5);
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
f->Call(env->Global(), 0, NULL);
@@ -1943,7 +1988,8 @@ TEST(ScriptBreakPointIgnoreCount) {
// Reload the script and get f again checking that the ignore survives.
v8::Script::Compile(script, &origin)->Run();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
@@ -1966,7 +2012,8 @@ TEST(ScriptBreakPointReload) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
v8::Local<v8::Function> f;
- v8::Local<v8::String> script = v8::String::New(
+ v8::Local<v8::String> script = v8::String::NewFromUtf8(
+ env->GetIsolate(),
"function f() {\n"
" function h() {\n"
" a = 0; // line 2\n"
@@ -1975,15 +2022,18 @@ TEST(ScriptBreakPointReload) {
" return h();\n"
"}");
- v8::ScriptOrigin origin_1 = v8::ScriptOrigin(v8::String::New("1"));
- v8::ScriptOrigin origin_2 = v8::ScriptOrigin(v8::String::New("2"));
+ v8::ScriptOrigin origin_1 =
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "1"));
+ v8::ScriptOrigin origin_2 =
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "2"));
// Set a script break point before the script is loaded.
- SetScriptBreakPointByNameFromJS("1", 2, 0);
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "1", 2, 0);
// Compile the script and get the function.
v8::Script::Compile(script, &origin_1)->Run();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
// Call f and check that the script break point is active.
break_point_hit_count = 0;
@@ -1993,7 +2043,8 @@ TEST(ScriptBreakPointReload) {
// Compile the script again with a different script data and get the
// function.
v8::Script::Compile(script, &origin_2)->Run();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
// Call f and check that no break points are set.
break_point_hit_count = 0;
@@ -2002,7 +2053,8 @@ TEST(ScriptBreakPointReload) {
// Compile the script again and get the function.
v8::Script::Compile(script, &origin_1)->Run();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
// Call f and check that the script break point is active.
break_point_hit_count = 0;
@@ -2024,28 +2076,32 @@ TEST(ScriptBreakPointMultiple) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
v8::Local<v8::Function> f;
- v8::Local<v8::String> script_f = v8::String::New(
- "function f() {\n"
- " a = 0; // line 1\n"
- "}");
+ v8::Local<v8::String> script_f =
+ v8::String::NewFromUtf8(env->GetIsolate(),
+ "function f() {\n"
+ " a = 0; // line 1\n"
+ "}");
v8::Local<v8::Function> g;
- v8::Local<v8::String> script_g = v8::String::New(
- "function g() {\n"
- " b = 0; // line 1\n"
- "}");
+ v8::Local<v8::String> script_g =
+ v8::String::NewFromUtf8(env->GetIsolate(),
+ "function g() {\n"
+ " b = 0; // line 1\n"
+ "}");
v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::New("test"));
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
// Set a script break point before the scripts are loaded.
- int sbp = SetScriptBreakPointByNameFromJS("test", 1, 0);
+ 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();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
v8::Script::Compile(script_g, &origin)->Run();
- g = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
+ g = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
// Call f and g and check that the script break point is active.
break_point_hit_count = 0;
@@ -2055,7 +2111,7 @@ TEST(ScriptBreakPointMultiple) {
CHECK_EQ(2, break_point_hit_count);
// Clear the script break point.
- ClearBreakPointFromJS(sbp);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp);
// Call f and g and check that the script break point is no longer active.
break_point_hit_count = 0;
@@ -2065,7 +2121,7 @@ TEST(ScriptBreakPointMultiple) {
CHECK_EQ(0, break_point_hit_count);
// Set script break point with the scripts loaded.
- sbp = SetScriptBreakPointByNameFromJS("test", 1, 0);
+ sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
// Call f and g and check that the script break point is active.
break_point_hit_count = 0;
@@ -2089,23 +2145,28 @@ TEST(ScriptBreakPointLineOffset) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
v8::Local<v8::Function> f;
- v8::Local<v8::String> script = v8::String::New(
- "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::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"
+ "}");
// Create script origin both name and line offset.
- v8::ScriptOrigin origin(v8::String::New("test.html"),
- v8::Integer::New(7));
+ v8::ScriptOrigin origin(
+ v8::String::NewFromUtf8(env->GetIsolate(), "test.html"),
+ v8::Integer::New(7));
// Set two script break points before the script is loaded.
- int sbp1 = SetScriptBreakPointByNameFromJS("test.html", 8, 0);
- int sbp2 = SetScriptBreakPointByNameFromJS("test.html", 9, 0);
+ int sbp1 =
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 8, 0);
+ int sbp2 =
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0);
// Compile the script and get the function.
v8::Script::Compile(script, &origin)->Run();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
// Call f and check that the script break point is active.
break_point_hit_count = 0;
@@ -2113,8 +2174,8 @@ TEST(ScriptBreakPointLineOffset) {
CHECK_EQ(2, break_point_hit_count);
// Clear the script break points.
- ClearBreakPointFromJS(sbp1);
- ClearBreakPointFromJS(sbp2);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp1);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp2);
// Call f and check that no script break points are active.
break_point_hit_count = 0;
@@ -2122,7 +2183,7 @@ TEST(ScriptBreakPointLineOffset) {
CHECK_EQ(0, break_point_hit_count);
// Set a script break point with the script loaded.
- sbp1 = SetScriptBreakPointByNameFromJS("test.html", 9, 0);
+ sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0);
// Call f and check that the script break point is active.
break_point_hit_count = 0;
@@ -2149,32 +2210,40 @@ TEST(ScriptBreakPointLine) {
v8::Local<v8::Function> f;
v8::Local<v8::Function> g;
- v8::Local<v8::String> script = v8::String::New(
- "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::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");
// Set a couple script break point before the script is loaded.
- int sbp1 = SetScriptBreakPointByNameFromJS("test.html", 0, -1);
- int sbp2 = SetScriptBreakPointByNameFromJS("test.html", 1, -1);
- int sbp3 = SetScriptBreakPointByNameFromJS("test.html", 5, -1);
+ int sbp1 =
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 0, -1);
+ int sbp2 =
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 1, -1);
+ int sbp3 =
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 5, -1);
// Compile the script and get the function.
break_point_hit_count = 0;
- v8::ScriptOrigin origin(v8::String::New("test.html"), v8::Integer::New(0));
+ v8::ScriptOrigin origin(
+ v8::String::NewFromUtf8(env->GetIsolate(), "test.html"),
+ v8::Integer::New(0));
v8::Script::Compile(script, &origin)->Run();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
- g = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ g = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
// Check that a break point was hit when the script was run.
CHECK_EQ(1, break_point_hit_count);
@@ -2191,8 +2260,9 @@ TEST(ScriptBreakPointLine) {
CHECK_EQ("g", last_function_hit);
// Clear the script break point on g and set one on h.
- ClearBreakPointFromJS(sbp3);
- int sbp4 = SetScriptBreakPointByNameFromJS("test.html", 6, -1);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp3);
+ int sbp4 =
+ 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);
@@ -2202,9 +2272,10 @@ TEST(ScriptBreakPointLine) {
// 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
// more.
- ClearBreakPointFromJS(sbp2);
- ClearBreakPointFromJS(sbp4);
- int sbp5 = SetScriptBreakPointByNameFromJS("test.html", 4, -1);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp2);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp4);
+ 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);
@@ -2217,7 +2288,8 @@ TEST(ScriptBreakPointLine) {
CHECK_EQ(0, StrLength(last_function_hit));
// Set a break point in the code after the last function decleration.
- int sbp6 = SetScriptBreakPointByNameFromJS("test.html", 12, -1);
+ int sbp6 =
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 12, -1);
// Reload the script which should hit three break points.
break_point_hit_count = 0;
@@ -2227,9 +2299,9 @@ TEST(ScriptBreakPointLine) {
// Clear the last break points, and reload the script which should not hit any
// break points.
- ClearBreakPointFromJS(sbp1);
- ClearBreakPointFromJS(sbp5);
- ClearBreakPointFromJS(sbp6);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp1);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp5);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp6);
break_point_hit_count = 0;
v8::Script::Compile(script, &origin)->Run();
CHECK_EQ(0, break_point_hit_count);
@@ -2247,21 +2319,24 @@ TEST(ScriptBreakPointLineTopLevel) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Local<v8::String> script = v8::String::New(
- "function f() {\n"
- " a = 1; // line 1\n"
- "}\n"
- "a = 2; // line 3\n");
+ 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::Local<v8::Function> f;
{
v8::HandleScope scope(env->GetIsolate());
- v8::Script::Compile(script, v8::String::New("test.html"))->Run();
+ v8::Script::Compile(
+ script, v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))->Run();
}
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
- SetScriptBreakPointByNameFromJS("test.html", 3, -1);
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
// Call f and check that there was no break points.
break_point_hit_count = 0;
@@ -2270,12 +2345,14 @@ TEST(ScriptBreakPointLineTopLevel) {
// Recompile and run script and check that break point was hit.
break_point_hit_count = 0;
- v8::Script::Compile(script, v8::String::New("test.html"))->Run();
+ v8::Script::Compile(
+ script, v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))->Run();
CHECK_EQ(1, break_point_hit_count);
// 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::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
CHECK_EQ(0, break_point_hit_count);
v8::Debug::SetDebugEventListener2(NULL);
@@ -2292,23 +2369,28 @@ TEST(ScriptBreakPointTopLevelCrash) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Local<v8::String> script_source = v8::String::New(
- "function f() {\n"
- " return 0;\n"
- "}\n"
- "f()");
+ v8::Local<v8::String> script_source =
+ v8::String::NewFromUtf8(env->GetIsolate(),
+ "function f() {\n"
+ " return 0;\n"
+ "}\n"
+ "f()");
- int sbp1 = SetScriptBreakPointByNameFromJS("test.html", 3, -1);
+ int sbp1 =
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
{
v8::HandleScope scope(env->GetIsolate());
break_point_hit_count = 0;
- v8::Script::Compile(script_source, v8::String::New("test.html"))->Run();
+ v8::Script::Compile(script_source,
+ v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))
+ ->Run();
CHECK_EQ(1, break_point_hit_count);
}
- int sbp2 = SetScriptBreakPointByNameFromJS("test.html", 3, -1);
- ClearBreakPointFromJS(sbp1);
- ClearBreakPointFromJS(sbp2);
+ int sbp2 =
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp1);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp2);
v8::Debug::SetDebugEventListener2(NULL);
CheckDebuggerUnloaded();
@@ -2347,13 +2429,16 @@ TEST(DebuggerStatement) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::New("function bar(){debugger}"))->Run();
- v8::Script::Compile(v8::String::New(
- "function foo(){debugger;debugger;}"))->Run();
- v8::Local<v8::Function> foo =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
- v8::Local<v8::Function> bar =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("bar")));
+ 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();
+ v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
+ v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar")));
// Run function with debugger statement
bar->Call(env->Global(), 0, NULL);
@@ -2374,9 +2459,11 @@ TEST(DebuggerStatementBreakpoint) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
- v8::Script::Compile(v8::String::New("function foo(){debugger;}"))->Run();
- v8::Local<v8::Function> foo =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){debugger;}"))
+ ->Run();
+ v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
// The debugger statement triggers breakpint hit
foo->Call(env->Global(), 0, NULL);
@@ -2417,13 +2504,13 @@ TEST(DebugEvaluate) {
{NULL, v8::Handle<v8::Value>()}
};
struct EvaluateCheck checks_hu[] = {
- {"x", v8::String::New("Hello, world!")},
+ {"x", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")},
{"a", v8::Undefined(isolate)},
{NULL, v8::Handle<v8::Value>()}
};
struct EvaluateCheck checks_hh[] = {
- {"x", v8::String::New("Hello, world!")},
- {"a", v8::String::New("Hello, world!")},
+ {"x", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")},
+ {"a", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")},
{NULL, v8::Handle<v8::Value>()}
};
@@ -2443,7 +2530,8 @@ TEST(DebugEvaluate) {
const int foo_break_position_2 = 29;
// Arguments with one parameter "Hello, world!"
- v8::Handle<v8::Value> argv_foo[1] = { v8::String::New("Hello, world!") };
+ v8::Handle<v8::Value> argv_foo[1] = {
+ v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")};
// Call foo with breakpoint set before a=x and undefined as parameter.
int bp = SetBreakPoint(foo, foo_break_position_1);
@@ -2493,7 +2581,7 @@ TEST(DebugEvaluate) {
// "Hello, world!".
checks = checks_hu;
v8::Handle<v8::Value> argv_bar_2[2] = {
- v8::String::New("Hello, world!"),
+ v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
v8::Number::New(barbar_break_position)
};
bar->Call(env->Global(), 2, argv_bar_2);
@@ -2502,7 +2590,7 @@ TEST(DebugEvaluate) {
// "Hello, world!".
checks = checks_hh;
v8::Handle<v8::Value> argv_bar_3[2] = {
- v8::String::New("Hello, world!"),
+ v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
v8::Number::New(barbar_break_position + 1)
};
bar->Call(env->Global(), 2, argv_bar_3);
@@ -2690,10 +2778,10 @@ DebugProcessDebugMessagesData process_debug_messages_data;
static void DebugProcessDebugMessagesHandler(
const v8::Debug::Message& message) {
v8::Handle<v8::String> json = message.GetJSON();
- v8::String::AsciiValue ascii(json);
+ v8::String::Utf8Value utf8(json);
EvaluateResult* array_item = process_debug_messages_data.current();
- bool res = GetEvaluateStringResult(*ascii,
+ bool res = GetEvaluateStringResult(*utf8,
array_item->buffer,
EvaluateResult::kBufferSize);
if (res) {
@@ -2713,7 +2801,8 @@ TEST(DebugEvaluateWithoutStack) {
const char* source =
"var v1 = 'Pinguin';\n function getAnimal() { return 'Capy' + 'bara'; }";
- v8::Script::Compile(v8::String::New(source))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source))
+ ->Run();
v8::Debug::ProcessDebugMessages();
@@ -3489,7 +3578,8 @@ TEST(DebugStepWith) {
" with (b) {}"
"}"
"foo()";
- env->Global()->Set(v8::String::New("b"), v8::Object::New());
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"),
+ v8::Object::New());
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
v8::Handle<v8::Value> result;
SetBreakPoint(foo, 8); // "var a = {};"
@@ -3823,12 +3913,14 @@ TEST(PauseInScript) {
const char* script_name = "StepInHandlerTest";
// Set breakpoint in the script.
- SetScriptBreakPointByNameFromJS(script_name, 0, -1);
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1);
break_point_hit_count = 0;
- v8::ScriptOrigin origin(v8::String::New(script_name), v8::Integer::New(0));
- v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(src),
- &origin);
+ v8::ScriptOrigin origin(
+ v8::String::NewFromUtf8(env->GetIsolate(), script_name),
+ v8::Integer::New(0));
+ v8::Handle<v8::Script> script = v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), src), &origin);
v8::Local<v8::Value> r = script->Run();
CHECK(r->IsFunction());
@@ -3932,7 +4024,7 @@ TEST(BreakOnException) {
// No break on exception using JavaScript
DebugEventCounterClear();
MessageCallbackCountClear();
- ChangeBreakOnExceptionFromJS(false, false);
+ ChangeBreakOnExceptionFromJS(env->GetIsolate(), false, false);
caught->Call(env->Global(), 0, NULL);
CHECK_EQ(0, exception_hit_count);
CHECK_EQ(0, uncaught_exception_hit_count);
@@ -3945,7 +4037,7 @@ TEST(BreakOnException) {
// Break on uncaught exception using JavaScript
DebugEventCounterClear();
MessageCallbackCountClear();
- ChangeBreakOnExceptionFromJS(false, true);
+ ChangeBreakOnExceptionFromJS(env->GetIsolate(), false, true);
caught->Call(env->Global(), 0, NULL);
CHECK_EQ(0, exception_hit_count);
CHECK_EQ(0, uncaught_exception_hit_count);
@@ -3958,7 +4050,7 @@ TEST(BreakOnException) {
// Break on exception and uncaught exception using JavaScript
DebugEventCounterClear();
MessageCallbackCountClear();
- ChangeBreakOnExceptionFromJS(true, true);
+ ChangeBreakOnExceptionFromJS(env->GetIsolate(), true, true);
caught->Call(env->Global(), 0, NULL);
CHECK_EQ(1, exception_hit_count);
CHECK_EQ(0, message_callback_count);
@@ -3971,7 +4063,7 @@ TEST(BreakOnException) {
// Break on exception using JavaScript
DebugEventCounterClear();
MessageCallbackCountClear();
- ChangeBreakOnExceptionFromJS(true, false);
+ ChangeBreakOnExceptionFromJS(env->GetIsolate(), true, false);
caught->Call(env->Global(), 0, NULL);
CHECK_EQ(1, exception_hit_count);
CHECK_EQ(0, uncaught_exception_hit_count);
@@ -4015,28 +4107,30 @@ TEST(BreakOnCompileException) {
CHECK_EQ(-1, last_js_stack_height);
// Throws SyntaxError: Unexpected end of input
- v8::Script::Compile(v8::String::New("+++"));
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "+++"));
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::New("x x"));
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "x x"));
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::New("eval('+++')"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "eval('+++')"))
+ ->Run();
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::New("eval('x x')"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "eval('x x')"))
+ ->Run();
CHECK_EQ(4, exception_hit_count);
CHECK_EQ(4, uncaught_exception_hit_count);
CHECK_EQ(4, message_callback_count);
@@ -4263,9 +4357,12 @@ TEST(NoBreakWhenBootstrapping) {
static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
v8::Handle<v8::Array> result = v8::Array::New(3);
- result->Set(v8::Integer::New(0), v8::String::New("a"));
- result->Set(v8::Integer::New(1), v8::String::New("b"));
- result->Set(v8::Integer::New(2), v8::String::New("c"));
+ result->Set(v8::Integer::New(0),
+ v8::String::NewFromUtf8(info.GetIsolate(), "a"));
+ result->Set(v8::Integer::New(1),
+ v8::String::NewFromUtf8(info.GetIsolate(), "b"));
+ result->Set(v8::Integer::New(2),
+ v8::String::NewFromUtf8(info.GetIsolate(), "c"));
info.GetReturnValue().Set(result);
}
@@ -4282,13 +4379,13 @@ static void NamedGetter(v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
v8::String::Utf8Value n(name);
if (strcmp(*n, "a") == 0) {
- info.GetReturnValue().Set(v8::String::New("AA"));
+ info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "AA"));
return;
} else if (strcmp(*n, "b") == 0) {
- info.GetReturnValue().Set(v8::String::New("BB"));
+ info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "BB"));
return;
} else if (strcmp(*n, "c") == 0) {
- info.GetReturnValue().Set(v8::String::New("CC"));
+ info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "CC"));
return;
} else {
info.GetReturnValue().SetUndefined();
@@ -4313,8 +4410,9 @@ TEST(InterceptorPropertyMirror) {
// Create object with named interceptor.
v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
named->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum);
- env->Global()->Set(v8::String::New("intercepted_named"),
- named->NewInstance());
+ env->Global()->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_named"),
+ named->NewInstance());
// Create object with indexed interceptor.
v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New();
@@ -4323,14 +4421,17 @@ TEST(InterceptorPropertyMirror) {
NULL,
NULL,
IndexedEnum);
- env->Global()->Set(v8::String::New("intercepted_indexed"),
- indexed->NewInstance());
+ env->Global()->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_indexed"),
+ indexed->NewInstance());
// Create object with both named and indexed interceptor.
v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New();
both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum);
both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum);
- env->Global()->Set(v8::String::New("intercepted_both"), both->NewInstance());
+ env->Global()->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_both"),
+ both->NewInstance());
// Get mirrors for the three objects with interceptor.
CompileRun(
@@ -4442,25 +4543,29 @@ TEST(HiddenPrototypePropertyMirror) {
env.ExposeDebug();
v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
- t0->InstanceTemplate()->Set(v8::String::New("x"), v8::Number::New(0));
+ t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "x"),
+ v8::Number::New(0));
v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
t1->SetHiddenPrototype(true);
- t1->InstanceTemplate()->Set(v8::String::New("y"), v8::Number::New(1));
+ t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "y"),
+ v8::Number::New(1));
v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
t2->SetHiddenPrototype(true);
- t2->InstanceTemplate()->Set(v8::String::New("z"), v8::Number::New(2));
+ t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "z"),
+ v8::Number::New(2));
v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
- t3->InstanceTemplate()->Set(v8::String::New("u"), v8::Number::New(3));
+ t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "u"),
+ v8::Number::New(3));
// Create object and set them on the global object.
v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::New("o0"), o0);
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o0"), o0);
v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::New("o1"), o1);
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o1"), o1);
v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::New("o2"), o2);
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o2"), o2);
v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::New("o3"), o3);
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o3"), o3);
// Get mirrors for the four objects.
CompileRun(
@@ -4485,7 +4590,7 @@ TEST(HiddenPrototypePropertyMirror) {
// 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::New("__proto__"), o1);
+ o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o1);
CHECK_EQ(2, CompileRun(
"o0_mirror.propertyNames().length")->Int32Value());
CHECK_EQ(0, CompileRun(
@@ -4496,7 +4601,7 @@ TEST(HiddenPrototypePropertyMirror) {
// 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::New("__proto__"), o2);
+ o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o2);
CHECK_EQ(3, CompileRun(
"o0_mirror.propertyNames().length")->Int32Value());
CHECK_EQ(0, CompileRun(
@@ -4512,7 +4617,7 @@ TEST(HiddenPrototypePropertyMirror) {
// from o1 and o2 should still be seen on o0.
// Final prototype chain: o0 -> o1 -> o2 -> o3
// Hidden prototypes: ^^ ^^
- o0->Set(v8::String::New("__proto__"), o3);
+ o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o3);
CHECK_EQ(3, CompileRun(
"o0_mirror.propertyNames().length")->Int32Value());
CHECK_EQ(1, CompileRun(
@@ -4543,14 +4648,15 @@ TEST(NativeGetterPropertyMirror) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Handle<v8::String> name = v8::String::New("x");
+ v8::Handle<v8::String> name = v8::String::NewFromUtf8(env->GetIsolate(), "x");
// Create object with named accessor.
v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
named->SetAccessor(name, &ProtperyXNativeGetter, NULL,
v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
// Create object with named property getter.
- env->Global()->Set(v8::String::New("instance"), named->NewInstance());
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ named->NewInstance());
CHECK_EQ(10, CompileRun("instance.x")->Int32Value());
// Get mirror for the object with property getter.
@@ -4581,14 +4687,15 @@ TEST(NativeGetterThrowingErrorPropertyMirror) {
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- v8::Handle<v8::String> name = v8::String::New("x");
+ v8::Handle<v8::String> name = v8::String::NewFromUtf8(env->GetIsolate(), "x");
// Create object with named accessor.
v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL,
v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
// Create object with named property getter.
- env->Global()->Set(v8::String::New("instance"), named->NewInstance());
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ named->NewInstance());
// Get mirror for the object with property getter.
CompileRun("var instance_mirror = debug.MakeMirror(instance);");
@@ -4618,12 +4725,14 @@ TEST(NoHiddenProperties) {
// Create an object in the global scope.
const char* source = "var obj = {a: 1};";
- v8::Script::Compile(v8::String::New(source))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source))
+ ->Run();
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
- env->Global()->Get(v8::String::New("obj")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "obj")));
// Set a hidden property on the object.
- obj->SetHiddenValue(v8::String::New("v8::test-debug::a"),
- v8::Int32::New(11));
+ obj->SetHiddenValue(
+ v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::a"),
+ v8::Int32::New(11));
// Get mirror for the object with property getter.
CompileRun("var obj_mirror = debug.MakeMirror(obj);");
@@ -4640,25 +4749,33 @@ TEST(NoHiddenProperties) {
// Object created by t0 will become hidden prototype of object 'obj'.
v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
- t0->InstanceTemplate()->Set(v8::String::New("b"), v8::Number::New(2));
+ t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"),
+ v8::Number::New(2));
t0->SetHiddenPrototype(true);
v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
- t1->InstanceTemplate()->Set(v8::String::New("c"), v8::Number::New(3));
+ t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "c"),
+ v8::Number::New(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::New("v8::test-debug::b"),
- v8::Int32::New(12));
- env->Global()->Set(v8::String::New("protoObj"), protoObj);
+ protoObj->SetHiddenValue(
+ v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::b"),
+ v8::Int32::New(12));
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "protoObj"),
+ protoObj);
v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
- grandProtoObj->SetHiddenValue(v8::String::New("v8::test-debug::c"),
- v8::Int32::New(13));
- env->Global()->Set(v8::String::New("grandProtoObj"), grandProtoObj);
+ grandProtoObj->SetHiddenValue(
+ v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::c"),
+ v8::Int32::New(13));
+ env->Global()->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "grandProtoObj"),
+ grandProtoObj);
// Setting prototypes: obj->protoObj->grandProtoObj
- protoObj->Set(v8::String::New("__proto__"), grandProtoObj);
- obj->Set(v8::String::New("__proto__"), protoObj);
+ protoObj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"),
+ grandProtoObj);
+ obj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), protoObj);
// Get mirror for the object with property getter.
CompileRun("var obj_mirror = debug.MakeMirror(obj);");
@@ -4844,8 +4961,8 @@ class MessageQueueDebuggerThread : public v8::internal::Thread {
static void MessageHandler(const v8::Debug::Message& message) {
v8::Handle<v8::String> json = message.GetJSON();
- v8::String::AsciiValue ascii(json);
- if (IsBreakEventMessage(*ascii)) {
+ v8::String::Utf8Value utf8(json);
+ if (IsBreakEventMessage(*utf8)) {
// Lets test script wait until break occurs to send commands.
// Signals when a break is reported.
message_queue_barriers.semaphore_2.Signal();
@@ -5151,8 +5268,9 @@ void V8Thread::Run() {
v8::HandleScope scope(env->GetIsolate());
v8::Debug::SetMessageHandler2(&ThreadedMessageHandler);
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
- global_template->Set(v8::String::New("ThreadedAtBarrier1"),
- v8::FunctionTemplate::New(ThreadedAtBarrier1));
+ global_template->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
+ v8::FunctionTemplate::New(ThreadedAtBarrier1));
v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(),
NULL,
global_template);
@@ -5484,7 +5602,8 @@ static void CheckSourceLine(const v8::FunctionCallbackInfo<v8::Value>& args) {
// can throw exceptions.
static void CheckDataParameter(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::Handle<v8::String> data = v8::String::New("Test");
+ v8::Handle<v8::String> data =
+ v8::String::NewFromUtf8(args.GetIsolate(), "Test");
CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString());
CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
@@ -5510,73 +5629,92 @@ TEST(CallFunctionInDebugger) {
// CheckSourceLine and CheckDataParameter installed.
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
- global_template->Set(v8::String::New("CheckFrameCount"),
- v8::FunctionTemplate::New(CheckFrameCount));
- global_template->Set(v8::String::New("CheckSourceLine"),
- v8::FunctionTemplate::New(CheckSourceLine));
- global_template->Set(v8::String::New("CheckDataParameter"),
- v8::FunctionTemplate::New(CheckDataParameter));
- global_template->Set(v8::String::New("CheckClosure"),
- v8::FunctionTemplate::New(CheckClosure));
+ global_template->Set(
+ v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"),
+ v8::FunctionTemplate::New(CheckFrameCount));
+ global_template->Set(
+ v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"),
+ v8::FunctionTemplate::New(CheckSourceLine));
+ global_template->Set(
+ v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"),
+ v8::FunctionTemplate::New(CheckDataParameter));
+ global_template->Set(
+ v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"),
+ v8::FunctionTemplate::New(CheckClosure));
v8::Handle<v8::Context> context = v8::Context::New(CcTest::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::New(frame_count_source))->Run();
- frame_count = v8::Local<v8::Function>::Cast(
- context->Global()->Get(v8::String::New("frame_count")));
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(CcTest::isolate(), frame_count_source))->Run();
+ frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get(
+ v8::String::NewFromUtf8(CcTest::isolate(), "frame_count")));
// Compile a function for returning the source line for the top frame.
- v8::Script::Compile(v8::String::New(frame_source_line_source))->Run();
- frame_source_line = v8::Local<v8::Function>::Cast(
- context->Global()->Get(v8::String::New("frame_source_line")));
+ v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
+ frame_source_line_source))->Run();
+ frame_source_line = v8::Local<v8::Function>::Cast(context->Global()->Get(
+ v8::String::NewFromUtf8(CcTest::isolate(), "frame_source_line")));
// Compile a function returning the data parameter.
- v8::Script::Compile(v8::String::New(debugger_call_with_data_source))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
+ debugger_call_with_data_source))
+ ->Run();
debugger_call_with_data = v8::Local<v8::Function>::Cast(
- context->Global()->Get(v8::String::New("debugger_call_with_data")));
+ context->Global()->Get(v8::String::NewFromUtf8(
+ CcTest::isolate(), "debugger_call_with_data")));
// Compile a function capturing closure.
- debugger_call_with_closure = v8::Local<v8::Function>::Cast(
- v8::Script::Compile(
- v8::String::New(debugger_call_with_closure_source))->Run());
+ debugger_call_with_closure =
+ v8::Local<v8::Function>::Cast(v8::Script::Compile(
+ v8::String::NewFromUtf8(CcTest::isolate(),
+ debugger_call_with_closure_source))->Run());
// Calling a function through the debugger returns 0 frames if there are
// no JavaScript frames.
CHECK_EQ(v8::Integer::New(0), v8::Debug::Call(frame_count));
// Test that the number of frames can be retrieved.
- v8::Script::Compile(v8::String::New("CheckFrameCount(1)"))->Run();
- v8::Script::Compile(v8::String::New("function f() {"
- " CheckFrameCount(2);"
- "}; f()"))->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount(1)"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
+ "function f() {"
+ " CheckFrameCount(2);"
+ "}; f()"))->Run();
// Test that the source line can be retrieved.
- v8::Script::Compile(v8::String::New("CheckSourceLine(0)"))->Run();
- v8::Script::Compile(v8::String::New("function f() {\n"
- " CheckSourceLine(1)\n"
- " CheckSourceLine(2)\n"
- " CheckSourceLine(3)\n"
- "}; f()"))->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(0)"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
+ "function f() {\n"
+ " CheckSourceLine(1)\n"
+ " CheckSourceLine(2)\n"
+ " CheckSourceLine(3)\n"
+ "}; f()"))->Run();
// Test that a parameter can be passed to a function called in the debugger.
- v8::Script::Compile(v8::String::New("CheckDataParameter()"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
+ "CheckDataParameter()"))->Run();
// Test that a function with closure can be run in the debugger.
- v8::Script::Compile(v8::String::New("CheckClosure()"))->Run();
-
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure()"))->Run();
// Test that the source line is correct when there is a line offset.
- v8::ScriptOrigin origin(v8::String::New("test"),
+ v8::ScriptOrigin origin(v8::String::NewFromUtf8(CcTest::isolate(), "test"),
v8::Integer::New(7));
- v8::Script::Compile(v8::String::New("CheckSourceLine(7)"), &origin)->Run();
- v8::Script::Compile(v8::String::New("function f() {\n"
- " CheckSourceLine(8)\n"
- " CheckSourceLine(9)\n"
- " CheckSourceLine(10)\n"
- "}; f()"), &origin)->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(7)"), &origin)
+ ->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
+ "function f() {\n"
+ " CheckSourceLine(8)\n"
+ " CheckSourceLine(9)\n"
+ " CheckSourceLine(10)\n"
+ "}; f()"),
+ &origin)->Run();
}
@@ -5639,7 +5777,7 @@ TEST(DebuggerUnload) {
// Get the test functions again.
v8::Local<v8::Function> foo(v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("foo"))));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))));
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(0, break_point_hit_count);
@@ -6135,7 +6273,11 @@ TEST(DebugGetLoadedScripts) {
i::FLAG_allow_natives_syntax = allow_natives_syntax;
// Some scripts are retrieved - at least the number of native scripts.
- CHECK_GT((*env)->Global()->Get(v8::String::New("count"))->Int32Value(), 8);
+ CHECK_GT((*env)
+ ->Global()
+ ->Get(v8::String::NewFromUtf8(env->GetIsolate(), "count"))
+ ->Int32Value(),
+ 8);
}
@@ -6160,17 +6302,19 @@ TEST(ScriptNameAndData) {
v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
// Test function source.
- v8::Local<v8::String> script = v8::String::New(
- "function f() {\n"
- " debugger;\n"
- "}\n");
+ v8::Local<v8::String> script = v8::String::NewFromUtf8(env->GetIsolate(),
+ "function f() {\n"
+ " debugger;\n"
+ "}\n");
- v8::ScriptOrigin origin1 = v8::ScriptOrigin(v8::String::New("name"));
+ v8::ScriptOrigin origin1 =
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "name"));
v8::Handle<v8::Script> script1 = v8::Script::Compile(script, &origin1);
- script1->SetData(v8::String::New("data"));
+ script1->SetData(v8::String::NewFromUtf8(env->GetIsolate(), "data"));
script1->Run();
v8::Local<v8::Function> f;
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
@@ -6180,34 +6324,39 @@ TEST(ScriptNameAndData) {
// 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();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
f->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
CHECK_EQ("name", last_script_name_hit);
CHECK_EQ("", last_script_data_hit); // Undefined results in empty string.
- v8::Local<v8::String> data_obj_source = v8::String::New(
- "({ a: 'abc',\n"
- " b: 123,\n"
- " toString: function() { return this.a + ' ' + this.b; }\n"
- "})\n");
+ 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::Local<v8::Value> data_obj = v8::Script::Compile(data_obj_source)->Run();
- v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name"));
+ v8::ScriptOrigin origin2 =
+ v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "new name"));
v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2);
script2->Run();
script2->SetData(data_obj->ToString());
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
f->Call(env->Global(), 0, NULL);
CHECK_EQ(3, break_point_hit_count);
CHECK_EQ("new name", last_script_name_hit);
CHECK_EQ("abc 123", last_script_data_hit);
- v8::Handle<v8::Script> script3 =
- v8::Script::Compile(script, &origin2, NULL,
- v8::String::New("in compile"));
+ v8::Handle<v8::Script> script3 = v8::Script::Compile(
+ script, &origin2, NULL,
+ v8::String::NewFromUtf8(env->GetIsolate(), "in compile"));
CHECK_EQ("in compile", last_script_data_hit);
script3->Run();
- f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
f->Call(env->Global(), 0, NULL);
CHECK_EQ(4, break_point_hit_count);
CHECK_EQ("in compile", last_script_data_hit);
@@ -6259,8 +6408,8 @@ TEST(ContextData) {
CHECK(context_2->GetEmbedderData(0)->IsUndefined());
// Set and check different data values.
- v8::Handle<v8::String> data_1 = v8::String::New("1");
- v8::Handle<v8::String> data_2 = v8::String::New("2");
+ v8::Handle<v8::String> data_1 = v8::String::NewFromUtf8(isolate, "1");
+ v8::Handle<v8::String> data_2 = v8::String::NewFromUtf8(isolate, "2");
context_1->SetEmbedderData(0, data_1);
context_2->SetEmbedderData(0, data_2);
CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1));
@@ -6274,7 +6423,7 @@ TEST(ContextData) {
v8::Context::Scope context_scope(context_1);
expected_context = context_1;
expected_context_data = data_1;
- v8::Local<v8::Function> f = CompileFunction(source, "f");
+ v8::Local<v8::Function> f = CompileFunction(isolate, source, "f");
f->Call(context_1->Global(), 0, NULL);
}
@@ -6284,7 +6433,7 @@ TEST(ContextData) {
v8::Context::Scope context_scope(context_2);
expected_context = context_2;
expected_context_data = data_2;
- v8::Local<v8::Function> f = CompileFunction(source, "f");
+ v8::Local<v8::Function> f = CompileFunction(isolate, source, "f");
f->Call(context_2->Global(), 0, NULL);
}
@@ -6325,10 +6474,10 @@ TEST(DebugBreakInMessageHandler) {
// 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::New("f")));
- v8::Local<v8::Function> g =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
// Call f then g. The debugger statement in f will casue a break which will
// cause another break.
@@ -6391,9 +6540,10 @@ TEST(RegExpDebugBreak) {
"var sourceLineBeginningSkip = /^(?:[ \\v\\h]*(?:\\/\\*.*?\\*\\/)*)*/;\n"
"function f(s) { return s.match(sourceLineBeginningSkip)[0].length; }";
- v8::Local<v8::Function> f = CompileFunction(script, "f");
+ v8::Local<v8::Function> f = CompileFunction(env->GetIsolate(), script, "f");
const int argc = 1;
- v8::Handle<v8::Value> argv[argc] = { v8::String::New(" /* xxx */ a=0;") };
+ 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());
@@ -6425,7 +6575,8 @@ static void ExecuteScriptForContextCheck(
CHECK(context_1->GetEmbedderData(0)->IsUndefined());
// Set and check a data value.
- v8::Handle<v8::String> data_1 = v8::String::New("1");
+ v8::Handle<v8::String> data_1 =
+ v8::String::NewFromUtf8(CcTest::isolate(), "1");
context_1->SetEmbedderData(0, data_1);
CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1));
@@ -6437,7 +6588,7 @@ static void ExecuteScriptForContextCheck(
v8::Context::Scope context_scope(context_1);
expected_context = context_1;
expected_context_data = data_1;
- v8::Local<v8::Function> f = CompileFunction(source, "f");
+ v8::Local<v8::Function> f = CompileFunction(CcTest::isolate(), source, "f");
f->Call(context_1->Global(), 0, NULL);
}
@@ -6558,8 +6709,10 @@ TEST(ScriptCollectedEvent) {
script_collected_count = 0;
v8::Debug::SetDebugEventListener2(DebugEventScriptCollectedEvent);
{
- v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
- v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), "eval('a=1')"))->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), "eval('a=2')"))->Run();
}
// Do garbage collection to collect the script above which is no longer
@@ -6618,8 +6771,8 @@ TEST(ScriptCollectedEventContext) {
CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
- v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
- v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(isolate, "eval('a=1')"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(isolate, "eval('a=2')"))->Run();
// Leave context
{
@@ -6628,7 +6781,7 @@ TEST(ScriptCollectedEventContext) {
v8::Local<v8::Context>::New(isolate, context);
local_context->Exit();
}
- context.Dispose();
+ context.Reset();
// Do garbage collection to collect the script above which is no longer
// referenced.
@@ -6663,12 +6816,14 @@ TEST(AfterCompileMessageWhenMessageHandlerIsReset) {
const char* script = "var a=1";
v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
- v8::Script::Compile(v8::String::New(script))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
+ ->Run();
v8::Debug::SetMessageHandler2(NULL);
v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
v8::Debug::DebugBreak(env->GetIsolate());
- v8::Script::Compile(v8::String::New(script))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
+ ->Run();
// Setting listener to NULL should cause debugger unload.
v8::Debug::SetMessageHandler2(NULL);
@@ -6687,13 +6842,14 @@ TEST(BreakMessageWhenMessageHandlerIsReset) {
const char* script = "function f() {};";
v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
- v8::Script::Compile(v8::String::New(script))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
+ ->Run();
v8::Debug::SetMessageHandler2(NULL);
v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
v8::Debug::DebugBreak(env->GetIsolate());
- v8::Local<v8::Function> f =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ 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);
// Setting message handler to NULL should cause debugger unload.
@@ -6726,12 +6882,13 @@ TEST(ExceptionMessageWhenMessageHandlerIsReset) {
const char* script = "function f() {throw new Error()};";
v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
- v8::Script::Compile(v8::String::New(script))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
+ ->Run();
v8::Debug::SetMessageHandler2(NULL);
v8::Debug::SetMessageHandler2(ExceptionMessageHandler);
- v8::Local<v8::Function> f =
- v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ 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);
// Setting message handler to NULL should cause debugger unload.
@@ -6753,28 +6910,30 @@ TEST(ProvisionalBreakpointOnLineOutOfRange) {
// Set a couple of provisional breakpoint on lines out of the script lines
// range.
- int sbp1 = SetScriptBreakPointByNameFromJS(resource_name, 3,
- -1 /* no column */);
- int sbp2 = SetScriptBreakPointByNameFromJS(resource_name, 5, 5);
+ int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name,
+ 3, -1 /* no column */);
+ int sbp2 =
+ SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5);
after_compile_message_count = 0;
v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
v8::ScriptOrigin origin(
- v8::String::New(resource_name),
+ v8::String::NewFromUtf8(env->GetIsolate(), resource_name),
v8::Integer::New(10),
v8::Integer::New(1));
// Compile a script whose first line number is greater than the breakpoints'
// lines.
- v8::Script::Compile(v8::String::New(script), &origin)->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script),
+ &origin)->Run();
// 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
// sent.
CHECK_EQ(1, after_compile_message_count);
- ClearBreakPointFromJS(sbp1);
- ClearBreakPointFromJS(sbp2);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp1);
+ ClearBreakPointFromJS(env->GetIsolate(), sbp2);
v8::Debug::SetMessageHandler2(NULL);
}
@@ -6932,7 +7091,8 @@ TEST(Backtrace) {
v8::Debug::ProcessDebugMessages();
CHECK_EQ(BacktraceData::frame_counter, 0);
- v8::Handle<v8::String> void0 = v8::String::New("void(0)");
+ v8::Handle<v8::String> void0 =
+ v8::String::NewFromUtf8(env->GetIsolate(), "void(0)");
v8::Handle<v8::Script> script = v8::Script::Compile(void0, void0);
// Check backtrace from "void(0)" script.
@@ -6954,10 +7114,12 @@ TEST(Backtrace) {
TEST(GetMirror) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<v8::Value> obj = v8::Debug::GetMirror(v8::String::New("hodja"));
- v8::Handle<v8::Function> run_test = v8::Handle<v8::Function>::Cast(
- v8::Script::New(
- v8::String::New(
+ v8::Handle<v8::Value> obj =
+ v8::Debug::GetMirror(v8::String::NewFromUtf8(env->GetIsolate(), "hodja"));
+ v8::Handle<v8::Function> run_test =
+ v8::Handle<v8::Function>::Cast(v8::Script::New(
+ v8::String::NewFromUtf8(
+ env->GetIsolate(),
"function runTest(mirror) {"
" return mirror.isString() && (mirror.length() == 5);"
"}"
@@ -7058,9 +7220,9 @@ TEST(CallingContextIsNotDebugContext) {
// Create object with 'a' property accessor.
v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
- named->SetAccessor(v8::String::New("a"),
+ named->SetAccessor(v8::String::NewFromUtf8(env->GetIsolate(), "a"),
NamedGetterWithCallingContextCheck);
- env->Global()->Set(v8::String::New("obj"),
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "obj"),
named->NewInstance());
// Register the debug event listener
@@ -7108,7 +7270,8 @@ TEST(DebugEventContext) {
v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
expected_callback_data);
v8::Context::Scope context_scope(expected_context);
- v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run();
expected_context.Clear();
v8::Debug::SetDebugEventListener2(NULL);
expected_context_data = v8::Handle<v8::Value>();
@@ -7143,7 +7306,9 @@ TEST(DebugEventBreakData) {
was_debug_event_called = false;
was_debug_break_called = false;
v8::Debug::DebugBreakForCommand(NULL, isolate);
- v8::Script::Compile(v8::String::New("(function(x){return x;})(1);"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
+ "(function(x){return x;})(1);"))
+ ->Run();
CHECK(was_debug_event_called);
CHECK(!was_debug_break_called);
@@ -7152,7 +7317,9 @@ TEST(DebugEventBreakData) {
was_debug_event_called = false;
was_debug_break_called = false;
v8::Debug::DebugBreakForCommand(data1, isolate);
- v8::Script::Compile(v8::String::New("(function(x){return x+1;})(1);"))->Run();
+ 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);
@@ -7160,7 +7327,9 @@ TEST(DebugEventBreakData) {
was_debug_event_called = false;
was_debug_break_called = false;
v8::Debug::DebugBreak(isolate);
- v8::Script::Compile(v8::String::New("(function(x){return x+2;})(1);"))->Run();
+ 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);
@@ -7170,7 +7339,9 @@ TEST(DebugEventBreakData) {
was_debug_break_called = false;
v8::Debug::DebugBreak(isolate);
v8::Debug::DebugBreakForCommand(data2, isolate);
- v8::Script::Compile(v8::String::New("(function(x){return x+3;})(1);"))->Run();
+ 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);
@@ -7233,11 +7404,13 @@ TEST(DeoptimizeDuringDebugBreak) {
v8::Debug::SetDebugEventListener2(DebugEventBreakDeoptimize);
// Compile and run function bar which will optimize it for some flag settings.
- v8::Script::Compile(v8::String::New("function bar(){}; bar()"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(
+ env->GetIsolate(), "function bar(){}; bar()"))->Run();
// Set debug break and call bar again.
v8::Debug::DebugBreak(env->GetIsolate());
- v8::Script::Compile(v8::String::New("bar()"))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar()"))
+ ->Run();
CHECK(debug_event_break_deoptimize_done);
@@ -7247,6 +7420,7 @@ TEST(DeoptimizeDuringDebugBreak) {
static void DebugEventBreakWithOptimizedStack(
const v8::Debug::EventDetails& event_details) {
+ v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate();
v8::DebugEvent event = event_details.GetEvent();
v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
if (event == v8::Break) {
@@ -7259,12 +7433,12 @@ static void DebugEventBreakWithOptimizedStack(
frame_function_name->Call(exec_state, argc, argv);
CHECK(result->IsString());
v8::Handle<v8::String> function_name(result->ToString());
- CHECK(function_name->Equals(v8::String::New("loop")));
+ CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop")));
// Get the name of the first argument in frame i.
result = frame_argument_name->Call(exec_state, argc, argv);
CHECK(result->IsString());
v8::Handle<v8::String> argument_name(result->ToString());
- CHECK(argument_name->Equals(v8::String::New("count")));
+ CHECK(argument_name->Equals(v8::String::NewFromUtf8(isolate, "count")));
// 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'.
@@ -7277,7 +7451,7 @@ static void DebugEventBreakWithOptimizedStack(
result = frame_local_name->Call(exec_state, argc, argv);
CHECK(result->IsString());
v8::Handle<v8::String> local_name(result->ToString());
- CHECK(local_name->Equals(v8::String::New("local")));
+ CHECK(local_name->Equals(v8::String::NewFromUtf8(isolate, "local")));
// Get the value of the first local variable. If the function
// is optimized the value will be undefined, otherwise it will
// be 42.
@@ -7326,7 +7500,7 @@ TEST(DebugBreakStackInspection) {
" if (count < 1) { scheduleBreak(); loop(count + 1); }"
"}"
"loop(0);";
- v8::Script::Compile(v8::String::New(src))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), src))->Run();
}
@@ -7470,7 +7644,8 @@ TEST(DebugBreakInline) {
"%OptimizeFunctionOnNextCall(g); \n"
"g(true);";
v8::Debug::SetDebugEventListener2(DebugBreakInlineListener);
- inline_script = v8::Script::Compile(v8::String::New(source));
+ inline_script =
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source));
inline_script->Run();
}
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-declarative-accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698