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

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

Issue 1427643005: Remove usage of deprecated APIs from test-api.cc. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase + resolve merge conflicts. Created 5 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/cctest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 10cb9788c3b0ed8a0e43ddfb4baf6ece177fc88b..b3c6d58cbcbaa1a7585cb868084743b88992b18e 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -60,7 +60,6 @@ using ::v8::Context;
using ::v8::Extension;
using ::v8::Function;
using ::v8::FunctionTemplate;
-using ::v8::Handle;
using ::v8::HandleScope;
using ::v8::Local;
using ::v8::Maybe;
@@ -94,8 +93,7 @@ using ::v8::Value;
void RunWithProfiler(void (*test)()) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Local<v8::String> profile_name =
- v8::String::NewFromUtf8(env->GetIsolate(), "my_profile1");
+ v8::Local<v8::String> profile_name = v8_str("my_profile1");
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->StartProfiling(profile_name);
@@ -110,12 +108,21 @@ static void IncrementingSignatureCallback(
const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
signature_callback_count++;
- CHECK(signature_expected_receiver->Equals(args.Holder()));
- CHECK(signature_expected_receiver->Equals(args.This()));
- v8::Handle<v8::Array> result =
+ CHECK(signature_expected_receiver->Equals(
+ args.GetIsolate()->GetCurrentContext(),
+ args.Holder())
+ .FromJust());
+ CHECK(signature_expected_receiver->Equals(
+ args.GetIsolate()->GetCurrentContext(),
+ args.This())
+ .FromJust());
+ v8::Local<v8::Array> result =
v8::Array::New(args.GetIsolate(), args.Length());
- for (int i = 0; i < args.Length(); i++)
- result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]);
+ for (int i = 0; i < args.Length(); i++) {
+ CHECK(result->Set(args.GetIsolate()->GetCurrentContext(),
+ v8::Integer::New(args.GetIsolate(), i), args[i])
+ .FromJust());
+ }
args.GetReturnValue().Set(result);
}
@@ -154,13 +161,13 @@ THREADED_TEST(Handles) {
CHECK(!local_env.IsEmpty());
local_env->Enter();
- v8::Handle<v8::Primitive> undef = v8::Undefined(CcTest::isolate());
+ v8::Local<v8::Primitive> undef = v8::Undefined(CcTest::isolate());
CHECK(!undef.IsEmpty());
CHECK(undef->IsUndefined());
const char* source = "1 + 2 + 3";
Local<Script> script = v8_compile(source);
- CHECK_EQ(6, script->Run()->Int32Value());
+ CHECK_EQ(6, v8_run_int32value(script));
local_env->Exit();
}
@@ -168,7 +175,7 @@ THREADED_TEST(Handles) {
THREADED_TEST(IsolateOfContext) {
v8::HandleScope scope(CcTest::isolate());
- v8::Handle<Context> env = Context::New(CcTest::isolate());
+ v8::Local<Context> env = Context::New(CcTest::isolate());
CHECK(!env->GetIsolate()->InContext());
CHECK(env->GetIsolate() == CcTest::isolate());
@@ -199,7 +206,11 @@ static void TestSignature(const char* loop_js, Local<Value> receiver,
CHECK_EQ(10, signature_callback_count);
} else {
CHECK(v8_str("TypeError: Illegal invocation")
- ->Equals(try_catch.Exception()->ToString(isolate)));
+ ->Equals(isolate->GetCurrentContext(),
+ try_catch.Exception()
+ ->ToString(isolate->GetCurrentContext())
+ .ToLocalChecked())
+ .FromJust());
}
}
@@ -209,32 +220,43 @@ THREADED_TEST(ReceiverSignature) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
// Setup templates.
- v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::Signature> sig = v8::Signature::New(isolate, fun);
- v8::Handle<v8::FunctionTemplate> callback_sig =
- v8::FunctionTemplate::New(
- isolate, IncrementingSignatureCallback, Local<Value>(), sig);
- v8::Handle<v8::FunctionTemplate> callback =
+ v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::Signature> sig = v8::Signature::New(isolate, fun);
+ v8::Local<v8::FunctionTemplate> callback_sig = v8::FunctionTemplate::New(
+ isolate, IncrementingSignatureCallback, Local<Value>(), sig);
+ v8::Local<v8::FunctionTemplate> callback =
v8::FunctionTemplate::New(isolate, IncrementingSignatureCallback);
- v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New(isolate);
sub_fun->Inherit(fun);
- v8::Handle<v8::FunctionTemplate> unrel_fun =
+ v8::Local<v8::FunctionTemplate> unrel_fun =
v8::FunctionTemplate::New(isolate);
// Install properties.
- v8::Handle<v8::ObjectTemplate> fun_proto = fun->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> fun_proto = fun->PrototypeTemplate();
fun_proto->Set(v8_str("prop_sig"), callback_sig);
fun_proto->Set(v8_str("prop"), callback);
fun_proto->SetAccessorProperty(
v8_str("accessor_sig"), callback_sig, callback_sig);
fun_proto->SetAccessorProperty(v8_str("accessor"), callback, callback);
// Instantiate templates.
- Local<Value> fun_instance = fun->InstanceTemplate()->NewInstance();
- Local<Value> sub_fun_instance = sub_fun->InstanceTemplate()->NewInstance();
+ Local<Value> fun_instance =
+ fun->InstanceTemplate()->NewInstance(env.local()).ToLocalChecked();
+ Local<Value> sub_fun_instance =
+ sub_fun->InstanceTemplate()->NewInstance(env.local()).ToLocalChecked();
// Setup global variables.
- env->Global()->Set(v8_str("Fun"), fun->GetFunction());
- env->Global()->Set(v8_str("UnrelFun"), unrel_fun->GetFunction());
- env->Global()->Set(v8_str("fun_instance"), fun_instance);
- env->Global()->Set(v8_str("sub_fun_instance"), sub_fun_instance);
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("Fun"),
+ fun->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("UnrelFun"),
+ unrel_fun->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("fun_instance"), fun_instance)
+ .FromJust());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("sub_fun_instance"), sub_fun_instance)
+ .FromJust());
CompileRun(
"var accessor_sig_key = 'accessor_sig';"
"var accessor_key = 'accessor';"
@@ -283,8 +305,8 @@ THREADED_TEST(HulIgennem) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::Primitive> undef = v8::Undefined(isolate);
- Local<String> undef_str = undef->ToString(isolate);
+ v8::Local<v8::Primitive> undef = v8::Undefined(isolate);
+ Local<String> undef_str = undef->ToString(env.local()).ToLocalChecked();
char* value = i::NewArray<char>(undef_str->Utf8Length() + 1);
undef_str->WriteUtf8(value);
CHECK_EQ(0, strcmp(value, "undefined"));
@@ -297,14 +319,16 @@ THREADED_TEST(Access) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
Local<v8::Object> obj = v8::Object::New(isolate);
- Local<Value> foo_before = obj->Get(v8_str("foo"));
+ Local<Value> foo_before =
+ obj->Get(env.local(), v8_str("foo")).ToLocalChecked();
CHECK(foo_before->IsUndefined());
Local<String> bar_str = v8_str("bar");
- obj->Set(v8_str("foo"), bar_str);
- Local<Value> foo_after = obj->Get(v8_str("foo"));
+ CHECK(obj->Set(env.local(), v8_str("foo"), bar_str).FromJust());
+ Local<Value> foo_after =
+ obj->Get(env.local(), v8_str("foo")).ToLocalChecked();
CHECK(!foo_after->IsUndefined());
CHECK(foo_after->IsString());
- CHECK(bar_str->Equals(foo_after));
+ CHECK(bar_str->Equals(env.local(), foo_after).FromJust());
}
@@ -312,18 +336,22 @@ THREADED_TEST(AccessElement) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
Local<v8::Object> obj = v8::Object::New(env->GetIsolate());
- Local<Value> before = obj->Get(1);
+ Local<Value> before = obj->Get(env.local(), 1).ToLocalChecked();
CHECK(before->IsUndefined());
Local<String> bar_str = v8_str("bar");
- obj->Set(1, bar_str);
- Local<Value> after = obj->Get(1);
+ CHECK(obj->Set(env.local(), 1, bar_str).FromJust());
+ Local<Value> after = obj->Get(env.local(), 1).ToLocalChecked();
CHECK(!after->IsUndefined());
CHECK(after->IsString());
- CHECK(bar_str->Equals(after));
+ CHECK(bar_str->Equals(env.local(), after).FromJust());
Local<v8::Array> value = CompileRun("[\"a\", \"b\"]").As<v8::Array>();
- CHECK(v8_str("a")->Equals(value->Get(0)));
- CHECK(v8_str("b")->Equals(value->Get(1)));
+ CHECK(v8_str("a")
+ ->Equals(env.local(), value->Get(env.local(), 0).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("b")
+ ->Equals(env.local(), value->Get(env.local(), 1).ToLocalChecked())
+ .FromJust());
}
@@ -332,7 +360,7 @@ THREADED_TEST(Script) {
v8::HandleScope scope(env->GetIsolate());
const char* source = "1 + 2 + 3";
Local<Script> script = v8_compile(source);
- CHECK_EQ(6, script->Run()->Int32Value());
+ CHECK_EQ(6, v8_run_int32value(script));
}
@@ -403,11 +431,13 @@ THREADED_TEST(ScriptUsingStringResource) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
TestResource* resource = new TestResource(two_byte_source, &dispose_count);
- Local<String> source = String::NewExternal(env->GetIsolate(), resource);
+ Local<String> source =
+ String::NewExternalTwoByte(env->GetIsolate(), resource)
+ .ToLocalChecked();
Local<Script> script = v8_compile(source);
- Local<Value> value = script->Run();
+ Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber());
- CHECK_EQ(7, value->Int32Value());
+ CHECK_EQ(7, value->Int32Value(env.local()).FromJust());
CHECK(source->IsExternal());
CHECK_EQ(resource,
static_cast<TestResource*>(source->GetExternalStringResource()));
@@ -432,7 +462,9 @@ THREADED_TEST(ScriptUsingOneByteStringResource) {
v8::HandleScope scope(env->GetIsolate());
TestOneByteResource* resource =
new TestOneByteResource(i::StrDup(c_source), &dispose_count);
- Local<String> source = String::NewExternal(env->GetIsolate(), resource);
+ Local<String> source =
+ String::NewExternalOneByte(env->GetIsolate(), resource)
+ .ToLocalChecked();
CHECK(source->IsExternalOneByte());
CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource),
source->GetExternalOneByteStringResource());
@@ -441,9 +473,9 @@ THREADED_TEST(ScriptUsingOneByteStringResource) {
source->GetExternalStringResourceBase(&encoding));
CHECK_EQ(String::ONE_BYTE_ENCODING, encoding);
Local<Script> script = v8_compile(source);
- Local<Value> value = script->Run();
+ Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber());
- CHECK_EQ(7, value->Int32Value());
+ CHECK_EQ(7, value->Int32Value(env.local()).FromJust());
CcTest::heap()->CollectAllGarbage();
CHECK_EQ(0, dispose_count);
}
@@ -460,7 +492,9 @@ THREADED_TEST(ScriptMakingExternalString) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
Local<String> source =
- String::NewFromTwoByte(env->GetIsolate(), two_byte_source);
+ String::NewFromTwoByte(env->GetIsolate(), two_byte_source,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
// Trigger GCs so that the newly allocated string moves to old gen.
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
@@ -473,9 +507,9 @@ THREADED_TEST(ScriptMakingExternalString) {
&dispose_count));
CHECK(success);
Local<Script> script = v8_compile(source);
- Local<Value> value = script->Run();
+ Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber());
- CHECK_EQ(7, value->Int32Value());
+ CHECK_EQ(7, value->Int32Value(env.local()).FromJust());
CcTest::heap()->CollectAllGarbage();
CHECK_EQ(0, dispose_count);
}
@@ -499,9 +533,9 @@ THREADED_TEST(ScriptMakingExternalOneByteString) {
new TestOneByteResource(i::StrDup(c_source), &dispose_count));
CHECK(success);
Local<Script> script = v8_compile(source);
- Local<Value> value = script->Run();
+ Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber());
- CHECK_EQ(7, value->Int32Value());
+ CHECK_EQ(7, value->Int32Value(env.local()).FromJust());
CcTest::heap()->CollectAllGarbage();
CHECK_EQ(0, dispose_count);
}
@@ -521,7 +555,9 @@ TEST(MakingExternalStringConditions) {
uint16_t* two_byte_string = AsciiToTwoByteString("s1");
Local<String> small_string =
- String::NewFromTwoByte(env->GetIsolate(), two_byte_string);
+ String::NewFromTwoByte(env->GetIsolate(), two_byte_string,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
i::DeleteArray(two_byte_string);
// We should refuse to externalize small strings.
@@ -533,7 +569,9 @@ TEST(MakingExternalStringConditions) {
CHECK(small_string->CanMakeExternal());
two_byte_string = AsciiToTwoByteString("small string 2");
- small_string = String::NewFromTwoByte(env->GetIsolate(), two_byte_string);
+ small_string = String::NewFromTwoByte(env->GetIsolate(), two_byte_string,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
i::DeleteArray(two_byte_string);
const int buf_size = 10 * 1024;
@@ -543,7 +581,9 @@ TEST(MakingExternalStringConditions) {
two_byte_string = AsciiToTwoByteString(buf);
Local<String> large_string =
- String::NewFromTwoByte(env->GetIsolate(), two_byte_string);
+ String::NewFromTwoByte(env->GetIsolate(), two_byte_string,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
i::DeleteArray(buf);
i::DeleteArray(two_byte_string);
// Large strings should be immediately accepted.
@@ -559,7 +599,7 @@ TEST(MakingExternalOneByteStringConditions) {
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
- Local<String> small_string = String::NewFromUtf8(env->GetIsolate(), "s1");
+ Local<String> small_string = v8_str("s1");
// We should refuse to externalize small strings.
CHECK(!small_string->CanMakeExternal());
// Trigger GCs so that the newly allocated string moves to old gen.
@@ -572,7 +612,7 @@ TEST(MakingExternalOneByteStringConditions) {
char* buf = i::NewArray<char>(buf_size);
memset(buf, 'a', buf_size);
buf[buf_size - 1] = '\0';
- Local<String> large_string = String::NewFromUtf8(env->GetIsolate(), buf);
+ Local<String> large_string = v8_str(buf);
i::DeleteArray(buf);
// Large strings should be immediately accepted.
CHECK(large_string->CanMakeExternal());
@@ -618,8 +658,10 @@ THREADED_TEST(UsingExternalString) {
{
v8::HandleScope scope(CcTest::isolate());
uint16_t* two_byte_string = AsciiToTwoByteString("test string");
- Local<String> string = String::NewExternal(
- CcTest::isolate(), new TestResource(two_byte_string));
+ Local<String> string =
+ String::NewExternalTwoByte(CcTest::isolate(),
+ new TestResource(two_byte_string))
+ .ToLocalChecked();
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
// Trigger GCs so that the newly allocated string moves to old gen.
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
@@ -638,8 +680,11 @@ THREADED_TEST(UsingExternalOneByteString) {
{
v8::HandleScope scope(CcTest::isolate());
const char* one_byte_string = "test string";
- Local<String> string = String::NewExternal(
- CcTest::isolate(), new TestOneByteResource(i::StrDup(one_byte_string)));
+ Local<String> string =
+ String::NewExternalOneByte(
+ CcTest::isolate(),
+ new TestOneByteResource(i::StrDup(one_byte_string)))
+ .ToLocalChecked();
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
// Trigger GCs so that the newly allocated string moves to old gen.
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
@@ -684,8 +729,9 @@ THREADED_TEST(NewExternalForVeryLongString) {
v8::HandleScope scope(isolate);
v8::TryCatch try_catch(isolate);
RandomLengthOneByteResource r(1 << 30);
- v8::Local<v8::String> str = v8::String::NewExternal(isolate, &r);
- CHECK(str.IsEmpty());
+ v8::MaybeLocal<v8::String> maybe_str =
+ v8::String::NewExternalOneByte(isolate, &r);
+ CHECK(maybe_str.IsEmpty());
CHECK(!try_catch.HasCaught());
}
@@ -693,8 +739,9 @@ THREADED_TEST(NewExternalForVeryLongString) {
v8::HandleScope scope(isolate);
v8::TryCatch try_catch(isolate);
RandomLengthResource r(1 << 30);
- v8::Local<v8::String> str = v8::String::NewExternal(isolate, &r);
- CHECK(str.IsEmpty());
+ v8::MaybeLocal<v8::String> maybe_str =
+ v8::String::NewExternalTwoByte(isolate, &r);
+ CHECK(maybe_str.IsEmpty());
CHECK(!try_catch.HasCaught());
}
}
@@ -708,8 +755,11 @@ THREADED_TEST(ScavengeExternalString) {
{
v8::HandleScope scope(CcTest::isolate());
uint16_t* two_byte_string = AsciiToTwoByteString("test string");
- Local<String> string = String::NewExternal(
- CcTest::isolate(), new TestResource(two_byte_string, &dispose_count));
+ Local<String> string =
+ String::NewExternalTwoByte(
+ CcTest::isolate(),
+ new TestResource(two_byte_string, &dispose_count))
+ .ToLocalChecked();
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
in_new_space = CcTest::heap()->InNewSpace(*istring);
@@ -729,9 +779,11 @@ THREADED_TEST(ScavengeExternalOneByteString) {
{
v8::HandleScope scope(CcTest::isolate());
const char* one_byte_string = "test string";
- Local<String> string = String::NewExternal(
- CcTest::isolate(),
- new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count));
+ Local<String> string =
+ String::NewExternalOneByte(
+ CcTest::isolate(),
+ new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count))
+ .ToLocalChecked();
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
in_new_space = CcTest::heap()->InNewSpace(*istring);
@@ -775,11 +827,13 @@ TEST(ExternalStringWithDisposeHandling) {
{
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- Local<String> source = String::NewExternal(env->GetIsolate(), &res_stack);
+ Local<String> source =
+ String::NewExternalOneByte(env->GetIsolate(), &res_stack)
+ .ToLocalChecked();
Local<Script> script = v8_compile(source);
- Local<Value> value = script->Run();
+ Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber());
- CHECK_EQ(7, value->Int32Value());
+ CHECK_EQ(7, value->Int32Value(env.local()).FromJust());
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count);
}
@@ -796,11 +850,13 @@ TEST(ExternalStringWithDisposeHandling) {
{
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- Local<String> source = String::NewExternal(env->GetIsolate(), res_heap);
+ Local<String> source =
+ String::NewExternalOneByte(env->GetIsolate(), res_heap)
+ .ToLocalChecked();
Local<Script> script = v8_compile(source);
- Local<Value> value = script->Run();
+ Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber());
- CHECK_EQ(7, value->Int32Value());
+ CHECK_EQ(7, value->Int32Value(env.local()).FromJust());
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count);
}
@@ -826,34 +882,41 @@ THREADED_TEST(StringConcat) {
uint16_t* two_byte_source = AsciiToTwoByteString(two_byte_string_1);
Local<String> right =
- String::NewFromTwoByte(env->GetIsolate(), two_byte_source);
+ String::NewFromTwoByte(env->GetIsolate(), two_byte_source,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
i::DeleteArray(two_byte_source);
Local<String> source = String::Concat(left, right);
- right = String::NewExternal(
- env->GetIsolate(),
- new TestOneByteResource(i::StrDup(one_byte_extern_1)));
+ right = String::NewExternalOneByte(
+ env->GetIsolate(),
+ new TestOneByteResource(i::StrDup(one_byte_extern_1)))
+ .ToLocalChecked();
source = String::Concat(source, right);
- right = String::NewExternal(
- env->GetIsolate(),
- new TestResource(AsciiToTwoByteString(two_byte_extern_1)));
+ right = String::NewExternalTwoByte(
+ env->GetIsolate(),
+ new TestResource(AsciiToTwoByteString(two_byte_extern_1)))
+ .ToLocalChecked();
source = String::Concat(source, right);
right = v8_str(one_byte_string_2);
source = String::Concat(source, right);
two_byte_source = AsciiToTwoByteString(two_byte_string_2);
- right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source);
+ right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
i::DeleteArray(two_byte_source);
source = String::Concat(source, right);
- right = String::NewExternal(
- env->GetIsolate(),
- new TestResource(AsciiToTwoByteString(two_byte_extern_2)));
+ right = String::NewExternalTwoByte(
+ env->GetIsolate(),
+ new TestResource(AsciiToTwoByteString(two_byte_extern_2)))
+ .ToLocalChecked();
source = String::Concat(source, right);
Local<Script> script = v8_compile(source);
- Local<Value> value = script->Run();
+ Local<Value> value = script->Run(env.local()).ToLocalChecked();
CHECK(value->IsNumber());
- CHECK_EQ(68, value->Int32Value());
+ CHECK_EQ(68, value->Int32Value(env.local()).FromJust());
}
CcTest::i_isolate()->compilation_cache()->Clear();
CcTest::heap()->CollectAllGarbage();
@@ -864,10 +927,10 @@ THREADED_TEST(StringConcat) {
THREADED_TEST(GlobalProperties) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<v8::Object> global = env->Global();
- global->Set(v8_str("pi"), v8_num(3.1415926));
- Local<Value> pi = global->Get(v8_str("pi"));
- CHECK_EQ(3.1415926, pi->NumberValue());
+ v8::Local<v8::Object> global = env->Global();
+ CHECK(global->Set(env.local(), v8_str("pi"), v8_num(3.1415926)).FromJust());
+ Local<Value> pi = global->Get(env.local(), v8_str("pi")).ToLocalChecked();
+ CHECK_EQ(3.1415926, pi->NumberValue(env.local()).FromJust());
}
@@ -893,8 +956,14 @@ static void construct_callback(
const v8::FunctionCallbackInfo<Value>& info) {
ApiTestFuzzer::Fuzz();
CheckReturnValue(info, FUNCTION_ADDR(construct_callback));
- info.This()->Set(v8_str("x"), v8_num(1));
- info.This()->Set(v8_str("y"), v8_num(2));
+ CHECK(
+ info.This()
+ ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("x"), v8_num(1))
+ .FromJust());
+ CHECK(
+ info.This()
+ ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(2))
+ .FromJust());
info.GetReturnValue().Set(v8_str("bad value"));
info.GetReturnValue().Set(info.This());
}
@@ -920,11 +989,11 @@ static void TestFunctionTemplateInitializer(Handler handler,
Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate, handler);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("obj"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust());
Local<Script> script = v8_compile("obj()");
for (int i = 0; i < 30; i++) {
- CHECK_EQ(102, script->Run()->Int32Value());
+ CHECK_EQ(102, v8_run_int32value(script));
}
}
// Use SetCallHandler to initialize a function template, should work like
@@ -936,11 +1005,11 @@ static void TestFunctionTemplateInitializer(Handler handler,
Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
fun_templ->SetCallHandler(handler_2);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("obj"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust());
Local<Script> script = v8_compile("obj()");
for (int i = 0; i < 30; i++) {
- CHECK_EQ(102, script->Run()->Int32Value());
+ CHECK_EQ(102, v8_run_int32value(script));
}
}
}
@@ -956,19 +1025,20 @@ static void TestFunctionTemplateAccessor(Constructor constructor,
v8::FunctionTemplate::New(env->GetIsolate(), constructor);
fun_templ->SetClassName(v8_str("funky"));
fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("obj"), fun);
- Local<Value> result = v8_compile("(new obj()).toString()")->Run();
- CHECK(v8_str("[object funky]")->Equals(result));
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust());
+ Local<Value> result =
+ v8_compile("(new obj()).toString()")->Run(env.local()).ToLocalChecked();
+ CHECK(v8_str("[object funky]")->Equals(env.local(), result).FromJust());
CompileRun("var obj_instance = new obj();");
Local<Script> script;
script = v8_compile("obj_instance.x");
for (int i = 0; i < 30; i++) {
- CHECK_EQ(1, script->Run()->Int32Value());
+ CHECK_EQ(1, v8_run_int32value(script));
}
script = v8_compile("obj_instance.m");
for (int i = 0; i < 30; i++) {
- CHECK_EQ(239, script->Run()->Int32Value());
+ CHECK_EQ(239, v8_run_int32value(script));
}
}
@@ -992,20 +1062,24 @@ static void TestSimpleCallback(Callback callback) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> object_template =
+ v8::Local<v8::ObjectTemplate> object_template =
v8::ObjectTemplate::New(isolate);
object_template->Set(isolate, "callback",
v8::FunctionTemplate::New(isolate, callback));
- v8::Local<v8::Object> object = object_template->NewInstance();
- (*env)->Global()->Set(v8_str("callback_object"), object);
- v8::Handle<v8::Script> script;
+ v8::Local<v8::Object> object =
+ object_template->NewInstance(env.local()).ToLocalChecked();
+ CHECK((*env)
+ ->Global()
+ ->Set(env.local(), v8_str("callback_object"), object)
+ .FromJust());
+ v8::Local<v8::Script> script;
script = v8_compile("callback_object.callback(17)");
for (int i = 0; i < 30; i++) {
- CHECK_EQ(51424, script->Run()->Int32Value());
+ CHECK_EQ(51424, v8_run_int32value(script));
}
script = v8_compile("callback_object.callback(17, 24)");
for (int i = 0; i < 30; i++) {
- CHECK_EQ(51425, script->Run()->Int32Value());
+ CHECK_EQ(51425, v8_run_int32value(script));
}
}
@@ -1086,25 +1160,29 @@ void FastReturnValueCallback<void>(
template<>
void FastReturnValueCallback<Object>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
- v8::Handle<v8::Object> object;
+ v8::Local<v8::Object> object;
if (!fast_return_value_object_is_empty) {
object = Object::New(info.GetIsolate());
}
info.GetReturnValue().Set(object);
}
-template<typename T>
-Handle<Value> TestFastReturnValues() {
+template <typename T>
+Local<Value> TestFastReturnValues() {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::EscapableHandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> object_template =
+ v8::Local<v8::ObjectTemplate> object_template =
v8::ObjectTemplate::New(isolate);
v8::FunctionCallback callback = &FastReturnValueCallback<T>;
object_template->Set(isolate, "callback",
v8::FunctionTemplate::New(isolate, callback));
- v8::Local<v8::Object> object = object_template->NewInstance();
- (*env)->Global()->Set(v8_str("callback_object"), object);
+ v8::Local<v8::Object> object =
+ object_template->NewInstance(env.local()).ToLocalChecked();
+ CHECK((*env)
+ ->Global()
+ ->Set(env.local(), v8_str("callback_object"), object)
+ .FromJust());
return scope.Escape(CompileRun("callback_object.callback()"));
}
@@ -1113,7 +1191,7 @@ THREADED_PROFILED_TEST(FastReturnValues) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::Value> value;
+ v8::Local<v8::Value> value;
// check int32_t and uint32_t
int32_t int_values[] = {
0, 234, -723,
@@ -1126,24 +1204,28 @@ THREADED_PROFILED_TEST(FastReturnValues) {
fast_return_value_int32 = int_value;
value = TestFastReturnValues<int32_t>();
CHECK(value->IsInt32());
- CHECK(fast_return_value_int32 == value->Int32Value());
+ CHECK_EQ(fast_return_value_int32,
+ value->Int32Value(env.local()).FromJust());
// check uint32_t
fast_return_value_uint32 = static_cast<uint32_t>(int_value);
value = TestFastReturnValues<uint32_t>();
CHECK(value->IsUint32());
- CHECK(fast_return_value_uint32 == value->Uint32Value());
+ CHECK_EQ(fast_return_value_uint32,
+ value->Uint32Value(env.local()).FromJust());
}
}
// check double
value = TestFastReturnValues<double>();
CHECK(value->IsNumber());
- CHECK_EQ(kFastReturnValueDouble, value->ToNumber(isolate)->Value());
+ CHECK_EQ(kFastReturnValueDouble,
+ value->ToNumber(env.local()).ToLocalChecked()->Value());
// check bool values
for (int i = 0; i < 2; i++) {
fast_return_value_bool = i == 0;
value = TestFastReturnValues<bool>();
CHECK(value->IsBoolean());
- CHECK_EQ(fast_return_value_bool, value->ToBoolean(isolate)->Value());
+ CHECK_EQ(fast_return_value_bool,
+ value->ToBoolean(env.local()).ToLocalChecked()->Value());
}
// check oddballs
ReturnValueOddball oddballs[] = {
@@ -1183,33 +1265,30 @@ THREADED_TEST(FunctionTemplateSetLength) {
v8::HandleScope scope(isolate);
{
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(isolate,
- handle_callback,
- Handle<v8::Value>(),
- Handle<v8::Signature>(),
- 23);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("obj"), fun);
+ v8::FunctionTemplate::New(isolate, handle_callback, Local<v8::Value>(),
+ Local<v8::Signature>(), 23);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust());
Local<Script> script = v8_compile("obj.length");
- CHECK_EQ(23, script->Run()->Int32Value());
+ CHECK_EQ(23, v8_run_int32value(script));
}
{
Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate, handle_callback);
fun_templ->SetLength(22);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("obj"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust());
Local<Script> script = v8_compile("obj.length");
- CHECK_EQ(22, script->Run()->Int32Value());
+ CHECK_EQ(22, v8_run_int32value(script));
}
{
// Without setting length it defaults to 0.
Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate, handle_callback);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("obj"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust());
Local<Script> script = v8_compile("obj.length");
- CHECK_EQ(0, script->Run()->Int32Value());
+ CHECK_EQ(0, v8_run_int32value(script));
}
}
@@ -1227,19 +1306,22 @@ static void TestExternalPointerWrapping() {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::Value> data =
- v8::External::New(isolate, expected_ptr);
+ v8::Local<v8::Value> data = v8::External::New(isolate, expected_ptr);
- v8::Handle<v8::Object> obj = v8::Object::New(isolate);
- obj->Set(v8_str("func"),
- v8::FunctionTemplate::New(isolate, callback, data)->GetFunction());
- env->Global()->Set(v8_str("obj"), obj);
+ v8::Local<v8::Object> obj = v8::Object::New(isolate);
+ CHECK(obj->Set(env.local(), v8_str("func"),
+ v8::FunctionTemplate::New(isolate, callback, data)
+ ->GetFunction(env.local())
+ .ToLocalChecked())
+ .FromJust());
+ CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust());
- CHECK(CompileRun(
- "function foo() {\n"
- " for (var i = 0; i < 13; i++) obj.func();\n"
- "}\n"
- "foo(), true")->BooleanValue());
+ CHECK(CompileRun("function foo() {\n"
+ " for (var i = 0; i < 13; i++) obj.func();\n"
+ "}\n"
+ "foo(), true")
+ ->BooleanValue(env.local())
+ .FromJust());
}
@@ -1299,28 +1381,43 @@ THREADED_TEST(FindInstanceInPrototypeChain) {
Local<v8::FunctionTemplate> other = v8::FunctionTemplate::New(isolate);
derived->Inherit(base);
- Local<v8::Function> base_function = base->GetFunction();
- Local<v8::Function> derived_function = derived->GetFunction();
- Local<v8::Function> other_function = other->GetFunction();
-
- Local<v8::Object> base_instance = base_function->NewInstance();
- Local<v8::Object> derived_instance = derived_function->NewInstance();
- Local<v8::Object> derived_instance2 = derived_function->NewInstance();
- Local<v8::Object> other_instance = other_function->NewInstance();
- derived_instance2->Set(v8_str("__proto__"), derived_instance);
- other_instance->Set(v8_str("__proto__"), derived_instance2);
+ Local<v8::Function> base_function =
+ base->GetFunction(env.local()).ToLocalChecked();
+ Local<v8::Function> derived_function =
+ derived->GetFunction(env.local()).ToLocalChecked();
+ Local<v8::Function> other_function =
+ other->GetFunction(env.local()).ToLocalChecked();
+
+ Local<v8::Object> base_instance =
+ base_function->NewInstance(env.local()).ToLocalChecked();
+ Local<v8::Object> derived_instance =
+ derived_function->NewInstance(env.local()).ToLocalChecked();
+ Local<v8::Object> derived_instance2 =
+ derived_function->NewInstance(env.local()).ToLocalChecked();
+ Local<v8::Object> other_instance =
+ other_function->NewInstance(env.local()).ToLocalChecked();
+ CHECK(
+ derived_instance2->Set(env.local(), v8_str("__proto__"), derived_instance)
+ .FromJust());
+ CHECK(other_instance->Set(env.local(), v8_str("__proto__"), derived_instance2)
+ .FromJust());
// base_instance is only an instance of base.
- CHECK(
- base_instance->Equals(base_instance->FindInstanceInPrototypeChain(base)));
+ CHECK(base_instance->Equals(env.local(),
+ base_instance->FindInstanceInPrototypeChain(base))
+ .FromJust());
CHECK(base_instance->FindInstanceInPrototypeChain(derived).IsEmpty());
CHECK(base_instance->FindInstanceInPrototypeChain(other).IsEmpty());
// derived_instance is an instance of base and derived.
- CHECK(derived_instance->Equals(
- derived_instance->FindInstanceInPrototypeChain(base)));
- CHECK(derived_instance->Equals(
- derived_instance->FindInstanceInPrototypeChain(derived)));
+ CHECK(derived_instance->Equals(env.local(),
+ derived_instance->FindInstanceInPrototypeChain(
+ base))
+ .FromJust());
+ CHECK(derived_instance->Equals(env.local(),
+ derived_instance->FindInstanceInPrototypeChain(
+ derived))
+ .FromJust());
CHECK(derived_instance->FindInstanceInPrototypeChain(other).IsEmpty());
// other_instance is an instance of other and its immediate
@@ -1329,11 +1426,17 @@ THREADED_TEST(FindInstanceInPrototypeChain) {
// but it comes after derived_instance2 in the prototype chain of
// other_instance.
CHECK(derived_instance2->Equals(
- other_instance->FindInstanceInPrototypeChain(base)));
- CHECK(derived_instance2->Equals(
- other_instance->FindInstanceInPrototypeChain(derived)));
+ env.local(),
+ other_instance->FindInstanceInPrototypeChain(base))
+ .FromJust());
+ CHECK(derived_instance2->Equals(env.local(),
+ other_instance->FindInstanceInPrototypeChain(
+ derived))
+ .FromJust());
CHECK(other_instance->Equals(
- other_instance->FindInstanceInPrototypeChain(other)));
+ env.local(),
+ other_instance->FindInstanceInPrototypeChain(other))
+ .FromJust());
}
@@ -1463,12 +1566,12 @@ THREADED_TEST(OutOfSignedRangeUnsignedInteger) {
THREADED_TEST(IsNativeError) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<Value> syntax_error = CompileRun(
+ v8::Local<Value> syntax_error = CompileRun(
"var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; ");
CHECK(syntax_error->IsNativeError());
- v8::Handle<Value> not_error = CompileRun("{a:42}");
+ v8::Local<Value> not_error = CompileRun("{a:42}");
CHECK(!not_error->IsNativeError());
- v8::Handle<Value> not_object = CompileRun("42");
+ v8::Local<Value> not_object = CompileRun("42");
CHECK(!not_object->IsNativeError());
}
@@ -1478,10 +1581,10 @@ THREADED_TEST(IsGeneratorFunctionOrObject) {
v8::HandleScope scope(env->GetIsolate());
CompileRun("function *gen() { yield 1; }\nfunction func() {}");
- v8::Handle<Value> gen = CompileRun("gen");
- v8::Handle<Value> genObj = CompileRun("gen()");
- v8::Handle<Value> object = CompileRun("{a:42}");
- v8::Handle<Value> func = CompileRun("func");
+ v8::Local<Value> gen = CompileRun("gen");
+ v8::Local<Value> genObj = CompileRun("gen()");
+ v8::Local<Value> object = CompileRun("{a:42}");
+ v8::Local<Value> func = CompileRun("func");
CHECK(gen->IsGeneratorFunction());
CHECK(gen->IsFunction());
@@ -1504,12 +1607,12 @@ THREADED_TEST(IsGeneratorFunctionOrObject) {
THREADED_TEST(ArgumentsObject) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<Value> arguments_object =
+ v8::Local<Value> arguments_object =
CompileRun("var out = 0; (function(){ out = arguments; })(1,2,3); out;");
CHECK(arguments_object->IsArgumentsObject());
- v8::Handle<Value> array = CompileRun("[1,2,3]");
+ v8::Local<Value> array = CompileRun("[1,2,3]");
CHECK(!array->IsArgumentsObject());
- v8::Handle<Value> object = CompileRun("{a:42}");
+ v8::Local<Value> object = CompileRun("{a:42}");
CHECK(!object->IsArgumentsObject());
}
@@ -1517,10 +1620,10 @@ THREADED_TEST(ArgumentsObject) {
THREADED_TEST(IsMapOrSet) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<Value> map = CompileRun("new Map()");
- v8::Handle<Value> set = CompileRun("new Set()");
- v8::Handle<Value> weak_map = CompileRun("new WeakMap()");
- v8::Handle<Value> weak_set = CompileRun("new WeakSet()");
+ v8::Local<Value> map = CompileRun("new Map()");
+ v8::Local<Value> set = CompileRun("new Set()");
+ v8::Local<Value> weak_map = CompileRun("new WeakMap()");
+ v8::Local<Value> weak_set = CompileRun("new WeakSet()");
CHECK(map->IsMap());
CHECK(set->IsSet());
CHECK(weak_map->IsWeakMap());
@@ -1542,7 +1645,7 @@ THREADED_TEST(IsMapOrSet) {
CHECK(!weak_set->IsSet());
CHECK(!weak_set->IsWeakMap());
- v8::Handle<Value> object = CompileRun("{a:42}");
+ v8::Local<Value> object = CompileRun("{a:42}");
CHECK(!object->IsMap());
CHECK(!object->IsSet());
CHECK(!object->IsWeakMap());
@@ -1553,20 +1656,20 @@ THREADED_TEST(IsMapOrSet) {
THREADED_TEST(StringObject) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")");
+ v8::Local<Value> boxed_string = CompileRun("new String(\"test\")");
CHECK(boxed_string->IsStringObject());
- v8::Handle<Value> unboxed_string = CompileRun("\"test\"");
+ v8::Local<Value> unboxed_string = CompileRun("\"test\"");
CHECK(!unboxed_string->IsStringObject());
- v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)");
+ v8::Local<Value> boxed_not_string = CompileRun("new Number(42)");
CHECK(!boxed_not_string->IsStringObject());
- v8::Handle<Value> not_object = CompileRun("0");
+ v8::Local<Value> not_object = CompileRun("0");
CHECK(!not_object->IsStringObject());
- v8::Handle<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>();
+ v8::Local<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>();
CHECK(!as_boxed.IsEmpty());
Local<v8::String> the_string = as_boxed->ValueOf();
CHECK(!the_string.IsEmpty());
ExpectObject("\"test\"", the_string);
- v8::Handle<v8::Value> new_boxed_string = v8::StringObject::New(the_string);
+ v8::Local<v8::Value> new_boxed_string = v8::StringObject::New(the_string);
CHECK(new_boxed_string->IsStringObject());
as_boxed = new_boxed_string.As<v8::StringObject>();
the_string = as_boxed->ValueOf();
@@ -1578,28 +1681,28 @@ THREADED_TEST(StringObject) {
TEST(StringObjectDelete) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")");
+ v8::Local<Value> boxed_string = CompileRun("new String(\"test\")");
CHECK(boxed_string->IsStringObject());
- v8::Handle<v8::Object> str_obj = boxed_string.As<v8::Object>();
- CHECK(!str_obj->Delete(2));
- CHECK(!str_obj->Delete(v8_num(2)));
+ v8::Local<v8::Object> str_obj = boxed_string.As<v8::Object>();
+ CHECK(!str_obj->Delete(context.local(), 2).FromJust());
+ CHECK(!str_obj->Delete(context.local(), v8_num(2)).FromJust());
}
THREADED_TEST(NumberObject) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<Value> boxed_number = CompileRun("new Number(42)");
+ v8::Local<Value> boxed_number = CompileRun("new Number(42)");
CHECK(boxed_number->IsNumberObject());
- v8::Handle<Value> unboxed_number = CompileRun("42");
+ v8::Local<Value> unboxed_number = CompileRun("42");
CHECK(!unboxed_number->IsNumberObject());
- v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)");
+ v8::Local<Value> boxed_not_number = CompileRun("new Boolean(false)");
CHECK(!boxed_not_number->IsNumberObject());
- v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>();
+ v8::Local<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>();
CHECK(!as_boxed.IsEmpty());
double the_number = as_boxed->ValueOf();
CHECK_EQ(42.0, the_number);
- v8::Handle<v8::Value> new_boxed_number =
+ v8::Local<v8::Value> new_boxed_number =
v8::NumberObject::New(env->GetIsolate(), 43);
CHECK(new_boxed_number->IsNumberObject());
as_boxed = new_boxed_number.As<v8::NumberObject>();
@@ -1611,19 +1714,18 @@ THREADED_TEST(NumberObject) {
THREADED_TEST(BooleanObject) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)");
+ v8::Local<Value> boxed_boolean = CompileRun("new Boolean(true)");
CHECK(boxed_boolean->IsBooleanObject());
- v8::Handle<Value> unboxed_boolean = CompileRun("true");
+ v8::Local<Value> unboxed_boolean = CompileRun("true");
CHECK(!unboxed_boolean->IsBooleanObject());
- v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)");
+ v8::Local<Value> boxed_not_boolean = CompileRun("new Number(42)");
CHECK(!boxed_not_boolean->IsBooleanObject());
- v8::Handle<v8::BooleanObject> as_boxed =
- boxed_boolean.As<v8::BooleanObject>();
+ v8::Local<v8::BooleanObject> as_boxed = boxed_boolean.As<v8::BooleanObject>();
CHECK(!as_boxed.IsEmpty());
bool the_boolean = as_boxed->ValueOf();
CHECK_EQ(true, the_boolean);
- v8::Handle<v8::Value> boxed_true = v8::BooleanObject::New(true);
- v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false);
+ v8::Local<v8::Value> boxed_true = v8::BooleanObject::New(true);
+ v8::Local<v8::Value> boxed_false = v8::BooleanObject::New(false);
CHECK(boxed_true->IsBooleanObject());
CHECK(boxed_false->IsBooleanObject());
as_boxed = boxed_true.As<v8::BooleanObject>();
@@ -1640,22 +1742,21 @@ THREADED_TEST(PrimitiveAndWrappedBooleans) {
Local<Value> primitive_false = Boolean::New(env->GetIsolate(), false);
CHECK(primitive_false->IsBoolean());
CHECK(!primitive_false->IsBooleanObject());
- CHECK(!primitive_false->BooleanValue());
+ CHECK(!primitive_false->BooleanValue(env.local()).FromJust());
CHECK(!primitive_false->IsTrue());
CHECK(primitive_false->IsFalse());
Local<Value> false_value = BooleanObject::New(false);
CHECK(!false_value->IsBoolean());
CHECK(false_value->IsBooleanObject());
- CHECK(false_value->BooleanValue());
+ CHECK(false_value->BooleanValue(env.local()).FromJust());
CHECK(!false_value->IsTrue());
CHECK(!false_value->IsFalse());
Local<BooleanObject> false_boolean_object = false_value.As<BooleanObject>();
CHECK(!false_boolean_object->IsBoolean());
CHECK(false_boolean_object->IsBooleanObject());
- // TODO(svenpanne) Uncomment when BooleanObject::BooleanValue() is deleted.
- // CHECK(false_boolean_object->BooleanValue());
+ CHECK(false_boolean_object->BooleanValue(env.local()).FromJust());
CHECK(!false_boolean_object->ValueOf());
CHECK(!false_boolean_object->IsTrue());
CHECK(!false_boolean_object->IsFalse());
@@ -1663,22 +1764,21 @@ THREADED_TEST(PrimitiveAndWrappedBooleans) {
Local<Value> primitive_true = Boolean::New(env->GetIsolate(), true);
CHECK(primitive_true->IsBoolean());
CHECK(!primitive_true->IsBooleanObject());
- CHECK(primitive_true->BooleanValue());
+ CHECK(primitive_true->BooleanValue(env.local()).FromJust());
CHECK(primitive_true->IsTrue());
CHECK(!primitive_true->IsFalse());
Local<Value> true_value = BooleanObject::New(true);
CHECK(!true_value->IsBoolean());
CHECK(true_value->IsBooleanObject());
- CHECK(true_value->BooleanValue());
+ CHECK(true_value->BooleanValue(env.local()).FromJust());
CHECK(!true_value->IsTrue());
CHECK(!true_value->IsFalse());
Local<BooleanObject> true_boolean_object = true_value.As<BooleanObject>();
CHECK(!true_boolean_object->IsBoolean());
CHECK(true_boolean_object->IsBooleanObject());
- // TODO(svenpanne) Uncomment when BooleanObject::BooleanValue() is deleted.
- // CHECK(true_boolean_object->BooleanValue());
+ CHECK(true_boolean_object->BooleanValue(env.local()).FromJust());
CHECK(true_boolean_object->ValueOf());
CHECK(!true_boolean_object->IsTrue());
CHECK(!true_boolean_object->IsFalse());
@@ -1690,7 +1790,7 @@ THREADED_TEST(Number) {
v8::HandleScope scope(env->GetIsolate());
double PI = 3.1415926;
Local<v8::Number> pi_obj = v8::Number::New(env->GetIsolate(), PI);
- CHECK_EQ(PI, pi_obj->NumberValue());
+ CHECK_EQ(PI, pi_obj->NumberValue(env.local()).FromJust());
}
@@ -1699,11 +1799,11 @@ THREADED_TEST(ToNumber) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
Local<String> str = v8_str("3.1415926");
- CHECK_EQ(3.1415926, str->NumberValue());
- v8::Handle<v8::Boolean> t = v8::True(isolate);
- CHECK_EQ(1.0, t->NumberValue());
- v8::Handle<v8::Boolean> f = v8::False(isolate);
- CHECK_EQ(0.0, f->NumberValue());
+ CHECK_EQ(3.1415926, str->NumberValue(env.local()).FromJust());
+ v8::Local<v8::Boolean> t = v8::True(isolate);
+ CHECK_EQ(1.0, t->NumberValue(env.local()).FromJust());
+ v8::Local<v8::Boolean> f = v8::False(isolate);
+ CHECK_EQ(0.0, f->NumberValue(env.local()).FromJust());
}
@@ -1711,11 +1811,17 @@ THREADED_TEST(Date) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
double PI = 3.1415926;
- Local<Value> date = v8::Date::New(env->GetIsolate(), PI);
- CHECK_EQ(3.0, date->NumberValue());
- date.As<v8::Date>()->Set(v8_str("property"),
- v8::Integer::New(env->GetIsolate(), 42));
- CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value());
+ Local<Value> date = v8::Date::New(env.local(), PI).ToLocalChecked();
+ CHECK_EQ(3.0, date->NumberValue(env.local()).FromJust());
+ CHECK(date.As<v8::Date>()
+ ->Set(env.local(), v8_str("property"),
+ v8::Integer::New(env->GetIsolate(), 42))
+ .FromJust());
+ CHECK_EQ(42, date.As<v8::Date>()
+ ->Get(env.local(), v8_str("property"))
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
}
@@ -1723,23 +1829,27 @@ THREADED_TEST(Boolean) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::Boolean> t = v8::True(isolate);
+ v8::Local<v8::Boolean> t = v8::True(isolate);
CHECK(t->Value());
- v8::Handle<v8::Boolean> f = v8::False(isolate);
+ v8::Local<v8::Boolean> f = v8::False(isolate);
CHECK(!f->Value());
- v8::Handle<v8::Primitive> u = v8::Undefined(isolate);
- CHECK(!u->BooleanValue());
- v8::Handle<v8::Primitive> n = v8::Null(isolate);
- CHECK(!n->BooleanValue());
- v8::Handle<String> str1 = v8_str("");
- CHECK(!str1->BooleanValue());
- v8::Handle<String> str2 = v8_str("x");
- CHECK(str2->BooleanValue());
- CHECK(!v8::Number::New(isolate, 0)->BooleanValue());
- CHECK(v8::Number::New(isolate, -1)->BooleanValue());
- CHECK(v8::Number::New(isolate, 1)->BooleanValue());
- CHECK(v8::Number::New(isolate, 42)->BooleanValue());
- CHECK(!v8_compile("NaN")->Run()->BooleanValue());
+ v8::Local<v8::Primitive> u = v8::Undefined(isolate);
+ CHECK(!u->BooleanValue(env.local()).FromJust());
+ v8::Local<v8::Primitive> n = v8::Null(isolate);
+ CHECK(!n->BooleanValue(env.local()).FromJust());
+ v8::Local<String> str1 = v8_str("");
+ CHECK(!str1->BooleanValue(env.local()).FromJust());
+ v8::Local<String> str2 = v8_str("x");
+ CHECK(str2->BooleanValue(env.local()).FromJust());
+ CHECK(!v8::Number::New(isolate, 0)->BooleanValue(env.local()).FromJust());
+ CHECK(v8::Number::New(isolate, -1)->BooleanValue(env.local()).FromJust());
+ CHECK(v8::Number::New(isolate, 1)->BooleanValue(env.local()).FromJust());
+ CHECK(v8::Number::New(isolate, 42)->BooleanValue(env.local()).FromJust());
+ CHECK(!v8_compile("NaN")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
}
@@ -1759,19 +1869,19 @@ static void GetM(Local<String> name,
THREADED_TEST(GlobalPrototype) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> func_templ =
+ v8::Local<v8::FunctionTemplate> func_templ =
v8::FunctionTemplate::New(isolate);
func_templ->PrototypeTemplate()->Set(
isolate, "dummy", v8::FunctionTemplate::New(isolate, DummyCallHandler));
- v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate();
+ v8::Local<ObjectTemplate> templ = func_templ->InstanceTemplate();
templ->Set(isolate, "x", v8_num(200));
templ->SetAccessor(v8_str("m"), GetM);
LocalContext env(0, templ);
- v8::Handle<Script> script(v8_compile("dummy()"));
- v8::Handle<Value> result(script->Run());
- CHECK_EQ(13.4, result->NumberValue());
- CHECK_EQ(200, v8_compile("x")->Run()->Int32Value());
- CHECK_EQ(876, v8_compile("m")->Run()->Int32Value());
+ v8::Local<Script> script(v8_compile("dummy()"));
+ v8::Local<Value> result(script->Run(env.local()).ToLocalChecked());
+ CHECK_EQ(13.4, result->NumberValue(env.local()).FromJust());
+ CHECK_EQ(200, v8_run_int32value(v8_compile("x")));
+ CHECK_EQ(876, v8_run_int32value(v8_compile("m")));
}
@@ -1779,29 +1889,54 @@ THREADED_TEST(ObjectTemplate) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate);
- v8::Local<v8::String> class_name =
- v8::String::NewFromUtf8(isolate, "the_class_name");
+ v8::Local<v8::String> class_name = v8_str("the_class_name");
fun->SetClassName(class_name);
Local<ObjectTemplate> templ1 = ObjectTemplate::New(isolate, fun);
templ1->Set(isolate, "x", v8_num(10));
templ1->Set(isolate, "y", v8_num(13));
LocalContext env;
- Local<v8::Object> instance1 = templ1->NewInstance();
+ Local<v8::Object> instance1 =
+ templ1->NewInstance(env.local()).ToLocalChecked();
CHECK(class_name->StrictEquals(instance1->GetConstructorName()));
- env->Global()->Set(v8_str("p"), instance1);
- CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue());
- CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue());
+ CHECK(env->Global()->Set(env.local(), v8_str("p"), instance1).FromJust());
+ CHECK(v8_compile("(p.x == 10)")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK(v8_compile("(p.y == 13)")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
Local<v8::FunctionTemplate> fun2 = v8::FunctionTemplate::New(isolate);
fun2->PrototypeTemplate()->Set(isolate, "nirk", v8_num(123));
Local<ObjectTemplate> templ2 = fun2->InstanceTemplate();
templ2->Set(isolate, "a", v8_num(12));
templ2->Set(isolate, "b", templ1);
- Local<v8::Object> instance2 = templ2->NewInstance();
- env->Global()->Set(v8_str("q"), instance2);
- CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue());
- CHECK(v8_compile("(q.a == 12)")->Run()->BooleanValue());
- CHECK(v8_compile("(q.b.x == 10)")->Run()->BooleanValue());
- CHECK(v8_compile("(q.b.y == 13)")->Run()->BooleanValue());
+ Local<v8::Object> instance2 =
+ templ2->NewInstance(env.local()).ToLocalChecked();
+ CHECK(env->Global()->Set(env.local(), v8_str("q"), instance2).FromJust());
+ CHECK(v8_compile("(q.nirk == 123)")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK(v8_compile("(q.a == 12)")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK(v8_compile("(q.b.x == 10)")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK(v8_compile("(q.b.y == 13)")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
}
@@ -1821,7 +1956,7 @@ static void GetKnurd(Local<String> property,
THREADED_TEST(DescriptorInheritance) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> super = v8::FunctionTemplate::New(isolate);
super->PrototypeTemplate()->Set(isolate, "flabby",
v8::FunctionTemplate::New(isolate,
GetFlabby));
@@ -1829,50 +1964,121 @@ THREADED_TEST(DescriptorInheritance) {
super->InstanceTemplate()->SetAccessor(v8_str("knurd"), GetKnurd);
- v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(isolate);
base1->Inherit(super);
base1->PrototypeTemplate()->Set(isolate, "v1", v8_num(20.1));
- v8::Handle<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New(isolate);
base2->Inherit(super);
base2->PrototypeTemplate()->Set(isolate, "v2", v8_num(10.1));
LocalContext env;
- env->Global()->Set(v8_str("s"), super->GetFunction());
- env->Global()->Set(v8_str("base1"), base1->GetFunction());
- env->Global()->Set(v8_str("base2"), base2->GetFunction());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("s"),
+ super->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("base1"),
+ base1->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("base2"),
+ base2->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
// Checks right __proto__ chain.
- CHECK(CompileRun("base1.prototype.__proto__ == s.prototype")->BooleanValue());
- CHECK(CompileRun("base2.prototype.__proto__ == s.prototype")->BooleanValue());
+ CHECK(CompileRun("base1.prototype.__proto__ == s.prototype")
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK(CompileRun("base2.prototype.__proto__ == s.prototype")
+ ->BooleanValue(env.local())
+ .FromJust());
- CHECK(v8_compile("s.prototype.PI == 3.14")->Run()->BooleanValue());
+ CHECK(v8_compile("s.prototype.PI == 3.14")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
// Instance accessor should not be visible on function object or its prototype
- CHECK(CompileRun("s.knurd == undefined")->BooleanValue());
- CHECK(CompileRun("s.prototype.knurd == undefined")->BooleanValue());
- CHECK(CompileRun("base1.prototype.knurd == undefined")->BooleanValue());
-
- env->Global()->Set(v8_str("obj"),
- base1->GetFunction()->NewInstance());
- CHECK_EQ(17.2, v8_compile("obj.flabby()")->Run()->NumberValue());
- CHECK(v8_compile("'flabby' in obj")->Run()->BooleanValue());
- CHECK_EQ(15.2, v8_compile("obj.knurd")->Run()->NumberValue());
- CHECK(v8_compile("'knurd' in obj")->Run()->BooleanValue());
- CHECK_EQ(20.1, v8_compile("obj.v1")->Run()->NumberValue());
-
- env->Global()->Set(v8_str("obj2"),
- base2->GetFunction()->NewInstance());
- CHECK_EQ(17.2, v8_compile("obj2.flabby()")->Run()->NumberValue());
- CHECK(v8_compile("'flabby' in obj2")->Run()->BooleanValue());
- CHECK_EQ(15.2, v8_compile("obj2.knurd")->Run()->NumberValue());
- CHECK(v8_compile("'knurd' in obj2")->Run()->BooleanValue());
- CHECK_EQ(10.1, v8_compile("obj2.v2")->Run()->NumberValue());
+ CHECK(
+ CompileRun("s.knurd == undefined")->BooleanValue(env.local()).FromJust());
+ CHECK(CompileRun("s.prototype.knurd == undefined")
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK(CompileRun("base1.prototype.knurd == undefined")
+ ->BooleanValue(env.local())
+ .FromJust());
+
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("obj"), base1->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked())
+ .FromJust());
+ CHECK_EQ(17.2, v8_compile("obj.flabby()")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->NumberValue(env.local())
+ .FromJust());
+ CHECK(v8_compile("'flabby' in obj")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK_EQ(15.2, v8_compile("obj.knurd")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->NumberValue(env.local())
+ .FromJust());
+ CHECK(v8_compile("'knurd' in obj")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK_EQ(20.1, v8_compile("obj.v1")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->NumberValue(env.local())
+ .FromJust());
+
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("obj2"), base2->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked())
+ .FromJust());
+ CHECK_EQ(17.2, v8_compile("obj2.flabby()")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->NumberValue(env.local())
+ .FromJust());
+ CHECK(v8_compile("'flabby' in obj2")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK_EQ(15.2, v8_compile("obj2.knurd")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->NumberValue(env.local())
+ .FromJust());
+ CHECK(v8_compile("'knurd' in obj2")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->BooleanValue(env.local())
+ .FromJust());
+ CHECK_EQ(10.1, v8_compile("obj2.v2")
+ ->Run(env.local())
+ .ToLocalChecked()
+ ->NumberValue(env.local())
+ .FromJust());
// base1 and base2 cannot cross reference to each's prototype
- CHECK(v8_compile("obj.v2")->Run()->IsUndefined());
- CHECK(v8_compile("obj2.v1")->Run()->IsUndefined());
+ CHECK(v8_compile("obj.v2")->Run(env.local()).ToLocalChecked()->IsUndefined());
+ CHECK(
+ v8_compile("obj2.v1")->Run(env.local()).ToLocalChecked()->IsUndefined());
}
@@ -1880,15 +2086,18 @@ THREADED_TEST(DescriptorInheritance) {
void SimpleAccessorGetter(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
- Handle<Object> self = Handle<Object>::Cast(info.This());
- info.GetReturnValue().Set(
- self->Get(String::Concat(v8_str("accessor_"), name)));
+ Local<Object> self = Local<Object>::Cast(info.This());
+ info.GetReturnValue().Set(self->Get(info.GetIsolate()->GetCurrentContext(),
+ String::Concat(v8_str("accessor_"), name))
+ .ToLocalChecked());
}
void SimpleAccessorSetter(Local<String> name, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) {
- Handle<Object> self = Handle<Object>::Cast(info.This());
- self->Set(String::Concat(v8_str("accessor_"), name), value);
+ Local<Object> self = Local<Object>::Cast(info.This());
+ CHECK(self->Set(info.GetIsolate()->GetCurrentContext(),
+ String::Concat(v8_str("accessor_"), name), value)
+ .FromJust());
}
void SymbolAccessorGetter(Local<Name> name,
@@ -1944,59 +2153,81 @@ THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) {
THREADED_TEST(UndefinedIsNotEnumerable) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<Value> result = CompileRun("this.propertyIsEnumerable(undefined)");
+ v8::Local<Value> result = CompileRun("this.propertyIsEnumerable(undefined)");
CHECK(result->IsFalse());
}
-v8::Handle<Script> call_recursively_script;
+v8::Local<Script> call_recursively_script;
static const int kTargetRecursionDepth = 150; // near maximum
static void CallScriptRecursivelyCall(
const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
- int depth = args.This()->Get(v8_str("depth"))->Int32Value();
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ int depth = args.This()
+ ->Get(context, v8_str("depth"))
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust();
if (depth == kTargetRecursionDepth) return;
- args.This()->Set(v8_str("depth"),
- v8::Integer::New(args.GetIsolate(), depth + 1));
- args.GetReturnValue().Set(call_recursively_script->Run());
+ CHECK(args.This()
+ ->Set(context, v8_str("depth"),
+ v8::Integer::New(args.GetIsolate(), depth + 1))
+ .FromJust());
+ args.GetReturnValue().Set(
+ call_recursively_script->Run(context).ToLocalChecked());
}
static void CallFunctionRecursivelyCall(
const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
- int depth = args.This()->Get(v8_str("depth"))->Int32Value();
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ int depth = args.This()
+ ->Get(context, v8_str("depth"))
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust();
if (depth == kTargetRecursionDepth) {
printf("[depth = %d]\n", depth);
return;
}
- args.This()->Set(v8_str("depth"),
- v8::Integer::New(args.GetIsolate(), depth + 1));
- v8::Handle<Value> function =
- args.This()->Get(v8_str("callFunctionRecursively"));
- args.GetReturnValue().Set(
- function.As<Function>()->Call(args.This(), 0, NULL));
+ CHECK(args.This()
+ ->Set(context, v8_str("depth"),
+ v8::Integer::New(args.GetIsolate(), depth + 1))
+ .FromJust());
+ v8::Local<Value> function =
+ args.This()
+ ->Get(context, v8_str("callFunctionRecursively"))
+ .ToLocalChecked();
+ args.GetReturnValue().Set(function.As<Function>()
+ ->Call(context, args.This(), 0, NULL)
+ .ToLocalChecked());
}
THREADED_TEST(DeepCrossLanguageRecursion) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> global = ObjectTemplate::New(isolate);
global->Set(v8_str("callScriptRecursively"),
v8::FunctionTemplate::New(isolate, CallScriptRecursivelyCall));
global->Set(v8_str("callFunctionRecursively"),
v8::FunctionTemplate::New(isolate, CallFunctionRecursivelyCall));
LocalContext env(NULL, global);
- env->Global()->Set(v8_str("depth"), v8::Integer::New(isolate, 0));
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("depth"), v8::Integer::New(isolate, 0))
+ .FromJust());
call_recursively_script = v8_compile("callScriptRecursively()");
- call_recursively_script->Run();
- call_recursively_script = v8::Handle<Script>();
+ call_recursively_script->Run(env.local()).ToLocalChecked();
+ call_recursively_script = v8::Local<Script>();
- env->Global()->Set(v8_str("depth"), v8::Integer::New(isolate, 0));
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("depth"), v8::Integer::New(isolate, 0))
+ .FromJust());
CompileRun("callFunctionRecursively()");
}
@@ -2022,17 +2253,20 @@ static void ThrowingPropertyHandlerSet(
THREADED_TEST(CallbackExceptionRegression) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
obj->SetHandler(v8::NamedPropertyHandlerConfiguration(
ThrowingPropertyHandlerGet, ThrowingPropertyHandlerSet));
LocalContext env;
- env->Global()->Set(v8_str("obj"), obj->NewInstance());
- v8::Handle<Value> otto =
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("obj"),
+ obj->NewInstance(env.local()).ToLocalChecked())
+ .FromJust());
+ v8::Local<Value> otto =
CompileRun("try { with (obj) { otto; } } catch (e) { e; }");
- CHECK(v8_str("otto")->Equals(otto));
- v8::Handle<Value> netto =
+ CHECK(v8_str("otto")->Equals(env.local(), otto).FromJust());
+ v8::Local<Value> netto =
CompileRun("try { with (obj) { netto = 4; } } catch (e) { e; }");
- CHECK(v8_str("netto")->Equals(netto));
+ CHECK(v8_str("netto")->Equals(env.local(), netto).FromJust());
}
@@ -2042,9 +2276,12 @@ THREADED_TEST(FunctionPrototype) {
Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(isolate);
Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321));
LocalContext env;
- env->Global()->Set(v8_str("Foo"), Foo->GetFunction());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("Foo"),
+ Foo->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
Local<Script> script = v8_compile("Foo.prototype.plak");
- CHECK_EQ(script->Run()->Int32Value(), 321);
+ CHECK_EQ(v8_run_int32value(script), 321);
}
@@ -2056,11 +2293,14 @@ THREADED_TEST(InternalFields) {
Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
instance_templ->SetInternalFieldCount(1);
- Local<v8::Object> obj = templ->GetFunction()->NewInstance();
+ Local<v8::Object> obj = templ->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked();
CHECK_EQ(1, obj->InternalFieldCount());
CHECK(obj->GetInternalField(0)->IsUndefined());
obj->SetInternalField(0, v8_num(17));
- CHECK_EQ(17, obj->GetInternalField(0)->Int32Value());
+ CHECK_EQ(17, obj->GetInternalField(0)->Int32Value(env.local()).FromJust());
}
@@ -2070,12 +2310,12 @@ THREADED_TEST(GlobalObjectInternalFields) {
Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate);
global_template->SetInternalFieldCount(1);
LocalContext env(NULL, global_template);
- v8::Handle<v8::Object> global_proxy = env->Global();
- v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
+ v8::Local<v8::Object> global_proxy = env->Global();
+ v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
CHECK_EQ(1, global->InternalFieldCount());
CHECK(global->GetInternalField(0)->IsUndefined());
global->SetInternalField(0, v8_num(17));
- CHECK_EQ(17, global->GetInternalField(0)->Int32Value());
+ CHECK_EQ(17, global->GetInternalField(0)->Int32Value(env.local()).FromJust());
}
@@ -2084,12 +2324,12 @@ THREADED_TEST(GlobalObjectHasRealIndexedProperty) {
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Object> global = env->Global();
- global->Set(0, v8::String::NewFromUtf8(CcTest::isolate(), "value"));
- CHECK(global->HasRealIndexedProperty(0));
+ CHECK(global->Set(env.local(), 0, v8_str("value")).FromJust());
+ CHECK(global->HasRealIndexedProperty(env.local(), 0).FromJust());
}
-static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj,
+static void CheckAlignedPointerInInternalField(Local<v8::Object> obj,
void* value) {
CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1));
obj->SetAlignedPointerInInternalField(0, value);
@@ -2106,7 +2346,10 @@ THREADED_TEST(InternalFieldsAlignedPointers) {
Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
instance_templ->SetInternalFieldCount(1);
- Local<v8::Object> obj = templ->GetFunction()->NewInstance();
+ Local<v8::Object> obj = templ->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked();
CHECK_EQ(1, obj->InternalFieldCount());
CheckAlignedPointerInInternalField(obj, NULL);
@@ -2169,7 +2412,7 @@ THREADED_TEST(EmbedderDataAlignedPointers) {
static void CheckEmbedderData(LocalContext* env, int index,
- v8::Handle<Value> data) {
+ v8::Local<Value> data) {
(*env)->SetEmbedderData(index, data);
CHECK((*env)->GetEmbedderData(index)->StrictEquals(data));
}
@@ -2180,15 +2423,15 @@ THREADED_TEST(EmbedderData) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- CheckEmbedderData(
- &env, 3, v8::String::NewFromUtf8(isolate, "The quick brown fox jumps"));
- CheckEmbedderData(&env, 2,
- v8::String::NewFromUtf8(isolate, "over the lazy dog."));
+ CheckEmbedderData(&env, 3, v8_str("The quick brown fox jumps"));
+ CheckEmbedderData(&env, 2, v8_str("over the lazy dog."));
CheckEmbedderData(&env, 1, v8::Number::New(isolate, 1.2345));
CheckEmbedderData(&env, 0, v8::Boolean::New(isolate, true));
}
+// TODO(vogelheim): Does this test even make sense in a post-deprecation world?
+/*
THREADED_TEST(GetIsolate) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
@@ -2197,6 +2440,7 @@ THREADED_TEST(GetIsolate) {
CHECK_EQ(isolate, obj->GetIsolate());
CHECK_EQ(isolate, CcTest::global()->GetIsolate());
}
+*/
THREADED_TEST(IdentityHash) {
@@ -2249,9 +2493,11 @@ void GlobalProxyIdentityHash(bool set_in_js) {
v8::Isolate* isolate = env->GetIsolate();
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
v8::HandleScope scope(isolate);
- Handle<Object> global_proxy = env->Global();
+ Local<Object> global_proxy = env->Global();
i::Handle<i::Object> i_global_proxy = v8::Utils::OpenHandle(*global_proxy);
- env->Global()->Set(v8_str("global"), global_proxy);
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("global"), global_proxy)
+ .FromJust());
i::Handle<i::Object> original_hash;
if (set_in_js) {
CompileRun("var m = new Set(); m.add(global);");
@@ -2268,7 +2514,7 @@ void GlobalProxyIdentityHash(bool set_in_js) {
CHECK_EQ(hash1, hash2);
{
// Re-attach global proxy to a new context, hash should stay the same.
- LocalContext env2(NULL, Handle<ObjectTemplate>(), global_proxy);
+ LocalContext env2(NULL, Local<ObjectTemplate>(), global_proxy);
int hash3 = global_proxy->GetIdentityHash();
CHECK_EQ(hash1, hash3);
}
@@ -2297,7 +2543,7 @@ TEST(SymbolIdentityHash) {
}
{
- v8::Handle<v8::Symbol> js_symbol =
+ v8::Local<v8::Symbol> js_symbol =
CompileRun("Symbol('foo')").As<v8::Symbol>();
int hash = js_symbol->GetIdentityHash();
int hash1 = js_symbol->GetIdentityHash();
@@ -2314,7 +2560,7 @@ TEST(StringIdentityHash) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- Local<v8::String> str = v8::String::NewFromUtf8(isolate, "str1");
+ Local<v8::String> str = v8_str("str1");
int hash = str->GetIdentityHash();
int hash1 = str->GetIdentityHash();
CHECK_EQ(hash, hash1);
@@ -2322,7 +2568,7 @@ TEST(StringIdentityHash) {
int hash3 = str->GetIdentityHash();
CHECK_EQ(hash, hash3);
- Local<v8::String> str2 = v8::String::NewFromUtf8(isolate, "str1");
+ Local<v8::String> str2 = v8_str("str1");
int hash4 = str2->GetIdentityHash();
CHECK_EQ(hash, hash4);
}
@@ -2345,92 +2591,145 @@ THREADED_TEST(SymbolProperties) {
CHECK(sym2->IsSymbol());
CHECK(!obj->IsSymbol());
- CHECK(sym1->Equals(sym1));
- CHECK(sym2->Equals(sym2));
- CHECK(!sym1->Equals(sym2));
- CHECK(!sym2->Equals(sym1));
+ CHECK(sym1->Equals(env.local(), sym1).FromJust());
+ CHECK(sym2->Equals(env.local(), sym2).FromJust());
+ CHECK(!sym1->Equals(env.local(), sym2).FromJust());
+ CHECK(!sym2->Equals(env.local(), sym1).FromJust());
CHECK(sym1->StrictEquals(sym1));
CHECK(sym2->StrictEquals(sym2));
CHECK(!sym1->StrictEquals(sym2));
CHECK(!sym2->StrictEquals(sym1));
- CHECK(sym2->Name()->Equals(v8_str("my-symbol")));
+ CHECK(sym2->Name()->Equals(env.local(), v8_str("my-symbol")).FromJust());
v8::Local<v8::Value> sym_val = sym2;
CHECK(sym_val->IsSymbol());
- CHECK(sym_val->Equals(sym2));
+ CHECK(sym_val->Equals(env.local(), sym2).FromJust());
CHECK(sym_val->StrictEquals(sym2));
- CHECK(v8::Symbol::Cast(*sym_val)->Equals(sym2));
+ CHECK(v8::Symbol::Cast(*sym_val)->Equals(env.local(), sym2).FromJust());
v8::Local<v8::Value> sym_obj = v8::SymbolObject::New(isolate, sym2);
CHECK(sym_obj->IsSymbolObject());
CHECK(!sym2->IsSymbolObject());
CHECK(!obj->IsSymbolObject());
- CHECK(sym_obj->Equals(sym2));
+ CHECK(sym_obj->Equals(env.local(), sym2).FromJust());
CHECK(!sym_obj->StrictEquals(sym2));
- CHECK(v8::SymbolObject::Cast(*sym_obj)->Equals(sym_obj));
- CHECK(v8::SymbolObject::Cast(*sym_obj)->ValueOf()->Equals(sym2));
+ CHECK(v8::SymbolObject::Cast(*sym_obj)
+ ->Equals(env.local(), sym_obj)
+ .FromJust());
+ CHECK(v8::SymbolObject::Cast(*sym_obj)
+ ->ValueOf()
+ ->Equals(env.local(), sym2)
+ .FromJust());
// Make sure delete of a non-existent symbol property works.
- CHECK(obj->Delete(sym1));
- CHECK(!obj->Has(sym1));
-
- CHECK(obj->Set(sym1, v8::Integer::New(isolate, 1503)));
- CHECK(obj->Has(sym1));
- CHECK_EQ(1503, obj->Get(sym1)->Int32Value());
- CHECK(obj->Set(sym1, v8::Integer::New(isolate, 2002)));
- CHECK(obj->Has(sym1));
- CHECK_EQ(2002, obj->Get(sym1)->Int32Value());
- CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1));
-
- CHECK_EQ(0u, obj->GetOwnPropertyNames()->Length());
- unsigned num_props = obj->GetPropertyNames()->Length();
- CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"),
- v8::Integer::New(isolate, 20)));
- CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length());
- CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length());
+ CHECK(obj->Delete(env.local(), sym1).FromJust());
+ CHECK(!obj->Has(env.local(), sym1).FromJust());
+
+ CHECK(
+ obj->Set(env.local(), sym1, v8::Integer::New(isolate, 1503)).FromJust());
+ CHECK(obj->Has(env.local(), sym1).FromJust());
+ CHECK_EQ(1503, obj->Get(env.local(), sym1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK(
+ obj->Set(env.local(), sym1, v8::Integer::New(isolate, 2002)).FromJust());
+ CHECK(obj->Has(env.local(), sym1).FromJust());
+ CHECK_EQ(2002, obj->Get(env.local(), sym1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(v8::None, obj->GetPropertyAttributes(env.local(), sym1).FromJust());
+
+ CHECK_EQ(0u,
+ obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
+ unsigned num_props =
+ obj->GetPropertyNames(env.local()).ToLocalChecked()->Length();
+ CHECK(obj->Set(env.local(), v8_str("bla"), v8::Integer::New(isolate, 20))
+ .FromJust());
+ CHECK_EQ(1u,
+ obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
+ CHECK_EQ(num_props + 1,
+ obj->GetPropertyNames(env.local()).ToLocalChecked()->Length());
CcTest::heap()->CollectAllGarbage();
- CHECK(obj->SetAccessor(sym3, SymbolAccessorGetter, SymbolAccessorSetter));
- CHECK(obj->Get(sym3)->IsUndefined());
- CHECK(obj->Set(sym3, v8::Integer::New(isolate, 42)));
- CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42)));
- CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))
- ->Equals(v8::Integer::New(isolate, 42)));
+ CHECK(obj->SetAccessor(env.local(), sym3, SymbolAccessorGetter,
+ SymbolAccessorSetter)
+ .FromJust());
+ CHECK(obj->Get(env.local(), sym3).ToLocalChecked()->IsUndefined());
+ CHECK(obj->Set(env.local(), sym3, v8::Integer::New(isolate, 42)).FromJust());
+ CHECK(obj->Get(env.local(), sym3)
+ .ToLocalChecked()
+ ->Equals(env.local(), v8::Integer::New(isolate, 42))
+ .FromJust());
+ CHECK(obj->Get(env.local(), v8_str("accessor_sym3"))
+ .ToLocalChecked()
+ ->Equals(env.local(), v8::Integer::New(isolate, 42))
+ .FromJust());
// Add another property and delete it afterwards to force the object in
// slow case.
- CHECK(obj->Set(sym2, v8::Integer::New(isolate, 2008)));
- CHECK_EQ(2002, obj->Get(sym1)->Int32Value());
- CHECK_EQ(2008, obj->Get(sym2)->Int32Value());
- CHECK_EQ(2002, obj->Get(sym1)->Int32Value());
- CHECK_EQ(2u, obj->GetOwnPropertyNames()->Length());
-
- CHECK(obj->Has(sym1));
- CHECK(obj->Has(sym2));
- CHECK(obj->Has(sym3));
- CHECK(obj->Has(v8::String::NewFromUtf8(isolate, "accessor_sym3")));
- CHECK(obj->Delete(sym2));
- CHECK(obj->Has(sym1));
- CHECK(!obj->Has(sym2));
- CHECK(obj->Has(sym3));
- CHECK(obj->Has(v8::String::NewFromUtf8(isolate, "accessor_sym3")));
- CHECK_EQ(2002, obj->Get(sym1)->Int32Value());
- CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42)));
- CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))
- ->Equals(v8::Integer::New(isolate, 42)));
- CHECK_EQ(2u, obj->GetOwnPropertyNames()->Length());
+ CHECK(
+ obj->Set(env.local(), sym2, v8::Integer::New(isolate, 2008)).FromJust());
+ CHECK_EQ(2002, obj->Get(env.local(), sym1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(2008, obj->Get(env.local(), sym2)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(2002, obj->Get(env.local(), sym1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(2u,
+ obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
+
+ CHECK(obj->Has(env.local(), sym1).FromJust());
+ CHECK(obj->Has(env.local(), sym2).FromJust());
+ CHECK(obj->Has(env.local(), sym3).FromJust());
+ CHECK(obj->Has(env.local(), v8_str("accessor_sym3")).FromJust());
+ CHECK(obj->Delete(env.local(), sym2).FromJust());
+ CHECK(obj->Has(env.local(), sym1).FromJust());
+ CHECK(!obj->Has(env.local(), sym2).FromJust());
+ CHECK(obj->Has(env.local(), sym3).FromJust());
+ CHECK(obj->Has(env.local(), v8_str("accessor_sym3")).FromJust());
+ CHECK_EQ(2002, obj->Get(env.local(), sym1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK(obj->Get(env.local(), sym3)
+ .ToLocalChecked()
+ ->Equals(env.local(), v8::Integer::New(isolate, 42))
+ .FromJust());
+ CHECK(obj->Get(env.local(), v8_str("accessor_sym3"))
+ .ToLocalChecked()
+ ->Equals(env.local(), v8::Integer::New(isolate, 42))
+ .FromJust());
+ CHECK_EQ(2u,
+ obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
// Symbol properties are inherited.
v8::Local<v8::Object> child = v8::Object::New(isolate);
- child->SetPrototype(obj);
- CHECK(child->Has(sym1));
- CHECK_EQ(2002, child->Get(sym1)->Int32Value());
- CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42)));
- CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))
- ->Equals(v8::Integer::New(isolate, 42)));
- CHECK_EQ(0u, child->GetOwnPropertyNames()->Length());
+ CHECK(child->SetPrototype(env.local(), obj).FromJust());
+ CHECK(child->Has(env.local(), sym1).FromJust());
+ CHECK_EQ(2002, child->Get(env.local(), sym1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK(obj->Get(env.local(), sym3)
+ .ToLocalChecked()
+ ->Equals(env.local(), v8::Integer::New(isolate, 42))
+ .FromJust());
+ CHECK(obj->Get(env.local(), v8_str("accessor_sym3"))
+ .ToLocalChecked()
+ ->Equals(env.local(), v8::Integer::New(isolate, 42))
+ .FromJust());
+ CHECK_EQ(0u,
+ child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
}
@@ -2442,9 +2741,10 @@ THREADED_TEST(SymbolTemplateProperties) {
v8::Local<v8::Name> name = v8::Symbol::New(isolate);
CHECK(!name.IsEmpty());
foo->PrototypeTemplate()->Set(name, v8::FunctionTemplate::New(isolate));
- v8::Local<v8::Object> new_instance = foo->InstanceTemplate()->NewInstance();
+ v8::Local<v8::Object> new_instance =
+ foo->InstanceTemplate()->NewInstance(env.local()).ToLocalChecked();
CHECK(!new_instance.IsEmpty());
- CHECK(new_instance->Has(name));
+ CHECK(new_instance->Has(env.local(), name).FromJust());
}
@@ -2460,7 +2760,12 @@ THREADED_TEST(PrivateProperties) {
CcTest::heap()->CollectAllGarbage();
- CHECK(priv2->Name()->Equals(v8::String::NewFromUtf8(isolate, "my-private")));
+ CHECK(priv2->Name()
+ ->Equals(env.local(),
+ v8::String::NewFromUtf8(isolate, "my-private",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked())
+ .FromJust());
// Make sure delete of a non-existent private symbol property works.
obj->DeletePrivate(env.local(), priv1).FromJust();
@@ -2469,20 +2774,31 @@ THREADED_TEST(PrivateProperties) {
CHECK(obj->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 1503))
.FromJust());
CHECK(obj->HasPrivate(env.local(), priv1).FromJust());
- CHECK_EQ(1503,
- obj->GetPrivate(env.local(), priv1).ToLocalChecked()->Int32Value());
+ CHECK_EQ(1503, obj->GetPrivate(env.local(), priv1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
CHECK(obj->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 2002))
.FromJust());
CHECK(obj->HasPrivate(env.local(), priv1).FromJust());
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), priv1).ToLocalChecked()->Int32Value());
-
- CHECK_EQ(0u, obj->GetOwnPropertyNames()->Length());
- unsigned num_props = obj->GetPropertyNames()->Length();
- CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"),
- v8::Integer::New(isolate, 20)));
- CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length());
- CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), priv1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+
+ CHECK_EQ(0u,
+ obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
+ unsigned num_props =
+ obj->GetPropertyNames(env.local()).ToLocalChecked()->Length();
+ CHECK(obj->Set(env.local(), v8::String::NewFromUtf8(
+ isolate, "bla", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::Integer::New(isolate, 20))
+ .FromJust());
+ CHECK_EQ(1u,
+ obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
+ CHECK_EQ(num_props + 1,
+ obj->GetPropertyNames(env.local()).ToLocalChecked()->Length());
CcTest::heap()->CollectAllGarbage();
@@ -2490,28 +2806,39 @@ THREADED_TEST(PrivateProperties) {
// slow case.
CHECK(obj->SetPrivate(env.local(), priv2, v8::Integer::New(isolate, 2008))
.FromJust());
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), priv1).ToLocalChecked()->Int32Value());
- CHECK_EQ(2008,
- obj->GetPrivate(env.local(), priv2).ToLocalChecked()->Int32Value());
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), priv1).ToLocalChecked()->Int32Value());
- CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), priv1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(2008, obj->GetPrivate(env.local(), priv2)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), priv1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(1u,
+ obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
CHECK(obj->HasPrivate(env.local(), priv1).FromJust());
CHECK(obj->HasPrivate(env.local(), priv2).FromJust());
CHECK(obj->DeletePrivate(env.local(), priv2).FromJust());
CHECK(obj->HasPrivate(env.local(), priv1).FromJust());
CHECK(!obj->HasPrivate(env.local(), priv2).FromJust());
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), priv1).ToLocalChecked()->Int32Value());
- CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), priv1)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(1u,
+ obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
// Private properties are not inherited (for the time being).
v8::Local<v8::Object> child = v8::Object::New(isolate);
- child->SetPrototype(obj);
+ CHECK(child->SetPrototype(env.local(), obj).FromJust());
CHECK(!child->HasPrivate(env.local(), priv1).FromJust());
- CHECK_EQ(0u, child->GetOwnPropertyNames()->Length());
+ CHECK_EQ(0u,
+ child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length());
}
@@ -2534,7 +2861,8 @@ THREADED_TEST(GlobalSymbols) {
CHECK(!sym->SameValue(glob));
CompileRun("var sym2 = Symbol.for('my-symbol')");
- v8::Local<Value> sym2 = env->Global()->Get(v8_str("sym2"));
+ v8::Local<Value> sym2 =
+ env->Global()->Get(env.local(), v8_str("sym2")).ToLocalChecked();
CHECK(sym2->SameValue(glob));
CHECK(!sym2->SameValue(glob_api));
}
@@ -2549,7 +2877,8 @@ static void CheckWellKnownSymbol(v8::Local<v8::Symbol>(*getter)(v8::Isolate*),
v8::Local<v8::Symbol> symbol = getter(isolate);
std::string script = std::string("var sym = ") + name;
CompileRun(script.c_str());
- v8::Local<Value> value = env->Global()->Get(v8_str("sym"));
+ v8::Local<Value> value =
+ env->Global()->Get(env.local(), v8_str("sym")).ToLocalChecked();
CHECK(!value.IsEmpty());
CHECK(!symbol.IsEmpty());
@@ -2582,8 +2911,9 @@ THREADED_TEST(GlobalPrivates) {
CHECK(!obj->HasPrivate(env.local(), priv).FromJust());
CompileRun("var intern = %CreatePrivateSymbol('my-private')");
- v8::Local<Value> intern = env->Global()->Get(v8_str("intern"));
- CHECK(!obj->Has(intern));
+ v8::Local<Value> intern =
+ env->Global()->Get(env.local(), v8_str("intern")).ToLocalChecked();
+ CHECK(!obj->Has(env.local(), intern).FromJust());
}
@@ -2600,10 +2930,12 @@ class ScopedArrayBufferContents {
};
template <typename T>
-static void CheckInternalFieldsAreZero(v8::Handle<T> value) {
+static void CheckInternalFieldsAreZero(v8::Local<T> value) {
CHECK_EQ(T::kInternalFieldCount, value->InternalFieldCount());
for (int i = 0; i < value->InternalFieldCount(); i++) {
- CHECK_EQ(0, value->GetInternalField(i)->Int32Value());
+ CHECK_EQ(0, value->GetInternalField(i)
+ ->Int32Value(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
}
}
@@ -2625,23 +2957,23 @@ THREADED_TEST(ArrayBuffer_ApiInternalToExternal) {
CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()));
uint8_t* data = static_cast<uint8_t*>(ab_contents.Data());
DCHECK(data != NULL);
- env->Global()->Set(v8_str("ab"), ab);
+ CHECK(env->Global()->Set(env.local(), v8_str("ab"), ab).FromJust());
- v8::Handle<v8::Value> result = CompileRun("ab.byteLength");
- CHECK_EQ(1024, result->Int32Value());
+ v8::Local<v8::Value> result = CompileRun("ab.byteLength");
+ CHECK_EQ(1024, result->Int32Value(env.local()).FromJust());
result = CompileRun(
"var u8 = new Uint8Array(ab);"
"u8[0] = 0xFF;"
"u8[1] = 0xAA;"
"u8.length");
- CHECK_EQ(1024, result->Int32Value());
+ CHECK_EQ(1024, result->Int32Value(env.local()).FromJust());
CHECK_EQ(0xFF, data[0]);
CHECK_EQ(0xAA, data[1]);
data[0] = 0xCC;
data[1] = 0x11;
result = CompileRun("u8[0] + u8[1]");
- CHECK_EQ(0xDD, result->Int32Value());
+ CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust());
}
@@ -2664,18 +2996,18 @@ THREADED_TEST(ArrayBuffer_JSInternalToExternal) {
CHECK(ab1->IsExternal());
result = CompileRun("ab1.byteLength");
- CHECK_EQ(2, result->Int32Value());
+ CHECK_EQ(2, result->Int32Value(env.local()).FromJust());
result = CompileRun("u8_a[0]");
- CHECK_EQ(0xAA, result->Int32Value());
+ CHECK_EQ(0xAA, result->Int32Value(env.local()).FromJust());
result = CompileRun("u8_a[1]");
- CHECK_EQ(0xFF, result->Int32Value());
+ CHECK_EQ(0xFF, result->Int32Value(env.local()).FromJust());
result = CompileRun(
"var u8_b = new Uint8Array(ab1);"
"u8_b[0] = 0xBB;"
"u8_a[0]");
- CHECK_EQ(0xBB, result->Int32Value());
+ CHECK_EQ(0xBB, result->Int32Value(env.local()).FromJust());
result = CompileRun("u8_b[1]");
- CHECK_EQ(0xFF, result->Int32Value());
+ CHECK_EQ(0xFF, result->Int32Value(env.local()).FromJust());
CHECK_EQ(2, static_cast<int>(ab1_contents.ByteLength()));
uint8_t* ab1_data = static_cast<uint8_t*>(ab1_contents.Data());
@@ -2684,7 +3016,7 @@ THREADED_TEST(ArrayBuffer_JSInternalToExternal) {
ab1_data[0] = 0xCC;
ab1_data[1] = 0x11;
result = CompileRun("u8_a[0] + u8_a[1]");
- CHECK_EQ(0xDD, result->Int32Value());
+ CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust());
}
@@ -2701,23 +3033,23 @@ THREADED_TEST(ArrayBuffer_External) {
CHECK_EQ(100, static_cast<int>(ab3->ByteLength()));
CHECK(ab3->IsExternal());
- env->Global()->Set(v8_str("ab3"), ab3);
+ CHECK(env->Global()->Set(env.local(), v8_str("ab3"), ab3).FromJust());
- v8::Handle<v8::Value> result = CompileRun("ab3.byteLength");
- CHECK_EQ(100, result->Int32Value());
+ v8::Local<v8::Value> result = CompileRun("ab3.byteLength");
+ CHECK_EQ(100, result->Int32Value(env.local()).FromJust());
result = CompileRun(
"var u8_b = new Uint8Array(ab3);"
"u8_b[0] = 0xBB;"
"u8_b[1] = 0xCC;"
"u8_b.length");
- CHECK_EQ(100, result->Int32Value());
+ CHECK_EQ(100, result->Int32Value(env.local()).FromJust());
CHECK_EQ(0xBB, my_data[0]);
CHECK_EQ(0xCC, my_data[1]);
my_data[0] = 0xCC;
my_data[1] = 0x11;
result = CompileRun("u8_b[0] + u8_b[1]");
- CHECK_EQ(0xDD, result->Int32Value());
+ CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust());
}
@@ -2739,13 +3071,13 @@ THREADED_TEST(ArrayBuffer_DisableNeuter) {
}
-static void CheckDataViewIsNeutered(v8::Handle<v8::DataView> dv) {
+static void CheckDataViewIsNeutered(v8::Local<v8::DataView> dv) {
CHECK_EQ(0, static_cast<int>(dv->ByteLength()));
CHECK_EQ(0, static_cast<int>(dv->ByteOffset()));
}
-static void CheckIsNeutered(v8::Handle<v8::TypedArray> ta) {
+static void CheckIsNeutered(v8::Local<v8::TypedArray> ta) {
CHECK_EQ(0, static_cast<int>(ta->ByteLength()));
CHECK_EQ(0, static_cast<int>(ta->Length()));
CHECK_EQ(0, static_cast<int>(ta->ByteOffset()));
@@ -2758,16 +3090,16 @@ static void CheckIsTypedArrayVarNeutered(const char* name) {
"%s.byteLength == 0 && %s.byteOffset == 0 && %s.length == 0",
name, name, name);
CHECK(CompileRun(source.start())->IsTrue());
- v8::Handle<v8::TypedArray> ta =
- v8::Handle<v8::TypedArray>::Cast(CompileRun(name));
+ v8::Local<v8::TypedArray> ta =
+ v8::Local<v8::TypedArray>::Cast(CompileRun(name));
CheckIsNeutered(ta);
}
template <typename TypedArray, int kElementSize>
-static Handle<TypedArray> CreateAndCheck(Handle<v8::ArrayBuffer> ab,
- int byteOffset, int length) {
- v8::Handle<TypedArray> ta = TypedArray::New(ab, byteOffset, length);
+static Local<TypedArray> CreateAndCheck(Local<v8::ArrayBuffer> ab,
+ int byteOffset, int length) {
+ v8::Local<TypedArray> ta = TypedArray::New(ab, byteOffset, length);
CheckInternalFieldsAreZero<v8::ArrayBufferView>(ta);
CHECK_EQ(byteOffset, static_cast<int>(ta->ByteOffset()));
CHECK_EQ(length, static_cast<int>(ta->Length()));
@@ -2781,31 +3113,31 @@ THREADED_TEST(ArrayBuffer_NeuteringApi) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(isolate, 1024);
+ v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(isolate, 1024);
- v8::Handle<v8::Uint8Array> u8a =
+ v8::Local<v8::Uint8Array> u8a =
CreateAndCheck<v8::Uint8Array, 1>(buffer, 1, 1023);
- v8::Handle<v8::Uint8ClampedArray> u8c =
+ v8::Local<v8::Uint8ClampedArray> u8c =
CreateAndCheck<v8::Uint8ClampedArray, 1>(buffer, 1, 1023);
- v8::Handle<v8::Int8Array> i8a =
+ v8::Local<v8::Int8Array> i8a =
CreateAndCheck<v8::Int8Array, 1>(buffer, 1, 1023);
- v8::Handle<v8::Uint16Array> u16a =
+ v8::Local<v8::Uint16Array> u16a =
CreateAndCheck<v8::Uint16Array, 2>(buffer, 2, 511);
- v8::Handle<v8::Int16Array> i16a =
+ v8::Local<v8::Int16Array> i16a =
CreateAndCheck<v8::Int16Array, 2>(buffer, 2, 511);
- v8::Handle<v8::Uint32Array> u32a =
+ v8::Local<v8::Uint32Array> u32a =
CreateAndCheck<v8::Uint32Array, 4>(buffer, 4, 255);
- v8::Handle<v8::Int32Array> i32a =
+ v8::Local<v8::Int32Array> i32a =
CreateAndCheck<v8::Int32Array, 4>(buffer, 4, 255);
- v8::Handle<v8::Float32Array> f32a =
+ v8::Local<v8::Float32Array> f32a =
CreateAndCheck<v8::Float32Array, 4>(buffer, 4, 255);
- v8::Handle<v8::Float64Array> f64a =
+ v8::Local<v8::Float64Array> f64a =
CreateAndCheck<v8::Float64Array, 8>(buffer, 8, 127);
- v8::Handle<v8::DataView> dv = v8::DataView::New(buffer, 1, 1023);
+ v8::Local<v8::DataView> dv = v8::DataView::New(buffer, 1, 1023);
CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv);
CHECK_EQ(1, static_cast<int>(dv->ByteOffset()));
CHECK_EQ(1023, static_cast<int>(dv->ByteLength()));
@@ -2844,16 +3176,15 @@ THREADED_TEST(ArrayBuffer_NeuteringScript) {
"var f64a = new Float64Array(ab, 8, 127);"
"var dv = new DataView(ab, 1, 1023);");
- v8::Handle<v8::ArrayBuffer> ab =
+ v8::Local<v8::ArrayBuffer> ab =
Local<v8::ArrayBuffer>::Cast(CompileRun("ab"));
- v8::Handle<v8::DataView> dv =
- v8::Handle<v8::DataView>::Cast(CompileRun("dv"));
+ v8::Local<v8::DataView> dv = v8::Local<v8::DataView>::Cast(CompileRun("dv"));
ScopedArrayBufferContents contents(ab->Externalize());
ab->Neuter();
CHECK_EQ(0, static_cast<int>(ab->ByteLength()));
- CHECK_EQ(0, CompileRun("ab.byteLength")->Int32Value());
+ CHECK_EQ(0, v8_run_int32value(v8_compile("ab.byteLength")));
CheckIsTypedArrayVarNeutered("u8a");
CheckIsTypedArrayVarNeutered("u8c");
@@ -2902,23 +3233,23 @@ THREADED_TEST(SharedArrayBuffer_ApiInternalToExternal) {
CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()));
uint8_t* data = static_cast<uint8_t*>(ab_contents.Data());
DCHECK(data != NULL);
- env->Global()->Set(v8_str("ab"), ab);
+ CHECK(env->Global()->Set(env.local(), v8_str("ab"), ab).FromJust());
- v8::Handle<v8::Value> result = CompileRun("ab.byteLength");
- CHECK_EQ(1024, result->Int32Value());
+ v8::Local<v8::Value> result = CompileRun("ab.byteLength");
+ CHECK_EQ(1024, result->Int32Value(env.local()).FromJust());
result = CompileRun(
"var u8 = new Uint8Array(ab);"
"u8[0] = 0xFF;"
"u8[1] = 0xAA;"
"u8.length");
- CHECK_EQ(1024, result->Int32Value());
+ CHECK_EQ(1024, result->Int32Value(env.local()).FromJust());
CHECK_EQ(0xFF, data[0]);
CHECK_EQ(0xAA, data[1]);
data[0] = 0xCC;
data[1] = 0x11;
result = CompileRun("u8[0] + u8[1]");
- CHECK_EQ(0xDD, result->Int32Value());
+ CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust());
}
@@ -2942,18 +3273,18 @@ THREADED_TEST(SharedArrayBuffer_JSInternalToExternal) {
CHECK(ab1->IsExternal());
result = CompileRun("ab1.byteLength");
- CHECK_EQ(2, result->Int32Value());
+ CHECK_EQ(2, result->Int32Value(env.local()).FromJust());
result = CompileRun("u8_a[0]");
- CHECK_EQ(0xAA, result->Int32Value());
+ CHECK_EQ(0xAA, result->Int32Value(env.local()).FromJust());
result = CompileRun("u8_a[1]");
- CHECK_EQ(0xFF, result->Int32Value());
+ CHECK_EQ(0xFF, result->Int32Value(env.local()).FromJust());
result = CompileRun(
"var u8_b = new Uint8Array(ab1);"
"u8_b[0] = 0xBB;"
"u8_a[0]");
- CHECK_EQ(0xBB, result->Int32Value());
+ CHECK_EQ(0xBB, result->Int32Value(env.local()).FromJust());
result = CompileRun("u8_b[1]");
- CHECK_EQ(0xFF, result->Int32Value());
+ CHECK_EQ(0xFF, result->Int32Value(env.local()).FromJust());
CHECK_EQ(2, static_cast<int>(ab1_contents.ByteLength()));
uint8_t* ab1_data = static_cast<uint8_t*>(ab1_contents.Data());
@@ -2962,7 +3293,7 @@ THREADED_TEST(SharedArrayBuffer_JSInternalToExternal) {
ab1_data[0] = 0xCC;
ab1_data[1] = 0x11;
result = CompileRun("u8_a[0] + u8_a[1]");
- CHECK_EQ(0xDD, result->Int32Value());
+ CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust());
}
@@ -2980,23 +3311,23 @@ THREADED_TEST(SharedArrayBuffer_External) {
CHECK_EQ(100, static_cast<int>(ab3->ByteLength()));
CHECK(ab3->IsExternal());
- env->Global()->Set(v8_str("ab3"), ab3);
+ CHECK(env->Global()->Set(env.local(), v8_str("ab3"), ab3).FromJust());
- v8::Handle<v8::Value> result = CompileRun("ab3.byteLength");
- CHECK_EQ(100, result->Int32Value());
+ v8::Local<v8::Value> result = CompileRun("ab3.byteLength");
+ CHECK_EQ(100, result->Int32Value(env.local()).FromJust());
result = CompileRun(
"var u8_b = new Uint8Array(ab3);"
"u8_b[0] = 0xBB;"
"u8_b[1] = 0xCC;"
"u8_b.length");
- CHECK_EQ(100, result->Int32Value());
+ CHECK_EQ(100, result->Int32Value(env.local()).FromJust());
CHECK_EQ(0xBB, my_data[0]);
CHECK_EQ(0xCC, my_data[1]);
my_data[0] = 0xCC;
my_data[1] = 0x11;
result = CompileRun("u8_b[0] + u8_b[1]");
- CHECK_EQ(0xDD, result->Int32Value());
+ CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust());
}
@@ -3018,40 +3349,64 @@ THREADED_TEST(HiddenProperties) {
CHECK(obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 1503))
.FromJust());
- CHECK_EQ(1503,
- obj->GetPrivate(env.local(), key).ToLocalChecked()->Int32Value());
+ CHECK_EQ(1503, obj->GetPrivate(env.local(), key)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
CHECK(obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 2002))
.FromJust());
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), key).ToLocalChecked()->Int32Value());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), key)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
CcTest::heap()->CollectAllGarbage();
// Make sure we do not find the hidden property.
- CHECK(!obj->Has(empty));
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), key).ToLocalChecked()->Int32Value());
- CHECK(obj->Get(empty)->IsUndefined());
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), key).ToLocalChecked()->Int32Value());
- CHECK(obj->Set(empty, v8::Integer::New(isolate, 2003)));
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), key).ToLocalChecked()->Int32Value());
- CHECK_EQ(2003, obj->Get(empty)->Int32Value());
+ CHECK(!obj->Has(env.local(), empty).FromJust());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), key)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK(obj->Get(env.local(), empty).ToLocalChecked()->IsUndefined());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), key)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK(
+ obj->Set(env.local(), empty, v8::Integer::New(isolate, 2003)).FromJust());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), key)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(2003, obj->Get(env.local(), empty)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
CcTest::heap()->CollectAllGarbage();
// Add another property and delete it afterwards to force the object in
// slow case.
- CHECK(obj->Set(prop_name, v8::Integer::New(isolate, 2008)));
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), key).ToLocalChecked()->Int32Value());
- CHECK_EQ(2008, obj->Get(prop_name)->Int32Value());
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), key).ToLocalChecked()->Int32Value());
- CHECK(obj->Delete(prop_name));
- CHECK_EQ(2002,
- obj->GetPrivate(env.local(), key).ToLocalChecked()->Int32Value());
+ CHECK(obj->Set(env.local(), prop_name, v8::Integer::New(isolate, 2008))
+ .FromJust());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), key)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(2008, obj->Get(env.local(), prop_name)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), key)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
+ CHECK(obj->Delete(env.local(), prop_name).FromJust());
+ CHECK_EQ(2002, obj->GetPrivate(env.local(), key)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
CcTest::heap()->CollectAllGarbage();
@@ -3089,8 +3444,10 @@ THREADED_TEST(Regress97784) {
obj->SetPrivate(env.local(), key, v8::Integer::New(env->GetIsolate(), 42))
.FromJust());
ExpectFalse("set_called");
- CHECK_EQ(42,
- obj->GetPrivate(env.local(), key).ToLocalChecked()->Int32Value());
+ CHECK_EQ(42, obj->GetPrivate(env.local(), key)
+ .ToLocalChecked()
+ ->Int32Value(env.local())
+ .FromJust());
}
@@ -3099,9 +3456,9 @@ THREADED_TEST(External) {
int x = 3;
Local<v8::External> ext = v8::External::New(CcTest::isolate(), &x);
LocalContext env;
- env->Global()->Set(v8_str("ext"), ext);
+ CHECK(env->Global()->Set(env.local(), v8_str("ext"), ext).FromJust());
Local<Value> reext_obj = CompileRun("this.ext");
- v8::Handle<v8::External> reext = reext_obj.As<v8::External>();
+ v8::Local<v8::External> reext = reext_obj.As<v8::External>();
int* ptr = static_cast<int*>(reext->Value());
CHECK_EQ(x, 3);
*ptr = 10;
@@ -3397,7 +3754,7 @@ Local<v8::Object> NewObjectForIntKey(
v8::Isolate* isolate, const v8::Global<v8::ObjectTemplate>& templ,
int key) {
auto local = Local<v8::ObjectTemplate>::New(isolate, templ);
- auto obj = local->NewInstance();
+ auto obj = local->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
obj->SetAlignedPointerInInternalField(0, IntKeyToVoidPointer(key));
return obj;
}
@@ -3468,7 +3825,7 @@ void TestGlobalValueMap() {
map.Set(7, expected);
CHECK_EQ(1, static_cast<int>(map.Size()));
obj = map.Get(7);
- CHECK(expected->Equals(obj));
+ CHECK(expected->Equals(env.local(), obj).FromJust());
{
typename Map::PersistentValueReference ref = map.GetReference(7);
CHECK(expected->Equals(ref.NewLocal(isolate)));
@@ -3553,10 +3910,10 @@ TEST(PersistentValueVector) {
CHECK(!vector.IsEmpty());
CHECK_EQ(5, static_cast<int>(vector.Size()));
CHECK(obj3.IsEmpty());
- CHECK(obj1->Equals(vector.Get(0)));
- CHECK(obj1->Equals(vector.Get(2)));
- CHECK(obj1->Equals(vector.Get(4)));
- CHECK(obj2->Equals(vector.Get(1)));
+ CHECK(obj1->Equals(env.local(), vector.Get(0)).FromJust());
+ CHECK(obj1->Equals(env.local(), vector.Get(2)).FromJust());
+ CHECK(obj1->Equals(env.local(), vector.Get(4)).FromJust());
+ CHECK(obj2->Equals(env.local(), vector.Get(1)).FromJust());
CHECK_EQ(5 + handle_count, global_handles->global_handles_count());
@@ -3707,9 +4064,11 @@ THREADED_TEST(ApiObjectGroups) {
{
HandleScope scope(iso);
CHECK(Local<Object>::New(iso, g1s2.handle.As<Object>())
- ->Set(0, Local<Value>::New(iso, g2s2.handle)));
+ ->Set(env.local(), 0, Local<Value>::New(iso, g2s2.handle))
+ .FromJust());
CHECK(Local<Object>::New(iso, g2s1.handle.As<Object>())
- ->Set(0, Local<Value>::New(iso, g1s1.handle)));
+ ->Set(env.local(), 0, Local<Value>::New(iso, g1s1.handle))
+ .FromJust());
}
{
@@ -3783,8 +4142,8 @@ THREADED_TEST(ApiObjectGroupsForSubtypes) {
{
HandleScope scope(iso);
g1s1.handle.Reset(iso, Object::New(iso));
- g1s2.handle.Reset(iso, String::NewFromUtf8(iso, "foo1"));
- g1c1.handle.Reset(iso, String::NewFromUtf8(iso, "foo2"));
+ g1s2.handle.Reset(iso, v8_str("foo1"));
+ g1c1.handle.Reset(iso, v8_str("foo2"));
g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback,
v8::WeakCallbackType::kParameter);
g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback,
@@ -3793,8 +4152,8 @@ THREADED_TEST(ApiObjectGroupsForSubtypes) {
v8::WeakCallbackType::kParameter);
g2s1.handle.Reset(iso, Object::New(iso));
- g2s2.handle.Reset(iso, String::NewFromUtf8(iso, "foo3"));
- g2c1.handle.Reset(iso, String::NewFromUtf8(iso, "foo4"));
+ g2s2.handle.Reset(iso, v8_str("foo3"));
+ g2c1.handle.Reset(iso, v8_str("foo4"));
g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback,
v8::WeakCallbackType::kParameter);
g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback,
@@ -3810,9 +4169,11 @@ THREADED_TEST(ApiObjectGroupsForSubtypes) {
{
HandleScope scope(iso);
CHECK(Local<Object>::New(iso, g1s1.handle)
- ->Set(0, Local<Object>::New(iso, g2s1.handle)));
+ ->Set(env.local(), 0, Local<Object>::New(iso, g2s1.handle))
+ .FromJust());
CHECK(Local<Object>::New(iso, g2s1.handle)
- ->Set(0, Local<Object>::New(iso, g1s1.handle)));
+ ->Set(env.local(), 0, Local<Object>::New(iso, g1s1.handle))
+ .FromJust());
}
{
@@ -4048,15 +4409,18 @@ TEST(ApiObjectGroupsCycleForScavenger) {
iso->SetObjectGroupId(g1s1.handle, UniqueId(1));
iso->SetObjectGroupId(g1s2.handle, UniqueId(1));
Local<Object>::New(iso, g1s1.handle.As<Object>())
- ->Set(v8_str("x"), Local<Value>::New(iso, g2s1.handle));
+ ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g2s1.handle))
+ .FromJust();
iso->SetObjectGroupId(g2s1.handle, UniqueId(2));
iso->SetObjectGroupId(g2s2.handle, UniqueId(2));
Local<Object>::New(iso, g2s1.handle.As<Object>())
- ->Set(v8_str("x"), Local<Value>::New(iso, g3s1.handle));
+ ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g3s1.handle))
+ .FromJust();
iso->SetObjectGroupId(g3s1.handle, UniqueId(3));
iso->SetObjectGroupId(g3s2.handle, UniqueId(3));
Local<Object>::New(iso, g3s1.handle.As<Object>())
- ->Set(v8_str("x"), Local<Value>::New(iso, g1s1.handle));
+ ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g1s1.handle))
+ .FromJust();
}
v8::internal::Heap* heap =
@@ -4083,15 +4447,18 @@ TEST(ApiObjectGroupsCycleForScavenger) {
iso->SetObjectGroupId(g1s1.handle, UniqueId(1));
iso->SetObjectGroupId(g1s2.handle, UniqueId(1));
Local<Object>::New(iso, g1s1.handle.As<Object>())
- ->Set(v8_str("x"), Local<Value>::New(iso, g2s1.handle));
+ ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g2s1.handle))
+ .FromJust();
iso->SetObjectGroupId(g2s1.handle, UniqueId(2));
iso->SetObjectGroupId(g2s2.handle, UniqueId(2));
Local<Object>::New(iso, g2s1.handle.As<Object>())
- ->Set(v8_str("x"), Local<Value>::New(iso, g3s1.handle));
+ ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g3s1.handle))
+ .FromJust();
iso->SetObjectGroupId(g3s1.handle, UniqueId(3));
iso->SetObjectGroupId(g3s2.handle, UniqueId(3));
Local<Object>::New(iso, g3s1.handle.As<Object>())
- ->Set(v8_str("x"), Local<Value>::New(iso, g1s1.handle));
+ ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g1s1.handle))
+ .FromJust();
}
heap->CollectAllGarbage();
@@ -4106,7 +4473,7 @@ THREADED_TEST(ScriptException) {
v8::HandleScope scope(env->GetIsolate());
Local<Script> script = v8_compile("throw 'panama!';");
v8::TryCatch try_catch(env->GetIsolate());
- Local<Value> result = script->Run();
+ v8::MaybeLocal<Value> result = script->Run(env.local());
CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
String::Utf8Value exception_value(try_catch.Exception());
@@ -4124,19 +4491,26 @@ TEST(TryCatchCustomException) {
"(function f() { throw new CustomError(); })();");
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()
- ->ToObject(isolate)
- ->Get(v8_str("a"))
- ->Equals(v8_str("b")));
+ ->ToObject(env.local())
+ .ToLocalChecked()
+ ->Get(env.local(), v8_str("a"))
+ .ToLocalChecked()
+ ->Equals(env.local(), v8_str("b"))
+ .FromJust());
}
bool message_received;
-static void check_message_0(v8::Handle<v8::Message> message,
- v8::Handle<Value> data) {
- CHECK_EQ(5.76, data->NumberValue());
- CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue());
+static void check_message_0(v8::Local<v8::Message> message,
+ v8::Local<Value> data) {
+ CHECK_EQ(5.76, data->NumberValue(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
+ CHECK_EQ(6.75, message->GetScriptOrigin()
+ .ResourceName()
+ ->NumberValue(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
CHECK(!message->IsSharedCrossOrigin());
message_received = true;
}
@@ -4147,19 +4521,20 @@ THREADED_TEST(MessageHandler0) {
v8::HandleScope scope(CcTest::isolate());
CHECK(!message_received);
LocalContext context;
- v8::V8::AddMessageListener(check_message_0, v8_num(5.76));
- v8::Handle<v8::Script> script = CompileWithOrigin("throw 'error'", "6.75");
- script->Run();
+ CcTest::isolate()->AddMessageListener(check_message_0, v8_num(5.76));
+ v8::Local<v8::Script> script = CompileWithOrigin("throw 'error'", "6.75");
+ CHECK(script->Run(context.local()).IsEmpty());
CHECK(message_received);
// clear out the message listener
- v8::V8::RemoveMessageListeners(check_message_0);
+ CcTest::isolate()->RemoveMessageListeners(check_message_0);
}
-static void check_message_1(v8::Handle<v8::Message> message,
- v8::Handle<Value> data) {
+static void check_message_1(v8::Local<v8::Message> message,
+ v8::Local<Value> data) {
CHECK(data->IsNumber());
- CHECK_EQ(1337, data->Int32Value());
+ CHECK_EQ(1337,
+ data->Int32Value(CcTest::isolate()->GetCurrentContext()).FromJust());
CHECK(!message->IsSharedCrossOrigin());
message_received = true;
}
@@ -4169,17 +4544,17 @@ TEST(MessageHandler1) {
message_received = false;
v8::HandleScope scope(CcTest::isolate());
CHECK(!message_received);
- v8::V8::AddMessageListener(check_message_1);
+ CcTest::isolate()->AddMessageListener(check_message_1);
LocalContext context;
CompileRun("throw 1337;");
CHECK(message_received);
// clear out the message listener
- v8::V8::RemoveMessageListeners(check_message_1);
+ CcTest::isolate()->RemoveMessageListeners(check_message_1);
}
-static void check_message_2(v8::Handle<v8::Message> message,
- v8::Handle<Value> data) {
+static void check_message_2(v8::Local<v8::Message> message,
+ v8::Local<Value> data) {
LocalContext context;
CHECK(data->IsObject());
v8::Local<v8::Value> hidden_property =
@@ -4188,7 +4563,9 @@ static void check_message_2(v8::Handle<v8::Message> message,
context.local(),
v8::Private::ForApi(CcTest::isolate(), v8_str("hidden key")))
.ToLocalChecked();
- CHECK(v8_str("hidden value")->Equals(hidden_property));
+ CHECK(v8_str("hidden value")
+ ->Equals(context.local(), hidden_property)
+ .FromJust());
CHECK(!message->IsSharedCrossOrigin());
message_received = true;
}
@@ -4198,7 +4575,7 @@ TEST(MessageHandler2) {
message_received = false;
v8::HandleScope scope(CcTest::isolate());
CHECK(!message_received);
- v8::V8::AddMessageListener(check_message_2);
+ CcTest::isolate()->AddMessageListener(check_message_2);
LocalContext context;
v8::Local<v8::Value> error = v8::Exception::Error(v8_str("custom error"));
v8::Object::Cast(*error)
@@ -4206,22 +4583,30 @@ TEST(MessageHandler2) {
v8::Private::ForApi(CcTest::isolate(), v8_str("hidden key")),
v8_str("hidden value"))
.FromJust();
- context->Global()->Set(v8_str("error"), error);
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("error"), error)
+ .FromJust());
CompileRun("throw error;");
CHECK(message_received);
// clear out the message listener
- v8::V8::RemoveMessageListeners(check_message_2);
+ CcTest::isolate()->RemoveMessageListeners(check_message_2);
}
-static void check_message_3(v8::Handle<v8::Message> message,
- v8::Handle<Value> data) {
+static void check_message_3(v8::Local<v8::Message> message,
+ v8::Local<Value> data) {
CHECK(message->IsSharedCrossOrigin());
CHECK(message->GetScriptOrigin().Options().IsSharedCrossOrigin());
CHECK(message->GetScriptOrigin().Options().IsEmbedderDebugScript());
CHECK(message->GetScriptOrigin().Options().IsOpaque());
- CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue());
- CHECK_EQ(7.40, message->GetScriptOrigin().SourceMapUrl()->NumberValue());
+ CHECK_EQ(6.75, message->GetScriptOrigin()
+ .ResourceName()
+ ->NumberValue(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
+ CHECK_EQ(7.40, message->GetScriptOrigin()
+ .SourceMapUrl()
+ ->NumberValue(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
message_received = true;
}
@@ -4231,25 +4616,29 @@ TEST(MessageHandler3) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
CHECK(!message_received);
- v8::V8::AddMessageListener(check_message_3);
+ isolate->AddMessageListener(check_message_3);
LocalContext context;
v8::ScriptOrigin origin = v8::ScriptOrigin(
v8_str("6.75"), v8::Integer::New(isolate, 1),
- v8::Integer::New(isolate, 2), v8::True(isolate), Handle<v8::Integer>(),
+ v8::Integer::New(isolate, 2), v8::True(isolate), Local<v8::Integer>(),
v8::True(isolate), v8_str("7.40"), v8::True(isolate));
- v8::Handle<v8::Script> script =
- Script::Compile(v8_str("throw 'error'"), &origin);
- script->Run();
+ v8::Local<v8::Script> script =
+ Script::Compile(context.local(), v8_str("throw 'error'"), &origin)
+ .ToLocalChecked();
+ CHECK(script->Run(context.local()).IsEmpty());
CHECK(message_received);
// clear out the message listener
- v8::V8::RemoveMessageListeners(check_message_3);
+ isolate->RemoveMessageListeners(check_message_3);
}
-static void check_message_4(v8::Handle<v8::Message> message,
- v8::Handle<Value> data) {
+static void check_message_4(v8::Local<v8::Message> message,
+ v8::Local<Value> data) {
CHECK(!message->IsSharedCrossOrigin());
- CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue());
+ CHECK_EQ(6.75, message->GetScriptOrigin()
+ .ResourceName()
+ ->NumberValue(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
message_received = true;
}
@@ -4259,32 +4648,39 @@ TEST(MessageHandler4) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
CHECK(!message_received);
- v8::V8::AddMessageListener(check_message_4);
+ isolate->AddMessageListener(check_message_4);
LocalContext context;
v8::ScriptOrigin origin =
v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
v8::Integer::New(isolate, 2), v8::False(isolate));
- v8::Handle<v8::Script> script =
- Script::Compile(v8_str("throw 'error'"), &origin);
- script->Run();
+ v8::Local<v8::Script> script =
+ Script::Compile(context.local(), v8_str("throw 'error'"), &origin)
+ .ToLocalChecked();
+ CHECK(script->Run(context.local()).IsEmpty());
CHECK(message_received);
// clear out the message listener
- v8::V8::RemoveMessageListeners(check_message_4);
+ isolate->RemoveMessageListeners(check_message_4);
}
-static void check_message_5a(v8::Handle<v8::Message> message,
- v8::Handle<Value> data) {
+static void check_message_5a(v8::Local<v8::Message> message,
+ v8::Local<Value> data) {
CHECK(message->IsSharedCrossOrigin());
- CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue());
+ CHECK_EQ(6.75, message->GetScriptOrigin()
+ .ResourceName()
+ ->NumberValue(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
message_received = true;
}
-static void check_message_5b(v8::Handle<v8::Message> message,
- v8::Handle<Value> data) {
+static void check_message_5b(v8::Local<v8::Message> message,
+ v8::Local<Value> data) {
CHECK(!message->IsSharedCrossOrigin());
- CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue());
+ CHECK_EQ(6.75, message->GetScriptOrigin()
+ .ResourceName()
+ ->NumberValue(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
message_received = true;
}
@@ -4294,28 +4690,30 @@ TEST(MessageHandler5) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
CHECK(!message_received);
- v8::V8::AddMessageListener(check_message_5a);
+ isolate->AddMessageListener(check_message_5a);
LocalContext context;
v8::ScriptOrigin origin1 =
v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
v8::Integer::New(isolate, 2), v8::True(isolate));
- v8::Handle<v8::Script> script =
- Script::Compile(v8_str("throw 'error'"), &origin1);
- script->Run();
+ v8::Local<v8::Script> script =
+ Script::Compile(context.local(), v8_str("throw 'error'"), &origin1)
+ .ToLocalChecked();
+ CHECK(script->Run(context.local()).IsEmpty());
CHECK(message_received);
// clear out the message listener
- v8::V8::RemoveMessageListeners(check_message_5a);
+ isolate->RemoveMessageListeners(check_message_5a);
message_received = false;
- v8::V8::AddMessageListener(check_message_5b);
+ isolate->AddMessageListener(check_message_5b);
v8::ScriptOrigin origin2 =
v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
v8::Integer::New(isolate, 2), v8::False(isolate));
- script = Script::Compile(v8_str("throw 'error'"), &origin2);
- script->Run();
+ script = Script::Compile(context.local(), v8_str("throw 'error'"), &origin2)
+ .ToLocalChecked();
+ CHECK(script->Run(context.local()).IsEmpty());
CHECK(message_received);
// clear out the message listener
- v8::V8::RemoveMessageListeners(check_message_5b);
+ isolate->RemoveMessageListeners(check_message_5b);
}
@@ -4333,7 +4731,7 @@ TEST(NativeWeakMap) {
CHECK(weak_map->Get(local1)->IsUndefined());
weak_map->Set(local1, value);
CHECK(weak_map->Has(local1));
- CHECK(value->Equals(weak_map->Get(local1)));
+ CHECK(value->Equals(env.local(), weak_map->Get(local1)).FromJust());
WeakCallCounter counter(1234);
WeakCallCounterAndPersistent<Value> o1(&counter);
@@ -4358,18 +4756,24 @@ TEST(NativeWeakMap) {
CHECK(weak_map->Has(obj2));
CHECK(weak_map->Has(sym1));
- CHECK(value->Equals(weak_map->Get(local1)));
- CHECK(value->Equals(weak_map->Get(obj1)));
- CHECK(value->Equals(weak_map->Get(obj2)));
- CHECK(value->Equals(weak_map->Get(sym1)));
+ CHECK(value->Equals(env.local(), weak_map->Get(local1)).FromJust());
+ CHECK(value->Equals(env.local(), weak_map->Get(obj1)).FromJust());
+ CHECK(value->Equals(env.local(), weak_map->Get(obj2)).FromJust());
+ CHECK(value->Equals(env.local(), weak_map->Get(sym1)).FromJust());
}
CcTest::heap()->CollectAllGarbage();
{
HandleScope scope(isolate);
- CHECK(value->Equals(weak_map->Get(local1)));
- CHECK(value->Equals(weak_map->Get(Local<Value>::New(isolate, o1.handle))));
- CHECK(value->Equals(weak_map->Get(Local<Value>::New(isolate, o2.handle))));
- CHECK(value->Equals(weak_map->Get(Local<Value>::New(isolate, s1.handle))));
+ CHECK(value->Equals(env.local(), weak_map->Get(local1)).FromJust());
+ CHECK(value->Equals(env.local(),
+ weak_map->Get(Local<Value>::New(isolate, o1.handle)))
+ .FromJust());
+ CHECK(value->Equals(env.local(),
+ weak_map->Get(Local<Value>::New(isolate, o2.handle)))
+ .FromJust());
+ CHECK(value->Equals(env.local(),
+ weak_map->Get(Local<Value>::New(isolate, s1.handle)))
+ .FromJust());
}
o1.handle.SetWeak(&o1, &WeakPointerCallback,
@@ -4386,7 +4790,7 @@ TEST(NativeWeakMap) {
CHECK(o2.handle.IsEmpty());
CHECK(s1.handle.IsEmpty());
- CHECK(value->Equals(weak_map->Get(local1)));
+ CHECK(value->Equals(env.local(), weak_map->Get(local1)).FromJust());
CHECK(weak_map->Delete(local1));
CHECK(!weak_map->Has(local1));
CHECK(weak_map->Get(local1)->IsUndefined());
@@ -4397,30 +4801,71 @@ THREADED_TEST(GetSetProperty) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- context->Global()->Set(v8_str("foo"), v8_num(14));
- context->Global()->Set(v8_str("12"), v8_num(92));
- context->Global()->Set(v8::Integer::New(isolate, 16), v8_num(32));
- context->Global()->Set(v8_num(13), v8_num(56));
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("foo"), v8_num(14))
+ .FromJust());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("12"), v8_num(92))
+ .FromJust());
+ CHECK(context->Global()
+ ->Set(context.local(), v8::Integer::New(isolate, 16), v8_num(32))
+ .FromJust());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_num(13), v8_num(56))
+ .FromJust());
Local<Value> foo = CompileRun("this.foo");
- CHECK_EQ(14, foo->Int32Value());
+ CHECK_EQ(14, foo->Int32Value(context.local()).FromJust());
Local<Value> twelve = CompileRun("this[12]");
- CHECK_EQ(92, twelve->Int32Value());
+ CHECK_EQ(92, twelve->Int32Value(context.local()).FromJust());
Local<Value> sixteen = CompileRun("this[16]");
- CHECK_EQ(32, sixteen->Int32Value());
+ CHECK_EQ(32, sixteen->Int32Value(context.local()).FromJust());
Local<Value> thirteen = CompileRun("this[13]");
- CHECK_EQ(56, thirteen->Int32Value());
- CHECK_EQ(92,
- context->Global()->Get(v8::Integer::New(isolate, 12))->Int32Value());
- CHECK_EQ(92, context->Global()->Get(v8_str("12"))->Int32Value());
- CHECK_EQ(92, context->Global()->Get(v8_num(12))->Int32Value());
- CHECK_EQ(32,
- context->Global()->Get(v8::Integer::New(isolate, 16))->Int32Value());
- CHECK_EQ(32, context->Global()->Get(v8_str("16"))->Int32Value());
- CHECK_EQ(32, context->Global()->Get(v8_num(16))->Int32Value());
- CHECK_EQ(56,
- context->Global()->Get(v8::Integer::New(isolate, 13))->Int32Value());
- CHECK_EQ(56, context->Global()->Get(v8_str("13"))->Int32Value());
- CHECK_EQ(56, context->Global()->Get(v8_num(13))->Int32Value());
+ CHECK_EQ(56, thirteen->Int32Value(context.local()).FromJust());
+ CHECK_EQ(92, context->Global()
+ ->Get(context.local(), v8::Integer::New(isolate, 12))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(92, context->Global()
+ ->Get(context.local(), v8_str("12"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(92, context->Global()
+ ->Get(context.local(), v8_num(12))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(32, context->Global()
+ ->Get(context.local(), v8::Integer::New(isolate, 16))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(32, context->Global()
+ ->Get(context.local(), v8_str("16"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(32, context->Global()
+ ->Get(context.local(), v8_num(16))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(56, context->Global()
+ ->Get(context.local(), v8::Integer::New(isolate, 13))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(56, context->Global()
+ ->Get(context.local(), v8_str("13"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(56, context->Global()
+ ->Get(context.local(), v8_num(13))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
}
@@ -4429,38 +4874,78 @@ THREADED_TEST(PropertyAttributes) {
v8::HandleScope scope(context->GetIsolate());
// none
Local<String> prop = v8_str("none");
- context->Global()->Set(prop, v8_num(7));
- CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop));
+ CHECK(context->Global()->Set(context.local(), prop, v8_num(7)).FromJust());
+ CHECK_EQ(v8::None, context->Global()
+ ->GetPropertyAttributes(context.local(), prop)
+ .FromJust());
// read-only
prop = v8_str("read_only");
- context->Global()->ForceSet(prop, v8_num(7), v8::ReadOnly);
- CHECK_EQ(7, context->Global()->Get(prop)->Int32Value());
- CHECK_EQ(v8::ReadOnly, context->Global()->GetPropertyAttributes(prop));
+ context->Global()
+ ->DefineOwnProperty(context.local(), prop, v8_num(7), v8::ReadOnly)
+ .FromJust();
+ CHECK_EQ(7, context->Global()
+ ->Get(context.local(), prop)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(v8::ReadOnly, context->Global()
+ ->GetPropertyAttributes(context.local(), prop)
+ .FromJust());
CompileRun("read_only = 9");
- CHECK_EQ(7, context->Global()->Get(prop)->Int32Value());
- context->Global()->Set(prop, v8_num(10));
- CHECK_EQ(7, context->Global()->Get(prop)->Int32Value());
+ CHECK_EQ(7, context->Global()
+ ->Get(context.local(), prop)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(context->Global()->Set(context.local(), prop, v8_num(10)).FromJust());
+ CHECK_EQ(7, context->Global()
+ ->Get(context.local(), prop)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
// dont-delete
prop = v8_str("dont_delete");
- context->Global()->ForceSet(prop, v8_num(13), v8::DontDelete);
- CHECK_EQ(13, context->Global()->Get(prop)->Int32Value());
+ context->Global()
+ ->DefineOwnProperty(context.local(), prop, v8_num(13), v8::DontDelete)
+ .FromJust();
+ CHECK_EQ(13, context->Global()
+ ->Get(context.local(), prop)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
CompileRun("delete dont_delete");
- CHECK_EQ(13, context->Global()->Get(prop)->Int32Value());
- CHECK_EQ(v8::DontDelete, context->Global()->GetPropertyAttributes(prop));
+ CHECK_EQ(13, context->Global()
+ ->Get(context.local(), prop)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(v8::DontDelete, context->Global()
+ ->GetPropertyAttributes(context.local(), prop)
+ .FromJust());
// dont-enum
prop = v8_str("dont_enum");
- context->Global()->ForceSet(prop, v8_num(28), v8::DontEnum);
- CHECK_EQ(v8::DontEnum, context->Global()->GetPropertyAttributes(prop));
+ context->Global()
+ ->DefineOwnProperty(context.local(), prop, v8_num(28), v8::DontEnum)
+ .FromJust();
+ CHECK_EQ(v8::DontEnum, context->Global()
+ ->GetPropertyAttributes(context.local(), prop)
+ .FromJust());
// absent
prop = v8_str("absent");
- CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop));
+ CHECK_EQ(v8::None, context->Global()
+ ->GetPropertyAttributes(context.local(), prop)
+ .FromJust());
Local<Value> fake_prop = v8_num(1);
- CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(fake_prop));
+ CHECK_EQ(v8::None, context->Global()
+ ->GetPropertyAttributes(context.local(), fake_prop)
+ .FromJust());
// exception
TryCatch try_catch(context->GetIsolate());
Local<Value> exception =
CompileRun("({ toString: function() { throw 'exception';} })");
- CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(exception));
+ CHECK(context->Global()
+ ->GetPropertyAttributes(context.local(), exception)
+ .IsNothing());
CHECK(try_catch.HasCaught());
String::Utf8Value exception_value(try_catch.Exception());
CHECK_EQ(0, strcmp("exception", *exception_value));
@@ -4473,22 +4958,34 @@ THREADED_TEST(Array) {
v8::HandleScope scope(context->GetIsolate());
Local<v8::Array> array = v8::Array::New(context->GetIsolate());
CHECK_EQ(0u, array->Length());
- CHECK(array->Get(0)->IsUndefined());
- CHECK(!array->Has(0));
- CHECK(array->Get(100)->IsUndefined());
- CHECK(!array->Has(100));
- array->Set(2, v8_num(7));
+ CHECK(array->Get(context.local(), 0).ToLocalChecked()->IsUndefined());
+ CHECK(!array->Has(context.local(), 0).FromJust());
+ CHECK(array->Get(context.local(), 100).ToLocalChecked()->IsUndefined());
+ CHECK(!array->Has(context.local(), 100).FromJust());
+ CHECK(array->Set(context.local(), 2, v8_num(7)).FromJust());
CHECK_EQ(3u, array->Length());
- CHECK(!array->Has(0));
- CHECK(!array->Has(1));
- CHECK(array->Has(2));
- CHECK_EQ(7, array->Get(2)->Int32Value());
+ CHECK(!array->Has(context.local(), 0).FromJust());
+ CHECK(!array->Has(context.local(), 1).FromJust());
+ CHECK(array->Has(context.local(), 2).FromJust());
+ CHECK_EQ(7, array->Get(context.local(), 2)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
Local<Value> obj = CompileRun("[1, 2, 3]");
Local<v8::Array> arr = obj.As<v8::Array>();
CHECK_EQ(3u, arr->Length());
- CHECK_EQ(1, arr->Get(0)->Int32Value());
- CHECK_EQ(2, arr->Get(1)->Int32Value());
- CHECK_EQ(3, arr->Get(2)->Int32Value());
+ CHECK_EQ(1, arr->Get(context.local(), 0)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(2, arr->Get(context.local(), 1)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(3, arr->Get(context.local(), 2)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
array = v8::Array::New(context->GetIsolate(), 27);
CHECK_EQ(27u, array->Length());
array = v8::Array::New(context->GetIsolate(), -27);
@@ -4500,7 +4997,10 @@ void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::EscapableHandleScope scope(args.GetIsolate());
ApiTestFuzzer::Fuzz();
Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length());
- for (int i = 0; i < args.Length(); i++) result->Set(i, args[i]);
+ for (int i = 0; i < args.Length(); i++) {
+ CHECK(result->Set(CcTest::isolate()->GetCurrentContext(), i, args[i])
+ .FromJust());
+ }
args.GetReturnValue().Set(scope.Escape(result));
}
@@ -4519,28 +5019,58 @@ THREADED_TEST(Vector) {
const char* fun2 = "f(11)";
Local<v8::Array> a1 = CompileRun(fun2).As<v8::Array>();
CHECK_EQ(1u, a1->Length());
- CHECK_EQ(11, a1->Get(0)->Int32Value());
+ CHECK_EQ(11, a1->Get(context.local(), 0)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
const char* fun3 = "f(12, 13)";
Local<v8::Array> a2 = CompileRun(fun3).As<v8::Array>();
CHECK_EQ(2u, a2->Length());
- CHECK_EQ(12, a2->Get(0)->Int32Value());
- CHECK_EQ(13, a2->Get(1)->Int32Value());
+ CHECK_EQ(12, a2->Get(context.local(), 0)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(13, a2->Get(context.local(), 1)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
const char* fun4 = "f(14, 15, 16)";
Local<v8::Array> a3 = CompileRun(fun4).As<v8::Array>();
CHECK_EQ(3u, a3->Length());
- CHECK_EQ(14, a3->Get(0)->Int32Value());
- CHECK_EQ(15, a3->Get(1)->Int32Value());
- CHECK_EQ(16, a3->Get(2)->Int32Value());
+ CHECK_EQ(14, a3->Get(context.local(), 0)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(15, a3->Get(context.local(), 1)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(16, a3->Get(context.local(), 2)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
const char* fun5 = "f(17, 18, 19, 20)";
Local<v8::Array> a4 = CompileRun(fun5).As<v8::Array>();
CHECK_EQ(4u, a4->Length());
- CHECK_EQ(17, a4->Get(0)->Int32Value());
- CHECK_EQ(18, a4->Get(1)->Int32Value());
- CHECK_EQ(19, a4->Get(2)->Int32Value());
- CHECK_EQ(20, a4->Get(3)->Int32Value());
+ CHECK_EQ(17, a4->Get(context.local(), 0)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(18, a4->Get(context.local(), 1)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(19, a4->Get(context.local(), 2)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(20, a4->Get(context.local(), 3)
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
}
@@ -4563,67 +5093,126 @@ THREADED_TEST(FunctionCall) {
" 'use strict';"
" return this;"
"}");
- Local<Function> Foo =
- Local<Function>::Cast(context->Global()->Get(v8_str("Foo")));
- Local<Function> ReturnThisSloppy =
- Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisSloppy")));
- Local<Function> ReturnThisStrict =
- Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisStrict")));
-
- v8::Handle<Value>* args0 = NULL;
- Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->Call(Foo, 0, args0));
+ Local<Function> Foo = Local<Function>::Cast(
+ context->Global()->Get(context.local(), v8_str("Foo")).ToLocalChecked());
+ Local<Function> ReturnThisSloppy = Local<Function>::Cast(
+ context->Global()
+ ->Get(context.local(), v8_str("ReturnThisSloppy"))
+ .ToLocalChecked());
+ Local<Function> ReturnThisStrict = Local<Function>::Cast(
+ context->Global()
+ ->Get(context.local(), v8_str("ReturnThisStrict"))
+ .ToLocalChecked());
+
+ v8::Local<Value>* args0 = NULL;
+ Local<v8::Array> a0 = Local<v8::Array>::Cast(
+ Foo->Call(context.local(), Foo, 0, args0).ToLocalChecked());
CHECK_EQ(0u, a0->Length());
- v8::Handle<Value> args1[] = {v8_num(1.1)};
- Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->Call(Foo, 1, args1));
+ v8::Local<Value> args1[] = {v8_num(1.1)};
+ Local<v8::Array> a1 = Local<v8::Array>::Cast(
+ Foo->Call(context.local(), Foo, 1, args1).ToLocalChecked());
CHECK_EQ(1u, a1->Length());
- CHECK_EQ(1.1, a1->Get(v8::Integer::New(isolate, 0))->NumberValue());
-
- v8::Handle<Value> args2[] = {v8_num(2.2), v8_num(3.3)};
- Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->Call(Foo, 2, args2));
+ CHECK_EQ(1.1, a1->Get(context.local(), v8::Integer::New(isolate, 0))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+
+ v8::Local<Value> args2[] = {v8_num(2.2), v8_num(3.3)};
+ Local<v8::Array> a2 = Local<v8::Array>::Cast(
+ Foo->Call(context.local(), Foo, 2, args2).ToLocalChecked());
CHECK_EQ(2u, a2->Length());
- CHECK_EQ(2.2, a2->Get(v8::Integer::New(isolate, 0))->NumberValue());
- CHECK_EQ(3.3, a2->Get(v8::Integer::New(isolate, 1))->NumberValue());
-
- v8::Handle<Value> args3[] = {v8_num(4.4), v8_num(5.5), v8_num(6.6)};
- Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->Call(Foo, 3, args3));
+ CHECK_EQ(2.2, a2->Get(context.local(), v8::Integer::New(isolate, 0))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(3.3, a2->Get(context.local(), v8::Integer::New(isolate, 1))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+
+ v8::Local<Value> args3[] = {v8_num(4.4), v8_num(5.5), v8_num(6.6)};
+ Local<v8::Array> a3 = Local<v8::Array>::Cast(
+ Foo->Call(context.local(), Foo, 3, args3).ToLocalChecked());
CHECK_EQ(3u, a3->Length());
- CHECK_EQ(4.4, a3->Get(v8::Integer::New(isolate, 0))->NumberValue());
- CHECK_EQ(5.5, a3->Get(v8::Integer::New(isolate, 1))->NumberValue());
- CHECK_EQ(6.6, a3->Get(v8::Integer::New(isolate, 2))->NumberValue());
-
- v8::Handle<Value> args4[] = {v8_num(7.7), v8_num(8.8), v8_num(9.9),
- v8_num(10.11)};
- Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->Call(Foo, 4, args4));
+ CHECK_EQ(4.4, a3->Get(context.local(), v8::Integer::New(isolate, 0))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(5.5, a3->Get(context.local(), v8::Integer::New(isolate, 1))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(6.6, a3->Get(context.local(), v8::Integer::New(isolate, 2))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+
+ v8::Local<Value> args4[] = {v8_num(7.7), v8_num(8.8), v8_num(9.9),
+ v8_num(10.11)};
+ Local<v8::Array> a4 = Local<v8::Array>::Cast(
+ Foo->Call(context.local(), Foo, 4, args4).ToLocalChecked());
CHECK_EQ(4u, a4->Length());
- CHECK_EQ(7.7, a4->Get(v8::Integer::New(isolate, 0))->NumberValue());
- CHECK_EQ(8.8, a4->Get(v8::Integer::New(isolate, 1))->NumberValue());
- CHECK_EQ(9.9, a4->Get(v8::Integer::New(isolate, 2))->NumberValue());
- CHECK_EQ(10.11, a4->Get(v8::Integer::New(isolate, 3))->NumberValue());
-
- Local<v8::Value> r1 = ReturnThisSloppy->Call(v8::Undefined(isolate), 0, NULL);
+ CHECK_EQ(7.7, a4->Get(context.local(), v8::Integer::New(isolate, 0))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(8.8, a4->Get(context.local(), v8::Integer::New(isolate, 1))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(9.9, a4->Get(context.local(), v8::Integer::New(isolate, 2))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(10.11, a4->Get(context.local(), v8::Integer::New(isolate, 3))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+
+ Local<v8::Value> r1 =
+ ReturnThisSloppy->Call(context.local(), v8::Undefined(isolate), 0, NULL)
+ .ToLocalChecked();
CHECK(r1->StrictEquals(context->Global()));
- Local<v8::Value> r2 = ReturnThisSloppy->Call(v8::Null(isolate), 0, NULL);
+ Local<v8::Value> r2 =
+ ReturnThisSloppy->Call(context.local(), v8::Null(isolate), 0, NULL)
+ .ToLocalChecked();
CHECK(r2->StrictEquals(context->Global()));
- Local<v8::Value> r3 = ReturnThisSloppy->Call(v8_num(42), 0, NULL);
+ Local<v8::Value> r3 =
+ ReturnThisSloppy->Call(context.local(), v8_num(42), 0, NULL)
+ .ToLocalChecked();
CHECK(r3->IsNumberObject());
CHECK_EQ(42.0, r3.As<v8::NumberObject>()->ValueOf());
- Local<v8::Value> r4 = ReturnThisSloppy->Call(v8_str("hello"), 0, NULL);
+ Local<v8::Value> r4 =
+ ReturnThisSloppy->Call(context.local(), v8_str("hello"), 0, NULL)
+ .ToLocalChecked();
CHECK(r4->IsStringObject());
CHECK(r4.As<v8::StringObject>()->ValueOf()->StrictEquals(v8_str("hello")));
- Local<v8::Value> r5 = ReturnThisSloppy->Call(v8::True(isolate), 0, NULL);
+ Local<v8::Value> r5 =
+ ReturnThisSloppy->Call(context.local(), v8::True(isolate), 0, NULL)
+ .ToLocalChecked();
CHECK(r5->IsBooleanObject());
CHECK(r5.As<v8::BooleanObject>()->ValueOf());
- Local<v8::Value> r6 = ReturnThisStrict->Call(v8::Undefined(isolate), 0, NULL);
+ Local<v8::Value> r6 =
+ ReturnThisStrict->Call(context.local(), v8::Undefined(isolate), 0, NULL)
+ .ToLocalChecked();
CHECK(r6->IsUndefined());
- Local<v8::Value> r7 = ReturnThisStrict->Call(v8::Null(isolate), 0, NULL);
+ Local<v8::Value> r7 =
+ ReturnThisStrict->Call(context.local(), v8::Null(isolate), 0, NULL)
+ .ToLocalChecked();
CHECK(r7->IsNull());
- Local<v8::Value> r8 = ReturnThisStrict->Call(v8_num(42), 0, NULL);
+ Local<v8::Value> r8 =
+ ReturnThisStrict->Call(context.local(), v8_num(42), 0, NULL)
+ .ToLocalChecked();
CHECK(r8->StrictEquals(v8_num(42)));
- Local<v8::Value> r9 = ReturnThisStrict->Call(v8_str("hello"), 0, NULL);
+ Local<v8::Value> r9 =
+ ReturnThisStrict->Call(context.local(), v8_str("hello"), 0, NULL)
+ .ToLocalChecked();
CHECK(r9->StrictEquals(v8_str("hello")));
- Local<v8::Value> r10 = ReturnThisStrict->Call(v8::True(isolate), 0, NULL);
+ Local<v8::Value> r10 =
+ ReturnThisStrict->Call(context.local(), v8::True(isolate), 0, NULL)
+ .ToLocalChecked();
CHECK(r10->StrictEquals(v8::True(isolate)));
}
@@ -4640,47 +5229,74 @@ THREADED_TEST(ConstructCall) {
" }"
" return result;"
"}");
- Local<Function> Foo =
- Local<Function>::Cast(context->Global()->Get(v8_str("Foo")));
+ Local<Function> Foo = Local<Function>::Cast(
+ context->Global()->Get(context.local(), v8_str("Foo")).ToLocalChecked());
- v8::Handle<Value>* args0 = NULL;
- Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->NewInstance(0, args0));
+ v8::Local<Value>* args0 = NULL;
+ Local<v8::Array> a0 = Local<v8::Array>::Cast(
+ Foo->NewInstance(context.local(), 0, args0).ToLocalChecked());
CHECK_EQ(0u, a0->Length());
- v8::Handle<Value> args1[] = {v8_num(1.1)};
- Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->NewInstance(1, args1));
+ v8::Local<Value> args1[] = {v8_num(1.1)};
+ Local<v8::Array> a1 = Local<v8::Array>::Cast(
+ Foo->NewInstance(context.local(), 1, args1).ToLocalChecked());
CHECK_EQ(1u, a1->Length());
- CHECK_EQ(1.1, a1->Get(v8::Integer::New(isolate, 0))->NumberValue());
-
- v8::Handle<Value> args2[] = {v8_num(2.2), v8_num(3.3)};
- Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->NewInstance(2, args2));
+ CHECK_EQ(1.1, a1->Get(context.local(), v8::Integer::New(isolate, 0))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+
+ v8::Local<Value> args2[] = {v8_num(2.2), v8_num(3.3)};
+ Local<v8::Array> a2 = Local<v8::Array>::Cast(
+ Foo->NewInstance(context.local(), 2, args2).ToLocalChecked());
CHECK_EQ(2u, a2->Length());
- CHECK_EQ(2.2, a2->Get(v8::Integer::New(isolate, 0))->NumberValue());
- CHECK_EQ(3.3, a2->Get(v8::Integer::New(isolate, 1))->NumberValue());
-
- v8::Handle<Value> args3[] = {v8_num(4.4), v8_num(5.5), v8_num(6.6)};
- Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->NewInstance(3, args3));
+ CHECK_EQ(2.2, a2->Get(context.local(), v8::Integer::New(isolate, 0))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(3.3, a2->Get(context.local(), v8::Integer::New(isolate, 1))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+
+ v8::Local<Value> args3[] = {v8_num(4.4), v8_num(5.5), v8_num(6.6)};
+ Local<v8::Array> a3 = Local<v8::Array>::Cast(
+ Foo->NewInstance(context.local(), 3, args3).ToLocalChecked());
CHECK_EQ(3u, a3->Length());
- CHECK_EQ(4.4, a3->Get(v8::Integer::New(isolate, 0))->NumberValue());
- CHECK_EQ(5.5, a3->Get(v8::Integer::New(isolate, 1))->NumberValue());
- CHECK_EQ(6.6, a3->Get(v8::Integer::New(isolate, 2))->NumberValue());
-
- v8::Handle<Value> args4[] = {v8_num(7.7), v8_num(8.8), v8_num(9.9),
- v8_num(10.11)};
- Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->NewInstance(4, args4));
+ CHECK_EQ(4.4, a3->Get(context.local(), v8::Integer::New(isolate, 0))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(5.5, a3->Get(context.local(), v8::Integer::New(isolate, 1))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(6.6, a3->Get(context.local(), v8::Integer::New(isolate, 2))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+
+ v8::Local<Value> args4[] = {v8_num(7.7), v8_num(8.8), v8_num(9.9),
+ v8_num(10.11)};
+ Local<v8::Array> a4 = Local<v8::Array>::Cast(
+ Foo->NewInstance(context.local(), 4, args4).ToLocalChecked());
CHECK_EQ(4u, a4->Length());
- CHECK_EQ(7.7, a4->Get(v8::Integer::New(isolate, 0))->NumberValue());
- CHECK_EQ(8.8, a4->Get(v8::Integer::New(isolate, 1))->NumberValue());
- CHECK_EQ(9.9, a4->Get(v8::Integer::New(isolate, 2))->NumberValue());
- CHECK_EQ(10.11, a4->Get(v8::Integer::New(isolate, 3))->NumberValue());
-}
-
-
-static void CheckUncle(v8::TryCatch* try_catch) {
- CHECK(try_catch->HasCaught());
- String::Utf8Value str_value(try_catch->Exception());
- CHECK_EQ(0, strcmp(*str_value, "uncle?"));
- try_catch->Reset();
+ CHECK_EQ(7.7, a4->Get(context.local(), v8::Integer::New(isolate, 0))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(8.8, a4->Get(context.local(), v8::Integer::New(isolate, 1))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(9.9, a4->Get(context.local(), v8::Integer::New(isolate, 2))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
+ CHECK_EQ(10.11, a4->Get(context.local(), v8::Integer::New(isolate, 3))
+ .ToLocalChecked()
+ ->NumberValue(context.local())
+ .FromJust());
}
@@ -4690,47 +5306,57 @@ THREADED_TEST(ConversionNumber) {
v8::HandleScope scope(isolate);
// Very large number.
CompileRun("var obj = Math.pow(2,32) * 1237;");
- Local<Value> obj = env->Global()->Get(v8_str("obj"));
- CHECK_EQ(5312874545152.0, obj->ToNumber(isolate)->Value());
- CHECK_EQ(0, obj->ToInt32(isolate)->Value());
+ Local<Value> obj =
+ env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
+ CHECK_EQ(5312874545152.0,
+ obj->ToNumber(env.local()).ToLocalChecked()->Value());
+ CHECK_EQ(0, obj->ToInt32(env.local()).ToLocalChecked()->Value());
CHECK(0u ==
- obj->ToUint32(isolate)->Value()); // NOLINT - no CHECK_EQ for unsigned.
+ obj->ToUint32(env.local())
+ .ToLocalChecked()
+ ->Value()); // NOLINT - no CHECK_EQ for unsigned.
// Large number.
CompileRun("var obj = -1234567890123;");
- obj = env->Global()->Get(v8_str("obj"));
- CHECK_EQ(-1234567890123.0, obj->ToNumber(isolate)->Value());
- CHECK_EQ(-1912276171, obj->ToInt32(isolate)->Value());
- CHECK(2382691125u == obj->ToUint32(isolate)->Value()); // NOLINT
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
+ CHECK_EQ(-1234567890123.0,
+ obj->ToNumber(env.local()).ToLocalChecked()->Value());
+ CHECK_EQ(-1912276171, obj->ToInt32(env.local()).ToLocalChecked()->Value());
+ CHECK(2382691125u ==
+ obj->ToUint32(env.local()).ToLocalChecked()->Value()); // NOLINT
// Small positive integer.
CompileRun("var obj = 42;");
- obj = env->Global()->Get(v8_str("obj"));
- CHECK_EQ(42.0, obj->ToNumber(isolate)->Value());
- CHECK_EQ(42, obj->ToInt32(isolate)->Value());
- CHECK(42u == obj->ToUint32(isolate)->Value()); // NOLINT
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
+ CHECK_EQ(42.0, obj->ToNumber(env.local()).ToLocalChecked()->Value());
+ CHECK_EQ(42, obj->ToInt32(env.local()).ToLocalChecked()->Value());
+ CHECK(42u == obj->ToUint32(env.local()).ToLocalChecked()->Value()); // NOLINT
// Negative integer.
CompileRun("var obj = -37;");
- obj = env->Global()->Get(v8_str("obj"));
- CHECK_EQ(-37.0, obj->ToNumber(isolate)->Value());
- CHECK_EQ(-37, obj->ToInt32(isolate)->Value());
- CHECK(4294967259u == obj->ToUint32(isolate)->Value()); // NOLINT
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
+ CHECK_EQ(-37.0, obj->ToNumber(env.local()).ToLocalChecked()->Value());
+ CHECK_EQ(-37, obj->ToInt32(env.local()).ToLocalChecked()->Value());
+ CHECK(4294967259u ==
+ obj->ToUint32(env.local()).ToLocalChecked()->Value()); // NOLINT
// Positive non-int32 integer.
CompileRun("var obj = 0x81234567;");
- obj = env->Global()->Get(v8_str("obj"));
- CHECK_EQ(2166572391.0, obj->ToNumber(isolate)->Value());
- CHECK_EQ(-2128394905, obj->ToInt32(isolate)->Value());
- CHECK(2166572391u == obj->ToUint32(isolate)->Value()); // NOLINT
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
+ CHECK_EQ(2166572391.0, obj->ToNumber(env.local()).ToLocalChecked()->Value());
+ CHECK_EQ(-2128394905, obj->ToInt32(env.local()).ToLocalChecked()->Value());
+ CHECK(2166572391u ==
+ obj->ToUint32(env.local()).ToLocalChecked()->Value()); // NOLINT
// Fraction.
CompileRun("var obj = 42.3;");
- obj = env->Global()->Get(v8_str("obj"));
- CHECK_EQ(42.3, obj->ToNumber(isolate)->Value());
- CHECK_EQ(42, obj->ToInt32(isolate)->Value());
- CHECK(42u == obj->ToUint32(isolate)->Value()); // NOLINT
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
+ CHECK_EQ(42.3, obj->ToNumber(env.local()).ToLocalChecked()->Value());
+ CHECK_EQ(42, obj->ToInt32(env.local()).ToLocalChecked()->Value());
+ CHECK(42u == obj->ToUint32(env.local()).ToLocalChecked()->Value()); // NOLINT
// Large negative fraction.
CompileRun("var obj = -5726623061.75;");
- obj = env->Global()->Get(v8_str("obj"));
- CHECK_EQ(-5726623061.75, obj->ToNumber(isolate)->Value());
- CHECK_EQ(-1431655765, obj->ToInt32(isolate)->Value());
- CHECK(2863311531u == obj->ToUint32(isolate)->Value()); // NOLINT
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
+ CHECK_EQ(-5726623061.75,
+ obj->ToNumber(env.local()).ToLocalChecked()->Value());
+ CHECK_EQ(-1431655765, obj->ToInt32(env.local()).ToLocalChecked()->Value());
+ CHECK(2863311531u ==
+ obj->ToUint32(env.local()).ToLocalChecked()->Value()); // NOLINT
}
@@ -4739,52 +5365,61 @@ THREADED_TEST(isNumberType) {
v8::HandleScope scope(env->GetIsolate());
// Very large number.
CompileRun("var obj = Math.pow(2,32) * 1237;");
- Local<Value> obj = env->Global()->Get(v8_str("obj"));
+ Local<Value> obj =
+ env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
CHECK(!obj->IsInt32());
CHECK(!obj->IsUint32());
// Large negative number.
CompileRun("var obj = -1234567890123;");
- obj = env->Global()->Get(v8_str("obj"));
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
CHECK(!obj->IsInt32());
CHECK(!obj->IsUint32());
// Small positive integer.
CompileRun("var obj = 42;");
- obj = env->Global()->Get(v8_str("obj"));
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
CHECK(obj->IsInt32());
CHECK(obj->IsUint32());
// Negative integer.
CompileRun("var obj = -37;");
- obj = env->Global()->Get(v8_str("obj"));
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
CHECK(obj->IsInt32());
CHECK(!obj->IsUint32());
// Positive non-int32 integer.
CompileRun("var obj = 0x81234567;");
- obj = env->Global()->Get(v8_str("obj"));
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
CHECK(!obj->IsInt32());
CHECK(obj->IsUint32());
// Fraction.
CompileRun("var obj = 42.3;");
- obj = env->Global()->Get(v8_str("obj"));
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
CHECK(!obj->IsInt32());
CHECK(!obj->IsUint32());
// Large negative fraction.
CompileRun("var obj = -5726623061.75;");
- obj = env->Global()->Get(v8_str("obj"));
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
CHECK(!obj->IsInt32());
CHECK(!obj->IsUint32());
// Positive zero
CompileRun("var obj = 0.0;");
- obj = env->Global()->Get(v8_str("obj"));
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
CHECK(obj->IsInt32());
CHECK(obj->IsUint32());
// Positive zero
CompileRun("var obj = -0.0;");
- obj = env->Global()->Get(v8_str("obj"));
+ obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
CHECK(!obj->IsInt32());
CHECK(!obj->IsUint32());
}
+static void CheckUncle(v8::TryCatch* try_catch) {
+ CHECK(try_catch->HasCaught());
+ String::Utf8Value str_value(try_catch->Exception());
+ CHECK_EQ(0, strcmp(*str_value, "uncle?"));
+ try_catch->Reset();
+}
+
+
THREADED_TEST(ConversionException) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
@@ -4793,49 +5428,40 @@ THREADED_TEST(ConversionException) {
"function TestClass() { };"
"TestClass.prototype.toString = function () { throw 'uncle?'; };"
"var obj = new TestClass();");
- Local<Value> obj = env->Global()->Get(v8_str("obj"));
+ Local<Value> obj =
+ env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
v8::TryCatch try_catch(isolate);
- Local<Value> to_string_result = obj->ToString(isolate);
- CHECK(to_string_result.IsEmpty());
+ CHECK(obj->ToString(env.local()).IsEmpty());
CheckUncle(&try_catch);
- Local<Value> to_number_result = obj->ToNumber(isolate);
- CHECK(to_number_result.IsEmpty());
+ CHECK(obj->ToNumber(env.local()).IsEmpty());
CheckUncle(&try_catch);
- Local<Value> to_integer_result = obj->ToInteger(isolate);
- CHECK(to_integer_result.IsEmpty());
+ CHECK(obj->ToInteger(env.local()).IsEmpty());
CheckUncle(&try_catch);
- Local<Value> to_uint32_result = obj->ToUint32(isolate);
- CHECK(to_uint32_result.IsEmpty());
+ CHECK(obj->ToUint32(env.local()).IsEmpty());
CheckUncle(&try_catch);
- Local<Value> to_int32_result = obj->ToInt32(isolate);
- CHECK(to_int32_result.IsEmpty());
+ CHECK(obj->ToInt32(env.local()).IsEmpty());
CheckUncle(&try_catch);
- Local<Value> to_object_result = v8::Undefined(isolate)->ToObject(isolate);
- CHECK(to_object_result.IsEmpty());
+ CHECK(v8::Undefined(isolate)->ToObject(env.local()).IsEmpty());
CHECK(try_catch.HasCaught());
try_catch.Reset();
- int32_t int32_value = obj->Int32Value();
- CHECK_EQ(0, int32_value);
+ CHECK(obj->Int32Value(env.local()).IsNothing());
CheckUncle(&try_catch);
- uint32_t uint32_value = obj->Uint32Value();
- CHECK_EQ(0u, uint32_value);
+ CHECK(obj->Uint32Value(env.local()).IsNothing());
CheckUncle(&try_catch);
- double number_value = obj->NumberValue();
- CHECK(std::isnan(number_value));
+ CHECK(obj->NumberValue(env.local()).IsNothing());
CheckUncle(&try_catch);
- int64_t integer_value = obj->IntegerValue();
- CHECK_EQ(0, integer_value);
+ CHECK(obj->IntegerValue(env.local()).IsNothing());
CheckUncle(&try_catch);
}
@@ -4853,7 +5479,10 @@ void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
v8::HandleScope scope(args.GetIsolate());
v8::TryCatch try_catch(args.GetIsolate());
- Local<Value> result = CompileRun(args[0]->ToString(args.GetIsolate()));
+ Local<Value> result =
+ CompileRun(args[0]
+ ->ToString(args.GetIsolate()->GetCurrentContext())
+ .ToLocalChecked());
CHECK(!try_catch.HasCaught() || result.IsEmpty());
args.GetReturnValue().Set(try_catch.HasCaught());
}
@@ -4873,8 +5502,10 @@ THREADED_TEST(APICatch) {
"} catch (e) {"
" thrown = true;"
"}");
- Local<Value> thrown = context->Global()->Get(v8_str("thrown"));
- CHECK(thrown->BooleanValue());
+ Local<Value> thrown = context->Global()
+ ->Get(context.local(), v8_str("thrown"))
+ .ToLocalChecked();
+ CHECK(thrown->BooleanValue(context.local()).FromJust());
}
@@ -4916,10 +5547,13 @@ TEST(TryCatchInTryFinally) {
}
-static void check_reference_error_message(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
+static void check_reference_error_message(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
const char* reference_error = "Uncaught ReferenceError: asdf is not defined";
- CHECK(message->Get()->Equals(v8_str(reference_error)));
+ CHECK(message->Get()
+ ->Equals(CcTest::isolate()->GetCurrentContext(),
+ v8_str(reference_error))
+ .FromJust());
}
@@ -4935,7 +5569,7 @@ static void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(APIThrowMessageOverwrittenToString) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::V8::AddMessageListener(check_reference_error_message);
+ isolate->AddMessageListener(check_reference_error_message);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("fail"), v8::FunctionTemplate::New(isolate, Fail));
LocalContext context(NULL, templ);
@@ -4962,29 +5596,32 @@ TEST(APIThrowMessageOverwrittenToString) {
CompileRun("asdf;");
CompileRun("ReferenceError.prototype = new Object();");
CompileRun("asdf;");
- v8::Handle<Value> string = CompileRun("try { asdf; } catch(e) { e + ''; }");
- CHECK(string->Equals(v8_str("Whoops")));
+ v8::Local<Value> string = CompileRun("try { asdf; } catch(e) { e + ''; }");
+ CHECK(string->Equals(context.local(), v8_str("Whoops")).FromJust());
CompileRun(
"ReferenceError.prototype.constructor = new Object();"
"ReferenceError.prototype.constructor.name = 1;"
"Number.prototype.toString = function() { return 'Whoops'; };"
"ReferenceError.prototype.toString = Object.prototype.toString;");
CompileRun("asdf;");
- v8::V8::RemoveMessageListeners(check_reference_error_message);
+ isolate->RemoveMessageListeners(check_reference_error_message);
}
-static void check_custom_error_tostring(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
+static void check_custom_error_tostring(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
const char* uncaught_error = "Uncaught MyError toString";
- CHECK(message->Get()->Equals(v8_str(uncaught_error)));
+ CHECK(message->Get()
+ ->Equals(CcTest::isolate()->GetCurrentContext(),
+ v8_str(uncaught_error))
+ .FromJust());
}
TEST(CustomErrorToString) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::V8::AddMessageListener(check_custom_error_tostring);
+ context->GetIsolate()->AddMessageListener(check_custom_error_tostring);
CompileRun(
"function MyError(name, message) { "
" this.name = name; "
@@ -4995,22 +5632,25 @@ TEST(CustomErrorToString) {
" return 'MyError toString'; "
"}; "
"throw new MyError('my name', 'my message'); ");
- v8::V8::RemoveMessageListeners(check_custom_error_tostring);
+ context->GetIsolate()->RemoveMessageListeners(check_custom_error_tostring);
}
-static void check_custom_error_message(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
+static void check_custom_error_message(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
const char* uncaught_error = "Uncaught MyError: my message";
printf("%s\n", *v8::String::Utf8Value(message->Get()));
- CHECK(message->Get()->Equals(v8_str(uncaught_error)));
+ CHECK(message->Get()
+ ->Equals(CcTest::isolate()->GetCurrentContext(),
+ v8_str(uncaught_error))
+ .FromJust());
}
TEST(CustomErrorMessage) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::V8::AddMessageListener(check_custom_error_message);
+ context->GetIsolate()->AddMessageListener(check_custom_error_message);
// Handlebars.
CompileRun(
@@ -5046,32 +5686,36 @@ TEST(CustomErrorMessage) {
"MyError.prototype = Object.create(Error.prototype); "
"throw new MyError('my message'); ");
- v8::V8::RemoveMessageListeners(check_custom_error_message);
+ context->GetIsolate()->RemoveMessageListeners(check_custom_error_message);
}
-static void check_custom_rethrowing_message(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
+static void check_custom_rethrowing_message(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
const char* uncaught_error = "Uncaught exception";
- CHECK(message->Get()->Equals(v8_str(uncaught_error)));
+ CHECK(message->Get()
+ ->Equals(CcTest::isolate()->GetCurrentContext(),
+ v8_str(uncaught_error))
+ .FromJust());
}
TEST(CustomErrorRethrowsOnToString) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::V8::AddMessageListener(check_custom_rethrowing_message);
+ context->GetIsolate()->AddMessageListener(check_custom_rethrowing_message);
CompileRun(
"var e = { toString: function() { throw e; } };"
"try { throw e; } finally {}");
- v8::V8::RemoveMessageListeners(check_custom_rethrowing_message);
+ context->GetIsolate()->RemoveMessageListeners(
+ check_custom_rethrowing_message);
}
-static void receive_message(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
+static void receive_message(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
message->Get();
message_received = true;
}
@@ -5081,14 +5725,14 @@ TEST(APIThrowMessage) {
message_received = false;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::V8::AddMessageListener(receive_message);
+ isolate->AddMessageListener(receive_message);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("ThrowFromC"),
v8::FunctionTemplate::New(isolate, ThrowFromC));
LocalContext context(0, templ);
CompileRun("ThrowFromC();");
CHECK(message_received);
- v8::V8::RemoveMessageListeners(receive_message);
+ isolate->RemoveMessageListeners(receive_message);
}
@@ -5096,7 +5740,7 @@ TEST(APIThrowMessageAndVerboseTryCatch) {
message_received = false;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::V8::AddMessageListener(receive_message);
+ isolate->AddMessageListener(receive_message);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("ThrowFromC"),
v8::FunctionTemplate::New(isolate, ThrowFromC));
@@ -5107,7 +5751,7 @@ TEST(APIThrowMessageAndVerboseTryCatch) {
CHECK(try_catch.HasCaught());
CHECK(result.IsEmpty());
CHECK(message_received);
- v8::V8::RemoveMessageListeners(receive_message);
+ isolate->RemoveMessageListeners(receive_message);
}
@@ -5115,14 +5759,14 @@ TEST(APIStackOverflowAndVerboseTryCatch) {
message_received = false;
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::V8::AddMessageListener(receive_message);
+ context->GetIsolate()->AddMessageListener(receive_message);
v8::TryCatch try_catch(context->GetIsolate());
try_catch.SetVerbose(true);
Local<Value> result = CompileRun("function foo() { foo(); } foo();");
CHECK(try_catch.HasCaught());
CHECK(result.IsEmpty());
CHECK(message_received);
- v8::V8::RemoveMessageListeners(receive_message);
+ context->GetIsolate()->RemoveMessageListeners(receive_message);
}
@@ -5146,19 +5790,23 @@ THREADED_TEST(ExternalScriptException) {
void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
CHECK_EQ(4, args.Length());
- int count = args[0]->Int32Value();
- int cInterval = args[2]->Int32Value();
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ int count = args[0]->Int32Value(context).FromJust();
+ int cInterval = args[2]->Int32Value(context).FromJust();
if (count == 0) {
args.GetIsolate()->ThrowException(v8_str("FromC"));
return;
} else {
- Local<v8::Object> global = args.GetIsolate()->GetCurrentContext()->Global();
- Local<Value> fun = global->Get(v8_str("JSThrowCountDown"));
- v8::Handle<Value> argv[] = {v8_num(count - 1), args[1], args[2], args[3]};
+ Local<v8::Object> global = context->Global();
+ Local<Value> fun =
+ global->Get(context, v8_str("JSThrowCountDown")).ToLocalChecked();
+ v8::Local<Value> argv[] = {v8_num(count - 1), args[1], args[2], args[3]};
if (count % cInterval == 0) {
v8::TryCatch try_catch(args.GetIsolate());
- Local<Value> result = fun.As<Function>()->Call(global, 4, argv);
- int expected = args[3]->Int32Value();
+ Local<Value> result = fun.As<Function>()
+ ->Call(context, global, 4, argv)
+ .FromMaybe(Local<Value>());
+ int expected = args[3]->Int32Value(context).FromJust();
if (try_catch.HasCaught()) {
CHECK_EQ(expected, count);
CHECK(result.IsEmpty());
@@ -5169,7 +5817,9 @@ void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(result);
return;
} else {
- args.GetReturnValue().Set(fun.As<Function>()->Call(global, 4, argv));
+ args.GetReturnValue().Set(fun.As<Function>()
+ ->Call(context, global, 4, argv)
+ .FromMaybe(v8::Local<v8::Value>()));
return;
}
}
@@ -5179,9 +5829,10 @@ void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) {
void JSCheck(const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
CHECK_EQ(3, args.Length());
- bool equality = args[0]->BooleanValue();
- int count = args[1]->Int32Value();
- int expected = args[2]->Int32Value();
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ bool equality = args[0]->BooleanValue(context).FromJust();
+ int count = args[1]->Int32Value(context).FromJust();
+ int expected = args[2]->Int32Value(context).FromJust();
if (equality) {
CHECK_EQ(count, expected);
} else {
@@ -5252,35 +5903,37 @@ TEST(ExceptionOrder) {
" return CThrowCountDown(count - 1, jsInterval, cInterval, expected);"
" }"
"}");
- Local<Function> fun =
- Local<Function>::Cast(context->Global()->Get(v8_str("JSThrowCountDown")));
+ Local<Function> fun = Local<Function>::Cast(
+ context->Global()
+ ->Get(context.local(), v8_str("JSThrowCountDown"))
+ .ToLocalChecked());
const int argc = 4;
// count jsInterval cInterval expected
// *JS[4] *C[3] @JS[2] C[1] JS[0]
- v8::Handle<Value> a0[argc] = {v8_num(4), v8_num(2), v8_num(3), v8_num(2)};
- fun->Call(fun, argc, a0);
+ v8::Local<Value> a0[argc] = {v8_num(4), v8_num(2), v8_num(3), v8_num(2)};
+ fun->Call(context.local(), fun, argc, a0).ToLocalChecked();
// JS[5] *C[4] JS[3] @C[2] JS[1] C[0]
- v8::Handle<Value> a1[argc] = {v8_num(5), v8_num(6), v8_num(1), v8_num(2)};
- fun->Call(fun, argc, a1);
+ v8::Local<Value> a1[argc] = {v8_num(5), v8_num(6), v8_num(1), v8_num(2)};
+ fun->Call(context.local(), fun, argc, a1).ToLocalChecked();
// JS[6] @C[5] JS[4] C[3] JS[2] C[1] JS[0]
- v8::Handle<Value> a2[argc] = {v8_num(6), v8_num(7), v8_num(5), v8_num(5)};
- fun->Call(fun, argc, a2);
+ v8::Local<Value> a2[argc] = {v8_num(6), v8_num(7), v8_num(5), v8_num(5)};
+ fun->Call(context.local(), fun, argc, a2).ToLocalChecked();
// @JS[6] C[5] JS[4] C[3] JS[2] C[1] JS[0]
- v8::Handle<Value> a3[argc] = {v8_num(6), v8_num(6), v8_num(7), v8_num(6)};
- fun->Call(fun, argc, a3);
+ v8::Local<Value> a3[argc] = {v8_num(6), v8_num(6), v8_num(7), v8_num(6)};
+ fun->Call(context.local(), fun, argc, a3).ToLocalChecked();
// JS[6] *C[5] @JS[4] C[3] JS[2] C[1] JS[0]
- v8::Handle<Value> a4[argc] = {v8_num(6), v8_num(4), v8_num(5), v8_num(4)};
- fun->Call(fun, argc, a4);
+ v8::Local<Value> a4[argc] = {v8_num(6), v8_num(4), v8_num(5), v8_num(4)};
+ fun->Call(context.local(), fun, argc, a4).ToLocalChecked();
// JS[6] C[5] *JS[4] @C[3] JS[2] C[1] JS[0]
- v8::Handle<Value> a5[argc] = {v8_num(6), v8_num(4), v8_num(3), v8_num(3)};
- fun->Call(fun, argc, a5);
+ v8::Local<Value> a5[argc] = {v8_num(6), v8_num(4), v8_num(3), v8_num(3)};
+ fun->Call(context.local(), fun, argc, a5).ToLocalChecked();
}
@@ -5297,24 +5950,40 @@ THREADED_TEST(ThrowValues) {
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(isolate, ThrowValue));
LocalContext context(0, templ);
- v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
- "function Run(obj) {"
- " try {"
- " Throw(obj);"
- " } catch (e) {"
- " return e;"
- " }"
- " return 'no exception';"
- "}"
- "[Run('str'), Run(1), Run(0), Run(null), Run(void 0)];"));
+ v8::Local<v8::Array> result = v8::Local<v8::Array>::Cast(
+ CompileRun("function Run(obj) {"
+ " try {"
+ " Throw(obj);"
+ " } catch (e) {"
+ " return e;"
+ " }"
+ " return 'no exception';"
+ "}"
+ "[Run('str'), Run(1), Run(0), Run(null), Run(void 0)];"));
CHECK_EQ(5u, result->Length());
- CHECK(result->Get(v8::Integer::New(isolate, 0))->IsString());
- CHECK(result->Get(v8::Integer::New(isolate, 1))->IsNumber());
- CHECK_EQ(1, result->Get(v8::Integer::New(isolate, 1))->Int32Value());
- CHECK(result->Get(v8::Integer::New(isolate, 2))->IsNumber());
- CHECK_EQ(0, result->Get(v8::Integer::New(isolate, 2))->Int32Value());
- CHECK(result->Get(v8::Integer::New(isolate, 3))->IsNull());
- CHECK(result->Get(v8::Integer::New(isolate, 4))->IsUndefined());
+ CHECK(result->Get(context.local(), v8::Integer::New(isolate, 0))
+ .ToLocalChecked()
+ ->IsString());
+ CHECK(result->Get(context.local(), v8::Integer::New(isolate, 1))
+ .ToLocalChecked()
+ ->IsNumber());
+ CHECK_EQ(1, result->Get(context.local(), v8::Integer::New(isolate, 1))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(result->Get(context.local(), v8::Integer::New(isolate, 2))
+ .ToLocalChecked()
+ ->IsNumber());
+ CHECK_EQ(0, result->Get(context.local(), v8::Integer::New(isolate, 2))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(result->Get(context.local(), v8::Integer::New(isolate, 3))
+ .ToLocalChecked()
+ ->IsNull());
+ CHECK(result->Get(context.local(), v8::Integer::New(isolate, 4))
+ .ToLocalChecked()
+ ->IsUndefined());
}
@@ -5325,12 +5994,12 @@ THREADED_TEST(CatchZero) {
CHECK(!try_catch.HasCaught());
CompileRun("throw 10");
CHECK(try_catch.HasCaught());
- CHECK_EQ(10, try_catch.Exception()->Int32Value());
+ CHECK_EQ(10, try_catch.Exception()->Int32Value(context.local()).FromJust());
try_catch.Reset();
CHECK(!try_catch.HasCaught());
CompileRun("throw 0");
CHECK(try_catch.HasCaught());
- CHECK_EQ(0, try_catch.Exception()->Int32Value());
+ CHECK_EQ(0, try_catch.Exception()->Int32Value(context.local()).FromJust());
}
@@ -5364,9 +6033,12 @@ THREADED_TEST(TryCatchAndFinally) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- context->Global()->Set(
- v8_str("native_with_try_catch"),
- v8::FunctionTemplate::New(isolate, WithTryCatch)->GetFunction());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("native_with_try_catch"),
+ v8::FunctionTemplate::New(isolate, WithTryCatch)
+ ->GetFunction(context.local())
+ .ToLocalChecked())
+ .FromJust());
v8::TryCatch try_catch(isolate);
CHECK(!try_catch.HasCaught());
CompileRun(
@@ -5430,13 +6102,15 @@ TEST(TryCatchNested) {
void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) {
CHECK(try_catch->HasCaught());
- Handle<Message> message = try_catch->Message();
- Handle<Value> resource = message->GetScriptOrigin().ResourceName();
+ Local<Message> message = try_catch->Message();
+ Local<Value> resource = message->GetScriptOrigin().ResourceName();
CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner"));
CHECK_EQ(0,
strcmp(*v8::String::Utf8Value(message->Get()), "Uncaught Error: a"));
- CHECK_EQ(1, message->GetLineNumber());
- CHECK_EQ(0, message->GetStartColumn());
+ CHECK_EQ(1, message->GetLineNumber(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
+ CHECK_EQ(0, message->GetStartColumn(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
}
@@ -5522,14 +6196,14 @@ THREADED_TEST(Equality) {
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(context->GetIsolate());
// Check that equality works at all before relying on CHECK_EQ
- CHECK(v8_str("a")->Equals(v8_str("a")));
- CHECK(!v8_str("a")->Equals(v8_str("b")));
+ CHECK(v8_str("a")->Equals(context.local(), v8_str("a")).FromJust());
+ CHECK(!v8_str("a")->Equals(context.local(), v8_str("b")).FromJust());
- CHECK(v8_str("a")->Equals(v8_str("a")));
- CHECK(!v8_str("a")->Equals(v8_str("b")));
- CHECK(v8_num(1)->Equals(v8_num(1)));
- CHECK(v8_num(1.00)->Equals(v8_num(1)));
- CHECK(!v8_num(1)->Equals(v8_num(2)));
+ CHECK(v8_str("a")->Equals(context.local(), v8_str("a")).FromJust());
+ CHECK(!v8_str("a")->Equals(context.local(), v8_str("b")).FromJust());
+ CHECK(v8_num(1)->Equals(context.local(), v8_num(1)).FromJust());
+ CHECK(v8_num(1.00)->Equals(context.local(), v8_num(1)).FromJust());
+ CHECK(!v8_num(1)->Equals(context.local(), v8_num(2)).FromJust());
// Assume String is not internalized.
CHECK(v8_str("a")->StrictEquals(v8_str("a")));
@@ -5543,7 +6217,7 @@ THREADED_TEST(Equality) {
CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate)));
CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate)));
- v8::Handle<v8::Object> obj = v8::Object::New(isolate);
+ v8::Local<v8::Object> obj = v8::Object::New(isolate);
v8::Persistent<v8::Object> alias(isolate, obj);
CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj));
alias.Reset();
@@ -5564,15 +6238,20 @@ THREADED_TEST(MultiRun) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
Local<Script> script = v8_compile("x");
- for (int i = 0; i < 10; i++) script->Run();
+ for (int i = 0; i < 10; i++) {
+ script->Run(context.local()).IsEmpty();
+ }
}
-static void GetXValue(Local<String> name,
+static void GetXValue(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
- CHECK(info.Data()->Equals(v8_str("donut")));
- CHECK(name->Equals(v8_str("x")));
+ CHECK(info.Data()
+ ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str("donut"))
+ .FromJust());
+ CHECK(name->Equals(CcTest::isolate()->GetCurrentContext(), v8_str("x"))
+ .FromJust());
info.GetReturnValue().Set(name);
}
@@ -5583,11 +6262,14 @@ THREADED_TEST(SimplePropertyRead) {
v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"));
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
Local<Script> script = v8_compile("obj.x");
for (int i = 0; i < 10; i++) {
- Local<Value> result = script->Run();
- CHECK(result->Equals(v8_str("x")));
+ Local<Value> result = script->Run(context.local()).ToLocalChecked();
+ CHECK(result->Equals(context.local(), v8_str("x")).FromJust());
}
}
@@ -5598,15 +6280,18 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) {
v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"));
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
// Uses getOwnPropertyDescriptor to check the configurable status
Local<Script> script_desc = v8_compile(
"var prop = Object.getOwnPropertyDescriptor( "
"obj, 'x');"
"prop.configurable;");
- Local<Value> result = script_desc->Run();
- CHECK_EQ(result->BooleanValue(), true);
+ Local<Value> result = script_desc->Run(context.local()).ToLocalChecked();
+ CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true);
// Redefine get - but still configurable
Local<Script> script_define = v8_compile(
@@ -5614,12 +6299,12 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) {
" configurable: true };"
"Object.defineProperty(obj, 'x', desc);"
"obj.x");
- result = script_define->Run();
- CHECK(result->Equals(v8_num(42)));
+ result = script_define->Run(context.local()).ToLocalChecked();
+ CHECK(result->Equals(context.local(), v8_num(42)).FromJust());
// Check that the accessor is still configurable
- result = script_desc->Run();
- CHECK_EQ(result->BooleanValue(), true);
+ result = script_desc->Run(context.local()).ToLocalChecked();
+ CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true);
// Redefine to a non-configurable
script_define = v8_compile(
@@ -5627,14 +6312,14 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) {
" configurable: false };"
"Object.defineProperty(obj, 'x', desc);"
"obj.x");
- result = script_define->Run();
- CHECK(result->Equals(v8_num(43)));
- result = script_desc->Run();
- CHECK_EQ(result->BooleanValue(), false);
+ result = script_define->Run(context.local()).ToLocalChecked();
+ CHECK(result->Equals(context.local(), v8_num(43)).FromJust());
+ result = script_desc->Run(context.local()).ToLocalChecked();
+ CHECK_EQ(result->BooleanValue(context.local()).FromJust(), false);
// Make sure that it is not possible to redefine again
v8::TryCatch try_catch(isolate);
- result = script_define->Run();
+ CHECK(script_define->Run(context.local()).IsEmpty());
CHECK(try_catch.HasCaught());
String::Utf8Value exception_value(try_catch.Exception());
CHECK_EQ(0,
@@ -5648,42 +6333,43 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) {
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"));
LocalContext context;
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
Local<Script> script_desc = v8_compile(
"var prop ="
"Object.getOwnPropertyDescriptor( "
"obj, 'x');"
"prop.configurable;");
- Local<Value> result = script_desc->Run();
- CHECK_EQ(result->BooleanValue(), true);
+ Local<Value> result = script_desc->Run(context.local()).ToLocalChecked();
+ CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true);
Local<Script> script_define = v8_compile(
"var desc = {get: function(){return 42; },"
" configurable: true };"
"Object.defineProperty(obj, 'x', desc);"
"obj.x");
- result = script_define->Run();
- CHECK(result->Equals(v8_num(42)));
-
-
- result = script_desc->Run();
- CHECK_EQ(result->BooleanValue(), true);
+ result = script_define->Run(context.local()).ToLocalChecked();
+ CHECK(result->Equals(context.local(), v8_num(42)).FromJust());
+ result = script_desc->Run(context.local()).ToLocalChecked();
+ CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true);
script_define = v8_compile(
"var desc = {get: function(){return 43; },"
" configurable: false };"
"Object.defineProperty(obj, 'x', desc);"
"obj.x");
- result = script_define->Run();
- CHECK(result->Equals(v8_num(43)));
- result = script_desc->Run();
+ result = script_define->Run(context.local()).ToLocalChecked();
+ CHECK(result->Equals(context.local(), v8_num(43)).FromJust());
- CHECK_EQ(result->BooleanValue(), false);
+ result = script_desc->Run(context.local()).ToLocalChecked();
+ CHECK_EQ(result->BooleanValue(context.local()).FromJust(), false);
v8::TryCatch try_catch(isolate);
- result = script_define->Run();
+ CHECK(script_define->Run(context.local()).IsEmpty());
CHECK(try_catch.HasCaught());
String::Utf8Value exception_value(try_catch.Exception());
CHECK_EQ(0,
@@ -5691,9 +6377,13 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) {
}
-static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context,
- char const* name) {
- return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name)));
+static v8::Local<v8::Object> GetGlobalProperty(LocalContext* context,
+ char const* name) {
+ return v8::Local<v8::Object>::Cast(
+ (*context)
+ ->Global()
+ ->Get(CcTest::isolate()->GetCurrentContext(), v8_str(name))
+ .ToLocalChecked());
}
@@ -5703,20 +6393,27 @@ THREADED_TEST(DefineAPIAccessorOnObject) {
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
LocalContext context;
- context->Global()->Set(v8_str("obj1"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj1"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun("var obj2 = {};");
CHECK(CompileRun("obj1.x")->IsUndefined());
CHECK(CompileRun("obj2.x")->IsUndefined());
CHECK(GetGlobalProperty(&context, "obj1")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"))
+ .FromJust());
ExpectString("obj1.x", "x");
CHECK(CompileRun("obj2.x")->IsUndefined());
CHECK(GetGlobalProperty(&context, "obj2")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"))
+ .FromJust());
ExpectString("obj1.x", "x");
ExpectString("obj2.x", "x");
@@ -5742,9 +6439,13 @@ THREADED_TEST(DefineAPIAccessorOnObject) {
ExpectTrue("Object.getOwnPropertyDescriptor(obj2, 'x').configurable");
CHECK(GetGlobalProperty(&context, "obj1")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"))
+ .FromJust());
CHECK(GetGlobalProperty(&context, "obj2")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"))
+ .FromJust());
ExpectString("obj1.x", "x");
ExpectString("obj2.x", "x");
@@ -5759,17 +6460,20 @@ THREADED_TEST(DefineAPIAccessorOnObject) {
CompileRun(
"Object.defineProperty(obj2, 'x',"
"{ get: function() { return 'z'; }, configurable: false })");
-
ExpectTrue("!Object.getOwnPropertyDescriptor(obj1, 'x').configurable");
ExpectTrue("!Object.getOwnPropertyDescriptor(obj2, 'x').configurable");
ExpectString("obj1.x", "z");
ExpectString("obj2.x", "z");
- CHECK(!GetGlobalProperty(&context, "obj1")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
- CHECK(!GetGlobalProperty(&context, "obj2")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
+ CHECK(GetGlobalProperty(&context, "obj1")
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"))
+ .IsNothing());
+ CHECK(GetGlobalProperty(&context, "obj2")
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"))
+ .IsNothing());
ExpectString("obj1.x", "z");
ExpectString("obj2.x", "z");
@@ -5782,15 +6486,20 @@ THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) {
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
LocalContext context;
- context->Global()->Set(v8_str("obj1"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj1"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun("var obj2 = {};");
CHECK(GetGlobalProperty(&context, "obj1")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"),
- v8::DEFAULT, v8::DontDelete));
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"), v8::DEFAULT, v8::DontDelete)
+ .FromJust());
CHECK(GetGlobalProperty(&context, "obj2")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"),
- v8::DEFAULT, v8::DontDelete));
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"), v8::DEFAULT, v8::DontDelete)
+ .FromJust());
ExpectString("obj1.x", "x");
ExpectString("obj2.x", "x");
@@ -5798,10 +6507,14 @@ THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) {
ExpectTrue("!Object.getOwnPropertyDescriptor(obj1, 'x').configurable");
ExpectTrue("!Object.getOwnPropertyDescriptor(obj2, 'x').configurable");
- CHECK(!GetGlobalProperty(&context, "obj1")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
- CHECK(!GetGlobalProperty(&context, "obj2")
- ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
+ CHECK(GetGlobalProperty(&context, "obj1")
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"))
+ .IsNothing());
+ CHECK(GetGlobalProperty(&context, "obj2")
+ ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,
+ v8_str("donut"))
+ .IsNothing());
{
v8::TryCatch try_catch(isolate);
@@ -5826,11 +6539,14 @@ THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) {
}
-static void Get239Value(Local<String> name,
+static void Get239Value(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
- CHECK(info.Data()->Equals(v8_str("donut")));
- CHECK(name->Equals(v8_str("239")));
+ CHECK(info.Data()
+ ->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("donut"))
+ .FromJust());
+ CHECK(name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("239"))
+ .FromJust());
info.GetReturnValue().Set(name);
}
@@ -5841,13 +6557,20 @@ THREADED_TEST(ElementAPIAccessor) {
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
LocalContext context;
- context->Global()->Set(v8_str("obj1"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj1"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun("var obj2 = {};");
CHECK(GetGlobalProperty(&context, "obj1")
- ->SetAccessor(v8_str("239"), Get239Value, NULL, v8_str("donut")));
+ ->SetAccessor(context.local(), v8_str("239"), Get239Value, NULL,
+ v8_str("donut"))
+ .FromJust());
CHECK(GetGlobalProperty(&context, "obj2")
- ->SetAccessor(v8_str("239"), Get239Value, NULL, v8_str("donut")));
+ ->SetAccessor(context.local(), v8_str("239"), Get239Value, NULL,
+ v8_str("donut"))
+ .FromJust());
ExpectString("obj1[239]", "239");
ExpectString("obj2[239]", "239");
@@ -5859,11 +6582,12 @@ THREADED_TEST(ElementAPIAccessor) {
v8::Persistent<Value> xValue;
-static void SetXValue(Local<String> name, Local<Value> value,
+static void SetXValue(Local<Name> name, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) {
- CHECK(value->Equals(v8_num(4)));
- CHECK(info.Data()->Equals(v8_str("donut")));
- CHECK(name->Equals(v8_str("x")));
+ Local<Context> context = info.GetIsolate()->GetCurrentContext();
+ CHECK(value->Equals(context, v8_num(4)).FromJust());
+ CHECK(info.Data()->Equals(context, v8_str("donut")).FromJust());
+ CHECK(name->Equals(context, v8_str("x")).FromJust());
CHECK(xValue.IsEmpty());
xValue.Reset(info.GetIsolate(), value);
}
@@ -5875,12 +6599,18 @@ THREADED_TEST(SimplePropertyWrite) {
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut"));
LocalContext context;
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
Local<Script> script = v8_compile("obj.x = 4");
for (int i = 0; i < 10; i++) {
CHECK(xValue.IsEmpty());
- script->Run();
- CHECK(v8_num(4)->Equals(Local<Value>::New(CcTest::isolate(), xValue)));
+ script->Run(context.local()).ToLocalChecked();
+ CHECK(v8_num(4)
+ ->Equals(context.local(),
+ Local<Value>::New(CcTest::isolate(), xValue))
+ .FromJust());
xValue.Reset();
}
}
@@ -5892,12 +6622,18 @@ THREADED_TEST(SetterOnly) {
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut"));
LocalContext context;
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
Local<Script> script = v8_compile("obj.x = 4; obj.x");
for (int i = 0; i < 10; i++) {
CHECK(xValue.IsEmpty());
- script->Run();
- CHECK(v8_num(4)->Equals(Local<Value>::New(CcTest::isolate(), xValue)));
+ script->Run(context.local()).ToLocalChecked();
+ CHECK(v8_num(4)
+ ->Equals(context.local(),
+ Local<Value>::New(CcTest::isolate(), xValue))
+ .FromJust());
xValue.Reset();
}
}
@@ -5910,10 +6646,13 @@ THREADED_TEST(NoAccessors) {
templ->SetAccessor(v8_str("x"), static_cast<v8::AccessorGetterCallback>(NULL),
NULL, v8_str("donut"));
LocalContext context;
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
Local<Script> script = v8_compile("obj.x = 4; obj.x");
for (int i = 0; i < 10; i++) {
- script->Run();
+ script->Run(context.local()).ToLocalChecked();
}
}
@@ -5921,7 +6660,7 @@ THREADED_TEST(NoAccessors) {
THREADED_TEST(MultiContexts) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ v8::Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("dummy"),
v8::FunctionTemplate::New(isolate, DummyCallHandler));
@@ -5930,26 +6669,43 @@ THREADED_TEST(MultiContexts) {
// Create an environment
LocalContext context0(0, templ);
context0->SetSecurityToken(password);
- v8::Handle<v8::Object> global0 = context0->Global();
- global0->Set(v8_str("custom"), v8_num(1234));
- CHECK_EQ(1234, global0->Get(v8_str("custom"))->Int32Value());
+ v8::Local<v8::Object> global0 = context0->Global();
+ CHECK(global0->Set(context0.local(), v8_str("custom"), v8_num(1234))
+ .FromJust());
+ CHECK_EQ(1234, global0->Get(context0.local(), v8_str("custom"))
+ .ToLocalChecked()
+ ->Int32Value(context0.local())
+ .FromJust());
// Create an independent environment
LocalContext context1(0, templ);
context1->SetSecurityToken(password);
- v8::Handle<v8::Object> global1 = context1->Global();
- global1->Set(v8_str("custom"), v8_num(1234));
- CHECK(!global0->Equals(global1));
- CHECK_EQ(1234, global0->Get(v8_str("custom"))->Int32Value());
- CHECK_EQ(1234, global1->Get(v8_str("custom"))->Int32Value());
+ v8::Local<v8::Object> global1 = context1->Global();
+ CHECK(global1->Set(context1.local(), v8_str("custom"), v8_num(1234))
+ .FromJust());
+ CHECK(!global0->Equals(context1.local(), global1).FromJust());
+ CHECK_EQ(1234, global0->Get(context1.local(), v8_str("custom"))
+ .ToLocalChecked()
+ ->Int32Value(context0.local())
+ .FromJust());
+ CHECK_EQ(1234, global1->Get(context1.local(), v8_str("custom"))
+ .ToLocalChecked()
+ ->Int32Value(context1.local())
+ .FromJust());
// Now create a new context with the old global
LocalContext context2(0, templ, global1);
context2->SetSecurityToken(password);
- v8::Handle<v8::Object> global2 = context2->Global();
- CHECK(global1->Equals(global2));
- CHECK_EQ(0, global1->Get(v8_str("custom"))->Int32Value());
- CHECK_EQ(0, global2->Get(v8_str("custom"))->Int32Value());
+ v8::Local<v8::Object> global2 = context2->Global();
+ CHECK(global1->Equals(context2.local(), global2).FromJust());
+ CHECK_EQ(0, global1->Get(context2.local(), v8_str("custom"))
+ .ToLocalChecked()
+ ->Int32Value(context1.local())
+ .FromJust());
+ CHECK_EQ(0, global2->Get(context2.local(), v8_str("custom"))
+ .ToLocalChecked()
+ ->Int32Value(context2.local())
+ .FromJust());
}
@@ -5960,24 +6716,34 @@ THREADED_TEST(FunctionPrototypeAcrossContexts) {
v8::HandleScope scope(CcTest::isolate());
LocalContext env0;
- v8::Handle<v8::Object> global0 = env0->Global();
- v8::Handle<v8::Object> object0 =
- global0->Get(v8_str("Object")).As<v8::Object>();
- v8::Handle<v8::Object> tostring0 =
- object0->Get(v8_str("toString")).As<v8::Object>();
- v8::Handle<v8::Object> proto0 =
- tostring0->Get(v8_str("__proto__")).As<v8::Object>();
- proto0->Set(v8_str("custom"), v8_num(1234));
+ v8::Local<v8::Object> global0 = env0->Global();
+ v8::Local<v8::Object> object0 = global0->Get(env0.local(), v8_str("Object"))
+ .ToLocalChecked()
+ .As<v8::Object>();
+ v8::Local<v8::Object> tostring0 =
+ object0->Get(env0.local(), v8_str("toString"))
+ .ToLocalChecked()
+ .As<v8::Object>();
+ v8::Local<v8::Object> proto0 =
+ tostring0->Get(env0.local(), v8_str("__proto__"))
+ .ToLocalChecked()
+ .As<v8::Object>();
+ CHECK(proto0->Set(env0.local(), v8_str("custom"), v8_num(1234)).FromJust());
LocalContext env1;
- v8::Handle<v8::Object> global1 = env1->Global();
- v8::Handle<v8::Object> object1 =
- global1->Get(v8_str("Object")).As<v8::Object>();
- v8::Handle<v8::Object> tostring1 =
- object1->Get(v8_str("toString")).As<v8::Object>();
- v8::Handle<v8::Object> proto1 =
- tostring1->Get(v8_str("__proto__")).As<v8::Object>();
- CHECK(!proto1->Has(v8_str("custom")));
+ v8::Local<v8::Object> global1 = env1->Global();
+ v8::Local<v8::Object> object1 = global1->Get(env1.local(), v8_str("Object"))
+ .ToLocalChecked()
+ .As<v8::Object>();
+ v8::Local<v8::Object> tostring1 =
+ object1->Get(env1.local(), v8_str("toString"))
+ .ToLocalChecked()
+ .As<v8::Object>();
+ v8::Local<v8::Object> proto1 =
+ tostring1->Get(env1.local(), v8_str("__proto__"))
+ .ToLocalChecked()
+ .As<v8::Object>();
+ CHECK(!proto1->Has(env1.local(), v8_str("custom")).FromJust());
}
@@ -5997,11 +6763,17 @@ THREADED_TEST(Regress892105) {
LocalContext env0;
Local<Script> script0 = v8_compile(source);
- CHECK_EQ(8901.0, script0->Run()->NumberValue());
+ CHECK_EQ(8901.0, script0->Run(env0.local())
+ .ToLocalChecked()
+ ->NumberValue(env0.local())
+ .FromJust());
LocalContext env1;
Local<Script> script1 = v8_compile(source);
- CHECK_EQ(8901.0, script1->Run()->NumberValue());
+ CHECK_EQ(8901.0, script1->Run(env1.local())
+ .ToLocalChecked()
+ ->NumberValue(env1.local())
+ .FromJust());
}
@@ -6013,8 +6785,12 @@ THREADED_TEST(UndetectableObject) {
v8::FunctionTemplate::New(env->GetIsolate());
desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
- Local<v8::Object> obj = desc->GetFunction()->NewInstance();
- env->Global()->Set(v8_str("undetectable"), obj);
+ Local<v8::Object> obj = desc->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked();
+ CHECK(
+ env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust());
ExpectString("undetectable.toString()", "[object Object]");
ExpectString("typeof undetectable", "undefined");
@@ -6057,8 +6833,12 @@ THREADED_TEST(VoidLiteral) {
Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate);
desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
- Local<v8::Object> obj = desc->GetFunction()->NewInstance();
- env->Global()->Set(v8_str("undetectable"), obj);
+ Local<v8::Object> obj = desc->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked();
+ CHECK(
+ env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust());
ExpectBoolean("undefined == void 0", true);
ExpectBoolean("undetectable == void 0", true);
@@ -6103,8 +6883,12 @@ THREADED_TEST(ExtensibleOnUndetectable) {
Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate);
desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
- Local<v8::Object> obj = desc->GetFunction()->NewInstance();
- env->Global()->Set(v8_str("undetectable"), obj);
+ Local<v8::Object> obj = desc->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked();
+ CHECK(
+ env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust());
Local<String> source = v8_str(
"undetectable.x = 42;"
@@ -6112,18 +6896,20 @@ THREADED_TEST(ExtensibleOnUndetectable) {
Local<Script> script = v8_compile(source);
- CHECK(v8::Integer::New(isolate, 42)->Equals(script->Run()));
+ CHECK(v8::Integer::New(isolate, 42)
+ ->Equals(env.local(), script->Run(env.local()).ToLocalChecked())
+ .FromJust());
ExpectBoolean("Object.isExtensible(undetectable)", true);
source = v8_str("Object.preventExtensions(undetectable);");
script = v8_compile(source);
- script->Run();
+ script->Run(env.local()).ToLocalChecked();
ExpectBoolean("Object.isExtensible(undetectable)", false);
source = v8_str("undetectable.y = 2000;");
script = v8_compile(source);
- script->Run();
+ script->Run(env.local()).ToLocalChecked();
ExpectBoolean("undetectable.y == undefined", true);
}
@@ -6175,10 +6961,11 @@ TEST(SimpleExtensions) {
v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource));
const char* extension_names[] = {"simpletest"};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
Context::Scope lock(context);
- v8::Handle<Value> result = CompileRun("Foo()");
- CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 4)));
+ v8::Local<Value> result = CompileRun("Foo()");
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 4))
+ .FromJust());
}
@@ -6197,15 +6984,15 @@ TEST(StackTraceInExtension) {
new Extension("stacktracetest", kStackTraceFromExtensionSource));
const char* extension_names[] = {"stacktracetest"};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
Context::Scope lock(context);
CompileRun(
"function user() { bar(); }"
"var error;"
"try{ user(); } catch (e) { error = e; }");
- CHECK_EQ(-1, CompileRun("error.stack.indexOf('foo')")->Int32Value());
- CHECK_EQ(-1, CompileRun("error.stack.indexOf('bar')")->Int32Value());
- CHECK_NE(-1, CompileRun("error.stack.indexOf('user')")->Int32Value());
+ CHECK_EQ(-1, v8_run_int32value(v8_compile("error.stack.indexOf('foo')")));
+ CHECK_EQ(-1, v8_run_int32value(v8_compile("error.stack.indexOf('bar')")));
+ CHECK_NE(-1, v8_run_int32value(v8_compile("error.stack.indexOf('user')")));
}
@@ -6214,10 +7001,11 @@ TEST(NullExtensions) {
v8::RegisterExtension(new Extension("nulltest", NULL));
const char* extension_names[] = {"nulltest"};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
Context::Scope lock(context);
- v8::Handle<Value> result = CompileRun("1+3");
- CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 4)));
+ v8::Local<Value> result = CompileRun("1+3");
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 4))
+ .FromJust());
}
@@ -6233,7 +7021,7 @@ TEST(ExtensionMissingSourceLength) {
new Extension("srclentest_fail", kEmbeddedExtensionSource));
const char* extension_names[] = {"srclentest_fail"};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
CHECK(0 == *context);
}
@@ -6248,11 +7036,13 @@ TEST(ExtensionWithSourceLength) {
extension_name.start(), kEmbeddedExtensionSource, 0, 0, source_len));
const char* extension_names[1] = {extension_name.start()};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
if (source_len == kEmbeddedExtensionSourceValidLen) {
Context::Scope lock(context);
- v8::Handle<Value> result = CompileRun("Ret54321()");
- CHECK(v8::Integer::New(CcTest::isolate(), 54321)->Equals(result));
+ v8::Local<Value> result = CompileRun("Ret54321()");
+ CHECK(v8::Integer::New(CcTest::isolate(), 54321)
+ ->Equals(context, result)
+ .FromJust());
} else {
// Anything but exactly the right length should fail to compile.
CHECK(0 == *context);
@@ -6284,12 +7074,14 @@ TEST(UseEvalFromExtension) {
v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2));
const char* extension_names[] = {"evaltest1", "evaltest2"};
v8::ExtensionConfiguration extensions(2, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
Context::Scope lock(context);
- v8::Handle<Value> result = CompileRun("UseEval1()");
- CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 42)));
+ v8::Local<Value> result = CompileRun("UseEval1()");
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 42))
+ .FromJust());
result = CompileRun("UseEval2()");
- CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 42)));
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 42))
+ .FromJust());
}
@@ -6316,12 +7108,14 @@ TEST(UseWithFromExtension) {
v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2));
const char* extension_names[] = {"withtest1", "withtest2"};
v8::ExtensionConfiguration extensions(2, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
Context::Scope lock(context);
- v8::Handle<Value> result = CompileRun("UseWith1()");
- CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 87)));
+ v8::Local<Value> result = CompileRun("UseWith1()");
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 87))
+ .FromJust());
result = CompileRun("UseWith2()");
- CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 87)));
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 87))
+ .FromJust());
}
@@ -6330,10 +7124,11 @@ TEST(AutoExtensions) {
Extension* extension = new Extension("autotest", kSimpleExtensionSource);
extension->set_auto_enable(true);
v8::RegisterExtension(extension);
- v8::Handle<Context> context = Context::New(CcTest::isolate());
+ v8::Local<Context> context = Context::New(CcTest::isolate());
Context::Scope lock(context);
- v8::Handle<Value> result = CompileRun("Foo()");
- CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 4)));
+ v8::Local<Value> result = CompileRun("Foo()");
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 4))
+ .FromJust());
}
@@ -6348,7 +7143,7 @@ TEST(SyntaxErrorExtensions) {
new Extension("syntaxerror", kSyntaxErrorInExtensionSource));
const char* extension_names[] = {"syntaxerror"};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
CHECK(context.IsEmpty());
}
@@ -6364,7 +7159,7 @@ TEST(ExceptionExtensions) {
new Extension("exception", kExceptionInExtensionSource));
const char* extension_names[] = {"exception"};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
CHECK(context.IsEmpty());
}
@@ -6385,10 +7180,11 @@ TEST(NativeCallInExtensions) {
new Extension("nativecall", kNativeCallInExtensionSource));
const char* extension_names[] = {"nativecall"};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
Context::Scope lock(context);
- v8::Handle<Value> result = CompileRun(kNativeCallTest);
- CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 3)));
+ v8::Local<Value> result = CompileRun(kNativeCallTest);
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 3))
+ .FromJust());
}
@@ -6398,8 +7194,8 @@ class NativeFunctionExtension : public Extension {
v8::FunctionCallback fun = &Echo)
: Extension(name, source), function_(fun) {}
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
- v8::Isolate* isolate, v8::Handle<v8::String> name) {
+ virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
+ v8::Isolate* isolate, v8::Local<v8::String> name) {
return v8::FunctionTemplate::New(isolate, function_);
}
@@ -6419,10 +7215,11 @@ TEST(NativeFunctionDeclaration) {
new NativeFunctionExtension(name, "native function foo();"));
const char* extension_names[] = {name};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
Context::Scope lock(context);
- v8::Handle<Value> result = CompileRun("foo(42);");
- CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 42)));
+ v8::Local<Value> result = CompileRun("foo(42);");
+ CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 42))
+ .FromJust());
}
@@ -6434,7 +7231,7 @@ TEST(NativeFunctionDeclarationError) {
new NativeFunctionExtension(name, "native\nfunction foo();"));
const char* extension_names[] = {name};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
CHECK(context.IsEmpty());
}
@@ -6448,7 +7245,7 @@ TEST(NativeFunctionDeclarationErrorEscape) {
new NativeFunctionExtension(name, "nativ\\u0065 function foo();"));
const char* extension_names[] = {name};
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &extensions);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
CHECK(context.IsEmpty());
}
@@ -6457,8 +7254,12 @@ static void CheckDependencies(const char* name, const char* expected) {
v8::HandleScope handle_scope(CcTest::isolate());
v8::ExtensionConfiguration config(1, &name);
LocalContext context(&config);
- CHECK(String::NewFromUtf8(CcTest::isolate(), expected)
- ->Equals(context->Global()->Get(v8_str("loaded"))));
+ CHECK(
+ v8_str(expected)
+ ->Equals(context.local(), context->Global()
+ ->Get(context.local(), v8_str("loaded"))
+ .ToLocalChecked())
+ .FromJust());
}
@@ -6487,8 +7288,12 @@ THREADED_TEST(ExtensionDependency) {
static const char* exts[2] = {"C", "E"};
v8::ExtensionConfiguration config(2, exts);
LocalContext context(&config);
- CHECK(v8_str("undefinedACBDE")
- ->Equals(context->Global()->Get(v8_str("loaded"))));
+ CHECK(
+ v8_str("undefinedACBDE")
+ ->Equals(context.local(), context->Global()
+ ->Get(context.local(), v8_str("loaded"))
+ .ToLocalChecked())
+ .FromJust());
}
@@ -6506,7 +7311,10 @@ static const char* kExtensionTestScript =
static void CallFun(const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
if (args.IsConstructCall()) {
- args.This()->Set(v8_str("data"), args.Data());
+ CHECK(args.This()
+ ->Set(args.GetIsolate()->GetCurrentContext(), v8_str("data"),
+ args.Data())
+ .FromJust());
args.GetReturnValue().SetNull();
return;
}
@@ -6517,26 +7325,28 @@ static void CallFun(const v8::FunctionCallbackInfo<v8::Value>& args) {
class FunctionExtension : public Extension {
public:
FunctionExtension() : Extension("functiontest", kExtensionTestScript) {}
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
- v8::Isolate* isolate, v8::Handle<String> name);
+ virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
+ v8::Isolate* isolate, v8::Local<String> name);
};
static int lookup_count = 0;
-v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate(
- v8::Isolate* isolate, v8::Handle<String> name) {
+v8::Local<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate(
+ v8::Isolate* isolate, v8::Local<String> name) {
lookup_count++;
- if (name->Equals(v8_str("A"))) {
+ if (name->Equals(isolate->GetCurrentContext(), v8_str("A")).FromJust()) {
return v8::FunctionTemplate::New(isolate, CallFun,
v8::Integer::New(isolate, 8));
- } else if (name->Equals(v8_str("B"))) {
+ } else if (name->Equals(isolate->GetCurrentContext(), v8_str("B"))
+ .FromJust()) {
return v8::FunctionTemplate::New(isolate, CallFun,
v8::Integer::New(isolate, 7));
- } else if (name->Equals(v8_str("C"))) {
+ } else if (name->Equals(isolate->GetCurrentContext(), v8_str("C"))
+ .FromJust()) {
return v8::FunctionTemplate::New(isolate, CallFun,
v8::Integer::New(isolate, 6));
} else {
- return v8::Handle<v8::FunctionTemplate>();
+ return v8::Local<v8::FunctionTemplate>();
}
}
@@ -6548,9 +7358,15 @@ THREADED_TEST(FunctionLookup) {
v8::ExtensionConfiguration config(1, exts);
LocalContext context(&config);
CHECK_EQ(3, lookup_count);
- CHECK(v8::Integer::New(CcTest::isolate(), 8)->Equals(CompileRun("Foo(0)")));
- CHECK(v8::Integer::New(CcTest::isolate(), 7)->Equals(CompileRun("Foo(1)")));
- CHECK(v8::Integer::New(CcTest::isolate(), 6)->Equals(CompileRun("Foo(2)")));
+ CHECK(v8::Integer::New(CcTest::isolate(), 8)
+ ->Equals(context.local(), CompileRun("Foo(0)"))
+ .FromJust());
+ CHECK(v8::Integer::New(CcTest::isolate(), 7)
+ ->Equals(context.local(), CompileRun("Foo(1)"))
+ .FromJust());
+ CHECK(v8::Integer::New(CcTest::isolate(), 6)
+ ->Equals(context.local(), CompileRun("Foo(2)"))
+ .FromJust());
}
@@ -6564,11 +7380,14 @@ THREADED_TEST(NativeFunctionConstructCall) {
// Run a few times to ensure that allocation of objects doesn't
// change behavior of a constructor function.
CHECK(v8::Integer::New(CcTest::isolate(), 8)
- ->Equals(CompileRun("(new A()).data")));
+ ->Equals(context.local(), CompileRun("(new A()).data"))
+ .FromJust());
CHECK(v8::Integer::New(CcTest::isolate(), 7)
- ->Equals(CompileRun("(new B()).data")));
+ ->Equals(context.local(), CompileRun("(new B()).data"))
+ .FromJust());
CHECK(v8::Integer::New(CcTest::isolate(), 6)
- ->Equals(CompileRun("(new C()).data")));
+ ->Equals(context.local(), CompileRun("(new C()).data"))
+ .FromJust());
}
}
@@ -6587,35 +7406,39 @@ void StoringErrorCallback(const char* location, const char* message) {
// tests that the fatal error handler gets called. This renders V8
// unusable and therefore this test cannot be run in parallel.
TEST(ErrorReporting) {
- v8::V8::SetFatalErrorHandler(StoringErrorCallback);
+ CcTest::isolate()->SetFatalErrorHandler(StoringErrorCallback);
static const char* aDeps[] = {"B"};
v8::RegisterExtension(new Extension("A", "", 1, aDeps));
static const char* bDeps[] = {"A"};
v8::RegisterExtension(new Extension("B", "", 1, bDeps));
last_location = NULL;
v8::ExtensionConfiguration config(1, bDeps);
- v8::Handle<Context> context = Context::New(CcTest::isolate(), &config);
+ v8::Local<Context> context = Context::New(CcTest::isolate(), &config);
CHECK(context.IsEmpty());
CHECK(last_location);
}
-static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message,
- v8::Handle<Value> data) {
+static void MissingScriptInfoMessageListener(v8::Local<v8::Message> message,
+ v8::Local<Value> data) {
+ v8::Isolate* isolate = CcTest::isolate();
+ Local<Context> context = isolate->GetCurrentContext();
CHECK(message->GetScriptOrigin().ResourceName()->IsUndefined());
- CHECK(v8::Undefined(CcTest::isolate())
- ->Equals(message->GetScriptOrigin().ResourceName()));
- message->GetLineNumber();
- message->GetSourceLine();
+ CHECK(v8::Undefined(isolate)
+ ->Equals(context, message->GetScriptOrigin().ResourceName())
+ .FromJust());
+ message->GetLineNumber(context).FromJust();
+ message->GetSourceLine(context).ToLocalChecked();
}
THREADED_TEST(ErrorWithMissingScriptInfo) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::V8::AddMessageListener(MissingScriptInfoMessageListener);
+ context->GetIsolate()->AddMessageListener(MissingScriptInfoMessageListener);
CompileRun("throw Error()");
- v8::V8::RemoveMessageListeners(MissingScriptInfoMessageListener);
+ context->GetIsolate()->RemoveMessageListeners(
+ MissingScriptInfoMessageListener);
}
@@ -6634,7 +7457,7 @@ static void SetFlag(const v8::WeakCallbackInfo<FlagAndPersistent>& data) {
static void IndependentWeakHandle(bool global_gc, bool interlinked) {
v8::Isolate* iso = CcTest::isolate();
v8::HandleScope scope(iso);
- v8::Handle<Context> context = Context::New(iso);
+ v8::Local<Context> context = Context::New(iso);
Context::Scope context_scope(context);
FlagAndPersistent object_a, object_b;
@@ -6648,8 +7471,8 @@ static void IndependentWeakHandle(bool global_gc, bool interlinked) {
object_a.handle.Reset(iso, a);
object_b.handle.Reset(iso, b);
if (interlinked) {
- a->Set(v8_str("x"), b);
- b->Set(v8_str("x"), a);
+ a->Set(context, v8_str("x"), b).FromJust();
+ b->Set(context, v8_str("x"), a).FromJust();
}
if (global_gc) {
CcTest::heap()->CollectAllGarbage();
@@ -6658,8 +7481,8 @@ static void IndependentWeakHandle(bool global_gc, bool interlinked) {
}
// We are relying on this creating a big flag array and reserving the space
// up front.
- v8::Handle<Value> big_array = CompileRun("new Array(5000)");
- a->Set(v8_str("y"), big_array);
+ v8::Local<Value> big_array = CompileRun("new Array(5000)");
+ a->Set(context, v8_str("y"), big_array).FromJust();
big_heap_size = CcTest::heap()->SizeOfObjects();
}
@@ -6726,8 +7549,8 @@ void CheckInternalFields(
const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
v8::Persistent<v8::Object>* handle = data.GetParameter();
handle->Reset();
- Trivial* t1 = reinterpret_cast<Trivial*>(data.GetInternalField1());
- Trivial2* t2 = reinterpret_cast<Trivial2*>(data.GetInternalField2());
+ Trivial* t1 = reinterpret_cast<Trivial*>(data.GetInternalField(0));
+ Trivial2* t2 = reinterpret_cast<Trivial2*>(data.GetInternalField(1));
CHECK_EQ(42, t1->x());
CHECK_EQ(103, t2->x());
t1->set_x(1729);
@@ -6747,7 +7570,10 @@ void InternalFieldCallback(bool global_gc) {
instance_templ->SetInternalFieldCount(2);
{
v8::HandleScope scope(isolate);
- Local<v8::Object> obj = templ->GetFunction()->NewInstance();
+ Local<v8::Object> obj = templ->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked();
v8::Persistent<v8::Object> handle(isolate, obj);
CHECK_EQ(2, obj->InternalFieldCount());
CHECK(obj->GetInternalField(0)->IsUndefined());
@@ -6805,7 +7631,7 @@ void v8::internal::HeapTester::ResetWeakHandle(bool global_gc) {
v8::Isolate* iso = CcTest::isolate();
v8::HandleScope scope(iso);
- v8::Handle<Context> context = Context::New(iso);
+ v8::Local<Context> context = Context::New(iso);
Context::Scope context_scope(context);
FlagAndPersistent object_a, object_b;
@@ -6886,7 +7712,7 @@ THREADED_TEST(GCFromWeakCallbacks) {
v8::Isolate* isolate = CcTest::isolate();
v8::Locker locker(CcTest::isolate());
v8::HandleScope scope(isolate);
- v8::Handle<Context> context = Context::New(isolate);
+ v8::Local<Context> context = Context::New(isolate);
Context::Scope context_scope(context);
static const int kNumberOfGCTypes = 2;
@@ -6916,19 +7742,20 @@ THREADED_TEST(GCFromWeakCallbacks) {
}
-v8::Handle<Function> args_fun;
+v8::Local<Function> args_fun;
static void ArgumentsTestCallback(
const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
v8::Isolate* isolate = args.GetIsolate();
- CHECK(args_fun->Equals(args.Callee()));
+ Local<Context> context = isolate->GetCurrentContext();
+ CHECK(args_fun->Equals(context, args.Callee()).FromJust());
CHECK_EQ(3, args.Length());
- CHECK(v8::Integer::New(isolate, 1)->Equals(args[0]));
- CHECK(v8::Integer::New(isolate, 2)->Equals(args[1]));
- CHECK(v8::Integer::New(isolate, 3)->Equals(args[2]));
- CHECK(v8::Undefined(isolate)->Equals(args[3]));
+ CHECK(v8::Integer::New(isolate, 1)->Equals(context, args[0]).FromJust());
+ CHECK(v8::Integer::New(isolate, 2)->Equals(context, args[1]).FromJust());
+ CHECK(v8::Integer::New(isolate, 3)->Equals(context, args[2]).FromJust());
+ CHECK(v8::Undefined(isolate)->Equals(context, args[3]).FromJust());
v8::HandleScope scope(args.GetIsolate());
CcTest::heap()->CollectAllGarbage();
}
@@ -6937,12 +7764,15 @@ static void ArgumentsTestCallback(
THREADED_TEST(Arguments) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> global = ObjectTemplate::New(isolate);
global->Set(v8_str("f"),
v8::FunctionTemplate::New(isolate, ArgumentsTestCallback));
LocalContext context(NULL, global);
- args_fun = context->Global()->Get(v8_str("f")).As<Function>();
- v8_compile("f(1, 2, 3)")->Run();
+ args_fun = context->Global()
+ ->Get(context.local(), v8_str("f"))
+ .ToLocalChecked()
+ .As<Function>();
+ v8_compile("f(1, 2, 3)")->Run(context.local()).ToLocalChecked();
}
@@ -6950,29 +7780,47 @@ static int p_getter_count;
static int p_getter_count2;
-static void PGetter(Local<String> name,
+static void PGetter(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
p_getter_count++;
- v8::Handle<v8::Object> global =
- info.GetIsolate()->GetCurrentContext()->Global();
- CHECK(info.Holder()->Equals(global->Get(v8_str("o1"))));
- if (name->Equals(v8_str("p1"))) {
- CHECK(info.This()->Equals(global->Get(v8_str("o1"))));
- } else if (name->Equals(v8_str("p2"))) {
- CHECK(info.This()->Equals(global->Get(v8_str("o2"))));
- } else if (name->Equals(v8_str("p3"))) {
- CHECK(info.This()->Equals(global->Get(v8_str("o3"))));
- } else if (name->Equals(v8_str("p4"))) {
- CHECK(info.This()->Equals(global->Get(v8_str("o4"))));
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ v8::Local<v8::Object> global = context->Global();
+ CHECK(
+ info.Holder()
+ ->Equals(context, global->Get(context, v8_str("o1")).ToLocalChecked())
+ .FromJust());
+ if (name->Equals(context, v8_str("p1")).FromJust()) {
+ CHECK(info.This()
+ ->Equals(context,
+ global->Get(context, v8_str("o1")).ToLocalChecked())
+ .FromJust());
+ } else if (name->Equals(context, v8_str("p2")).FromJust()) {
+ CHECK(info.This()
+ ->Equals(context,
+ global->Get(context, v8_str("o2")).ToLocalChecked())
+ .FromJust());
+ } else if (name->Equals(context, v8_str("p3")).FromJust()) {
+ CHECK(info.This()
+ ->Equals(context,
+ global->Get(context, v8_str("o3")).ToLocalChecked())
+ .FromJust());
+ } else if (name->Equals(context, v8_str("p4")).FromJust()) {
+ CHECK(info.This()
+ ->Equals(context,
+ global->Get(context, v8_str("o4")).ToLocalChecked())
+ .FromJust());
}
}
-static void RunHolderTest(v8::Handle<v8::ObjectTemplate> obj) {
+static void RunHolderTest(v8::Local<v8::ObjectTemplate> obj) {
ApiTestFuzzer::Fuzz();
LocalContext context;
- context->Global()->Set(v8_str("o1"), obj->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o1"),
+ obj->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"o1.__proto__ = { };"
"var o2 = { __proto__: o1 };"
@@ -6989,17 +7837,32 @@ static void PGetter2(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
p_getter_count2++;
- v8::Handle<v8::Object> global =
- info.GetIsolate()->GetCurrentContext()->Global();
- CHECK(info.Holder()->Equals(global->Get(v8_str("o1"))));
- if (name->Equals(v8_str("p1"))) {
- CHECK(info.This()->Equals(global->Get(v8_str("o1"))));
- } else if (name->Equals(v8_str("p2"))) {
- CHECK(info.This()->Equals(global->Get(v8_str("o2"))));
- } else if (name->Equals(v8_str("p3"))) {
- CHECK(info.This()->Equals(global->Get(v8_str("o3"))));
- } else if (name->Equals(v8_str("p4"))) {
- CHECK(info.This()->Equals(global->Get(v8_str("o4"))));
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ v8::Local<v8::Object> global = context->Global();
+ CHECK(
+ info.Holder()
+ ->Equals(context, global->Get(context, v8_str("o1")).ToLocalChecked())
+ .FromJust());
+ if (name->Equals(context, v8_str("p1")).FromJust()) {
+ CHECK(info.This()
+ ->Equals(context,
+ global->Get(context, v8_str("o1")).ToLocalChecked())
+ .FromJust());
+ } else if (name->Equals(context, v8_str("p2")).FromJust()) {
+ CHECK(info.This()
+ ->Equals(context,
+ global->Get(context, v8_str("o2")).ToLocalChecked())
+ .FromJust());
+ } else if (name->Equals(context, v8_str("p3")).FromJust()) {
+ CHECK(info.This()
+ ->Equals(context,
+ global->Get(context, v8_str("o3")).ToLocalChecked())
+ .FromJust());
+ } else if (name->Equals(context, v8_str("p4")).FromJust()) {
+ CHECK(info.This()
+ ->Equals(context,
+ global->Get(context, v8_str("o4")).ToLocalChecked())
+ .FromJust());
}
}
@@ -7007,7 +7870,7 @@ static void PGetter2(Local<Name> name,
THREADED_TEST(GetterHolders) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
obj->SetAccessor(v8_str("p1"), PGetter);
obj->SetAccessor(v8_str("p2"), PGetter);
obj->SetAccessor(v8_str("p3"), PGetter);
@@ -7021,7 +7884,7 @@ THREADED_TEST(GetterHolders) {
THREADED_TEST(PreInterceptorHolders) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
obj->SetHandler(v8::NamedPropertyHandlerConfiguration(PGetter2));
p_getter_count2 = 0;
RunHolderTest(obj);
@@ -7032,19 +7895,26 @@ THREADED_TEST(PreInterceptorHolders) {
THREADED_TEST(ObjectInstantiation) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetAccessor(v8_str("t"), PGetter2);
LocalContext context;
- context->Global()->Set(v8_str("o"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
for (int i = 0; i < 100; i++) {
v8::HandleScope inner_scope(CcTest::isolate());
- v8::Handle<v8::Object> obj = templ->NewInstance();
- CHECK(!obj->Equals(context->Global()->Get(v8_str("o"))));
- context->Global()->Set(v8_str("o2"), obj);
- v8::Handle<Value> value =
- CompileRun("o.__proto__ === o2.__proto__");
- CHECK(v8::True(isolate)->Equals(value));
- context->Global()->Set(v8_str("o"), obj);
+ v8::Local<v8::Object> obj =
+ templ->NewInstance(context.local()).ToLocalChecked();
+ CHECK(!obj->Equals(context.local(), context->Global()
+ ->Get(context.local(), v8_str("o"))
+ .ToLocalChecked())
+ .FromJust());
+ CHECK(
+ context->Global()->Set(context.local(), v8_str("o2"), obj).FromJust());
+ v8::Local<Value> value = CompileRun("o.__proto__ === o2.__proto__");
+ CHECK(v8::True(isolate)->Equals(context.local(), value).FromJust());
+ CHECK(context->Global()->Set(context.local(), v8_str("o"), obj).FromJust());
}
}
@@ -7070,7 +7940,7 @@ static int StrNCmp16(uint16_t* a, uint16_t* b, int n) {
}
-int GetUtf8Length(Handle<String> str) {
+int GetUtf8Length(Local<String> str) {
int len = str->Utf8Length();
if (len < 0) {
i::Handle<i::String> istr(v8::Utils::OpenHandle(*str));
@@ -7084,27 +7954,37 @@ int GetUtf8Length(Handle<String> str) {
THREADED_TEST(StringWrite) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::Handle<String> str = v8_str("abcde");
+ v8::Local<String> str = v8_str("abcde");
// abc<Icelandic eth><Unicode snowman>.
- v8::Handle<String> str2 = v8_str("abc\303\260\342\230\203");
- v8::Handle<String> str3 = v8::String::NewFromUtf8(
- context->GetIsolate(), "abc\0def", v8::String::kNormalString, 7);
+ v8::Local<String> str2 = v8_str("abc\303\260\342\230\203");
+ v8::Local<String> str3 =
+ v8::String::NewFromUtf8(context->GetIsolate(), "abc\0def",
+ v8::NewStringType::kNormal, 7)
+ .ToLocalChecked();
// "ab" + lead surrogate + "cd" + trail surrogate + "ef"
uint16_t orphans[8] = { 0x61, 0x62, 0xd800, 0x63, 0x64, 0xdc00, 0x65, 0x66 };
- v8::Handle<String> orphans_str = v8::String::NewFromTwoByte(
- context->GetIsolate(), orphans, v8::String::kNormalString, 8);
+ v8::Local<String> orphans_str =
+ v8::String::NewFromTwoByte(context->GetIsolate(), orphans,
+ v8::NewStringType::kNormal, 8)
+ .ToLocalChecked();
// single lead surrogate
uint16_t lead[1] = { 0xd800 };
- v8::Handle<String> lead_str = v8::String::NewFromTwoByte(
- context->GetIsolate(), lead, v8::String::kNormalString, 1);
+ v8::Local<String> lead_str =
+ v8::String::NewFromTwoByte(context->GetIsolate(), lead,
+ v8::NewStringType::kNormal, 1)
+ .ToLocalChecked();
// single trail surrogate
uint16_t trail[1] = { 0xdc00 };
- v8::Handle<String> trail_str = v8::String::NewFromTwoByte(
- context->GetIsolate(), trail, v8::String::kNormalString, 1);
+ v8::Local<String> trail_str =
+ v8::String::NewFromTwoByte(context->GetIsolate(), trail,
+ v8::NewStringType::kNormal, 1)
+ .ToLocalChecked();
// surrogate pair
uint16_t pair[2] = { 0xd800, 0xdc00 };
- v8::Handle<String> pair_str = v8::String::NewFromTwoByte(
- context->GetIsolate(), pair, v8::String::kNormalString, 2);
+ v8::Local<String> pair_str =
+ v8::String::NewFromTwoByte(context->GetIsolate(), pair,
+ v8::NewStringType::kNormal, 2)
+ .ToLocalChecked();
const int kStride = 4; // Must match stride in for loops in JS below.
CompileRun(
"var left = '';"
@@ -7116,9 +7996,13 @@ THREADED_TEST(StringWrite) {
"for (var i = 0; i < 0xd800; i += 4) {"
" right = String.fromCharCode(i) + right;"
"}");
- v8::Handle<v8::Object> global = context->Global();
- Handle<String> left_tree = global->Get(v8_str("left")).As<String>();
- Handle<String> right_tree = global->Get(v8_str("right")).As<String>();
+ v8::Local<v8::Object> global = context->Global();
+ Local<String> left_tree = global->Get(context.local(), v8_str("left"))
+ .ToLocalChecked()
+ .As<String>();
+ Local<String> right_tree = global->Get(context.local(), v8_str("right"))
+ .ToLocalChecked()
+ .As<String>();
CHECK_EQ(5, str2->Length());
CHECK_EQ(0xd800 / kStride, left_tree->Length());
@@ -7394,15 +8278,17 @@ static void Utf16Helper(
const char* name,
const char* lengths_name,
int len) {
- Local<v8::Array> a =
- Local<v8::Array>::Cast(context->Global()->Get(v8_str(name)));
+ Local<v8::Array> a = Local<v8::Array>::Cast(
+ context->Global()->Get(context.local(), v8_str(name)).ToLocalChecked());
Local<v8::Array> alens =
- Local<v8::Array>::Cast(context->Global()->Get(v8_str(lengths_name)));
+ Local<v8::Array>::Cast(context->Global()
+ ->Get(context.local(), v8_str(lengths_name))
+ .ToLocalChecked());
for (int i = 0; i < len; i++) {
Local<v8::String> string =
- Local<v8::String>::Cast(a->Get(i));
- Local<v8::Number> expected_len =
- Local<v8::Number>::Cast(alens->Get(i));
+ Local<v8::String>::Cast(a->Get(context.local(), i).ToLocalChecked());
+ Local<v8::Number> expected_len = Local<v8::Number>::Cast(
+ alens->Get(context.local(), i).ToLocalChecked());
int length = GetUtf8Length(string);
CHECK_EQ(static_cast<int>(expected_len->Value()), length);
}
@@ -7458,7 +8344,7 @@ THREADED_TEST(Utf16) {
}
-static bool SameSymbol(Handle<String> s1, Handle<String> s2) {
+static bool SameSymbol(Local<String> s1, Local<String> s2) {
i::Handle<i::String> is1(v8::Utils::OpenHandle(*s1));
i::Handle<i::String> is2(v8::Utils::OpenHandle(*s2));
return *is1 == *is2;
@@ -7469,10 +8355,14 @@ THREADED_TEST(Utf16Symbol) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- Handle<String> symbol1 = v8::String::NewFromUtf8(
- context->GetIsolate(), "abc", v8::String::kInternalizedString);
- Handle<String> symbol2 = v8::String::NewFromUtf8(
- context->GetIsolate(), "abc", v8::String::kInternalizedString);
+ Local<String> symbol1 =
+ v8::String::NewFromUtf8(context->GetIsolate(), "abc",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
+ Local<String> symbol2 =
+ v8::String::NewFromUtf8(context->GetIsolate(), "abc",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
CHECK(SameSymbol(symbol1, symbol2));
CompileRun(
@@ -7490,35 +8380,49 @@ THREADED_TEST(Utf16Symbol) {
"if (sym3.charCodeAt(2) != 0xdc07) throw sym1.charCodeAt(2);"
"if (sym4.length != 3) throw sym4;"
"if (sym4.charCodeAt(2) != 0xdc08) throw sym2.charCodeAt(2);");
- Handle<String> sym0 = v8::String::NewFromUtf8(
- context->GetIsolate(), "benedictus", v8::String::kInternalizedString);
- Handle<String> sym0b = v8::String::NewFromUtf8(
- context->GetIsolate(), "S\303\270ren", v8::String::kInternalizedString);
- Handle<String> sym1 =
+ Local<String> sym0 =
+ v8::String::NewFromUtf8(context->GetIsolate(), "benedictus",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
+ Local<String> sym0b =
+ v8::String::NewFromUtf8(context->GetIsolate(), "S\303\270ren",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
+ Local<String> sym1 =
v8::String::NewFromUtf8(context->GetIsolate(), "\355\240\201\355\260\207",
- v8::String::kInternalizedString);
- Handle<String> sym2 =
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
+ Local<String> sym2 =
v8::String::NewFromUtf8(context->GetIsolate(), "\360\220\220\210",
- v8::String::kInternalizedString);
- Handle<String> sym3 = v8::String::NewFromUtf8(
- context->GetIsolate(), "x\355\240\201\355\260\207",
- v8::String::kInternalizedString);
- Handle<String> sym4 =
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
+ Local<String> sym3 = v8::String::NewFromUtf8(context->GetIsolate(),
+ "x\355\240\201\355\260\207",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
+ Local<String> sym4 =
v8::String::NewFromUtf8(context->GetIsolate(), "x\360\220\220\210",
- v8::String::kInternalizedString);
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
v8::Local<v8::Object> global = context->Global();
- Local<Value> s0 = global->Get(v8_str("sym0"));
- Local<Value> s0b = global->Get(v8_str("sym0b"));
- Local<Value> s1 = global->Get(v8_str("sym1"));
- Local<Value> s2 = global->Get(v8_str("sym2"));
- Local<Value> s3 = global->Get(v8_str("sym3"));
- Local<Value> s4 = global->Get(v8_str("sym4"));
- CHECK(SameSymbol(sym0, Handle<String>::Cast(s0)));
- CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b)));
- CHECK(SameSymbol(sym1, Handle<String>::Cast(s1)));
- CHECK(SameSymbol(sym2, Handle<String>::Cast(s2)));
- CHECK(SameSymbol(sym3, Handle<String>::Cast(s3)));
- CHECK(SameSymbol(sym4, Handle<String>::Cast(s4)));
+ Local<Value> s0 =
+ global->Get(context.local(), v8_str("sym0")).ToLocalChecked();
+ Local<Value> s0b =
+ global->Get(context.local(), v8_str("sym0b")).ToLocalChecked();
+ Local<Value> s1 =
+ global->Get(context.local(), v8_str("sym1")).ToLocalChecked();
+ Local<Value> s2 =
+ global->Get(context.local(), v8_str("sym2")).ToLocalChecked();
+ Local<Value> s3 =
+ global->Get(context.local(), v8_str("sym3")).ToLocalChecked();
+ Local<Value> s4 =
+ global->Get(context.local(), v8_str("sym4")).ToLocalChecked();
+ CHECK(SameSymbol(sym0, Local<String>::Cast(s0)));
+ CHECK(SameSymbol(sym0b, Local<String>::Cast(s0b)));
+ CHECK(SameSymbol(sym1, Local<String>::Cast(s1)));
+ CHECK(SameSymbol(sym2, Local<String>::Cast(s2)));
+ CHECK(SameSymbol(sym3, Local<String>::Cast(s3)));
+ CHECK(SameSymbol(sym4, Local<String>::Cast(s4)));
}
@@ -7578,29 +8482,32 @@ THREADED_TEST(ToArrayIndex) {
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<String> str = v8_str("42");
- v8::Handle<v8::Uint32> index = str->ToArrayIndex();
+ v8::Local<String> str = v8_str("42");
+ v8::MaybeLocal<v8::Uint32> index = str->ToArrayIndex(context.local());
CHECK(!index.IsEmpty());
- CHECK_EQ(42.0, index->Uint32Value());
+ CHECK_EQ(42.0,
+ index.ToLocalChecked()->Uint32Value(context.local()).FromJust());
str = v8_str("42asdf");
- index = str->ToArrayIndex();
+ index = str->ToArrayIndex(context.local());
CHECK(index.IsEmpty());
str = v8_str("-42");
- index = str->ToArrayIndex();
+ index = str->ToArrayIndex(context.local());
CHECK(index.IsEmpty());
str = v8_str("4294967294");
- index = str->ToArrayIndex();
+ index = str->ToArrayIndex(context.local());
CHECK(!index.IsEmpty());
- CHECK_EQ(4294967294.0, index->Uint32Value());
- v8::Handle<v8::Number> num = v8::Number::New(isolate, 1);
- index = num->ToArrayIndex();
+ CHECK_EQ(4294967294.0,
+ index.ToLocalChecked()->Uint32Value(context.local()).FromJust());
+ v8::Local<v8::Number> num = v8::Number::New(isolate, 1);
+ index = num->ToArrayIndex(context.local());
CHECK(!index.IsEmpty());
- CHECK_EQ(1.0, index->Uint32Value());
+ CHECK_EQ(1.0,
+ index.ToLocalChecked()->Uint32Value(context.local()).FromJust());
num = v8::Number::New(isolate, -1);
- index = num->ToArrayIndex();
+ index = num->ToArrayIndex(context.local());
CHECK(index.IsEmpty());
- v8::Handle<v8::Object> obj = v8::Object::New(isolate);
- index = obj->ToArrayIndex();
+ v8::Local<v8::Object> obj = v8::Object::New(isolate);
+ index = obj->ToArrayIndex(context.local());
CHECK(index.IsEmpty());
}
@@ -7609,33 +8516,58 @@ THREADED_TEST(ErrorConstruction) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::Handle<String> foo = v8_str("foo");
- v8::Handle<String> message = v8_str("message");
- v8::Handle<Value> range_error = v8::Exception::RangeError(foo);
+ v8::Local<String> foo = v8_str("foo");
+ v8::Local<String> message = v8_str("message");
+ v8::Local<Value> range_error = v8::Exception::RangeError(foo);
CHECK(range_error->IsObject());
- CHECK(range_error.As<v8::Object>()->Get(message)->Equals(foo));
- v8::Handle<Value> reference_error = v8::Exception::ReferenceError(foo);
+ CHECK(range_error.As<v8::Object>()
+ ->Get(context.local(), message)
+ .ToLocalChecked()
+ ->Equals(context.local(), foo)
+ .FromJust());
+ v8::Local<Value> reference_error = v8::Exception::ReferenceError(foo);
CHECK(reference_error->IsObject());
- CHECK(reference_error.As<v8::Object>()->Get(message)->Equals(foo));
- v8::Handle<Value> syntax_error = v8::Exception::SyntaxError(foo);
+ CHECK(reference_error.As<v8::Object>()
+ ->Get(context.local(), message)
+ .ToLocalChecked()
+ ->Equals(context.local(), foo)
+ .FromJust());
+ v8::Local<Value> syntax_error = v8::Exception::SyntaxError(foo);
CHECK(syntax_error->IsObject());
- CHECK(syntax_error.As<v8::Object>()->Get(message)->Equals(foo));
- v8::Handle<Value> type_error = v8::Exception::TypeError(foo);
+ CHECK(syntax_error.As<v8::Object>()
+ ->Get(context.local(), message)
+ .ToLocalChecked()
+ ->Equals(context.local(), foo)
+ .FromJust());
+ v8::Local<Value> type_error = v8::Exception::TypeError(foo);
CHECK(type_error->IsObject());
- CHECK(type_error.As<v8::Object>()->Get(message)->Equals(foo));
- v8::Handle<Value> error = v8::Exception::Error(foo);
+ CHECK(type_error.As<v8::Object>()
+ ->Get(context.local(), message)
+ .ToLocalChecked()
+ ->Equals(context.local(), foo)
+ .FromJust());
+ v8::Local<Value> error = v8::Exception::Error(foo);
CHECK(error->IsObject());
- CHECK(error.As<v8::Object>()->Get(message)->Equals(foo));
+ CHECK(error.As<v8::Object>()
+ ->Get(context.local(), message)
+ .ToLocalChecked()
+ ->Equals(context.local(), foo)
+ .FromJust());
}
static void ThrowV8Exception(const v8::FunctionCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
- v8::Handle<String> foo = v8_str("foo");
- v8::Handle<String> message = v8_str("message");
- v8::Handle<Value> error = v8::Exception::Error(foo);
+ v8::Local<String> foo = v8_str("foo");
+ v8::Local<String> message = v8_str("message");
+ v8::Local<Value> error = v8::Exception::Error(foo);
CHECK(error->IsObject());
- CHECK(error.As<v8::Object>()->Get(message)->Equals(foo));
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ CHECK(error.As<v8::Object>()
+ ->Get(context, message)
+ .ToLocalChecked()
+ ->Equals(context, foo)
+ .FromJust());
info.GetIsolate()->ThrowException(error);
info.GetReturnValue().SetUndefined();
}
@@ -7644,15 +8576,17 @@ static void ThrowV8Exception(const v8::FunctionCallbackInfo<v8::Value>& info) {
THREADED_TEST(ExceptionCreateMessage) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::Handle<String> foo_str = v8_str("foo");
- v8::Handle<String> message_str = v8_str("message");
+ v8::Local<String> foo_str = v8_str("foo");
+ v8::Local<String> message_str = v8_str("message");
- v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
+ context->GetIsolate()->SetCaptureStackTraceForUncaughtExceptions(true);
Local<v8::FunctionTemplate> fun =
v8::FunctionTemplate::New(context->GetIsolate(), ThrowV8Exception);
v8::Local<v8::Object> global = context->Global();
- global->Set(v8_str("throwV8Exception"), fun->GetFunction());
+ CHECK(global->Set(context.local(), v8_str("throwV8Exception"),
+ fun->GetFunction(context.local()).ToLocalChecked())
+ .FromJust());
TryCatch try_catch(context->GetIsolate());
CompileRun(
@@ -7662,17 +8596,21 @@ THREADED_TEST(ExceptionCreateMessage) {
"f1();");
CHECK(try_catch.HasCaught());
- v8::Handle<v8::Value> error = try_catch.Exception();
+ v8::Local<v8::Value> error = try_catch.Exception();
CHECK(error->IsObject());
- CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str));
+ CHECK(error.As<v8::Object>()
+ ->Get(context.local(), message_str)
+ .ToLocalChecked()
+ ->Equals(context.local(), foo_str)
+ .FromJust());
- v8::Handle<v8::Message> message =
+ v8::Local<v8::Message> message =
v8::Exception::CreateMessage(context->GetIsolate(), error);
CHECK(!message.IsEmpty());
- CHECK_EQ(2, message->GetLineNumber());
- CHECK_EQ(2, message->GetStartColumn());
+ CHECK_EQ(2, message->GetLineNumber(context.local()).FromJust());
+ CHECK_EQ(2, message->GetStartColumn(context.local()).FromJust());
- v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
+ v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace();
CHECK(!stackTrace.IsEmpty());
CHECK_EQ(2, stackTrace->GetFrameCount());
@@ -7680,7 +8618,7 @@ THREADED_TEST(ExceptionCreateMessage) {
CHECK(!stackTrace.IsEmpty());
CHECK_EQ(2, stackTrace->GetFrameCount());
- v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
+ context->GetIsolate()->SetCaptureStackTraceForUncaughtExceptions(false);
// Now check message location when SetCaptureStackTraceForUncaughtExceptions
// is false.
@@ -7695,12 +8633,16 @@ THREADED_TEST(ExceptionCreateMessage) {
error = try_catch.Exception();
CHECK(error->IsObject());
- CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str));
+ CHECK(error.As<v8::Object>()
+ ->Get(context.local(), message_str)
+ .ToLocalChecked()
+ ->Equals(context.local(), foo_str)
+ .FromJust());
message = v8::Exception::CreateMessage(context->GetIsolate(), error);
CHECK(!message.IsEmpty());
- CHECK_EQ(2, message->GetLineNumber());
- CHECK_EQ(9, message->GetStartColumn());
+ CHECK_EQ(2, message->GetLineNumber(context.local()).FromJust());
+ CHECK_EQ(9, message->GetStartColumn(context.local()).FromJust());
// Should be empty stack trace.
stackTrace = message->GetStackTrace();
@@ -7736,38 +8678,52 @@ static void YSetter(Local<String> name,
Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) {
Local<Object> this_obj = Local<Object>::Cast(info.This());
- if (this_obj->Has(name)) this_obj->Delete(name);
- this_obj->Set(name, value);
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
+ if (this_obj->Has(context, name).FromJust())
+ this_obj->Delete(context, name).FromJust();
+ CHECK(this_obj->Set(context, name, value).FromJust());
}
THREADED_TEST(DeleteAccessor) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
obj->SetAccessor(v8_str("y"), YGetter, YSetter);
LocalContext context;
- v8::Handle<v8::Object> holder = obj->NewInstance();
- context->Global()->Set(v8_str("holder"), holder);
- v8::Handle<Value> result = CompileRun(
- "holder.y = 11; holder.y = 12; holder.y");
- CHECK_EQ(12u, result->Uint32Value());
+ v8::Local<v8::Object> holder =
+ obj->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("holder"), holder)
+ .FromJust());
+ v8::Local<Value> result =
+ CompileRun("holder.y = 11; holder.y = 12; holder.y");
+ CHECK_EQ(12u, result->Uint32Value(context.local()).FromJust());
}
THREADED_TEST(TypeSwitch) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 };
- v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs);
+ v8::Local<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> templs[3] = {templ1, templ2, templ3};
+ v8::Local<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs);
LocalContext context;
- v8::Handle<v8::Object> obj0 = v8::Object::New(isolate);
- v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance();
- v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance();
- v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance();
+ v8::Local<v8::Object> obj0 = v8::Object::New(isolate);
+ v8::Local<v8::Object> obj1 = templ1->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ v8::Local<v8::Object> obj2 = templ2->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ v8::Local<v8::Object> obj3 = templ3->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
for (int i = 0; i < 10; i++) {
CHECK_EQ(0, type_switch->match(obj0));
CHECK_EQ(1, type_switch->match(obj1));
@@ -7787,20 +8743,22 @@ static void TroubleCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
trouble_nesting++;
// Call a JS function that throws an uncaught exception.
- Local<v8::Object> arg_this =
- args.GetIsolate()->GetCurrentContext()->Global();
- Local<Value> trouble_callee = (trouble_nesting == 3) ?
- arg_this->Get(v8_str("trouble_callee")) :
- arg_this->Get(v8_str("trouble_caller"));
+ Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ Local<v8::Object> arg_this = context->Global();
+ Local<Value> trouble_callee =
+ (trouble_nesting == 3)
+ ? arg_this->Get(context, v8_str("trouble_callee")).ToLocalChecked()
+ : arg_this->Get(context, v8_str("trouble_caller")).ToLocalChecked();
CHECK(trouble_callee->IsFunction());
- args.GetReturnValue().Set(
- Function::Cast(*trouble_callee)->Call(arg_this, 0, NULL));
+ args.GetReturnValue().Set(Function::Cast(*trouble_callee)
+ ->Call(context, arg_this, 0, NULL)
+ .FromMaybe(v8::Local<v8::Value>()));
}
static int report_count = 0;
-static void ApiUncaughtExceptionTestListener(v8::Handle<v8::Message>,
- v8::Handle<Value>) {
+static void ApiUncaughtExceptionTestListener(v8::Local<v8::Message>,
+ v8::Local<Value>) {
report_count++;
}
@@ -7812,12 +8770,14 @@ TEST(ApiUncaughtException) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener);
+ isolate->AddMessageListener(ApiUncaughtExceptionTestListener);
Local<v8::FunctionTemplate> fun =
v8::FunctionTemplate::New(isolate, TroubleCallback);
v8::Local<v8::Object> global = env->Global();
- global->Set(v8_str("trouble"), fun->GetFunction());
+ CHECK(global->Set(env.local(), v8_str("trouble"),
+ fun->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"function trouble_callee() {"
@@ -7827,15 +8787,20 @@ TEST(ApiUncaughtException) {
"function trouble_caller() {"
" trouble();"
"};");
- Local<Value> trouble = global->Get(v8_str("trouble"));
+ Local<Value> trouble =
+ global->Get(env.local(), v8_str("trouble")).ToLocalChecked();
CHECK(trouble->IsFunction());
- Local<Value> trouble_callee = global->Get(v8_str("trouble_callee"));
+ Local<Value> trouble_callee =
+ global->Get(env.local(), v8_str("trouble_callee")).ToLocalChecked();
CHECK(trouble_callee->IsFunction());
- Local<Value> trouble_caller = global->Get(v8_str("trouble_caller"));
+ Local<Value> trouble_caller =
+ global->Get(env.local(), v8_str("trouble_caller")).ToLocalChecked();
CHECK(trouble_caller->IsFunction());
- Function::Cast(*trouble_caller)->Call(global, 0, NULL);
+ Function::Cast(*trouble_caller)
+ ->Call(env.local(), global, 0, NULL)
+ .FromMaybe(v8::Local<v8::Value>());
CHECK_EQ(1, report_count);
- v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener);
+ isolate->RemoveMessageListeners(ApiUncaughtExceptionTestListener);
}
@@ -7845,7 +8810,7 @@ TEST(ApiUncaughtExceptionInObjectObserve) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener);
+ isolate->AddMessageListener(ApiUncaughtExceptionTestListener);
CompileRun(
"var obj = {};"
"var observe_count = 0;"
@@ -7861,19 +8826,22 @@ TEST(ApiUncaughtExceptionInObjectObserve) {
"obj.foo = 'bar';");
CHECK_EQ(3, report_count);
ExpectInt32("observe_count", 2);
- v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener);
+ isolate->RemoveMessageListeners(ApiUncaughtExceptionTestListener);
}
static const char* script_resource_name = "ExceptionInNativeScript.js";
-static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message,
- v8::Handle<Value>) {
- v8::Handle<v8::Value> name_val = message->GetScriptOrigin().ResourceName();
+static void ExceptionInNativeScriptTestListener(v8::Local<v8::Message> message,
+ v8::Local<Value>) {
+ v8::Local<v8::Value> name_val = message->GetScriptOrigin().ResourceName();
CHECK(!name_val.IsEmpty() && name_val->IsString());
v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName());
CHECK_EQ(0, strcmp(script_resource_name, *name));
- CHECK_EQ(3, message->GetLineNumber());
- v8::String::Utf8Value source_line(message->GetSourceLine());
+ v8::Local<v8::Context> context =
+ v8::Isolate::GetCurrent()->GetCurrentContext();
+ CHECK_EQ(3, message->GetLineNumber(context).FromJust());
+ v8::String::Utf8Value source_line(
+ message->GetSourceLine(context).ToLocalChecked());
CHECK_EQ(0, strcmp(" new o.foo();", *source_line));
}
@@ -7882,12 +8850,14 @@ TEST(ExceptionInNativeScript) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
- v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener);
+ isolate->AddMessageListener(ExceptionInNativeScriptTestListener);
Local<v8::FunctionTemplate> fun =
v8::FunctionTemplate::New(isolate, TroubleCallback);
v8::Local<v8::Object> global = env->Global();
- global->Set(v8_str("trouble"), fun->GetFunction());
+ CHECK(global->Set(env.local(), v8_str("trouble"),
+ fun->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
CompileRunWithOrigin(
"function trouble() {\n"
@@ -7895,10 +8865,11 @@ TEST(ExceptionInNativeScript) {
" new o.foo();\n"
"};",
script_resource_name);
- Local<Value> trouble = global->Get(v8_str("trouble"));
+ Local<Value> trouble =
+ global->Get(env.local(), v8_str("trouble")).ToLocalChecked();
CHECK(trouble->IsFunction());
- Function::Cast(*trouble)->Call(global, 0, NULL);
- v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener);
+ CHECK(Function::Cast(*trouble)->Call(env.local(), global, 0, NULL).IsEmpty());
+ isolate->RemoveMessageListeners(ExceptionInNativeScriptTestListener);
}
@@ -7936,7 +8907,9 @@ TEST(TryCatchFinallyUsingTryCatchHandler) {
void CEvaluate(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::HandleScope scope(args.GetIsolate());
- CompileRun(args[0]->ToString(args.GetIsolate()));
+ CompileRun(args[0]
+ ->ToString(args.GetIsolate()->GetCurrentContext())
+ .ToLocalChecked());
}
@@ -7982,56 +8955,60 @@ static bool SecurityTestCallback(Local<v8::Context> accessing_context,
TEST(SecurityHandler) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope0(isolate);
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
global_template->SetAccessCheckCallback(SecurityTestCallback);
// Create an environment
- v8::Handle<Context> context0 = Context::New(isolate, NULL, global_template);
+ v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
context0->Enter();
- v8::Handle<v8::Object> global0 = context0->Global();
- v8::Handle<Script> script0 = v8_compile("foo = 111");
- script0->Run();
- global0->Set(v8_str("0"), v8_num(999));
- v8::Handle<Value> foo0 = global0->Get(v8_str("foo"));
- CHECK_EQ(111, foo0->Int32Value());
- v8::Handle<Value> z0 = global0->Get(v8_str("0"));
- CHECK_EQ(999, z0->Int32Value());
+ v8::Local<v8::Object> global0 = context0->Global();
+ v8::Local<Script> script0 = v8_compile("foo = 111");
+ script0->Run(context0).ToLocalChecked();
+ CHECK(global0->Set(context0, v8_str("0"), v8_num(999)).FromJust());
+ v8::Local<Value> foo0 =
+ global0->Get(context0, v8_str("foo")).ToLocalChecked();
+ CHECK_EQ(111, foo0->Int32Value(context0).FromJust());
+ v8::Local<Value> z0 = global0->Get(context0, v8_str("0")).ToLocalChecked();
+ CHECK_EQ(999, z0->Int32Value(context0).FromJust());
// Create another environment, should fail security checks.
v8::HandleScope scope1(isolate);
- v8::Handle<Context> context1 =
- Context::New(isolate, NULL, global_template);
+ v8::Local<Context> context1 = Context::New(isolate, NULL, global_template);
context1->Enter();
- v8::Handle<v8::Object> global1 = context1->Global();
- global1->Set(v8_str("othercontext"), global0);
+ v8::Local<v8::Object> global1 = context1->Global();
+ global1->Set(context1, v8_str("othercontext"), global0).FromJust();
// This set will fail the security check.
- v8::Handle<Script> script1 =
- v8_compile("othercontext.foo = 222; othercontext[0] = 888;");
- script1->Run();
+ v8::Local<Script> script1 =
+ v8_compile("othercontext.foo = 222; othercontext[0] = 888;");
+ CHECK(script1->Run(context1).IsEmpty());
g_security_callback_result = true;
// This read will pass the security check.
- v8::Handle<Value> foo1 = global0->Get(v8_str("foo"));
- CHECK_EQ(111, foo1->Int32Value());
+ v8::Local<Value> foo1 =
+ global0->Get(context1, v8_str("foo")).ToLocalChecked();
+ CHECK_EQ(111, foo1->Int32Value(context0).FromJust());
// This read will pass the security check.
- v8::Handle<Value> z1 = global0->Get(v8_str("0"));
- CHECK_EQ(999, z1->Int32Value());
+ v8::Local<Value> z1 = global0->Get(context1, v8_str("0")).ToLocalChecked();
+ CHECK_EQ(999, z1->Int32Value(context1).FromJust());
// Create another environment, should pass security checks.
{
v8::HandleScope scope2(isolate);
LocalContext context2;
- v8::Handle<v8::Object> global2 = context2->Global();
- global2->Set(v8_str("othercontext"), global0);
- v8::Handle<Script> script2 =
+ v8::Local<v8::Object> global2 = context2->Global();
+ CHECK(global2->Set(context2.local(), v8_str("othercontext"), global0)
+ .FromJust());
+ v8::Local<Script> script2 =
v8_compile("othercontext.foo = 333; othercontext[0] = 888;");
- script2->Run();
- v8::Handle<Value> foo2 = global0->Get(v8_str("foo"));
- CHECK_EQ(333, foo2->Int32Value());
- v8::Handle<Value> z2 = global0->Get(v8_str("0"));
- CHECK_EQ(888, z2->Int32Value());
+ script2->Run(context2.local()).ToLocalChecked();
+ v8::Local<Value> foo2 =
+ global0->Get(context2.local(), v8_str("foo")).ToLocalChecked();
+ CHECK_EQ(333, foo2->Int32Value(context2.local()).FromJust());
+ v8::Local<Value> z2 =
+ global0->Get(context2.local(), v8_str("0")).ToLocalChecked();
+ CHECK_EQ(888, z2->Int32Value(context2.local()).FromJust());
}
context1->Exit();
@@ -8042,7 +9019,7 @@ TEST(SecurityHandler) {
THREADED_TEST(SecurityChecks) {
LocalContext env1;
v8::HandleScope handle_scope(env1->GetIsolate());
- v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
+ v8::Local<Context> env2 = Context::New(env1->GetIsolate());
Local<Value> foo = v8_str("foo");
Local<Value> bar = v8_str("bar");
@@ -8052,12 +9029,14 @@ THREADED_TEST(SecurityChecks) {
// Create a function in env1.
CompileRun("spy=function(){return spy;}");
- Local<Value> spy = env1->Global()->Get(v8_str("spy"));
+ Local<Value> spy =
+ env1->Global()->Get(env1.local(), v8_str("spy")).ToLocalChecked();
CHECK(spy->IsFunction());
// Create another function accessing global objects.
CompileRun("spy2=function(){return new this.Array();}");
- Local<Value> spy2 = env1->Global()->Get(v8_str("spy2"));
+ Local<Value> spy2 =
+ env1->Global()->Get(env1.local(), v8_str("spy2")).ToLocalChecked();
CHECK(spy2->IsFunction());
// Switch to env2 in the same domain and invoke spy on env2.
@@ -8065,7 +9044,9 @@ THREADED_TEST(SecurityChecks) {
env2->SetSecurityToken(foo);
// Enter env2
Context::Scope scope_env2(env2);
- Local<Value> result = Function::Cast(*spy)->Call(env2->Global(), 0, NULL);
+ Local<Value> result = Function::Cast(*spy)
+ ->Call(env2, env2->Global(), 0, NULL)
+ .ToLocalChecked();
CHECK(result->IsFunction());
}
@@ -8075,7 +9056,7 @@ THREADED_TEST(SecurityChecks) {
// Call cross_domain_call, it should throw an exception
v8::TryCatch try_catch(env1->GetIsolate());
- Function::Cast(*spy2)->Call(env2->Global(), 0, NULL);
+ CHECK(Function::Cast(*spy2)->Call(env2, env2->Global(), 0, NULL).IsEmpty());
CHECK(try_catch.HasCaught());
}
}
@@ -8085,18 +9066,25 @@ THREADED_TEST(SecurityChecks) {
THREADED_TEST(SecurityChecksForPrototypeChain) {
LocalContext current;
v8::HandleScope scope(current->GetIsolate());
- v8::Handle<Context> other = Context::New(current->GetIsolate());
+ v8::Local<Context> other = Context::New(current->GetIsolate());
// Change context to be able to get to the Object function in the
// other context without hitting the security checks.
v8::Local<Value> other_object;
{ Context::Scope scope(other);
- other_object = other->Global()->Get(v8_str("Object"));
- other->Global()->Set(v8_num(42), v8_num(87));
+ other_object =
+ other->Global()->Get(other, v8_str("Object")).ToLocalChecked();
+ CHECK(other->Global()->Set(other, v8_num(42), v8_num(87)).FromJust());
}
- current->Global()->Set(v8_str("other"), other->Global());
- CHECK(v8_compile("other")->Run()->Equals(other->Global()));
+ CHECK(current->Global()
+ ->Set(current.local(), v8_str("other"), other->Global())
+ .FromJust());
+ CHECK(v8_compile("other")
+ ->Run(current.local())
+ .ToLocalChecked()
+ ->Equals(current.local(), other->Global())
+ .FromJust());
// Make sure the security check fails here and we get an undefined
// result instead of getting the Object function. Repeat in a loop
@@ -8104,41 +9092,50 @@ THREADED_TEST(SecurityChecksForPrototypeChain) {
v8::Local<Script> access_other0 = v8_compile("other.Object");
v8::Local<Script> access_other1 = v8_compile("other[42]");
for (int i = 0; i < 5; i++) {
- CHECK(access_other0->Run().IsEmpty());
- CHECK(access_other1->Run().IsEmpty());
+ CHECK(access_other0->Run(current.local()).IsEmpty());
+ CHECK(access_other1->Run(current.local()).IsEmpty());
}
// Create an object that has 'other' in its prototype chain and make
// sure we cannot access the Object function indirectly through
// that. Repeat in a loop to make sure to exercise the IC code.
- v8_compile("function F() { };"
- "F.prototype = other;"
- "var f = new F();")->Run();
+ v8_compile(
+ "function F() { };"
+ "F.prototype = other;"
+ "var f = new F();")
+ ->Run(current.local())
+ .ToLocalChecked();
v8::Local<Script> access_f0 = v8_compile("f.Object");
v8::Local<Script> access_f1 = v8_compile("f[42]");
for (int j = 0; j < 5; j++) {
- CHECK(access_f0->Run().IsEmpty());
- CHECK(access_f1->Run().IsEmpty());
+ CHECK(access_f0->Run(current.local()).IsEmpty());
+ CHECK(access_f1->Run(current.local()).IsEmpty());
}
// Now it gets hairy: Set the prototype for the other global object
// to be the current global object. The prototype chain for 'f' now
// goes through 'other' but ends up in the current global object.
{ Context::Scope scope(other);
- other->Global()->Set(v8_str("__proto__"), current->Global());
+ CHECK(other->Global()
+ ->Set(other, v8_str("__proto__"), current->Global())
+ .FromJust());
}
// Set a named and an index property on the current global
// object. To force the lookup to go through the other global object,
// the properties must not exist in the other global object.
- current->Global()->Set(v8_str("foo"), v8_num(100));
- current->Global()->Set(v8_num(99), v8_num(101));
+ CHECK(current->Global()
+ ->Set(current.local(), v8_str("foo"), v8_num(100))
+ .FromJust());
+ CHECK(current->Global()
+ ->Set(current.local(), v8_num(99), v8_num(101))
+ .FromJust());
// Try to read the properties from f and make sure that the access
// gets stopped by the security checks on the other global object.
Local<Script> access_f2 = v8_compile("f.foo");
Local<Script> access_f3 = v8_compile("f[99]");
for (int k = 0; k < 5; k++) {
- CHECK(access_f2->Run().IsEmpty());
- CHECK(access_f3->Run().IsEmpty());
+ CHECK(access_f2->Run(current.local()).IsEmpty());
+ CHECK(access_f3->Run(current.local()).IsEmpty());
}
}
@@ -8156,21 +9153,28 @@ static bool SecurityTestCallbackWithGC(Local<v8::Context> accessing_context,
TEST(SecurityTestGCAllowed) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> object_template =
+ v8::Local<v8::ObjectTemplate> object_template =
v8::ObjectTemplate::New(isolate);
object_template->SetAccessCheckCallback(SecurityTestCallbackWithGC);
- v8::Handle<Context> context = Context::New(isolate);
+ v8::Local<Context> context = Context::New(isolate);
v8::Context::Scope context_scope(context);
- context->Global()->Set(v8_str("obj"), object_template->NewInstance());
+ CHECK(context->Global()
+ ->Set(context, v8_str("obj"),
+ object_template->NewInstance(context).ToLocalChecked())
+ .FromJust());
security_check_with_gc_called = false;
CompileRun("obj[0] = new String(1002);");
CHECK(security_check_with_gc_called);
security_check_with_gc_called = false;
- CHECK(CompileRun("obj[0]")->ToString(isolate)->Equals(v8_str("1002")));
+ CHECK(CompileRun("obj[0]")
+ ->ToString(context)
+ .ToLocalChecked()
+ ->Equals(context, v8_str("1002"))
+ .FromJust());
CHECK(security_check_with_gc_called);
}
@@ -8178,7 +9182,7 @@ TEST(SecurityTestGCAllowed) {
THREADED_TEST(CrossDomainDelete) {
LocalContext env1;
v8::HandleScope handle_scope(env1->GetIsolate());
- v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
+ v8::Local<Context> env2 = Context::New(env1->GetIsolate());
Local<Value> foo = v8_str("foo");
Local<Value> bar = v8_str("bar");
@@ -8187,8 +9191,9 @@ THREADED_TEST(CrossDomainDelete) {
env1->SetSecurityToken(foo);
env2->SetSecurityToken(foo);
- env1->Global()->Set(v8_str("prop"), v8_num(3));
- env2->Global()->Set(v8_str("env1"), env1->Global());
+ CHECK(
+ env1->Global()->Set(env1.local(), v8_str("prop"), v8_num(3)).FromJust());
+ CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust());
// Change env2 to a different domain and delete env1.prop.
env2->SetSecurityToken(bar);
@@ -8200,16 +9205,17 @@ THREADED_TEST(CrossDomainDelete) {
}
// Check that env1.prop still exists.
- Local<Value> v = env1->Global()->Get(v8_str("prop"));
+ Local<Value> v =
+ env1->Global()->Get(env1.local(), v8_str("prop")).ToLocalChecked();
CHECK(v->IsNumber());
- CHECK_EQ(3, v->Int32Value());
+ CHECK_EQ(3, v->Int32Value(env1.local()).FromJust());
}
THREADED_TEST(CrossDomainIsPropertyEnumerable) {
LocalContext env1;
v8::HandleScope handle_scope(env1->GetIsolate());
- v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
+ v8::Local<Context> env2 = Context::New(env1->GetIsolate());
Local<Value> foo = v8_str("foo");
Local<Value> bar = v8_str("bar");
@@ -8218,8 +9224,9 @@ THREADED_TEST(CrossDomainIsPropertyEnumerable) {
env1->SetSecurityToken(foo);
env2->SetSecurityToken(foo);
- env1->Global()->Set(v8_str("prop"), v8_num(3));
- env2->Global()->Set(v8_str("env1"), env1->Global());
+ CHECK(
+ env1->Global()->Set(env1.local(), v8_str("prop"), v8_num(3)).FromJust());
+ CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust());
// env1.prop is enumerable in env2.
Local<String> test = v8_str("propertyIsEnumerable.call(env1, 'prop')");
@@ -8242,7 +9249,7 @@ THREADED_TEST(CrossDomainIsPropertyEnumerable) {
THREADED_TEST(CrossDomainFor) {
LocalContext env1;
v8::HandleScope handle_scope(env1->GetIsolate());
- v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
+ v8::Local<Context> env2 = Context::New(env1->GetIsolate());
Local<Value> foo = v8_str("foo");
Local<Value> bar = v8_str("bar");
@@ -8251,8 +9258,9 @@ THREADED_TEST(CrossDomainFor) {
env1->SetSecurityToken(foo);
env2->SetSecurityToken(foo);
- env1->Global()->Set(v8_str("prop"), v8_num(3));
- env2->Global()->Set(v8_str("env1"), env1->Global());
+ CHECK(
+ env1->Global()->Set(env1.local(), v8_str("prop"), v8_num(3)).FromJust());
+ CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust());
// Change env2 to a different domain and set env1's global object
// as the __proto__ of an object in env2 and enumerate properties
@@ -8280,7 +9288,7 @@ THREADED_TEST(CrossDomainFor) {
THREADED_TEST(CrossDomainForInOnPrototype) {
LocalContext env1;
v8::HandleScope handle_scope(env1->GetIsolate());
- v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
+ v8::Local<Context> env2 = Context::New(env1->GetIsolate());
Local<Value> foo = v8_str("foo");
Local<Value> bar = v8_str("bar");
@@ -8289,8 +9297,9 @@ THREADED_TEST(CrossDomainForInOnPrototype) {
env1->SetSecurityToken(foo);
env2->SetSecurityToken(foo);
- env1->Global()->Set(v8_str("prop"), v8_num(3));
- env2->Global()->Set(v8_str("env1"), env1->Global());
+ CHECK(
+ env1->Global()->Set(env1.local(), v8_str("prop"), v8_num(3)).FromJust());
+ CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust());
// Change env2 to a different domain and set env1's global object
// as the __proto__ of an object in env2 and enumerate properties
@@ -8319,9 +9328,8 @@ THREADED_TEST(CrossDomainForInOnPrototype) {
TEST(ContextDetachGlobal) {
LocalContext env1;
v8::HandleScope handle_scope(env1->GetIsolate());
- v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
+ v8::Local<Context> env2 = Context::New(env1->GetIsolate());
- Local<v8::Object> global1 = env1->Global();
Local<Value> foo = v8_str("foo");
@@ -8334,44 +9342,54 @@ TEST(ContextDetachGlobal) {
// Create a function in env2 and add a reference to it in env1.
Local<v8::Object> global2 = env2->Global();
- global2->Set(v8_str("prop"), v8::Integer::New(env2->GetIsolate(), 1));
+ CHECK(global2->Set(env2, v8_str("prop"),
+ v8::Integer::New(env2->GetIsolate(), 1))
+ .FromJust());
CompileRun("function getProp() {return prop;}");
- env1->Global()->Set(v8_str("getProp"),
- global2->Get(v8_str("getProp")));
+ CHECK(env1->Global()
+ ->Set(env1.local(), v8_str("getProp"),
+ global2->Get(env2, v8_str("getProp")).ToLocalChecked())
+ .FromJust());
// Detach env2's global, and reuse the global object of env2
env2->Exit();
env2->DetachGlobal();
- v8::Handle<Context> env3 = Context::New(env1->GetIsolate(),
- 0,
- v8::Handle<v8::ObjectTemplate>(),
- global2);
+ v8::Local<Context> env3 = Context::New(
+ env1->GetIsolate(), 0, v8::Local<v8::ObjectTemplate>(), global2);
env3->SetSecurityToken(v8_str("bar"));
- env3->Enter();
+ env3->Enter();
Local<v8::Object> global3 = env3->Global();
- CHECK(global2->Equals(global3));
- CHECK(global3->Get(v8_str("prop"))->IsUndefined());
- CHECK(global3->Get(v8_str("getProp"))->IsUndefined());
- global3->Set(v8_str("prop"), v8::Integer::New(env3->GetIsolate(), -1));
- global3->Set(v8_str("prop2"), v8::Integer::New(env3->GetIsolate(), 2));
+ CHECK(global2->Equals(env3, global3).FromJust());
+ CHECK(global3->Get(env3, v8_str("prop")).ToLocalChecked()->IsUndefined());
+ CHECK(global3->Get(env3, v8_str("getProp")).ToLocalChecked()->IsUndefined());
+ CHECK(global3->Set(env3, v8_str("prop"),
+ v8::Integer::New(env3->GetIsolate(), -1))
+ .FromJust());
+ CHECK(global3->Set(env3, v8_str("prop2"),
+ v8::Integer::New(env3->GetIsolate(), 2))
+ .FromJust());
env3->Exit();
// Call getProp in env1, and it should return the value 1
{
- Local<Value> get_prop = global1->Get(v8_str("getProp"));
+ Local<v8::Object> global1 = env1->Global();
+ Local<Value> get_prop =
+ global1->Get(env1.local(), v8_str("getProp")).ToLocalChecked();
CHECK(get_prop->IsFunction());
v8::TryCatch try_catch(env1->GetIsolate());
- Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL);
+ Local<Value> r = Function::Cast(*get_prop)
+ ->Call(env1.local(), global1, 0, NULL)
+ .ToLocalChecked();
CHECK(!try_catch.HasCaught());
- CHECK_EQ(1, r->Int32Value());
+ CHECK_EQ(1, r->Int32Value(env1.local()).FromJust());
}
// Check that env3 is not accessible from env1
{
- Local<Value> r = global3->Get(v8_str("prop2"));
+ v8::MaybeLocal<Value> r = global3->Get(env1.local(), v8_str("prop2"));
CHECK(r.IsEmpty());
}
}
@@ -8382,7 +9400,7 @@ TEST(DetachGlobal) {
v8::HandleScope scope(env1->GetIsolate());
// Create second environment.
- v8::Handle<Context> env2 = Context::New(env1->GetIsolate());
+ v8::Local<Context> env2 = Context::New(env1->GetIsolate());
Local<Value> foo = v8_str("foo");
@@ -8393,16 +9411,20 @@ TEST(DetachGlobal) {
// Create a property on the global object in env2.
{
v8::Context::Scope scope(env2);
- env2->Global()->Set(v8_str("p"), v8::Integer::New(env2->GetIsolate(), 42));
+ CHECK(env2->Global()
+ ->Set(env2, v8_str("p"), v8::Integer::New(env2->GetIsolate(), 42))
+ .FromJust());
}
// Create a reference to env2 global from env1 global.
- env1->Global()->Set(v8_str("other"), env2->Global());
+ CHECK(env1->Global()
+ ->Set(env1.local(), v8_str("other"), env2->Global())
+ .FromJust());
// Check that we have access to other.p in env2 from env1.
Local<Value> result = CompileRun("other.p");
CHECK(result->IsInt32());
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(42, result->Int32Value(env1.local()).FromJust());
// Hold on to global from env2 and detach global from env2.
Local<v8::Object> global2 = env2->Global();
@@ -8414,11 +9436,9 @@ TEST(DetachGlobal) {
CHECK(result.IsEmpty());
// Reuse global2 for env3.
- v8::Handle<Context> env3 = Context::New(env1->GetIsolate(),
- 0,
- v8::Handle<v8::ObjectTemplate>(),
- global2);
- CHECK(global2->Equals(env3->Global()));
+ v8::Local<Context> env3 = Context::New(
+ env1->GetIsolate(), 0, v8::Local<v8::ObjectTemplate>(), global2);
+ CHECK(global2->Equals(env1.local(), env3->Global()).FromJust());
// Start by using the same security token for env3 as for env1 and env2.
env3->SetSecurityToken(foo);
@@ -8426,13 +9446,15 @@ TEST(DetachGlobal) {
// Create a property on the global object in env3.
{
v8::Context::Scope scope(env3);
- env3->Global()->Set(v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24));
+ CHECK(env3->Global()
+ ->Set(env3, v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24))
+ .FromJust());
}
// Check that other.p is now the property in env3 and that we have access.
result = CompileRun("other.p");
CHECK(result->IsInt32());
- CHECK_EQ(24, result->Int32Value());
+ CHECK_EQ(24, result->Int32Value(env3).FromJust());
// Change security token for env3 to something different from env1 and env2.
env3->SetSecurityToken(v8_str("bar"));
@@ -8446,8 +9468,9 @@ TEST(DetachGlobal) {
void GetThisX(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
info.GetReturnValue().Set(
- info.GetIsolate()->GetCurrentContext()->Global()->Get(v8_str("x")));
+ context->Global()->Get(context, v8_str("x")).ToLocalChecked());
}
@@ -8469,21 +9492,30 @@ TEST(DetachedAccesses) {
env1->SetSecurityToken(foo);
env2->SetSecurityToken(foo);
- env1->Global()->Set(v8_str("x"), v8_str("env1_x"));
+ CHECK(env1->Global()
+ ->Set(env1.local(), v8_str("x"), v8_str("env1_x"))
+ .FromJust());
{
v8::Context::Scope scope(env2);
- env2->Global()->Set(v8_str("x"), v8_str("env2_x"));
+ CHECK(env2->Global()->Set(env2, v8_str("x"), v8_str("env2_x")).FromJust());
CompileRun(
"function bound_x() { return x; }"
"function get_x() { return this.x; }"
"function get_x_w() { return (function() {return this.x;})(); }");
- env1->Global()->Set(v8_str("bound_x"), CompileRun("bound_x"));
- env1->Global()->Set(v8_str("get_x"), CompileRun("get_x"));
- env1->Global()->Set(v8_str("get_x_w"), CompileRun("get_x_w"));
- env1->Global()->Set(
- v8_str("this_x"),
- CompileRun("Object.getOwnPropertyDescriptor(this, 'this_x').get"));
+ CHECK(env1->Global()
+ ->Set(env1.local(), v8_str("bound_x"), CompileRun("bound_x"))
+ .FromJust());
+ CHECK(env1->Global()
+ ->Set(env1.local(), v8_str("get_x"), CompileRun("get_x"))
+ .FromJust());
+ CHECK(env1->Global()
+ ->Set(env1.local(), v8_str("get_x_w"), CompileRun("get_x_w"))
+ .FromJust());
+ env1->Global()
+ ->Set(env1.local(), v8_str("this_x"),
+ CompileRun("Object.getOwnPropertyDescriptor(this, 'this_x').get"))
+ .FromJust();
}
Local<Object> env2_global = env2->Global();
@@ -8491,24 +9523,22 @@ TEST(DetachedAccesses) {
Local<Value> result;
result = CompileRun("bound_x()");
- CHECK(v8_str("env2_x")->Equals(result));
+ CHECK(v8_str("env2_x")->Equals(env1.local(), result).FromJust());
result = CompileRun("get_x()");
CHECK(result.IsEmpty());
result = CompileRun("get_x_w()");
CHECK(result.IsEmpty());
result = CompileRun("this_x()");
- CHECK(v8_str("env2_x")->Equals(result));
+ CHECK(v8_str("env2_x")->Equals(env1.local(), result).FromJust());
// Reattach env2's proxy
- env2 = Context::New(env1->GetIsolate(),
- 0,
- v8::Handle<v8::ObjectTemplate>(),
+ env2 = Context::New(env1->GetIsolate(), 0, v8::Local<v8::ObjectTemplate>(),
env2_global);
env2->SetSecurityToken(foo);
{
v8::Context::Scope scope(env2);
- env2->Global()->Set(v8_str("x"), v8_str("env3_x"));
- env2->Global()->Set(v8_str("env1"), env1->Global());
+ CHECK(env2->Global()->Set(env2, v8_str("x"), v8_str("env3_x")).FromJust());
+ CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust());
result = CompileRun(
"results = [];"
"for (var i = 0; i < 4; i++ ) {"
@@ -8521,10 +9551,18 @@ TEST(DetachedAccesses) {
Local<v8::Array> results = Local<v8::Array>::Cast(result);
CHECK_EQ(16u, results->Length());
for (int i = 0; i < 16; i += 4) {
- CHECK(v8_str("env2_x")->Equals(results->Get(i + 0)));
- CHECK(v8_str("env1_x")->Equals(results->Get(i + 1)));
- CHECK(v8_str("env3_x")->Equals(results->Get(i + 2)));
- CHECK(v8_str("env2_x")->Equals(results->Get(i + 3)));
+ CHECK(v8_str("env2_x")
+ ->Equals(env2, results->Get(env2, i + 0).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("env1_x")
+ ->Equals(env2, results->Get(env2, i + 1).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("env3_x")
+ ->Equals(env2, results->Get(env2, i + 2).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("env2_x")
+ ->Equals(env2, results->Get(env2, i + 3).ToLocalChecked())
+ .FromJust());
}
}
@@ -8540,10 +9578,22 @@ TEST(DetachedAccesses) {
Local<v8::Array> results = Local<v8::Array>::Cast(result);
CHECK_EQ(16u, results->Length());
for (int i = 0; i < 16; i += 4) {
- CHECK(v8_str("env2_x")->Equals(results->Get(i + 0)));
- CHECK(v8_str("env3_x")->Equals(results->Get(i + 1)));
- CHECK(v8_str("env3_x")->Equals(results->Get(i + 2)));
- CHECK(v8_str("env2_x")->Equals(results->Get(i + 3)));
+ CHECK(v8_str("env2_x")
+ ->Equals(env1.local(),
+ results->Get(env1.local(), i + 0).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("env3_x")
+ ->Equals(env1.local(),
+ results->Get(env1.local(), i + 1).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("env3_x")
+ ->Equals(env1.local(),
+ results->Get(env1.local(), i + 2).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("env2_x")
+ ->Equals(env1.local(),
+ results->Get(env1.local(), i + 3).ToLocalChecked())
+ .FromJust());
}
result = CompileRun(
@@ -8558,10 +9608,22 @@ TEST(DetachedAccesses) {
results = Local<v8::Array>::Cast(result);
CHECK_EQ(16u, results->Length());
for (int i = 0; i < 16; i += 4) {
- CHECK(v8_str("env2_x")->Equals(results->Get(i + 0)));
- CHECK(v8_str("env1_x")->Equals(results->Get(i + 1)));
- CHECK(v8_str("env3_x")->Equals(results->Get(i + 2)));
- CHECK(v8_str("env2_x")->Equals(results->Get(i + 3)));
+ CHECK(v8_str("env2_x")
+ ->Equals(env1.local(),
+ results->Get(env1.local(), i + 0).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("env1_x")
+ ->Equals(env1.local(),
+ results->Get(env1.local(), i + 1).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("env3_x")
+ ->Equals(env1.local(),
+ results->Get(env1.local(), i + 2).ToLocalChecked())
+ .FromJust());
+ CHECK(v8_str("env2_x")
+ ->Equals(env1.local(),
+ results->Get(env1.local(), i + 3).ToLocalChecked())
+ .FromJust());
}
}
@@ -8569,8 +9631,8 @@ TEST(DetachedAccesses) {
static bool allowed_access = false;
static bool AccessBlocker(Local<v8::Context> accessing_context,
Local<v8::Object> accessed_object) {
- return CcTest::isolate()->GetCurrentContext()->Global()->Equals(
- accessed_object) ||
+ v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
+ return context->Global()->Equals(context, accessed_object).FromJust() ||
allowed_access;
}
@@ -8585,11 +9647,11 @@ static void EchoGetter(
}
-static void EchoSetter(Local<String> name,
- Local<Value> value,
- const v8::PropertyCallbackInfo<void>&) {
+static void EchoSetter(Local<String> name, Local<Value> value,
+ const v8::PropertyCallbackInfo<void>& args) {
if (value->IsNumber())
- g_echo_value = value->Int32Value();
+ g_echo_value =
+ value->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust();
}
@@ -8616,23 +9678,20 @@ static void UnreachableFunction(
TEST(AccessControl) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
global_template->SetAccessCheckCallback(AccessBlocker);
// Add an accessor accessible by cross-domain JS code.
global_template->SetAccessor(
- v8_str("accessible_prop"),
- EchoGetter, EchoSetter,
- v8::Handle<Value>(),
+ v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Local<Value>(),
v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
// Add an accessor that is not accessible by cross-domain JS code.
- global_template->SetAccessor(v8_str("blocked_prop"),
- UnreachableGetter, UnreachableSetter,
- v8::Handle<Value>(),
+ global_template->SetAccessor(v8_str("blocked_prop"), UnreachableGetter,
+ UnreachableSetter, v8::Local<Value>(),
v8::DEFAULT);
global_template->SetAccessorProperty(
@@ -8646,7 +9705,7 @@ TEST(AccessControl) {
v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
context0->Enter();
- v8::Handle<v8::Object> global0 = context0->Global();
+ v8::Local<v8::Object> global0 = context0->Global();
// Define a property with JS getter and setter.
CompileRun(
@@ -8654,11 +9713,13 @@ TEST(AccessControl) {
"function setter() { return 'setter'; }\n"
"Object.defineProperty(this, 'js_accessor_p', {get:getter, set:setter})");
- Local<Value> getter = global0->Get(v8_str("getter"));
- Local<Value> setter = global0->Get(v8_str("setter"));
+ Local<Value> getter =
+ global0->Get(context0, v8_str("getter")).ToLocalChecked();
+ Local<Value> setter =
+ global0->Get(context0, v8_str("setter")).ToLocalChecked();
// And define normal element.
- global0->Set(239, v8_str("239"));
+ CHECK(global0->Set(context0, 239, v8_str("239")).FromJust());
// Define an element with JS getter and setter.
CompileRun(
@@ -8666,16 +9727,18 @@ TEST(AccessControl) {
"function el_setter() { return 'el_setter'; };\n"
"Object.defineProperty(this, '42', {get: el_getter, set: el_setter});");
- Local<Value> el_getter = global0->Get(v8_str("el_getter"));
- Local<Value> el_setter = global0->Get(v8_str("el_setter"));
+ Local<Value> el_getter =
+ global0->Get(context0, v8_str("el_getter")).ToLocalChecked();
+ Local<Value> el_setter =
+ global0->Get(context0, v8_str("el_setter")).ToLocalChecked();
v8::HandleScope scope1(isolate);
v8::Local<Context> context1 = Context::New(isolate);
context1->Enter();
- v8::Handle<v8::Object> global1 = context1->Global();
- global1->Set(v8_str("other"), global0);
+ v8::Local<v8::Object> global1 = context1->Global();
+ CHECK(global1->Set(context1, v8_str("other"), global0).FromJust());
// Access blocked property.
CompileRun("other.blocked_prop = 1");
@@ -8732,22 +9795,22 @@ TEST(AccessControl) {
allowed_access = false;
- v8::Handle<Value> value;
+ v8::Local<Value> value;
// Access accessible property
value = CompileRun("other.accessible_prop = 3");
CHECK(value->IsNumber());
- CHECK_EQ(3, value->Int32Value());
+ CHECK_EQ(3, value->Int32Value(context1).FromJust());
CHECK_EQ(3, g_echo_value);
value = CompileRun("other.accessible_prop");
CHECK(value->IsNumber());
- CHECK_EQ(3, value->Int32Value());
+ CHECK_EQ(3, value->Int32Value(context1).FromJust());
value = CompileRun(
"Object.getOwnPropertyDescriptor(other, 'accessible_prop').value");
CHECK(value->IsNumber());
- CHECK_EQ(3, value->Int32Value());
+ CHECK_EQ(3, value->Int32Value(context1).FromJust());
value = CompileRun("propertyIsEnumerable.call(other, 'accessible_prop')");
CHECK(value->IsTrue());
@@ -8774,7 +9837,9 @@ TEST(AccessControl) {
// Test that preventExtensions fails on a non-accessible object even if that
// object is already non-extensible.
- global1->Set(v8_str("checked_object"), global_template->NewInstance());
+ CHECK(global1->Set(context1, v8_str("checked_object"),
+ global_template->NewInstance(context1).ToLocalChecked())
+ .FromJust());
allowed_access = true;
CompileRun("Object.preventExtensions(checked_object)");
ExpectFalse("Object.isExtensible(checked_object)");
@@ -8789,38 +9854,37 @@ TEST(AccessControl) {
TEST(AccessControlES5) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
global_template->SetAccessCheckCallback(AccessBlocker);
// Add accessible accessor.
global_template->SetAccessor(
- v8_str("accessible_prop"),
- EchoGetter, EchoSetter,
- v8::Handle<Value>(),
+ v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Local<Value>(),
v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
// Add an accessor that is not accessible by cross-domain JS code.
- global_template->SetAccessor(v8_str("blocked_prop"),
- UnreachableGetter, UnreachableSetter,
- v8::Handle<Value>(),
+ global_template->SetAccessor(v8_str("blocked_prop"), UnreachableGetter,
+ UnreachableSetter, v8::Local<Value>(),
v8::DEFAULT);
// Create an environment
v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
context0->Enter();
- v8::Handle<v8::Object> global0 = context0->Global();
+ v8::Local<v8::Object> global0 = context0->Global();
v8::Local<Context> context1 = Context::New(isolate);
context1->Enter();
- v8::Handle<v8::Object> global1 = context1->Global();
- global1->Set(v8_str("other"), global0);
+ v8::Local<v8::Object> global1 = context1->Global();
+ CHECK(global1->Set(context1, v8_str("other"), global0).FromJust());
// Regression test for issue 1154.
- CHECK(CompileRun("Object.keys(other).length == 0")->BooleanValue());
+ CHECK(CompileRun("Object.keys(other).length == 0")
+ ->BooleanValue(context1)
+ .FromJust());
CHECK(CompileRun("other.blocked_prop").IsEmpty());
// Regression test for issue 1027.
@@ -8867,33 +9931,34 @@ static bool AccessAlwaysBlocked(Local<v8::Context> accessing_context,
THREADED_TEST(AccessControlGetOwnPropertyNames) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> obj_template =
- v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42));
obj_template->SetAccessCheckCallback(AccessAlwaysBlocked);
// Add an accessor accessible by cross-domain JS code.
obj_template->SetAccessor(
- v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Handle<Value>(),
+ v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Local<Value>(),
v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
// Create an environment
v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template);
context0->Enter();
- v8::Handle<v8::Object> global0 = context0->Global();
+ v8::Local<v8::Object> global0 = context0->Global();
v8::HandleScope scope1(CcTest::isolate());
v8::Local<Context> context1 = Context::New(isolate);
context1->Enter();
- v8::Handle<v8::Object> global1 = context1->Global();
- global1->Set(v8_str("other"), global0);
- global1->Set(v8_str("object"), obj_template->NewInstance());
+ v8::Local<v8::Object> global1 = context1->Global();
+ CHECK(global1->Set(context1, v8_str("other"), global0).FromJust());
+ CHECK(global1->Set(context1, v8_str("object"),
+ obj_template->NewInstance(context1).ToLocalChecked())
+ .FromJust());
- v8::Handle<Value> value;
+ v8::Local<Value> value;
// Attempt to get the property names of the other global object and
// of an object that requires access checks. Accessing the other
@@ -8903,12 +9968,12 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
value = CompileRun(
"var names = Object.getOwnPropertyNames(other);"
"names.length == 1 && names[0] == 'accessible_prop';");
- CHECK(value->BooleanValue());
+ CHECK(value->BooleanValue(context1).FromJust());
value = CompileRun(
"var names = Object.getOwnPropertyNames(object);"
"names.length == 1 && names[0] == 'accessible_prop';");
- CHECK(value->BooleanValue());
+ CHECK(value->BooleanValue(context1).FromJust());
context1->Exit();
context0->Exit();
@@ -8918,11 +9983,13 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
TEST(Regress470113) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> obj_template =
- v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
obj_template->SetAccessCheckCallback(AccessAlwaysBlocked);
LocalContext env;
- env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("prohibited"),
+ obj_template->NewInstance(env.local()).ToLocalChecked())
+ .FromJust());
{
v8::TryCatch try_catch(isolate);
@@ -8949,49 +10016,47 @@ THREADED_TEST(CrossDomainAccessors) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::FunctionTemplate> func_template =
+ v8::Local<v8::FunctionTemplate> func_template =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate> global_template =
func_template->InstanceTemplate();
- v8::Handle<v8::ObjectTemplate> proto_template =
+ v8::Local<v8::ObjectTemplate> proto_template =
func_template->PrototypeTemplate();
// Add an accessor to proto that's accessible by cross-domain JS code.
- proto_template->SetAccessor(v8_str("accessible"),
- ConstTenGetter, 0,
- v8::Handle<Value>(),
- v8::ALL_CAN_READ);
+ proto_template->SetAccessor(v8_str("accessible"), ConstTenGetter, 0,
+ v8::Local<Value>(), v8::ALL_CAN_READ);
// Add an accessor that is not accessible by cross-domain JS code.
- global_template->SetAccessor(v8_str("unreachable"),
- UnreachableGetter, 0,
- v8::Handle<Value>(),
- v8::DEFAULT);
+ global_template->SetAccessor(v8_str("unreachable"), UnreachableGetter, 0,
+ v8::Local<Value>(), v8::DEFAULT);
v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
context0->Enter();
Local<v8::Object> global = context0->Global();
// Add a normal property that shadows 'accessible'
- global->Set(v8_str("accessible"), v8_num(11));
+ CHECK(global->Set(context0, v8_str("accessible"), v8_num(11)).FromJust());
// Enter a new context.
v8::HandleScope scope1(CcTest::isolate());
v8::Local<Context> context1 = Context::New(isolate);
context1->Enter();
- v8::Handle<v8::Object> global1 = context1->Global();
- global1->Set(v8_str("other"), global);
+ v8::Local<v8::Object> global1 = context1->Global();
+ CHECK(global1->Set(context1, v8_str("other"), global).FromJust());
// Should return 10, instead of 11
- v8::Handle<Value> value = v8_compile("other.accessible")->Run();
+ v8::Local<Value> value =
+ v8_compile("other.accessible")->Run(context1).ToLocalChecked();
CHECK(value->IsNumber());
- CHECK_EQ(10, value->Int32Value());
+ CHECK_EQ(10, value->Int32Value(context1).FromJust());
- value = v8_compile("other.unreachable")->Run();
- CHECK(value.IsEmpty());
+ v8::MaybeLocal<v8::Value> maybe_value =
+ v8_compile("other.unreachable")->Run(context1);
+ CHECK(maybe_value.IsEmpty());
context1->Exit();
context0->Exit();
@@ -9020,10 +10085,11 @@ TEST(AccessControlIC) {
// Create an object that requires access-check functions to be
// called for cross-domain access.
- v8::Handle<v8::ObjectTemplate> object_template =
+ v8::Local<v8::ObjectTemplate> object_template =
v8::ObjectTemplate::New(isolate);
object_template->SetAccessCheckCallback(AccessCounter);
- Local<v8::Object> object = object_template->NewInstance();
+ Local<v8::Object> object =
+ object_template->NewInstance(context0).ToLocalChecked();
v8::HandleScope scope1(isolate);
@@ -9032,10 +10098,10 @@ TEST(AccessControlIC) {
context1->Enter();
// Make easy access to the object from the other environment.
- v8::Handle<v8::Object> global1 = context1->Global();
- global1->Set(v8_str("obj"), object);
+ v8::Local<v8::Object> global1 = context1->Global();
+ CHECK(global1->Set(context1, v8_str("obj"), object).FromJust());
- v8::Handle<Value> value;
+ v8::Local<Value> value;
// Check that the named access-control function is called every time.
CompileRun("function testProp(obj) {"
@@ -9045,7 +10111,7 @@ TEST(AccessControlIC) {
"}");
value = CompileRun("testProp(obj)");
CHECK(value->IsNumber());
- CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(1, value->Int32Value(context1).FromJust());
CHECK_EQ(21, access_count);
// Check that the named access-control function is called every time.
@@ -9059,14 +10125,14 @@ TEST(AccessControlIC) {
// in that case.
value = CompileRun("testKeyed(obj)");
CHECK(value->IsNumber());
- CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(1, value->Int32Value(context1).FromJust());
CHECK_EQ(42, access_count);
// Force the inline caches into generic state and try again.
CompileRun("testKeyed({ a: 0 })");
CompileRun("testKeyed({ b: 0 })");
value = CompileRun("testKeyed(obj)");
CHECK(value->IsNumber());
- CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(1, value->Int32Value(context1).FromJust());
CHECK_EQ(63, access_count);
// Check that the indexed access-control function is called every time.
@@ -9079,14 +10145,14 @@ TEST(AccessControlIC) {
"}");
value = CompileRun("testIndexed(obj)");
CHECK(value->IsNumber());
- CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(1, value->Int32Value(context1).FromJust());
CHECK_EQ(21, access_count);
// Force the inline caches into generic state.
CompileRun("testIndexed(new Array(1))");
// Test that the indexed access check is called.
value = CompileRun("testIndexed(obj)");
CHECK(value->IsNumber());
- CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(1, value->Int32Value(context1).FromJust());
CHECK_EQ(42, access_count);
access_count = 0;
@@ -9102,13 +10168,13 @@ TEST(AccessControlIC) {
// Force obj into slow case.
value = CompileRun("delete obj.prop");
- CHECK(value->BooleanValue());
+ CHECK(value->BooleanValue(context1).FromJust());
// Force inline caches into dictionary probing mode.
CompileRun("var o = { x: 0 }; delete o.x; testProp(o);");
// Test that the named access check is called.
value = CompileRun("testProp(obj);");
CHECK(value->IsNumber());
- CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(1, value->Int32Value(context1).FromJust());
CHECK_EQ(33, access_count);
// Force the call inline cache into dictionary probing mode.
@@ -9145,14 +10211,17 @@ THREADED_TEST(InstanceProperties) {
instance->Set(v8_str("f"),
v8::FunctionTemplate::New(isolate, InstanceFunctionCallback));
- Local<Value> o = t->GetFunction()->NewInstance();
+ Local<Value> o = t->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
- context->Global()->Set(v8_str("i"), o);
+ CHECK(context->Global()->Set(context.local(), v8_str("i"), o).FromJust());
Local<Value> value = CompileRun("i.x");
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context.local()).FromJust());
value = CompileRun("i.f()");
- CHECK_EQ(12, value->Int32Value());
+ CHECK_EQ(12, value->Int32Value(context.local()).FromJust());
}
@@ -9200,22 +10269,22 @@ THREADED_TEST(GlobalObjectInstanceProperties) {
global_object = env->Global();
Local<Value> value = CompileRun("x");
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(env.local()).FromJust());
value = CompileRun("f()");
- CHECK_EQ(12, value->Int32Value());
+ CHECK_EQ(12, value->Int32Value(env.local()).FromJust());
value = CompileRun(script);
- CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(1, value->Int32Value(env.local()).FromJust());
}
{
// Create new environment reusing the global object.
LocalContext env(NULL, instance_template, global_object);
Local<Value> value = CompileRun("x");
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(env.local()).FromJust());
value = CompileRun("f()");
- CHECK_EQ(12, value->Int32Value());
+ CHECK_EQ(12, value->Int32Value(env.local()).FromJust());
value = CompileRun(script);
- CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(1, value->Int32Value(env.local()).FromJust());
}
}
@@ -9255,7 +10324,7 @@ THREADED_TEST(CallKnownGlobalReceiver) {
{
// Create new environment reusing the global object.
LocalContext env(NULL, instance_template, global_object);
- env->Global()->Set(v8_str("foo"), foo);
+ CHECK(env->Global()->Set(env.local(), v8_str("foo"), foo).FromJust());
CompileRun("foo()");
}
}
@@ -9322,25 +10391,30 @@ THREADED_TEST(ShadowObject) {
instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter);
- Local<Value> o = t->GetFunction()->NewInstance();
- context->Global()->Set(v8_str("__proto__"), o);
+ Local<Value> o = t->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("__proto__"), o)
+ .FromJust());
Local<Value> value =
CompileRun("this.propertyIsEnumerable(0)");
CHECK(value->IsBoolean());
- CHECK(!value->BooleanValue());
+ CHECK(!value->BooleanValue(context.local()).FromJust());
value = CompileRun("x");
- CHECK_EQ(12, value->Int32Value());
+ CHECK_EQ(12, value->Int32Value(context.local()).FromJust());
value = CompileRun("f()");
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context.local()).FromJust());
CompileRun("y = 43");
CHECK_EQ(1, shadow_y_setter_call_count);
value = CompileRun("y");
CHECK_EQ(1, shadow_y_getter_call_count);
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context.local()).FromJust());
}
@@ -9360,32 +10434,78 @@ THREADED_TEST(HiddenPrototype) {
Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3));
- Local<v8::Object> o0 = t0->GetFunction()->NewInstance();
- Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
- Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
- Local<v8::Object> o3 = t3->GetFunction()->NewInstance();
+ Local<v8::Object> o0 = t0->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o1 = t1->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o2 = t2->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o3 = t3->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
// Setting the prototype on an object skips hidden prototypes.
- CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value());
- o0->Set(v8_str("__proto__"), o1);
- CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(1, o0->Get(v8_str("y"))->Int32Value());
- o0->Set(v8_str("__proto__"), o2);
- CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(1, o0->Get(v8_str("y"))->Int32Value());
- CHECK_EQ(2, o0->Get(v8_str("z"))->Int32Value());
- o0->Set(v8_str("__proto__"), o3);
- CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(1, o0->Get(v8_str("y"))->Int32Value());
- CHECK_EQ(2, o0->Get(v8_str("z"))->Int32Value());
- CHECK_EQ(3, o0->Get(v8_str("u"))->Int32Value());
+ CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(o0->Set(context.local(), v8_str("__proto__"), o1).FromJust());
+ CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(o0->Set(context.local(), v8_str("__proto__"), o2).FromJust());
+ CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(2, o0->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(o0->Set(context.local(), v8_str("__proto__"), o3).FromJust());
+ CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(2, o0->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(3, o0->Get(context.local(), v8_str("u"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
// Getting the prototype of o0 should get the first visible one
// which is o3. Therefore, z should not be defined on the prototype
// object.
- Local<Value> proto = o0->Get(v8_str("__proto__"));
+ Local<Value> proto =
+ o0->Get(context.local(), v8_str("__proto__")).ToLocalChecked();
CHECK(proto->IsObject());
- CHECK(proto.As<v8::Object>()->Get(v8_str("z"))->IsUndefined());
+ CHECK(proto.As<v8::Object>()
+ ->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->IsUndefined());
}
@@ -9400,34 +10520,70 @@ THREADED_TEST(HiddenPrototypeSet) {
Local<v8::FunctionTemplate> pt = v8::FunctionTemplate::New(isolate);
ht->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
- Local<v8::Object> o = ot->GetFunction()->NewInstance();
- Local<v8::Object> h = ht->GetFunction()->NewInstance();
- Local<v8::Object> p = pt->GetFunction()->NewInstance();
- o->Set(v8_str("__proto__"), h);
- h->Set(v8_str("__proto__"), p);
+ Local<v8::Object> o = ot->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> h = ht->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> p = pt->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ CHECK(o->Set(context.local(), v8_str("__proto__"), h).FromJust());
+ CHECK(h->Set(context.local(), v8_str("__proto__"), p).FromJust());
// Setting a property that exists on the hidden prototype goes there.
- o->Set(v8_str("x"), v8_num(7));
- CHECK_EQ(7, o->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(7, h->Get(v8_str("x"))->Int32Value());
- CHECK(p->Get(v8_str("x"))->IsUndefined());
+ CHECK(o->Set(context.local(), v8_str("x"), v8_num(7)).FromJust());
+ CHECK_EQ(7, o->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(7, h->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(p->Get(context.local(), v8_str("x")).ToLocalChecked()->IsUndefined());
// Setting a new property should not be forwarded to the hidden prototype.
- o->Set(v8_str("y"), v8_num(6));
- CHECK_EQ(6, o->Get(v8_str("y"))->Int32Value());
- CHECK(h->Get(v8_str("y"))->IsUndefined());
- CHECK(p->Get(v8_str("y"))->IsUndefined());
+ CHECK(o->Set(context.local(), v8_str("y"), v8_num(6)).FromJust());
+ CHECK_EQ(6, o->Get(context.local(), v8_str("y"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(h->Get(context.local(), v8_str("y")).ToLocalChecked()->IsUndefined());
+ CHECK(p->Get(context.local(), v8_str("y")).ToLocalChecked()->IsUndefined());
// Setting a property that only exists on a prototype of the hidden prototype
// is treated normally again.
- p->Set(v8_str("z"), v8_num(8));
- CHECK_EQ(8, o->Get(v8_str("z"))->Int32Value());
- CHECK_EQ(8, h->Get(v8_str("z"))->Int32Value());
- CHECK_EQ(8, p->Get(v8_str("z"))->Int32Value());
- o->Set(v8_str("z"), v8_num(9));
- CHECK_EQ(9, o->Get(v8_str("z"))->Int32Value());
- CHECK_EQ(8, h->Get(v8_str("z"))->Int32Value());
- CHECK_EQ(8, p->Get(v8_str("z"))->Int32Value());
+ CHECK(p->Set(context.local(), v8_str("z"), v8_num(8)).FromJust());
+ CHECK_EQ(8, o->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(8, h->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(8, p->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(o->Set(context.local(), v8_str("z"), v8_num(9)).FromJust());
+ CHECK_EQ(9, o->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(8, h->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(8, p->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
}
@@ -9436,16 +10592,19 @@ THREADED_TEST(HiddenPrototypeIdentityHash) {
LocalContext context;
v8::HandleScope handle_scope(context->GetIsolate());
- Handle<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate());
+ Local<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate());
t->SetHiddenPrototype(true);
t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75));
- Handle<Object> p = t->GetFunction()->NewInstance();
- Handle<Object> o = Object::New(context->GetIsolate());
- o->SetPrototype(p);
+ Local<Object> p = t->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<Object> o = Object::New(context->GetIsolate());
+ CHECK(o->SetPrototype(context.local(), p).FromJust());
int hash = o->GetIdentityHash();
USE(hash);
- o->Set(v8_str("foo"), v8_num(42));
+ CHECK(o->Set(context.local(), v8_str("foo"), v8_num(42)).FromJust());
DCHECK_EQ(hash, o->GetIdentityHash());
}
@@ -9466,45 +10625,88 @@ THREADED_TEST(SetPrototype) {
Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3));
- Local<v8::Object> o0 = t0->GetFunction()->NewInstance();
- Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
- Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
- Local<v8::Object> o3 = t3->GetFunction()->NewInstance();
+ Local<v8::Object> o0 = t0->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o1 = t1->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o2 = t2->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o3 = t3->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
// Setting the prototype on an object does not skip hidden prototypes.
- CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value());
- CHECK(o0->SetPrototype(o1));
- CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(1, o0->Get(v8_str("y"))->Int32Value());
- CHECK(o1->SetPrototype(o2));
- CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(1, o0->Get(v8_str("y"))->Int32Value());
- CHECK_EQ(2, o0->Get(v8_str("z"))->Int32Value());
- CHECK(o2->SetPrototype(o3));
- CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(1, o0->Get(v8_str("y"))->Int32Value());
- CHECK_EQ(2, o0->Get(v8_str("z"))->Int32Value());
- CHECK_EQ(3, o0->Get(v8_str("u"))->Int32Value());
+ CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(o0->SetPrototype(context.local(), o1).FromJust());
+ CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(o1->SetPrototype(context.local(), o2).FromJust());
+ CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(2, o0->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK(o2->SetPrototype(context.local(), o3).FromJust());
+ CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(2, o0->Get(context.local(), v8_str("z"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(3, o0->Get(context.local(), v8_str("u"))
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
// Getting the prototype of o0 should get the first visible one
// which is o3. Therefore, z should not be defined on the prototype
// object.
- Local<Value> proto = o0->Get(v8_str("__proto__"));
+ Local<Value> proto =
+ o0->Get(context.local(), v8_str("__proto__")).ToLocalChecked();
CHECK(proto->IsObject());
- CHECK(proto.As<v8::Object>()->Equals(o3));
+ CHECK(proto.As<v8::Object>()->Equals(context.local(), o3).FromJust());
// However, Object::GetPrototype ignores hidden prototype.
Local<Value> proto0 = o0->GetPrototype();
CHECK(proto0->IsObject());
- CHECK(proto0.As<v8::Object>()->Equals(o1));
+ CHECK(proto0.As<v8::Object>()->Equals(context.local(), o1).FromJust());
Local<Value> proto1 = o1->GetPrototype();
CHECK(proto1->IsObject());
- CHECK(proto1.As<v8::Object>()->Equals(o2));
+ CHECK(proto1.As<v8::Object>()->Equals(context.local(), o2).FromJust());
Local<Value> proto2 = o2->GetPrototype();
CHECK(proto2->IsObject());
- CHECK(proto2.As<v8::Object>()->Equals(o3));
+ CHECK(proto2.As<v8::Object>()->Equals(context.local(), o3).FromJust());
}
@@ -9538,19 +10740,31 @@ THREADED_TEST(Regress91517) {
t2->InstanceTemplate()->Set(v8_str(name_buf.start()), v8_num(2));
}
- Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
- Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
- Local<v8::Object> o3 = t3->GetFunction()->NewInstance();
- Local<v8::Object> o4 = t4->GetFunction()->NewInstance();
+ Local<v8::Object> o1 = t1->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o2 = t2->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o3 = t3->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o4 = t4->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
// Create prototype chain of hidden prototypes.
- CHECK(o4->SetPrototype(o3));
- CHECK(o3->SetPrototype(o2));
- CHECK(o2->SetPrototype(o1));
+ CHECK(o4->SetPrototype(context.local(), o3).FromJust());
+ CHECK(o3->SetPrototype(context.local(), o2).FromJust());
+ CHECK(o2->SetPrototype(context.local(), o1).FromJust());
// Call the runtime version of GetOwnPropertyNames() on the natively
// created object through JavaScript.
- context->Global()->Set(v8_str("obj"), o4);
+ CHECK(context->Global()->Set(context.local(), v8_str("obj"), o4).FromJust());
// PROPERTY_ATTRIBUTES_NONE = 0
CompileRun("var names = %GetOwnPropertyNames(obj, 0);");
@@ -9585,7 +10799,10 @@ THREADED_TEST(Regress269562) {
i1->Set(v8_str("n1"), v8_num(1));
i1->Set(v8_str("n2"), v8_num(2));
- Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
+ Local<v8::Object> o1 = t1->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
Local<v8::FunctionTemplate> t2 =
v8::FunctionTemplate::New(context->GetIsolate());
t2->SetHiddenPrototype(true);
@@ -9594,12 +10811,15 @@ THREADED_TEST(Regress269562) {
t2->Inherit(t1);
t2->InstanceTemplate()->Set(v8_str("mine"), v8_num(4));
- Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
- CHECK(o2->SetPrototype(o1));
+ Local<v8::Object> o2 = t2->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ CHECK(o2->SetPrototype(context.local(), o1).FromJust());
v8::Local<v8::Symbol> sym =
v8::Symbol::New(context->GetIsolate(), v8_str("s1"));
- o1->Set(sym, v8_num(3));
+ CHECK(o1->Set(context.local(), sym, v8_num(3)).FromJust());
o1->SetPrivate(context.local(),
v8::Private::New(context->GetIsolate(), v8_str("h1")),
v8::Integer::New(context->GetIsolate(), 2013))
@@ -9607,8 +10827,8 @@ THREADED_TEST(Regress269562) {
// Call the runtime version of GetOwnPropertyNames() on
// the natively created object through JavaScript.
- context->Global()->Set(v8_str("obj"), o2);
- context->Global()->Set(v8_str("sym"), sym);
+ CHECK(context->Global()->Set(context.local(), v8_str("obj"), o2).FromJust());
+ CHECK(context->Global()->Set(context.local(), v8_str("sym"), sym).FromJust());
// PROPERTY_ATTRIBUTES_NONE = 0
CompileRun("var names = %GetOwnPropertyNames(obj, 0);");
@@ -9631,27 +10851,44 @@ THREADED_TEST(FunctionReadOnlyPrototype) {
Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(isolate, 42));
t1->ReadOnlyPrototype();
- context->Global()->Set(v8_str("func1"), t1->GetFunction());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("func1"),
+ t1->GetFunction(context.local()).ToLocalChecked())
+ .FromJust());
// Configured value of ReadOnly flag.
- CHECK(CompileRun(
- "(function() {"
- " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
- " return (descriptor['writable'] == false);"
- "})()")->BooleanValue());
- CHECK_EQ(42, CompileRun("func1.prototype.x")->Int32Value());
- CHECK_EQ(42,
- CompileRun("func1.prototype = {}; func1.prototype.x")->Int32Value());
+ CHECK(
+ CompileRun(
+ "(function() {"
+ " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
+ " return (descriptor['writable'] == false);"
+ "})()")
+ ->BooleanValue(context.local())
+ .FromJust());
+ CHECK_EQ(
+ 42,
+ CompileRun("func1.prototype.x")->Int32Value(context.local()).FromJust());
+ CHECK_EQ(42, CompileRun("func1.prototype = {}; func1.prototype.x")
+ ->Int32Value(context.local())
+ .FromJust());
Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(isolate, 42));
- context->Global()->Set(v8_str("func2"), t2->GetFunction());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("func2"),
+ t2->GetFunction(context.local()).ToLocalChecked())
+ .FromJust());
// Default value of ReadOnly flag.
- CHECK(CompileRun(
- "(function() {"
- " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
- " return (descriptor['writable'] == true);"
- "})()")->BooleanValue());
- CHECK_EQ(42, CompileRun("func2.prototype.x")->Int32Value());
+ CHECK(
+ CompileRun(
+ "(function() {"
+ " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
+ " return (descriptor['writable'] == true);"
+ "})()")
+ ->BooleanValue(context.local())
+ .FromJust());
+ CHECK_EQ(
+ 42,
+ CompileRun("func2.prototype.x")->Int32Value(context.local()).FromJust());
}
@@ -9662,18 +10899,26 @@ THREADED_TEST(SetPrototypeThrows) {
Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
- Local<v8::Object> o0 = t->GetFunction()->NewInstance();
- Local<v8::Object> o1 = t->GetFunction()->NewInstance();
+ Local<v8::Object> o0 = t->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ Local<v8::Object> o1 = t->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
- CHECK(o0->SetPrototype(o1));
+ CHECK(o0->SetPrototype(context.local(), o1).FromJust());
// If setting the prototype leads to the cycle, SetPrototype should
// return false and keep VM in sane state.
v8::TryCatch try_catch(isolate);
- CHECK(!o1->SetPrototype(o0));
+ CHECK(o1->SetPrototype(context.local(), o0).IsNothing());
CHECK(!try_catch.HasCaught());
DCHECK(!CcTest::i_isolate()->has_pending_exception());
- CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")->Int32Value());
+ CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")
+ ->Int32Value(context.local())
+ .FromJust());
}
@@ -9684,16 +10929,18 @@ THREADED_TEST(FunctionRemovePrototype) {
Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->RemovePrototype();
- Local<v8::Function> fun = t1->GetFunction();
- context->Global()->Set(v8_str("fun"), fun);
- CHECK(!CompileRun("'prototype' in fun")->BooleanValue());
+ Local<v8::Function> fun = t1->GetFunction(context.local()).ToLocalChecked();
+ CHECK(context->Global()->Set(context.local(), v8_str("fun"), fun).FromJust());
+ CHECK(!CompileRun("'prototype' in fun")
+ ->BooleanValue(context.local())
+ .FromJust());
v8::TryCatch try_catch(isolate);
CompileRun("new fun()");
CHECK(try_catch.HasCaught());
try_catch.Reset();
- fun->NewInstance();
+ CHECK(fun->NewInstance(context.local()).IsEmpty());
CHECK(try_catch.HasCaught());
}
@@ -9708,17 +10955,21 @@ THREADED_TEST(GetterSetterExceptions) {
"var x = { };"
"x.__defineSetter__('set', Throw);"
"x.__defineGetter__('get', Throw);");
- Local<v8::Object> x =
- Local<v8::Object>::Cast(context->Global()->Get(v8_str("x")));
+ Local<v8::Object> x = Local<v8::Object>::Cast(
+ context->Global()->Get(context.local(), v8_str("x")).ToLocalChecked());
v8::TryCatch try_catch(isolate);
- x->Set(v8_str("set"), v8::Integer::New(isolate, 8));
- x->Get(v8_str("get"));
- x->Set(v8_str("set"), v8::Integer::New(isolate, 8));
- x->Get(v8_str("get"));
- x->Set(v8_str("set"), v8::Integer::New(isolate, 8));
- x->Get(v8_str("get"));
- x->Set(v8_str("set"), v8::Integer::New(isolate, 8));
- x->Get(v8_str("get"));
+ CHECK(x->Set(context.local(), v8_str("set"), v8::Integer::New(isolate, 8))
+ .IsNothing());
+ CHECK(x->Get(context.local(), v8_str("get")).IsEmpty());
+ CHECK(x->Set(context.local(), v8_str("set"), v8::Integer::New(isolate, 8))
+ .IsNothing());
+ CHECK(x->Get(context.local(), v8_str("get")).IsEmpty());
+ CHECK(x->Set(context.local(), v8_str("set"), v8::Integer::New(isolate, 8))
+ .IsNothing());
+ CHECK(x->Get(context.local(), v8_str("get")).IsEmpty());
+ CHECK(x->Set(context.local(), v8_str("set"), v8::Integer::New(isolate, 8))
+ .IsNothing());
+ CHECK(x->Get(context.local(), v8_str("get")).IsEmpty());
}
@@ -9728,13 +10979,14 @@ THREADED_TEST(Constructor) {
v8::HandleScope handle_scope(isolate);
Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->SetClassName(v8_str("Fun"));
- Local<Function> cons = templ->GetFunction();
- context->Global()->Set(v8_str("Fun"), cons);
- Local<v8::Object> inst = cons->NewInstance();
+ Local<Function> cons = templ->GetFunction(context.local()).ToLocalChecked();
+ CHECK(
+ context->Global()->Set(context.local(), v8_str("Fun"), cons).FromJust());
+ Local<v8::Object> inst = cons->NewInstance(context.local()).ToLocalChecked();
i::Handle<i::JSReceiver> obj(v8::Utils::OpenHandle(*inst));
CHECK(obj->IsJSObject());
Local<Value> value = CompileRun("(new Fun()).constructor === Fun");
- CHECK(value->BooleanValue());
+ CHECK(value->BooleanValue(context.local()).FromJust());
}
@@ -9743,18 +10995,19 @@ static void ConstructorCallback(
ApiTestFuzzer::Fuzz();
Local<Object> This;
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
if (args.IsConstructCall()) {
Local<Object> Holder = args.Holder();
This = Object::New(args.GetIsolate());
Local<Value> proto = Holder->GetPrototype();
if (proto->IsObject()) {
- This->SetPrototype(proto);
+ This->SetPrototype(context, proto).FromJust();
}
} else {
This = args.This();
}
- This->Set(v8_str("a"), args[0]);
+ This->Set(context, v8_str("a"), args[0]).FromJust();
args.GetReturnValue().Set(This);
}
@@ -9774,8 +11027,11 @@ THREADED_TEST(ConstructorForObject) {
{
Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
instance_template->SetCallAsFunctionHandler(ConstructorCallback);
- Local<Object> instance = instance_template->NewInstance();
- context->Global()->Set(v8_str("obj"), instance);
+ Local<Object> instance =
+ instance_template->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"), instance)
+ .FromJust());
v8::TryCatch try_catch(isolate);
Local<Value> value;
CHECK(!try_catch.HasCaught());
@@ -9784,65 +11040,72 @@ THREADED_TEST(ConstructorForObject) {
value = CompileRun("(function() { var o = new obj(28); return o.a; })()");
CHECK(!try_catch.HasCaught());
CHECK(value->IsInt32());
- CHECK_EQ(28, value->Int32Value());
+ CHECK_EQ(28, value->Int32Value(context.local()).FromJust());
Local<Value> args1[] = {v8_num(28)};
- Local<Value> value_obj1 = instance->CallAsConstructor(1, args1);
+ Local<Value> value_obj1 =
+ instance->CallAsConstructor(context.local(), 1, args1).ToLocalChecked();
CHECK(value_obj1->IsObject());
Local<Object> object1 = Local<Object>::Cast(value_obj1);
- value = object1->Get(v8_str("a"));
+ value = object1->Get(context.local(), v8_str("a")).ToLocalChecked();
CHECK(value->IsInt32());
CHECK(!try_catch.HasCaught());
- CHECK_EQ(28, value->Int32Value());
+ CHECK_EQ(28, value->Int32Value(context.local()).FromJust());
// Call the Object's constructor with a String.
value =
CompileRun("(function() { var o = new obj('tipli'); return o.a; })()");
CHECK(!try_catch.HasCaught());
CHECK(value->IsString());
- String::Utf8Value string_value1(value->ToString(isolate));
+ String::Utf8Value string_value1(
+ value->ToString(context.local()).ToLocalChecked());
CHECK_EQ(0, strcmp("tipli", *string_value1));
Local<Value> args2[] = {v8_str("tipli")};
- Local<Value> value_obj2 = instance->CallAsConstructor(1, args2);
+ Local<Value> value_obj2 =
+ instance->CallAsConstructor(context.local(), 1, args2).ToLocalChecked();
CHECK(value_obj2->IsObject());
Local<Object> object2 = Local<Object>::Cast(value_obj2);
- value = object2->Get(v8_str("a"));
+ value = object2->Get(context.local(), v8_str("a")).ToLocalChecked();
CHECK(!try_catch.HasCaught());
CHECK(value->IsString());
- String::Utf8Value string_value2(value->ToString(isolate));
+ String::Utf8Value string_value2(
+ value->ToString(context.local()).ToLocalChecked());
CHECK_EQ(0, strcmp("tipli", *string_value2));
// Call the Object's constructor with a Boolean.
value = CompileRun("(function() { var o = new obj(true); return o.a; })()");
CHECK(!try_catch.HasCaught());
CHECK(value->IsBoolean());
- CHECK_EQ(true, value->BooleanValue());
+ CHECK_EQ(true, value->BooleanValue(context.local()).FromJust());
- Handle<Value> args3[] = {v8::True(isolate)};
- Local<Value> value_obj3 = instance->CallAsConstructor(1, args3);
+ Local<Value> args3[] = {v8::True(isolate)};
+ Local<Value> value_obj3 =
+ instance->CallAsConstructor(context.local(), 1, args3).ToLocalChecked();
CHECK(value_obj3->IsObject());
Local<Object> object3 = Local<Object>::Cast(value_obj3);
- value = object3->Get(v8_str("a"));
+ value = object3->Get(context.local(), v8_str("a")).ToLocalChecked();
CHECK(!try_catch.HasCaught());
CHECK(value->IsBoolean());
- CHECK_EQ(true, value->BooleanValue());
+ CHECK_EQ(true, value->BooleanValue(context.local()).FromJust());
// Call the Object's constructor with undefined.
- Handle<Value> args4[] = {v8::Undefined(isolate)};
- Local<Value> value_obj4 = instance->CallAsConstructor(1, args4);
+ Local<Value> args4[] = {v8::Undefined(isolate)};
+ Local<Value> value_obj4 =
+ instance->CallAsConstructor(context.local(), 1, args4).ToLocalChecked();
CHECK(value_obj4->IsObject());
Local<Object> object4 = Local<Object>::Cast(value_obj4);
- value = object4->Get(v8_str("a"));
+ value = object4->Get(context.local(), v8_str("a")).ToLocalChecked();
CHECK(!try_catch.HasCaught());
CHECK(value->IsUndefined());
// Call the Object's constructor with null.
- Handle<Value> args5[] = {v8::Null(isolate)};
- Local<Value> value_obj5 = instance->CallAsConstructor(1, args5);
+ Local<Value> args5[] = {v8::Null(isolate)};
+ Local<Value> value_obj5 =
+ instance->CallAsConstructor(context.local(), 1, args5).ToLocalChecked();
CHECK(value_obj5->IsObject());
Local<Object> object5 = Local<Object>::Cast(value_obj5);
- value = object5->Get(v8_str("a"));
+ value = object5->Get(context.local(), v8_str("a")).ToLocalChecked();
CHECK(!try_catch.HasCaught());
CHECK(value->IsNull());
}
@@ -9850,8 +11113,11 @@ THREADED_TEST(ConstructorForObject) {
// Check exception handling when there is no constructor set for the Object.
{
Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
- Local<Object> instance = instance_template->NewInstance();
- context->Global()->Set(v8_str("obj2"), instance);
+ Local<Object> instance =
+ instance_template->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj2"), instance)
+ .FromJust());
v8::TryCatch try_catch(isolate);
Local<Value> value;
CHECK(!try_catch.HasCaught());
@@ -9864,7 +11130,7 @@ THREADED_TEST(ConstructorForObject) {
try_catch.Reset();
Local<Value> args[] = {v8_num(29)};
- value = instance->CallAsConstructor(1, args);
+ CHECK(instance->CallAsConstructor(context.local(), 1, args).IsEmpty());
CHECK(try_catch.HasCaught());
String::Utf8Value exception_value2(try_catch.Exception());
CHECK_EQ(
@@ -9876,8 +11142,11 @@ THREADED_TEST(ConstructorForObject) {
{
Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
instance_template->SetCallAsFunctionHandler(ThrowValue);
- Local<Object> instance = instance_template->NewInstance();
- context->Global()->Set(v8_str("obj3"), instance);
+ Local<Object> instance =
+ instance_template->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj3"), instance)
+ .FromJust());
v8::TryCatch try_catch(isolate);
Local<Value> value;
CHECK(!try_catch.HasCaught());
@@ -9889,7 +11158,7 @@ THREADED_TEST(ConstructorForObject) {
try_catch.Reset();
Local<Value> args[] = {v8_num(23)};
- value = instance->CallAsConstructor(1, args);
+ CHECK(instance->CallAsConstructor(context.local(), 1, args).IsEmpty());
CHECK(try_catch.HasCaught());
String::Utf8Value exception_value2(try_catch.Exception());
CHECK_EQ(0, strcmp("23", *exception_value2));
@@ -9900,9 +11169,12 @@ THREADED_TEST(ConstructorForObject) {
{
Local<FunctionTemplate> function_template =
FunctionTemplate::New(isolate, FakeConstructorCallback);
- Local<Function> function = function_template->GetFunction();
+ Local<Function> function =
+ function_template->GetFunction(context.local()).ToLocalChecked();
Local<Object> instance1 = function;
- context->Global()->Set(v8_str("obj4"), instance1);
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj4"), instance1)
+ .FromJust());
v8::TryCatch try_catch(isolate);
Local<Value> value;
CHECK(!try_catch.HasCaught());
@@ -9915,14 +11187,18 @@ THREADED_TEST(ConstructorForObject) {
CHECK(value->IsObject());
Local<Value> args1[] = {v8_num(28)};
- value = instance1->CallAsConstructor(1, args1);
+ value = instance1->CallAsConstructor(context.local(), 1, args1)
+ .ToLocalChecked();
CHECK(!try_catch.HasCaught());
CHECK(value->IsObject());
Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
instance_template->SetCallAsFunctionHandler(FakeConstructorCallback);
- Local<Object> instance2 = instance_template->NewInstance();
- context->Global()->Set(v8_str("obj5"), instance2);
+ Local<Object> instance2 =
+ instance_template->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj5"), instance2)
+ .FromJust());
CHECK(!try_catch.HasCaught());
CHECK(instance2->IsObject());
@@ -9933,7 +11209,8 @@ THREADED_TEST(ConstructorForObject) {
CHECK(!value->IsObject());
Local<Value> args2[] = {v8_num(28)};
- value = instance2->CallAsConstructor(1, args2);
+ value = instance2->CallAsConstructor(context.local(), 1, args2)
+ .ToLocalChecked();
CHECK(!try_catch.HasCaught());
CHECK(!value->IsObject());
}
@@ -9946,8 +11223,9 @@ THREADED_TEST(FunctionDescriptorException) {
v8::HandleScope handle_scope(isolate);
Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->SetClassName(v8_str("Fun"));
- Local<Function> cons = templ->GetFunction();
- context->Global()->Set(v8_str("Fun"), cons);
+ Local<Function> cons = templ->GetFunction(context.local()).ToLocalChecked();
+ CHECK(
+ context->Global()->Set(context.local(), v8_str("Fun"), cons).FromJust());
Local<Value> value = CompileRun(
"function test() {"
" try {"
@@ -9962,7 +11240,7 @@ THREADED_TEST(FunctionDescriptorException) {
" return 4;"
"}"
"test();");
- CHECK_EQ(0, value->Int32Value());
+ CHECK_EQ(0, value->Int32Value(context.local()).FromJust());
}
@@ -9982,10 +11260,22 @@ THREADED_TEST(EvalAliasedDynamic) {
"var x = new Object();"
"x.eval = function(x) { return 1; };"
"result3 = f(x);");
- script->Run();
- CHECK_EQ(2, current->Global()->Get(v8_str("result1"))->Int32Value());
- CHECK_EQ(0, current->Global()->Get(v8_str("result2"))->Int32Value());
- CHECK_EQ(1, current->Global()->Get(v8_str("result3"))->Int32Value());
+ script->Run(current.local()).ToLocalChecked();
+ CHECK_EQ(2, current->Global()
+ ->Get(current.local(), v8_str("result1"))
+ .ToLocalChecked()
+ ->Int32Value(current.local())
+ .FromJust());
+ CHECK_EQ(0, current->Global()
+ ->Get(current.local(), v8_str("result2"))
+ .ToLocalChecked()
+ ->Int32Value(current.local())
+ .FromJust());
+ CHECK_EQ(1, current->Global()
+ ->Get(current.local(), v8_str("result3"))
+ .ToLocalChecked()
+ ->Int32Value(current.local())
+ .FromJust());
v8::TryCatch try_catch(current->GetIsolate());
script = v8_compile(
@@ -9994,9 +11284,13 @@ THREADED_TEST(EvalAliasedDynamic) {
" with (x) { return eval('bar'); }"
"}"
"result4 = f(this)");
- script->Run();
+ script->Run(current.local()).ToLocalChecked();
CHECK(!try_catch.HasCaught());
- CHECK_EQ(2, current->Global()->Get(v8_str("result4"))->Int32Value());
+ CHECK_EQ(2, current->Global()
+ ->Get(current.local(), v8_str("result4"))
+ .ToLocalChecked()
+ ->Int32Value(current.local())
+ .FromJust());
try_catch.Reset();
}
@@ -10012,20 +11306,24 @@ THREADED_TEST(CrossEval) {
current->SetSecurityToken(token);
// Set up reference from current to other.
- current->Global()->Set(v8_str("other"), other->Global());
+ CHECK(current->Global()
+ ->Set(current.local(), v8_str("other"), other->Global())
+ .FromJust());
// Check that new variables are introduced in other context.
Local<Script> script = v8_compile("other.eval('var foo = 1234')");
- script->Run();
+ script->Run(current.local()).ToLocalChecked();
Local<Value> foo = other->Global()->Get(v8_str("foo"));
- CHECK_EQ(1234, foo->Int32Value());
+ CHECK_EQ(1234, foo->Int32Value(other.local()).FromJust());
CHECK(!current->Global()->Has(v8_str("foo")));
// Check that writing to non-existing properties introduces them in
// the other context.
script = v8_compile("other.eval('na = 1234')");
script->Run();
- CHECK_EQ(1234, other->Global()->Get(v8_str("na"))->Int32Value());
+ CHECK_EQ(
+ 1234,
+ other->Global()->Get(v8_str("na"))->Int32Value(other.local()).FromJust());
CHECK(!current->Global()->Has(v8_str("na")));
// Check that global variables in current context are not visible in other
@@ -10049,14 +11347,18 @@ THREADED_TEST(CrossEval) {
// Check that global variables in the other environment are visible
// when evaluting code.
- other->Global()->Set(v8_str("bis"), v8_num(1234));
+ CHECK(other->Global()
+ ->Set(other.local(), v8_str("bis"), v8_num(1234))
+ .FromJust());
script = v8_compile("other.eval('bis')");
- CHECK_EQ(1234, script->Run()->Int32Value());
+ CHECK_EQ(1234, script->Run()->Int32Value(other.local()).FromJust());
CHECK(!try_catch.HasCaught());
// Check that the 'this' pointer points to the global object evaluating
// code.
- other->Global()->Set(v8_str("t"), other->Global());
+ CHECK(other->Global()
+ ->Set(other.local(), v8_str("t"), other->Global())
+ .FromJust());
script = v8_compile("other.eval('this == t')");
result = script->Run();
CHECK(result->IsTrue());
@@ -10088,7 +11390,7 @@ THREADED_TEST(EvalInDetachedGlobal) {
// Set up function in context0 that uses eval from context0.
context0->Enter();
- v8::Handle<v8::Value> fun = CompileRun(
+ v8::Local<v8::Value> fun = CompileRun(
"var x = 42;"
"(function() {"
" var e = eval;"
@@ -10100,13 +11402,13 @@ THREADED_TEST(EvalInDetachedGlobal) {
// detaching the global. Before detaching, the call succeeds and
// after detaching and exception is thrown.
context1->Enter();
- context1->Global()->Set(v8_str("fun"), fun);
- v8::Handle<v8::Value> x_value = CompileRun("fun('x')");
- CHECK_EQ(42, x_value->Int32Value());
+ CHECK(context1->Global()->Set(context1, v8_str("fun"), fun).FromJust());
+ v8::Local<v8::Value> x_value = CompileRun("fun('x')");
+ CHECK_EQ(42, x_value->Int32Value(context1).FromJust());
context0->DetachGlobal();
v8::TryCatch catcher(isolate);
x_value = CompileRun("fun('x')");
- CHECK_EQ(42, x_value->Int32Value());
+ CHECK_EQ(42, x_value->Int32Value(context1).FromJust());
context1->Exit();
}
@@ -10121,7 +11423,9 @@ THREADED_TEST(CrossLazyLoad) {
current->SetSecurityToken(token);
// Set up reference from current to other.
- current->Global()->Set(v8_str("other"), other->Global());
+ CHECK(current->Global()
+ ->Set(current.local(), v8_str("other"), other->Global())
+ .FromJust());
// Trigger lazy loading in other context.
Local<Script> script = v8_compile("other.eval('new Date(42)')");
@@ -10134,7 +11438,10 @@ static void call_as_function(const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
if (args.IsConstructCall()) {
if (args[0]->IsInt32()) {
- args.GetReturnValue().Set(v8_num(-args[0]->Int32Value()));
+ args.GetReturnValue().Set(
+ v8_num(-args[0]
+ ->Int32Value(args.GetIsolate()->GetCurrentContext())
+ .FromJust()));
return;
}
}
@@ -10160,63 +11467,73 @@ THREADED_TEST(CallAsFunction) {
Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance_template = t->InstanceTemplate();
instance_template->SetCallAsFunctionHandler(call_as_function);
- Local<v8::Object> instance = t->GetFunction()->NewInstance();
- context->Global()->Set(v8_str("obj"), instance);
+ Local<v8::Object> instance = t->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"), instance)
+ .FromJust());
v8::TryCatch try_catch(isolate);
Local<Value> value;
CHECK(!try_catch.HasCaught());
value = CompileRun("obj(42)");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context.local()).FromJust());
value = CompileRun("(function(o){return o(49)})(obj)");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(49, value->Int32Value());
+ CHECK_EQ(49, value->Int32Value(context.local()).FromJust());
// test special case of call as function
value = CompileRun("[obj]['0'](45)");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(45, value->Int32Value());
+ CHECK_EQ(45, value->Int32Value(context.local()).FromJust());
value = CompileRun(
"obj.call = Function.prototype.call;"
"obj.call(null, 87)");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(87, value->Int32Value());
+ CHECK_EQ(87, value->Int32Value(context.local()).FromJust());
// Regression tests for bug #1116356: Calling call through call/apply
// must work for non-function receivers.
const char* apply_99 = "Function.prototype.call.apply(obj, [this, 99])";
value = CompileRun(apply_99);
CHECK(!try_catch.HasCaught());
- CHECK_EQ(99, value->Int32Value());
+ CHECK_EQ(99, value->Int32Value(context.local()).FromJust());
const char* call_17 = "Function.prototype.call.call(obj, this, 17)";
value = CompileRun(call_17);
CHECK(!try_catch.HasCaught());
- CHECK_EQ(17, value->Int32Value());
+ CHECK_EQ(17, value->Int32Value(context.local()).FromJust());
// Check that the call-as-function handler can be called through
// new.
value = CompileRun("new obj(43)");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(-43, value->Int32Value());
+ CHECK_EQ(-43, value->Int32Value(context.local()).FromJust());
// Check that the call-as-function handler can be called through
// the API.
- v8::Handle<Value> args[] = {v8_num(28)};
+ v8::Local<Value> args[] = {v8_num(28)};
value = instance->CallAsFunction(instance, 1, args);
CHECK(!try_catch.HasCaught());
- CHECK_EQ(28, value->Int32Value());
+ CHECK_EQ(28, value->Int32Value(context.local()).FromJust());
}
{
Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance_template(t->InstanceTemplate());
USE(instance_template);
- Local<v8::Object> instance = t->GetFunction()->NewInstance();
- context->Global()->Set(v8_str("obj2"), instance);
+ Local<v8::Object> instance = t->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj2"), instance)
+ .FromJust());
v8::TryCatch try_catch(isolate);
Local<Value> value;
CHECK(!try_catch.HasCaught());
@@ -10232,7 +11549,7 @@ THREADED_TEST(CallAsFunction) {
// Call an object without call-as-function handler through the API
value = CompileRun("obj2(28)");
- v8::Handle<Value> args[] = {v8_num(28)};
+ v8::Local<Value> args[] = {v8_num(28)};
value = instance->CallAsFunction(instance, 1, args);
CHECK(value.IsEmpty());
CHECK(try_catch.HasCaught());
@@ -10246,8 +11563,13 @@ THREADED_TEST(CallAsFunction) {
Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance_template = t->InstanceTemplate();
instance_template->SetCallAsFunctionHandler(ThrowValue);
- Local<v8::Object> instance = t->GetFunction()->NewInstance();
- context->Global()->Set(v8_str("obj3"), instance);
+ Local<v8::Object> instance = t->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj3"), instance)
+ .FromJust());
v8::TryCatch try_catch(isolate);
Local<Value> value;
CHECK(!try_catch.HasCaught());
@@ -10259,7 +11581,7 @@ THREADED_TEST(CallAsFunction) {
CHECK_EQ(0, strcmp("22", *exception_value1));
try_catch.Reset();
- v8::Handle<Value> args[] = {v8_num(23)};
+ v8::Local<Value> args[] = {v8_num(23)};
value = instance->CallAsFunction(instance, 1, args);
CHECK(try_catch.HasCaught());
String::Utf8Value exception_value2(try_catch.Exception());
@@ -10271,7 +11593,10 @@ THREADED_TEST(CallAsFunction) {
Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance_template = t->InstanceTemplate();
instance_template->SetCallAsFunctionHandler(ReturnThis);
- Local<v8::Object> instance = t->GetFunction()->NewInstance();
+ Local<v8::Object> instance = t->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
Local<v8::Value> a1 =
instance->CallAsFunction(v8::Undefined(isolate), 0, NULL);
@@ -10345,7 +11670,8 @@ THREADED_TEST(CallableObject) {
{
Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
instance_template->SetCallAsFunctionHandler(call_as_function);
- Local<Object> instance = instance_template->NewInstance();
+ Local<Object> instance =
+ instance_template->NewInstance(context.local()).ToLocalChecked();
v8::TryCatch try_catch(isolate);
CHECK(instance->IsCallable());
@@ -10354,7 +11680,8 @@ THREADED_TEST(CallableObject) {
{
Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
- Local<Object> instance = instance_template->NewInstance();
+ Local<Object> instance =
+ instance_template->NewInstance(context.local()).ToLocalChecked();
v8::TryCatch try_catch(isolate);
CHECK(!instance->IsCallable());
@@ -10364,7 +11691,8 @@ THREADED_TEST(CallableObject) {
{
Local<FunctionTemplate> function_template =
FunctionTemplate::New(isolate, call_as_function);
- Local<Function> function = function_template->GetFunction();
+ Local<Function> function =
+ function_template->GetFunction(context.local()).ToLocalChecked();
Local<Object> instance = function;
v8::TryCatch try_catch(isolate);
@@ -10374,7 +11702,8 @@ THREADED_TEST(CallableObject) {
{
Local<FunctionTemplate> function_template = FunctionTemplate::New(isolate);
- Local<Function> function = function_template->GetFunction();
+ Local<Function> function =
+ function_template->GetFunction(context.local()).ToLocalChecked();
Local<Object> instance = function;
v8::TryCatch try_catch(isolate);
@@ -10445,7 +11774,8 @@ static void FastApiCallback_TrivialSignature(
CHECK_EQ(isolate, args.GetIsolate());
CHECK(args.This()->Equals(args.Holder()));
CHECK(args.Data()->Equals(v8_str("method_data")));
- args.GetReturnValue().Set(args[0]->Int32Value() + 1);
+ args.GetReturnValue().Set(
+ args[0]->Int32Value(isolate->GetCurrentContext()).FromJust() + 1);
}
static void FastApiCallback_SimpleSignature(
@@ -10459,7 +11789,8 @@ static void FastApiCallback_SimpleSignature(
// Note, we're using HasRealNamedProperty instead of Has to avoid
// invoking the interceptor again.
CHECK(args.Holder()->HasRealNamedProperty(v8_str("foo")));
- args.GetReturnValue().Set(args[0]->Int32Value() + 1);
+ args.GetReturnValue().Set(
+ args[0]->Int32Value(isolate->GetCurrentContext()).FromJust() + 1);
}
@@ -10488,13 +11819,16 @@ THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> nativeobject_templ =
+ v8::Local<v8::ObjectTemplate> nativeobject_templ =
v8::ObjectTemplate::New(isolate);
nativeobject_templ->Set(isolate, "callback",
v8::FunctionTemplate::New(isolate,
DirectApiCallback));
- v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
- context->Global()->Set(v8_str("nativeobject"), nativeobject_obj);
+ v8::Local<v8::Object> nativeobject_obj =
+ nativeobject_templ->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("nativeobject"), nativeobject_obj)
+ .FromJust());
// call the api function multiple times to ensure direct call stub creation.
CompileRun(
"function f() {"
@@ -10516,15 +11850,18 @@ THREADED_TEST(CallICFastApi_DirectCall_Throw) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> nativeobject_templ =
+ v8::Local<v8::ObjectTemplate> nativeobject_templ =
v8::ObjectTemplate::New(isolate);
nativeobject_templ->Set(isolate, "callback",
v8::FunctionTemplate::New(isolate,
ThrowingDirectApiCallback));
- v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
- context->Global()->Set(v8_str("nativeobject"), nativeobject_obj);
+ v8::Local<v8::Object> nativeobject_obj =
+ nativeobject_templ->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("nativeobject"), nativeobject_obj)
+ .FromJust());
// call the api function multiple times to ensure direct call stub creation.
- v8::Handle<Value> result = CompileRun(
+ v8::Local<Value> result = CompileRun(
"var result = '';"
"function f() {"
" for (var i = 1; i <= 5; i++) {"
@@ -10539,7 +11876,7 @@ THREADED_TEST(CallICFastApi_DirectCall_Throw) {
static int p_getter_count_3;
-static Handle<Value> DoDirectGetter() {
+static Local<Value> DoDirectGetter() {
if (++p_getter_count_3 % 3 == 0) {
CcTest::heap()->CollectAllGarbage();
GenerateSomeGarbage();
@@ -10561,11 +11898,14 @@ static void LoadICFastApi_DirectCall_GCMoveStub(Accessor accessor) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate);
obj->SetAccessor(v8_str("p1"), accessor);
- context->Global()->Set(v8_str("o1"), obj->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o1"),
+ obj->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
p_getter_count_3 = 0;
- v8::Handle<v8::Value> result = CompileRun(
+ v8::Local<v8::Value> result = CompileRun(
"function f() {"
" for (var i = 0; i < 30; i++) o1.p1;"
" return o1.p1"
@@ -10592,10 +11932,13 @@ THREADED_TEST(LoadICFastApi_DirectCall_Throw) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate);
obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback);
- context->Global()->Set(v8_str("o1"), obj->NewInstance());
- v8::Handle<Value> result = CompileRun(
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o1"),
+ obj->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
+ v8::Local<Value> result = CompileRun(
"var result = '';"
"for (var i = 0; i < 5; i++) {"
" try { o1.p1; } catch (e) { result += e; }"
@@ -10609,29 +11952,34 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature) {
int interceptor_call_count = 0;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ =
- v8::FunctionTemplate::New(isolate,
- FastApiCallback_TrivialSignature,
- v8_str("method_data"),
- v8::Handle<v8::Signature>());
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ isolate, FastApiCallback_TrivialSignature, v8_str("method_data"),
+ v8::Local<v8::Signature>());
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
- v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
v8::External::New(isolate, &interceptor_call_count)));
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"var result = 0;"
"for (var i = 0; i < 100; i++) {"
" result = o.method(41);"
"}");
- CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("result"))
+ ->Int32Value(context.local())
+ .FromJust());
CHECK_EQ(100, interceptor_call_count);
}
@@ -10640,22 +11988,26 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) {
int interceptor_call_count = 0;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
v8::Signature::New(isolate, fun_templ));
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
- v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
v8::External::New(isolate, &interceptor_call_count)));
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"o.foo = 17;"
"var receiver = {};"
@@ -10664,7 +12016,10 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) {
"for (var i = 0; i < 100; i++) {"
" result = receiver.method(41);"
"}");
- CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("result"))
+ ->Int32Value(context.local())
+ .FromJust());
CHECK_EQ(100, interceptor_call_count);
}
@@ -10673,22 +12028,26 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
int interceptor_call_count = 0;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
v8::Signature::New(isolate, fun_templ));
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
- v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
v8::External::New(isolate, &interceptor_call_count)));
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"o.foo = 17;"
"var receiver = {};"
@@ -10702,8 +12061,14 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
" receiver = {method: function(x) { return x - 1 }};"
" }"
"}");
- CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
- CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
+ CHECK_EQ(40, context->Global()
+ ->Get(v8_str("result"))
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("saved_result"))
+ ->Int32Value(context.local())
+ .FromJust());
CHECK_GE(interceptor_call_count, 50);
}
@@ -10712,22 +12077,26 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
int interceptor_call_count = 0;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
v8::Signature::New(isolate, fun_templ));
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
- v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
v8::External::New(isolate, &interceptor_call_count)));
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"o.foo = 17;"
"var receiver = {};"
@@ -10741,8 +12110,14 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
" o.method = function(x) { return x - 1 };"
" }"
"}");
- CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
- CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
+ CHECK_EQ(40, context->Global()
+ ->Get(v8_str("result"))
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("saved_result"))
+ ->Int32Value(context.local())
+ .FromJust());
CHECK_GE(interceptor_call_count, 50);
}
@@ -10751,22 +12126,26 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
int interceptor_call_count = 0;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
v8::Signature::New(isolate, fun_templ));
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
- v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
v8::External::New(isolate, &interceptor_call_count)));
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
v8::TryCatch try_catch(isolate);
CompileRun(
"o.foo = 17;"
@@ -10785,7 +12164,10 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
// TODO(verwaest): Adjust message.
CHECK(v8_str("TypeError: receiver.method is not a function")
->Equals(try_catch.Exception()->ToString(isolate)));
- CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("saved_result"))
+ ->Int32Value(context.local())
+ .FromJust());
CHECK_GE(interceptor_call_count, 50);
}
@@ -10794,22 +12176,26 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
int interceptor_call_count = 0;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
v8::Signature::New(isolate, fun_templ));
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
- v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
v8::External::New(isolate, &interceptor_call_count)));
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
v8::TryCatch try_catch(isolate);
CompileRun(
"o.foo = 17;"
@@ -10827,7 +12213,10 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
CHECK(try_catch.HasCaught());
CHECK(v8_str("TypeError: Illegal invocation")
->Equals(try_catch.Exception()->ToString(isolate)));
- CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("saved_result"))
+ ->Int32Value(context.local())
+ .FromJust());
CHECK_GE(interceptor_call_count, 50);
}
@@ -10835,48 +12224,57 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ =
- v8::FunctionTemplate::New(isolate,
- FastApiCallback_TrivialSignature,
- v8_str("method_data"),
- v8::Handle<v8::Signature>());
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ isolate, FastApiCallback_TrivialSignature, v8_str("method_data"),
+ v8::Local<v8::Signature>());
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
- v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
+ v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
USE(templ);
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"var result = 0;"
"for (var i = 0; i < 100; i++) {"
" result = o.method(41);"
"}");
- CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("result"))
+ ->Int32Value(context.local())
+ .FromJust());
}
THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
v8::Signature::New(isolate, fun_templ));
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
- v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
+ v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
CHECK(!templ.IsEmpty());
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"o.foo = 17;"
"var receiver = {};"
@@ -10886,27 +12284,34 @@ THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) {
" result = receiver.method(41);"
"}");
- CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("result"))
+ ->Int32Value(context.local())
+ .FromJust());
}
THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
v8::Signature::New(isolate, fun_templ));
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
- v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
+ v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
CHECK(!templ.IsEmpty());
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"o.foo = 17;"
"var receiver = {};"
@@ -10920,28 +12325,38 @@ THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) {
" receiver = {method: function(x) { return x - 1 }};"
" }"
"}");
- CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
- CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
+ CHECK_EQ(40, context->Global()
+ ->Get(v8_str("result"))
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("saved_result"))
+ ->Int32Value(context.local())
+ .FromJust());
}
THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
v8::Signature::New(isolate, fun_templ));
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
- v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
+ v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
CHECK(!templ.IsEmpty());
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
v8::TryCatch try_catch(isolate);
CompileRun(
"o.foo = 17;"
@@ -10960,27 +12375,34 @@ THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) {
// TODO(verwaest): Adjust message.
CHECK(v8_str("TypeError: receiver.method is not a function")
->Equals(try_catch.Exception()->ToString(isolate)));
- CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("saved_result"))
+ ->Int32Value(context.local())
+ .FromJust());
}
THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
+ v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
v8::Signature::New(isolate, fun_templ));
- v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
- v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
+ v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
CHECK(!templ.IsEmpty());
LocalContext context;
- v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ v8::Local<v8::Function> fun =
+ fun_templ->GetFunction(context.local()).ToLocalChecked();
GenerateSomeGarbage();
- context->Global()->Set(v8_str("o"), fun->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ fun->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
v8::TryCatch try_catch(isolate);
CompileRun(
"o.foo = 17;"
@@ -10998,14 +12420,17 @@ THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) {
CHECK(try_catch.HasCaught());
CHECK(v8_str("TypeError: Illegal invocation")
->Equals(try_catch.Exception()->ToString(isolate)));
- CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
+ CHECK_EQ(42, context->Global()
+ ->Get(v8_str("saved_result"))
+ ->Int32Value(context.local())
+ .FromJust());
}
static void ThrowingGetter(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
- info.GetIsolate()->ThrowException(Handle<Value>());
+ info.GetIsolate()->ThrowException(Local<Value>());
info.GetReturnValue().SetUndefined();
}
@@ -11018,7 +12443,10 @@ THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
Local<ObjectTemplate> instance_templ = templ->InstanceTemplate();
instance_templ->SetAccessor(v8_str("f"), ThrowingGetter);
- Local<Object> instance = templ->GetFunction()->NewInstance();
+ Local<Object> instance = templ->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
Local<Object> another = Object::New(context->GetIsolate());
another->SetPrototype(instance);
@@ -11096,23 +12524,23 @@ static void ThrowingCallbackWithTryCatch(
static int call_depth;
-static void WithTryCatch(Handle<Message> message, Handle<Value> data) {
+static void WithTryCatch(Local<Message> message, Local<Value> data) {
TryCatch try_catch(CcTest::isolate());
}
-static void ThrowFromJS(Handle<Message> message, Handle<Value> data) {
+static void ThrowFromJS(Local<Message> message, Local<Value> data) {
if (--call_depth) CompileRun("throw 'ThrowInJS';");
}
-static void ThrowViaApi(Handle<Message> message, Handle<Value> data) {
+static void ThrowViaApi(Local<Message> message, Local<Value> data) {
if (--call_depth) CcTest::isolate()->ThrowException(v8_str("ThrowViaApi"));
}
-static void WebKitLike(Handle<Message> message, Handle<Value> data) {
- Handle<String> errorMessageString = message->Get();
+static void WebKitLike(Local<Message> message, Local<Value> data) {
+ Local<String> errorMessageString = message->Get();
CHECK(!errorMessageString.IsEmpty());
message->GetStackTrace();
message->GetScriptOrigin().ResourceName();
@@ -11125,9 +12553,11 @@ THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch) {
HandleScope scope(isolate);
Local<Function> func =
- FunctionTemplate::New(isolate,
- ThrowingCallbackWithTryCatch)->GetFunction();
- context->Global()->Set(v8_str("func"), func);
+ FunctionTemplate::New(isolate, ThrowingCallbackWithTryCatch)
+ ->GetFunction(context.local())
+ .ToLocalChecked();
+ CHECK(
+ context->Global()->Set(context.local(), v8_str("func"), func).FromJust());
MessageCallback callbacks[] =
{ NULL, WebKitLike, ThrowViaApi, ThrowFromJS, WithTryCatch };
@@ -11191,34 +12621,39 @@ THREADED_TEST(Overriding) {
// so 'h' can be shadowed on the instance object.
Local<ObjectTemplate> child_proto_templ = child_templ->PrototypeTemplate();
child_proto_templ->SetAccessor(v8_str("h"), ParentGetter, 0,
- v8::Handle<Value>(), v8::DEFAULT, v8::ReadOnly);
+ v8::Local<Value>(), v8::DEFAULT, v8::ReadOnly);
// Add 'i' as an accessor to the instance template with ReadOnly attributes
// but the attribute does not have effect because it is duplicated with
// NULL setter.
child_instance_templ->SetAccessor(v8_str("i"), ChildGetter, 0,
- v8::Handle<Value>(), v8::DEFAULT, v8::ReadOnly);
-
+ v8::Local<Value>(), v8::DEFAULT,
+ v8::ReadOnly);
// Instantiate the child template.
- Local<v8::Object> instance = child_templ->GetFunction()->NewInstance();
+ Local<v8::Object> instance = child_templ->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
// Check that the child function overrides the parent one.
- context->Global()->Set(v8_str("o"), instance);
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"), instance)
+ .FromJust());
Local<Value> value = v8_compile("o.f")->Run();
// Check that the 'g' that was added last is hit.
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context.local()).FromJust());
value = v8_compile("o.g")->Run();
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context.local()).FromJust());
// Check that 'h' cannot be shadowed.
value = v8_compile("o.h = 3; o.h")->Run();
- CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(1, value->Int32Value(context.local()).FromJust());
// Check that 'i' cannot be shadowed or changed.
value = v8_compile("o.i = 3; o.i")->Run();
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context.local()).FromJust());
}
@@ -11239,7 +12674,10 @@ THREADED_TEST(IsConstructCall) {
LocalContext context;
- context->Global()->Set(v8_str("f"), templ->GetFunction());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("f"),
+ templ->GetFunction(context.local()).ToLocalChecked())
+ .FromJust());
Local<Value> value = v8_compile("f()")->Run();
CHECK(!value->BooleanValue());
value = v8_compile("new f()")->Run();
@@ -11263,7 +12701,10 @@ THREADED_TEST(ObjectProtoToString) {
"}")->Run();
// Normal ToString call should call replaced Object.prototype.toString
- Local<v8::Object> instance = templ->GetFunction()->NewInstance();
+ Local<v8::Object> instance = templ->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
Local<String> value = instance->ToString(isolate);
CHECK(value->IsString() && value->Equals(customized_tostring));
@@ -11300,7 +12741,10 @@ TEST(ObjectProtoToStringES6) {
"}");
// Normal ToString call should call replaced Object.prototype.toString
- Local<v8::Object> instance = templ->GetFunction()->NewInstance();
+ Local<v8::Object> instance = templ->GetFunction(context.local())
+ .ToLocalChecked()
+ ->NewInstance(context.local())
+ .ToLocalChecked();
Local<String> value = instance->ToString(isolate);
CHECK(value->IsString() && value->Equals(customized_tostring));
@@ -11643,10 +13087,10 @@ static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) {
{
v8::Locker nested_locker(isolate);
v8::HandleScope scope(isolate);
- v8::Handle<Value> exception;
+ v8::Local<Value> exception;
{
v8::TryCatch try_catch(isolate);
- v8::Handle<Value> value = CompileRun(code);
+ v8::Local<Value> value = CompileRun(code);
CHECK(value.IsEmpty());
CHECK(try_catch.HasCaught());
// Make sure to wrap the exception in a new handle because
@@ -11667,7 +13111,7 @@ static void ThrowInJSNoCatch(const v8::FunctionCallbackInfo<v8::Value>& args) {
{
v8::Locker nested_locker(CcTest::isolate());
v8::HandleScope scope(args.GetIsolate());
- v8::Handle<Value> value = CompileRun(code);
+ v8::Local<Value> value = CompileRun(code);
CHECK(value.IsEmpty());
args.GetReturnValue().Set(v8_str("foo"));
}
@@ -11684,8 +13128,8 @@ TEST(NestedLockers) {
v8::HandleScope scope(env->GetIsolate());
Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(isolate, ThrowInJS);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("throw_in_js"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()->Set(env.local(), v8_str("throw_in_js"), fun).FromJust());
Local<Script> script = v8_compile("(function () {"
" try {"
" throw_in_js();"
@@ -11694,7 +13138,7 @@ TEST(NestedLockers) {
" return e * 13;"
" }"
"})();");
- CHECK_EQ(91, script->Run()->Int32Value());
+ CHECK_EQ(91, script->Run()->Int32Value(env.local()).FromJust());
}
@@ -11706,8 +13150,8 @@ TEST(NestedLockersNoTryCatch) {
v8::HandleScope scope(env->GetIsolate());
Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(env->GetIsolate(), ThrowInJSNoCatch);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("throw_in_js"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()->Set(env.local(), v8_str("throw_in_js"), fun).FromJust());
Local<Script> script = v8_compile("(function () {"
" try {"
" throw_in_js();"
@@ -11716,7 +13160,7 @@ TEST(NestedLockersNoTryCatch) {
" return e * 13;"
" }"
"})();");
- CHECK_EQ(91, script->Run()->Int32Value());
+ CHECK_EQ(91, script->Run()->Int32Value(env.local()).FromJust());
}
@@ -11742,13 +13186,15 @@ THREADED_TEST(LockUnlockLock) {
LocalContext env;
Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(CcTest::isolate(), UnlockForAMoment);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("unlock_for_a_moment"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("unlock_for_a_moment"), fun)
+ .FromJust());
Local<Script> script = v8_compile("(function () {"
" unlock_for_a_moment();"
" return 42;"
"})();");
- CHECK_EQ(42, script->Run()->Int32Value());
+ CHECK_EQ(42, script->Run()->Int32Value(env.local()).FromJust());
}
{
v8::Locker locker(CcTest::isolate());
@@ -11756,13 +13202,15 @@ THREADED_TEST(LockUnlockLock) {
LocalContext env;
Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(CcTest::isolate(), UnlockForAMoment);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("unlock_for_a_moment"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("unlock_for_a_moment"), fun)
+ .FromJust());
Local<Script> script = v8_compile("(function () {"
" unlock_for_a_moment();"
" return 42;"
"})();");
- CHECK_EQ(42, script->Run()->Int32Value());
+ CHECK_EQ(42, script->Run()->Int32Value(env.local()).FromJust());
}
}
@@ -12031,7 +13479,7 @@ THREADED_TEST(CheckForCrossContextObjectLiterals) {
}
-static v8::Handle<Value> NestedScope(v8::Local<Context> env) {
+static v8::Local<Value> NestedScope(v8::Local<Context> env) {
v8::EscapableHandleScope inner(env->GetIsolate());
env->Enter();
v8::Local<Value> three = v8_num(3);
@@ -12046,8 +13494,8 @@ THREADED_TEST(NestedHandleScopeAndContexts) {
v8::HandleScope outer(isolate);
v8::Local<Context> env = Context::New(isolate);
env->Enter();
- v8::Handle<Value> value = NestedScope(env);
- v8::Handle<String> str(value->ToString(isolate));
+ v8::Local<Value> value = NestedScope(env);
+ v8::Local<String> str(value->ToString(isolate));
CHECK(!str.IsEmpty());
env->Exit();
}
@@ -12294,7 +13742,9 @@ void SetFunctionEntryHookTest::RunLoopInNewEnv(v8::Isolate* isolate) {
Local<ObjectTemplate> t = ObjectTemplate::New(isolate);
t->Set(v8_str("asdf"), v8::FunctionTemplate::New(isolate, RuntimeCallback));
- env->Global()->Set(v8_str("obj"), t->NewInstance());
+ CHECK(env->Global()
+ ->Set(env, v8_str("obj"), t->NewInstance(env).ToLocalChecked())
+ .FromJust());
const char* script =
"function bar() {\n"
@@ -12316,7 +13766,7 @@ void SetFunctionEntryHookTest::RunLoopInNewEnv(v8::Isolate* isolate) {
v8::Utils::OpenHandle(*env->Global()->Get(v8_str("foo"))));
DCHECK(!foo_func_.is_null());
- v8::Handle<v8::Value> value = CompileRun("bar();");
+ v8::Local<v8::Value> value = CompileRun("bar();");
CHECK(value->IsNumber());
CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value());
@@ -12681,8 +14131,10 @@ THREADED_TEST(Regress54) {
local->SetInternalFieldCount(1);
templ.Reset(isolate, inner.Escape(local));
}
- v8::Handle<v8::Object> result =
- v8::Local<v8::ObjectTemplate>::New(isolate, templ)->NewInstance();
+ v8::Local<v8::Object> result =
+ v8::Local<v8::ObjectTemplate>::New(isolate, templ)
+ ->NewInstance(context.local())
+ .ToLocalChecked();
CHECK_EQ(1, result->InternalFieldCount());
}
@@ -12693,25 +14145,25 @@ TEST(CatchStackOverflow) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
v8::TryCatch try_catch(context->GetIsolate());
- v8::Handle<v8::Value> result = CompileRun(
- "function f() {"
- " return f();"
- "}"
- ""
- "f();");
+ v8::Local<v8::Value> result = CompileRun(
+ "function f() {"
+ " return f();"
+ "}"
+ ""
+ "f();");
CHECK(result.IsEmpty());
}
-static void CheckTryCatchSourceInfo(v8::Handle<v8::Script> script,
+static void CheckTryCatchSourceInfo(v8::Local<v8::Script> script,
const char* resource_name,
int line_offset) {
v8::HandleScope scope(CcTest::isolate());
v8::TryCatch try_catch(CcTest::isolate());
- v8::Handle<v8::Value> result = script->Run();
+ v8::Local<v8::Value> result = script->Run();
CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
- v8::Handle<v8::Message> message = try_catch.Message();
+ v8::Local<v8::Message> message = try_catch.Message();
CHECK(!message.IsEmpty());
CHECK_EQ(10 + line_offset, message->GetLineNumber());
CHECK_EQ(91, message->GetStartPosition());
@@ -12744,21 +14196,19 @@ THREADED_TEST(TryCatchSourceInfo) {
"Foo();\n");
const char* resource_name;
- v8::Handle<v8::Script> script;
+ v8::Local<v8::Script> script;
resource_name = "test.js";
script = CompileWithOrigin(source, resource_name);
CheckTryCatchSourceInfo(script, resource_name, 0);
resource_name = "test1.js";
- v8::ScriptOrigin origin1(
- v8::String::NewFromUtf8(context->GetIsolate(), resource_name));
+ v8::ScriptOrigin origin1(v8_str(resource_name));
script = v8::Script::Compile(source, &origin1);
CheckTryCatchSourceInfo(script, resource_name, 0);
resource_name = "test2.js";
- v8::ScriptOrigin origin2(
- v8::String::NewFromUtf8(context->GetIsolate(), resource_name),
- v8::Integer::New(context->GetIsolate(), 7));
+ v8::ScriptOrigin origin2(v8_str(resource_name),
+ v8::Integer::New(context->GetIsolate(), 7));
script = v8::Script::Compile(source, &origin2);
CheckTryCatchSourceInfo(script, resource_name, 7);
}
@@ -12770,7 +14220,7 @@ THREADED_TEST(TryCatchSourceInfoForEOSError) {
v8::TryCatch try_catch(context->GetIsolate());
v8::Script::Compile(v8_str("!\n"));
CHECK(try_catch.HasCaught());
- v8::Handle<v8::Message> message = try_catch.Message();
+ v8::Local<v8::Message> message = try_catch.Message();
CHECK_EQ(1, message->GetLineNumber());
CHECK_EQ(0, message->GetStartColumn());
}
@@ -12779,17 +14229,15 @@ THREADED_TEST(TryCatchSourceInfoForEOSError) {
THREADED_TEST(CompilationCache) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::Handle<v8::String> source0 =
- v8::String::NewFromUtf8(context->GetIsolate(), "1234");
- v8::Handle<v8::String> source1 =
- v8::String::NewFromUtf8(context->GetIsolate(), "1234");
- v8::Handle<v8::Script> script0 = CompileWithOrigin(source0, "test.js");
- v8::Handle<v8::Script> script1 = CompileWithOrigin(source1, "test.js");
- v8::Handle<v8::Script> script2 =
+ v8::Local<v8::String> source0 = v8_str("1234");
+ v8::Local<v8::String> source1 = v8_str("1234");
+ v8::Local<v8::Script> script0 = CompileWithOrigin(source0, "test.js");
+ v8::Local<v8::Script> script1 = CompileWithOrigin(source1, "test.js");
+ v8::Local<v8::Script> script2 =
v8::Script::Compile(source0); // different origin
- CHECK_EQ(1234, script0->Run()->Int32Value());
- CHECK_EQ(1234, script1->Run()->Int32Value());
- CHECK_EQ(1234, script2->Run()->Int32Value());
+ CHECK_EQ(1234, script0->Run()->Int32Value(context.local()).FromJust());
+ CHECK_EQ(1234, script1->Run()->Int32Value(context.local()).FromJust());
+ CHECK_EQ(1234, script2->Run()->Int32Value(context.local()).FromJust());
}
@@ -12807,8 +14255,11 @@ THREADED_TEST(CallbackFunctionName) {
Local<ObjectTemplate> t = ObjectTemplate::New(isolate);
t->Set(v8_str("asdf"),
v8::FunctionTemplate::New(isolate, FunctionNameCallback));
- context->Global()->Set(v8_str("obj"), t->NewInstance());
- v8::Handle<v8::Value> value = CompileRun("obj.asdf.name");
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ t->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
+ v8::Local<v8::Value> value = CompileRun("obj.asdf.name");
CHECK(value->IsString());
v8::String::Utf8Value name(value);
CHECK_EQ(0, strcmp("asdf", *name));
@@ -12818,17 +14269,17 @@ THREADED_TEST(CallbackFunctionName) {
THREADED_TEST(DateAccess) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::Handle<v8::Value> date =
+ v8::Local<v8::Value> date =
v8::Date::New(context->GetIsolate(), 1224744689038.0);
CHECK(date->IsDate());
CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf());
}
-void CheckProperties(v8::Isolate* isolate, v8::Handle<v8::Value> val,
+void CheckProperties(v8::Isolate* isolate, v8::Local<v8::Value> val,
unsigned elmc, const char* elmv[]) {
- v8::Handle<v8::Object> obj = val.As<v8::Object>();
- v8::Handle<v8::Array> props = obj->GetPropertyNames();
+ v8::Local<v8::Object> obj = val.As<v8::Object>();
+ v8::Local<v8::Array> props = obj->GetPropertyNames();
CHECK_EQ(elmc, props->Length());
for (unsigned i = 0; i < elmc; i++) {
v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i)));
@@ -12837,10 +14288,10 @@ void CheckProperties(v8::Isolate* isolate, v8::Handle<v8::Value> val,
}
-void CheckOwnProperties(v8::Isolate* isolate, v8::Handle<v8::Value> val,
+void CheckOwnProperties(v8::Isolate* isolate, v8::Local<v8::Value> val,
unsigned elmc, const char* elmv[]) {
- v8::Handle<v8::Object> obj = val.As<v8::Object>();
- v8::Handle<v8::Array> props = obj->GetOwnPropertyNames();
+ v8::Local<v8::Object> obj = val.As<v8::Object>();
+ v8::Local<v8::Array> props = obj->GetOwnPropertyNames();
CHECK_EQ(elmc, props->Length());
for (unsigned i = 0; i < elmc; i++) {
v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i)));
@@ -12853,7 +14304,7 @@ THREADED_TEST(PropertyEnumeration) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::Value> obj = CompileRun(
+ v8::Local<v8::Value> obj = CompileRun(
"var result = [];"
"result[0] = {};"
"result[1] = {a: 1, b: 2};"
@@ -12862,7 +14313,7 @@ THREADED_TEST(PropertyEnumeration) {
"var x = { __proto__: proto, w: 0, z: 1 };"
"result[3] = x;"
"result;");
- v8::Handle<v8::Array> elms = obj.As<v8::Array>();
+ v8::Local<v8::Array> elms = obj.As<v8::Array>();
CHECK_EQ(4u, elms->Length());
int elmc0 = 0;
const char** elmv0 = NULL;
@@ -12897,7 +14348,7 @@ THREADED_TEST(PropertyEnumeration2) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::Value> obj = CompileRun(
+ v8::Local<v8::Value> obj = CompileRun(
"var result = [];"
"result[0] = {};"
"result[1] = {a: 1, b: 2};"
@@ -12906,15 +14357,15 @@ THREADED_TEST(PropertyEnumeration2) {
"var x = { __proto__: proto, w: 0, z: 1 };"
"result[3] = x;"
"result;");
- v8::Handle<v8::Array> elms = obj.As<v8::Array>();
+ v8::Local<v8::Array> elms = obj.As<v8::Array>();
CHECK_EQ(4u, elms->Length());
int elmc0 = 0;
const char** elmv0 = NULL;
CheckProperties(isolate,
elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0);
- v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(isolate, 0));
- v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames();
+ v8::Local<v8::Value> val = elms->Get(v8::Integer::New(isolate, 0));
+ v8::Local<v8::Array> props = val.As<v8::Object>()->GetPropertyNames();
CHECK_EQ(0u, props->Length());
for (uint32_t i = 0; i < props->Length(); i++) {
printf("p[%u]\n", i);
@@ -12945,14 +14396,20 @@ THREADED_TEST(AccessChecksReenabledCorrectly) {
}
}
- Local<v8::Object> instance_1 = templ->NewInstance();
- context->Global()->Set(v8_str("obj_1"), instance_1);
+ Local<v8::Object> instance_1 =
+ templ->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj_1"), instance_1)
+ .FromJust());
Local<Value> value_1 = CompileRun("obj_1.a");
CHECK(value_1.IsEmpty());
- Local<v8::Object> instance_2 = templ->NewInstance();
- context->Global()->Set(v8_str("obj_2"), instance_2);
+ Local<v8::Object> instance_2 =
+ templ->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj_2"), instance_2)
+ .FromJust());
Local<Value> value_2 = CompileRun("obj_2.a");
CHECK(value_2.IsEmpty());
@@ -12998,14 +14455,18 @@ THREADED_TEST(DictionaryICLoadedFunction) {
// Test LoadIC.
for (int i = 0; i < 2; i++) {
LocalContext context;
- context->Global()->Set(v8_str("tmp"), v8::True(CcTest::isolate()));
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))
+ .FromJust());
context->Global()->Delete(v8_str("tmp"));
CompileRun("for (var j = 0; j < 10; j++) new RegExp('');");
}
// Test CallIC.
for (int i = 0; i < 2; i++) {
LocalContext context;
- context->Global()->Set(v8_str("tmp"), v8::True(CcTest::isolate()));
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))
+ .FromJust());
context->Global()->Delete(v8_str("tmp"));
CompileRun("for (var j = 0; j < 10; j++) RegExp('')");
}
@@ -13034,10 +14495,12 @@ THREADED_TEST(CrossContextNew) {
// Call the constructor function from context0 and check that the
// result has the 'x' property.
context1->Enter();
- context1->Global()->Set(v8_str("other"), context0->Global());
+ CHECK(context1->Global()
+ ->Set(context1, v8_str("other"), context0->Global())
+ .FromJust());
Local<Value> value = CompileRun("var instance = new other.C(); instance.x");
CHECK(value->IsInt32());
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context1).FromJust());
context1->Exit();
}
@@ -13148,8 +14611,8 @@ THREADED_TEST(MorphCompositeStringTest) {
v8::Utils::ToLocal(factory->NewExternalStringFromOneByte(
&one_byte_resource).ToHandleChecked()));
- env->Global()->Set(v8_str("lhs"), lhs);
- env->Global()->Set(v8_str("rhs"), rhs);
+ CHECK(env->Global()->Set(env.local(), v8_str("lhs"), lhs).FromJust());
+ CHECK(env->Global()->Set(env.local(), v8_str("rhs"), rhs).FromJust());
CompileRun(
"var cons = lhs + rhs;"
@@ -13165,7 +14628,7 @@ THREADED_TEST(MorphCompositeStringTest) {
&uc16_resource);
// This should UTF-8 without flattening, since everything is ASCII.
- Handle<String> cons = v8_compile("cons")->Run().As<String>();
+ Local<String> cons = v8_compile("cons")->Run().As<String>();
CHECK_EQ(128, cons->Utf8Length());
int nchars = -1;
CHECK_EQ(129, cons->WriteUtf8(utf_buffer, -1, &nchars));
@@ -13188,11 +14651,9 @@ THREADED_TEST(MorphCompositeStringTest) {
const char* expected_slice_on_cons =
"ow is the time for all good men to come to the aid of the party"
"Now is the time for all good men to come to the aid of the part";
- CHECK(String::NewFromUtf8(env->GetIsolate(), expected_cons)
- ->Equals(env->Global()->Get(v8_str("cons"))));
- CHECK(String::NewFromUtf8(env->GetIsolate(), expected_slice)
- ->Equals(env->Global()->Get(v8_str("slice"))));
- CHECK(String::NewFromUtf8(env->GetIsolate(), expected_slice_on_cons)
+ CHECK(v8_str(expected_cons)->Equals(env->Global()->Get(v8_str("cons"))));
+ CHECK(v8_str(expected_slice)->Equals(env->Global()->Get(v8_str("slice"))));
+ CHECK(v8_str(expected_slice_on_cons)
->Equals(env->Global()->Get(v8_str("slice_on_cons"))));
}
i::DeleteArray(two_byte_string);
@@ -13306,17 +14767,17 @@ TEST(RegExpInterruption) {
TEST(ReadOnlyPropertyInGlobalProto) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
LocalContext context(0, templ);
- v8::Handle<v8::Object> global = context->Global();
- v8::Handle<v8::Object> global_proto =
- v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__")));
+ v8::Local<v8::Object> global = context->Global();
+ v8::Local<v8::Object> global_proto =
+ v8::Local<v8::Object>::Cast(global->Get(v8_str("__proto__")));
global_proto->ForceSet(v8_str("x"), v8::Integer::New(isolate, 0),
v8::ReadOnly);
global_proto->ForceSet(v8_str("y"), v8::Integer::New(isolate, 0),
v8::ReadOnly);
// Check without 'eval' or 'with'.
- v8::Handle<v8::Value> res =
+ v8::Local<v8::Value> res =
CompileRun("function f() { x = 42; return x; }; f()");
CHECK(v8::Integer::New(isolate, 0)->Equals(res));
// Check with 'eval'.
@@ -13367,40 +14828,44 @@ TEST(ForceSet) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
- v8::Handle<v8::String> access_property =
- v8::String::NewFromUtf8(isolate, "a");
+ v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::String> access_property = v8_str("a");
templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter);
LocalContext context(NULL, templ);
- v8::Handle<v8::Object> global = context->Global();
+ v8::Local<v8::Object> global = context->Global();
// Ordinary properties
- v8::Handle<v8::String> simple_property =
- v8::String::NewFromUtf8(isolate, "p");
+ v8::Local<v8::String> simple_property = v8_str("p");
global->ForceSet(simple_property, v8::Int32::New(isolate, 4), v8::ReadOnly);
- CHECK_EQ(4, global->Get(simple_property)->Int32Value());
+ CHECK_EQ(
+ 4, global->Get(simple_property)->Int32Value(context.local()).FromJust());
// This should fail because the property is read-only
global->Set(simple_property, v8::Int32::New(isolate, 5));
- CHECK_EQ(4, global->Get(simple_property)->Int32Value());
+ CHECK_EQ(
+ 4, global->Get(simple_property)->Int32Value(context.local()).FromJust());
// This should succeed even though the property is read-only
global->ForceSet(simple_property, v8::Int32::New(isolate, 6));
- CHECK_EQ(6, global->Get(simple_property)->Int32Value());
+ CHECK_EQ(
+ 6, global->Get(simple_property)->Int32Value(context.local()).FromJust());
// Accessors
CHECK_EQ(0, force_set_set_count);
CHECK_EQ(0, force_set_get_count);
- CHECK_EQ(3, global->Get(access_property)->Int32Value());
+ CHECK_EQ(
+ 3, global->Get(access_property)->Int32Value(context.local()).FromJust());
// CHECK_EQ the property shouldn't override it, just call the setter
// which in this case does nothing.
global->Set(access_property, v8::Int32::New(isolate, 7));
- CHECK_EQ(3, global->Get(access_property)->Int32Value());
+ CHECK_EQ(
+ 3, global->Get(access_property)->Int32Value(context.local()).FromJust());
CHECK_EQ(1, force_set_set_count);
CHECK_EQ(2, force_set_get_count);
// ForceSet doesn't call the accessors for now.
// TODO(verwaest): Update once blink doesn't rely on ForceSet to delete api
// accessors.
global->ForceSet(access_property, v8::Int32::New(isolate, 8));
- CHECK_EQ(8, global->Get(access_property)->Int32Value());
+ CHECK_EQ(
+ 8, global->Get(access_property)->Int32Value(context.local()).FromJust());
CHECK_EQ(1, force_set_set_count);
CHECK_EQ(2, force_set_get_count);
}
@@ -13409,26 +14874,27 @@ TEST(ForceSet) {
TEST(ForceSetWithInterceptor) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
ForceSetInterceptGetter, ForceSetInterceptSetter));
pass_on_get = true;
LocalContext context(NULL, templ);
- v8::Handle<v8::Object> global = context->Global();
+ v8::Local<v8::Object> global = context->Global();
force_set_get_count = 0;
force_set_set_count = 0;
pass_on_get = false;
- v8::Handle<v8::String> some_property =
- v8::String::NewFromUtf8(isolate, "a");
+ v8::Local<v8::String> some_property = v8_str("a");
CHECK_EQ(0, force_set_set_count);
CHECK_EQ(0, force_set_get_count);
- CHECK_EQ(3, global->Get(some_property)->Int32Value());
+ CHECK_EQ(3,
+ global->Get(some_property)->Int32Value(context.local()).FromJust());
// Setting the property shouldn't override it, just call the setter
// which in this case does nothing.
global->Set(some_property, v8::Int32::New(isolate, 7));
- CHECK_EQ(3, global->Get(some_property)->Int32Value());
+ CHECK_EQ(3,
+ global->Get(some_property)->Int32Value(context.local()).FromJust());
CHECK_EQ(1, force_set_set_count);
CHECK_EQ(2, force_set_get_count);
// Getting the property when the interceptor returns an empty handle
@@ -13441,18 +14907,19 @@ TEST(ForceSetWithInterceptor) {
// Forcing the property to be set should cause the value to be
// set locally without calling the interceptor.
global->ForceSet(some_property, v8::Int32::New(isolate, 8));
- CHECK_EQ(8, global->Get(some_property)->Int32Value());
+ CHECK_EQ(8,
+ global->Get(some_property)->Int32Value(context.local()).FromJust());
CHECK_EQ(1, force_set_set_count);
CHECK_EQ(4, force_set_get_count);
// Reenabling the interceptor should cause it to take precedence over
// the property
pass_on_get = false;
- CHECK_EQ(3, global->Get(some_property)->Int32Value());
+ CHECK_EQ(3,
+ global->Get(some_property)->Int32Value(context.local()).FromJust());
CHECK_EQ(1, force_set_set_count);
CHECK_EQ(5, force_set_get_count);
// The interceptor should also work for other properties
- CHECK_EQ(3, global->Get(v8::String::NewFromUtf8(isolate, "b"))
- ->Int32Value());
+ CHECK_EQ(3, global->Get(v8_str("b"))->Int32Value(context.local()).FromJust());
CHECK_EQ(1, force_set_set_count);
CHECK_EQ(6, force_set_get_count);
}
@@ -13699,9 +15166,9 @@ THREADED_TEST(InitGlobalVarInProtoChain) {
v8::HandleScope scope(context->GetIsolate());
// Introduce a variable in the prototype chain.
CompileRun("__proto__.x = 42");
- v8::Handle<v8::Value> result = CompileRun("var x = 43; x");
+ v8::Local<v8::Value> result = CompileRun("var x = 43; x");
CHECK(!result->IsUndefined());
- CHECK_EQ(43, result->Int32Value());
+ CHECK_EQ(43, result->Int32Value(context.local()).FromJust());
}
@@ -13714,15 +15181,14 @@ THREADED_TEST(ReplaceConstantFunction) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::Object> obj = v8::Object::New(isolate);
- v8::Handle<v8::FunctionTemplate> func_templ =
+ v8::Local<v8::Object> obj = v8::Object::New(isolate);
+ v8::Local<v8::FunctionTemplate> func_templ =
v8::FunctionTemplate::New(isolate);
- v8::Handle<v8::String> foo_string =
- v8::String::NewFromUtf8(isolate, "foo");
- obj->Set(foo_string, func_templ->GetFunction());
- v8::Handle<v8::Object> obj_clone = obj->Clone();
- obj_clone->Set(foo_string,
- v8::String::NewFromUtf8(isolate, "Hello"));
+ v8::Local<v8::String> foo_string = v8_str("foo");
+ obj->Set(foo_string,
+ func_templ->GetFunction(context.local()).ToLocalChecked());
+ v8::Local<v8::Object> obj_clone = obj->Clone();
+ obj_clone->Set(foo_string, v8_str("Hello"));
CHECK(!obj->Get(foo_string)->IsUndefined());
}
@@ -13738,8 +15204,8 @@ static void CheckElementValue(i::Isolate* isolate,
template <class ExternalArrayClass, class ElementType>
-static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
- v8::Handle<Object> obj,
+static void ObjectWithExternalArrayTestHelper(Local<Context> context,
+ v8::Local<Object> obj,
int element_count,
i::ExternalArrayType array_type,
int64_t low, int64_t high) {
@@ -13747,11 +15213,11 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
i::Isolate* isolate = jsobj->GetIsolate();
obj->Set(v8_str("field"),
v8::Int32::New(reinterpret_cast<v8::Isolate*>(isolate), 1503));
- context->Global()->Set(v8_str("ext_array"), obj);
- v8::Handle<v8::Value> result = CompileRun("ext_array.field");
- CHECK_EQ(1503, result->Int32Value());
+ CHECK(context->Global()->Set(context, v8_str("ext_array"), obj).FromJust());
+ v8::Local<v8::Value> result = CompileRun("ext_array.field");
+ CHECK_EQ(1503, result->Int32Value(context).FromJust());
result = CompileRun("ext_array[1]");
- CHECK_EQ(1, result->Int32Value());
+ CHECK_EQ(1, result->Int32Value(context).FromJust());
// Check assigned smis
result = CompileRun("for (var i = 0; i < 8; i++) {"
@@ -13763,14 +15229,14 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
"}"
"sum;");
- CHECK_EQ(28, result->Int32Value());
+ CHECK_EQ(28, result->Int32Value(context).FromJust());
// Check pass through of assigned smis
result = CompileRun("var sum = 0;"
"for (var i = 0; i < 8; i++) {"
" sum += ext_array[i] = ext_array[i] = -i;"
"}"
"sum;");
- CHECK_EQ(-28, result->Int32Value());
+ CHECK_EQ(-28, result->Int32Value(context).FromJust());
// Check assigned smis in reverse order
@@ -13782,7 +15248,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" sum += ext_array[i];"
"}"
"sum;");
- CHECK_EQ(28, result->Int32Value());
+ CHECK_EQ(28, result->Int32Value(context).FromJust());
// Check pass through of assigned HeapNumbers
result = CompileRun("var sum = 0;"
@@ -13790,7 +15256,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" sum += ext_array[i] = ext_array[i] = (-i * 0.5);"
"}"
"sum;");
- CHECK_EQ(-28, result->Int32Value());
+ CHECK_EQ(-28, result->Int32Value(context).FromJust());
// Check assigned HeapNumbers
result = CompileRun("for (var i = 0; i < 16; i+=2) {"
@@ -13801,7 +15267,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" sum += ext_array[i];"
"}"
"sum;");
- CHECK_EQ(28, result->Int32Value());
+ CHECK_EQ(28, result->Int32Value(context).FromJust());
// Check assigned HeapNumbers in reverse order
result = CompileRun("for (var i = 14; i >= 0; i-=2) {"
@@ -13812,7 +15278,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" sum += ext_array[i];"
"}"
"sum;");
- CHECK_EQ(28, result->Int32Value());
+ CHECK_EQ(28, result->Int32Value(context).FromJust());
i::ScopedVector<char> test_buf(1024);
@@ -13852,7 +15318,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
"sum;");
// Force GC to trigger verification.
CcTest::heap()->CollectAllGarbage();
- CHECK_EQ(28, result->Int32Value());
+ CHECK_EQ(28, result->Int32Value(context).FromJust());
// Make sure out-of-range loads do not throw.
i::SNPrintF(test_buf,
@@ -13885,7 +15351,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" ext_array[7] = undefined;"
"}"
"ext_array[7];");
- CHECK_EQ(0, result->Int32Value());
+ CHECK_EQ(0, result->Int32Value(context).FromJust());
if (array_type == i::kExternalFloat64Array ||
array_type == i::kExternalFloat32Array) {
CHECK(std::isnan(
@@ -13898,7 +15364,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" ext_array[6] = '2.3';"
"}"
"ext_array[6];");
- CHECK_EQ(2, result->Int32Value());
+ CHECK_EQ(2, result->Int32Value(context).FromJust());
CHECK_EQ(2,
static_cast<int>(
i::Object::GetElement(
@@ -13915,7 +15381,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" ext_array[i] = NaN;"
"}"
"ext_array[5];");
- CHECK_EQ(0, result->Int32Value());
+ CHECK_EQ(0, result->Int32Value(context).FromJust());
CheckElementValue(isolate, 0, jsobj, 5);
result = CompileRun("for (var i = 0; i < 8; i++) {"
@@ -13927,7 +15393,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
"ext_array[5];");
int expected_value =
(array_type == i::kExternalUint8ClampedArray) ? 255 : 0;
- CHECK_EQ(expected_value, result->Int32Value());
+ CHECK_EQ(expected_value, result->Int32Value(context).FromJust());
CheckElementValue(isolate, expected_value, jsobj, 5);
result = CompileRun("for (var i = 0; i < 8; i++) {"
@@ -13937,7 +15403,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" ext_array[i] = -Infinity;"
"}"
"ext_array[5];");
- CHECK_EQ(0, result->Int32Value());
+ CHECK_EQ(0, result->Int32Value(context).FromJust());
CheckElementValue(isolate, 0, jsobj, 5);
// Check truncation behavior of integral arrays.
@@ -13992,7 +15458,7 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" sum=ee_op_test_complex_func(sum);"
"}"
"sum;");
- CHECK_EQ(16000000, result->Int32Value());
+ CHECK_EQ(16000000, result->Int32Value(context).FromJust());
// Test count operations
result = CompileRun("function ee_op_test_count_func(sum) {"
@@ -14007,34 +15473,43 @@ static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
" sum=ee_op_test_count_func(sum);"
"}"
"sum;");
- CHECK_EQ(16000000, result->Int32Value());
+ CHECK_EQ(16000000, result->Int32Value(context).FromJust());
result = CompileRun("ext_array[3] = 33;"
"delete ext_array[3];"
"ext_array[3];");
- CHECK_EQ(33, result->Int32Value());
+ CHECK_EQ(33, result->Int32Value(context).FromJust());
result = CompileRun("ext_array[0] = 10; ext_array[1] = 11;"
"ext_array[2] = 12; ext_array[3] = 13;"
"ext_array.__defineGetter__('2',"
"function() { return 120; });"
"ext_array[2];");
- CHECK_EQ(12, result->Int32Value());
+ CHECK_EQ(12, result->Int32Value(context).FromJust());
result = CompileRun("var js_array = new Array(40);"
"js_array[0] = 77;"
"js_array;");
- CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
+ CHECK_EQ(77, v8::Object::Cast(*result)
+ ->Get(v8_str("0"))
+ ->Int32Value(context)
+ .FromJust());
result = CompileRun("ext_array[1] = 23;"
"ext_array.__proto__ = [];"
"js_array.__proto__ = ext_array;"
"js_array.concat(ext_array);");
- CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
- CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value());
+ CHECK_EQ(77, v8::Object::Cast(*result)
+ ->Get(v8_str("0"))
+ ->Int32Value(context)
+ .FromJust());
+ CHECK_EQ(23, v8::Object::Cast(*result)
+ ->Get(v8_str("1"))
+ ->Int32Value(context)
+ .FromJust());
result = CompileRun("ext_array[1] = 23;");
- CHECK_EQ(23, result->Int32Value());
+ CHECK_EQ(23, result->Int32Value(context).FromJust());
}
@@ -14065,7 +15540,7 @@ static void FixedTypedArrayTestHelper(i::ExternalArrayType array_type,
CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)),
static_cast<int64_t>(fixed_array->get_scalar(i)));
}
- v8::Handle<v8::Object> obj = v8::Utils::ToLocal(jsobj);
+ v8::Local<v8::Object> obj = v8::Utils::ToLocal(jsobj);
ObjectWithExternalArrayTestHelper<FixedTypedArrayClass, ElementType>(
context.local(), obj, kElementCount, array_type,
@@ -14378,18 +15853,18 @@ THREADED_TEST(SharedDataView) {
}
-#define IS_ARRAY_BUFFER_VIEW_TEST(View) \
- THREADED_TEST(Is##View) { \
- LocalContext env; \
- v8::Isolate* isolate = env->GetIsolate(); \
- v8::HandleScope handle_scope(isolate); \
- \
- Handle<Value> result = CompileRun( \
- "var ab = new ArrayBuffer(128);" \
- "new " #View "(ab)"); \
- CHECK(result->IsArrayBufferView()); \
- CHECK(result->Is##View()); \
- CheckInternalFieldsAreZero<v8::ArrayBufferView>(result.As<v8::View>()); \
+#define IS_ARRAY_BUFFER_VIEW_TEST(View) \
+ THREADED_TEST(Is##View) { \
+ LocalContext env; \
+ v8::Isolate* isolate = env->GetIsolate(); \
+ v8::HandleScope handle_scope(isolate); \
+ \
+ Local<Value> result = CompileRun( \
+ "var ab = new ArrayBuffer(128);" \
+ "new " #View "(ab)"); \
+ CHECK(result->IsArrayBufferView()); \
+ CHECK(result->Is##View()); \
+ CheckInternalFieldsAreZero<v8::ArrayBufferView>(result.As<v8::View>()); \
}
IS_ARRAY_BUFFER_VIEW_TEST(Uint8Array)
@@ -14411,20 +15886,30 @@ THREADED_TEST(ScriptContextDependence) {
LocalContext c1;
v8::HandleScope scope(c1->GetIsolate());
const char *source = "foo";
- v8::Handle<v8::Script> dep = v8_compile(source);
- v8::ScriptCompiler::Source script_source(v8::String::NewFromUtf8(
- c1->GetIsolate(), source));
- v8::Handle<v8::UnboundScript> indep =
+ v8::Local<v8::Script> dep = v8_compile(source);
+ v8::ScriptCompiler::Source script_source(
+ v8::String::NewFromUtf8(c1->GetIsolate(), source,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
+ v8::Local<v8::UnboundScript> indep =
v8::ScriptCompiler::CompileUnbound(c1->GetIsolate(), &script_source);
- c1->Global()->Set(v8::String::NewFromUtf8(c1->GetIsolate(), "foo"),
+ c1->Global()->Set(v8::String::NewFromUtf8(c1->GetIsolate(), "foo",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked(),
v8::Integer::New(c1->GetIsolate(), 100));
- CHECK_EQ(dep->Run()->Int32Value(), 100);
- CHECK_EQ(indep->BindToCurrentContext()->Run()->Int32Value(), 100);
+ CHECK_EQ(dep->Run()->Int32Value(c1.local()).FromJust(), 100);
+ CHECK_EQ(
+ indep->BindToCurrentContext()->Run()->Int32Value(c1.local()).FromJust(),
+ 100);
LocalContext c2;
- c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo"),
+ c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked(),
v8::Integer::New(c2->GetIsolate(), 101));
- CHECK_EQ(dep->Run()->Int32Value(), 100);
- CHECK_EQ(indep->BindToCurrentContext()->Run()->Int32Value(), 101);
+ CHECK_EQ(dep->Run()->Int32Value(c2.local()).FromJust(), 100);
+ CHECK_EQ(
+ indep->BindToCurrentContext()->Run()->Int32Value(c2.local()).FromJust(),
+ 101);
}
@@ -14433,10 +15918,8 @@ THREADED_TEST(StackTrace) {
v8::HandleScope scope(context->GetIsolate());
v8::TryCatch try_catch(context->GetIsolate());
const char *source = "function foo() { FAIL.FAIL; }; foo();";
- v8::Handle<v8::String> src =
- v8::String::NewFromUtf8(context->GetIsolate(), source);
- v8::Handle<v8::String> origin =
- v8::String::NewFromUtf8(context->GetIsolate(), "stack-trace-test");
+ v8::Local<v8::String> src = v8_str(source);
+ v8::Local<v8::String> origin = v8_str("stack-trace-test");
v8::ScriptCompiler::Source script_source(src, v8::ScriptOrigin(origin));
v8::ScriptCompiler::CompileUnbound(context->GetIsolate(), &script_source)
->BindToCurrentContext()
@@ -14449,9 +15932,9 @@ THREADED_TEST(StackTrace) {
// Checks that a StackFrame has certain expected values.
void checkStackFrame(const char* expected_script_name,
- const char* expected_func_name, int expected_line_number,
- int expected_column, bool is_eval, bool is_constructor,
- v8::Handle<v8::StackFrame> frame) {
+ const char* expected_func_name, int expected_line_number,
+ int expected_column, bool is_eval, bool is_constructor,
+ v8::Local<v8::StackFrame> frame) {
v8::HandleScope scope(CcTest::isolate());
v8::String::Utf8Value func_name(frame->GetFunctionName());
v8::String::Utf8Value script_name(frame->GetScriptName());
@@ -14482,9 +15965,10 @@ void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) {
DCHECK(args.Length() == 1);
- int testGroup = args[0]->Int32Value();
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
+ int testGroup = args[0]->Int32Value(context).FromJust();
if (testGroup == kOverviewTest) {
- v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
+ v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 10, v8::StackTrace::kOverview);
CHECK_EQ(4, stackTrace->GetFrameCount());
checkStackFrame(origin, "bar", 2, 10, false, false,
@@ -14498,7 +15982,7 @@ void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(stackTrace->AsArray()->IsArray());
} else if (testGroup == kDetailedTest) {
- v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
+ v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 10, v8::StackTrace::kDetailed);
CHECK_EQ(4, stackTrace->GetFrameCount());
checkStackFrame(origin, "bat", 4, 22, false, false,
@@ -14551,8 +16035,7 @@ void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(CaptureStackTrace) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::String> origin =
- v8::String::NewFromUtf8(isolate, "capture-stack-trace-test");
+ v8::Local<v8::String> origin = v8_str("capture-stack-trace-test");
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("AnalyzeStackInNativeCode"),
v8::FunctionTemplate::New(isolate, AnalyzeStackInNativeCode));
@@ -14569,11 +16052,10 @@ TEST(CaptureStackTrace) {
" bar();\n"
"}\n"
"var x;eval('new foo();');";
- v8::Handle<v8::String> overview_src =
- v8::String::NewFromUtf8(isolate, overview_source);
+ v8::Local<v8::String> overview_src = v8_str(overview_source);
v8::ScriptCompiler::Source script_source(overview_src,
v8::ScriptOrigin(origin));
- v8::Handle<Value> overview_result(
+ v8::Local<Value> overview_result(
v8::ScriptCompiler::CompileUnbound(isolate, &script_source)
->BindToCurrentContext()
->Run());
@@ -14589,16 +16071,15 @@ TEST(CaptureStackTrace) {
" bat();\n"
"}\n"
"eval('new baz();');";
- v8::Handle<v8::String> detailed_src =
- v8::String::NewFromUtf8(isolate, detailed_source);
+ v8::Local<v8::String> detailed_src = v8_str(detailed_source);
// Make the script using a non-zero line and column offset.
- v8::Handle<v8::Integer> line_offset = v8::Integer::New(isolate, 3);
- v8::Handle<v8::Integer> column_offset = v8::Integer::New(isolate, 5);
+ v8::Local<v8::Integer> line_offset = v8::Integer::New(isolate, 3);
+ v8::Local<v8::Integer> column_offset = v8::Integer::New(isolate, 5);
v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset);
v8::ScriptCompiler::Source script_source2(detailed_src, detailed_origin);
- v8::Handle<v8::UnboundScript> detailed_script(
+ v8::Local<v8::UnboundScript> detailed_script(
v8::ScriptCompiler::CompileUnbound(isolate, &script_source2));
- v8::Handle<Value> detailed_result(
+ v8::Local<Value> detailed_result(
detailed_script->BindToCurrentContext()->Run());
CHECK(!detailed_result.IsEmpty());
CHECK(detailed_result->IsObject());
@@ -14633,10 +16114,9 @@ TEST(CaptureStackTrace) {
static void StackTraceForUncaughtExceptionListener(
- v8::Handle<v8::Message> message,
- v8::Handle<Value>) {
+ v8::Local<v8::Message> message, v8::Local<Value>) {
report_count++;
- v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
+ v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
CHECK_EQ(2, stack_trace->GetFrameCount());
checkStackFrame("origin", "foo", 2, 3, false, false,
stack_trace->GetFrame(0));
@@ -14721,9 +16201,9 @@ TEST(CaptureStackTraceForUncaughtExceptionAndSetters) {
}
-static void StackTraceFunctionNameListener(v8::Handle<v8::Message> message,
- v8::Handle<Value>) {
- v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
+static void StackTraceFunctionNameListener(v8::Local<v8::Message> message,
+ v8::Local<Value>) {
+ v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
CHECK_EQ(5, stack_trace->GetFrameCount());
checkStackFrame("origin", "foo:0", 4, 7, false, false,
stack_trace->GetFrame(0));
@@ -14769,10 +16249,10 @@ TEST(GetStackTraceContainsFunctionsWithFunctionName) {
}
-static void RethrowStackTraceHandler(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
+static void RethrowStackTraceHandler(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
// Use the frame where JavaScript is called from.
- v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
+ v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
CHECK(!stack_trace.IsEmpty());
int frame_count = stack_trace->GetFrameCount();
CHECK_EQ(3, frame_count);
@@ -14813,9 +16293,9 @@ TEST(RethrowStackTrace) {
}
-static void RethrowPrimitiveStackTraceHandler(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
- v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
+static void RethrowPrimitiveStackTraceHandler(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
+ v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
CHECK(!stack_trace.IsEmpty());
int frame_count = stack_trace->GetFrameCount();
CHECK_EQ(2, frame_count);
@@ -14849,10 +16329,10 @@ TEST(RethrowPrimitiveStackTrace) {
}
-static void RethrowExistingStackTraceHandler(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
+static void RethrowExistingStackTraceHandler(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
// Use the frame where JavaScript is called from.
- v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
+ v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
CHECK(!stack_trace.IsEmpty());
CHECK_EQ(1, stack_trace->GetFrameCount());
CHECK_EQ(1, stack_trace->GetFrame(0)->GetLineNumber());
@@ -14875,10 +16355,10 @@ TEST(RethrowExistingStackTrace) {
}
-static void RethrowBogusErrorStackTraceHandler(v8::Handle<v8::Message> message,
- v8::Handle<v8::Value> data) {
+static void RethrowBogusErrorStackTraceHandler(v8::Local<v8::Message> message,
+ v8::Local<v8::Value> data) {
// Use the frame where JavaScript is called from.
- v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
+ v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
CHECK(!stack_trace.IsEmpty());
CHECK_EQ(1, stack_trace->GetFrameCount());
CHECK_EQ(2, stack_trace->GetFrame(0)->GetLineNumber());
@@ -14914,9 +16394,9 @@ void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) {
promise_reject_counter++;
CcTest::global()->Set(v8_str("rejected"), reject_message.GetPromise());
CcTest::global()->Set(v8_str("value"), reject_message.GetValue());
- v8::Handle<v8::Message> message = v8::Exception::CreateMessage(
+ v8::Local<v8::Message> message = v8::Exception::CreateMessage(
CcTest::isolate(), reject_message.GetValue());
- v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
+ v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
promise_reject_msg_line_number = message->GetLineNumber();
promise_reject_msg_column_number = message->GetStartColumn() + 1;
@@ -14940,12 +16420,12 @@ void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) {
}
-v8::Handle<v8::Promise> GetPromise(const char* name) {
- return v8::Handle<v8::Promise>::Cast(CcTest::global()->Get(v8_str(name)));
+v8::Local<v8::Promise> GetPromise(const char* name) {
+ return v8::Local<v8::Promise>::Cast(CcTest::global()->Get(v8_str(name)));
}
-v8::Handle<v8::Value> RejectValue() {
+v8::Local<v8::Value> RejectValue() {
return CcTest::global()->Get(v8_str("value"));
}
@@ -15284,12 +16764,12 @@ TEST(PromiseRejectCallback) {
void AnalyzeStackOfEvalWithSourceURL(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::HandleScope scope(args.GetIsolate());
- v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
+ v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 10, v8::StackTrace::kDetailed);
CHECK_EQ(5, stackTrace->GetFrameCount());
- v8::Handle<v8::String> url = v8_str("eval_url");
+ v8::Local<v8::String> url = v8_str("eval_url");
for (int i = 0; i < 3; i++) {
- v8::Handle<v8::String> name =
+ v8::Local<v8::String> name =
stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
CHECK(!name.IsEmpty());
CHECK(url->Equals(name));
@@ -15332,7 +16812,7 @@ static int scriptIdInStack[2];
void AnalyzeScriptIdInStack(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::HandleScope scope(args.GetIsolate());
- v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
+ v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 10, v8::StackTrace::kScriptId);
CHECK_EQ(2, stackTrace->GetFrameCount());
for (int i = 0; i < 2; i++) {
@@ -15349,12 +16829,11 @@ TEST(ScriptIdInStackTrace) {
v8::FunctionTemplate::New(isolate, AnalyzeScriptIdInStack));
LocalContext context(0, templ);
- v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8(
- isolate,
- "function foo() {\n"
- " AnalyzeScriptIdInStack();"
- "}\n"
- "foo();\n");
+ v8::Local<v8::String> scriptSource = v8_str(
+ "function foo() {\n"
+ " AnalyzeScriptIdInStack();"
+ "}\n"
+ "foo();\n");
v8::Local<v8::Script> script = CompileWithOrigin(scriptSource, "test");
script->Run();
for (int i = 0; i < 2; i++) {
@@ -15367,12 +16846,12 @@ TEST(ScriptIdInStackTrace) {
void AnalyzeStackOfInlineScriptWithSourceURL(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::HandleScope scope(args.GetIsolate());
- v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
+ v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 10, v8::StackTrace::kDetailed);
CHECK_EQ(4, stackTrace->GetFrameCount());
- v8::Handle<v8::String> url = v8_str("source_url");
+ v8::Local<v8::String> url = v8_str("source_url");
for (int i = 0; i < 3; i++) {
- v8::Handle<v8::String> name =
+ v8::Local<v8::String> name =
stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
CHECK(!name.IsEmpty());
CHECK(url->Equals(name));
@@ -15413,12 +16892,12 @@ TEST(InlineScriptWithSourceURLInStackTrace) {
void AnalyzeStackOfDynamicScriptWithSourceURL(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::HandleScope scope(args.GetIsolate());
- v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
+ v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 10, v8::StackTrace::kDetailed);
CHECK_EQ(4, stackTrace->GetFrameCount());
- v8::Handle<v8::String> url = v8_str("source_url");
+ v8::Local<v8::String> url = v8_str("source_url");
for (int i = 0; i < 3; i++) {
- v8::Handle<v8::String> name =
+ v8::Local<v8::String> name =
stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
CHECK(!name.IsEmpty());
CHECK(url->Equals(name));
@@ -15497,8 +16976,7 @@ TEST(EvalWithSourceURLInMessageScriptResourceNameOrSourceURL) {
CHECK(try_catch.HasCaught());
Local<v8::Message> message = try_catch.Message();
- Handle<Value> sourceURL =
- message->GetScriptOrigin().ResourceName();
+ Local<Value> sourceURL = message->GetScriptOrigin().ResourceName();
CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url"));
}
@@ -15521,8 +16999,7 @@ TEST(RecursionWithSourceURLInMessageScriptResourceNameOrSourceURL) {
CHECK(try_catch.HasCaught());
Local<v8::Message> message = try_catch.Message();
- Handle<Value> sourceURL =
- message->GetScriptOrigin().ResourceName();
+ Local<Value> sourceURL = message->GetScriptOrigin().ResourceName();
CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url"));
}
@@ -15612,8 +17089,10 @@ TEST(SetStackLimit) {
v8::HandleScope scope(env->GetIsolate());
Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(env->GetIsolate(), GetStackLimitCallback);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("get_stack_limit"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("get_stack_limit"), fun)
+ .FromJust());
CompileRun("get_stack_limit();");
CHECK(stack_limit == set_limit);
@@ -15634,8 +17113,10 @@ TEST(SetStackLimitInThread) {
LocalContext env;
Local<v8::FunctionTemplate> fun_templ =
v8::FunctionTemplate::New(CcTest::isolate(), GetStackLimitCallback);
- Local<Function> fun = fun_templ->GetFunction();
- env->Global()->Set(v8_str("get_stack_limit"), fun);
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("get_stack_limit"), fun)
+ .FromJust());
CompileRun("get_stack_limit();");
CHECK(stack_limit == set_limit);
@@ -15668,7 +17149,7 @@ class VisitorImpl : public v8::ExternalResourceVisitor {
}
}
virtual ~VisitorImpl() {}
- virtual void VisitExternalString(v8::Handle<v8::String> string) {
+ virtual void VisitExternalString(v8::Local<v8::String> string) {
if (!string->IsExternal()) {
CHECK(string->IsExternalOneByte());
return;
@@ -15755,8 +17236,10 @@ TEST(VisitExternalStrings) {
// Externalized symbol.
resource[2] = new TestResource(two_byte_string, NULL, false);
- v8::Local<v8::String> string2 = v8::String::NewFromUtf8(
- env->GetIsolate(), string, v8::String::kInternalizedString);
+ v8::Local<v8::String> string2 =
+ v8::String::NewFromUtf8(env->GetIsolate(), string,
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
CHECK(string2->MakeExternal(resource[2]));
// Symbolized External.
@@ -15932,7 +17415,7 @@ THREADED_TEST(QuietSignalingNaNs) {
double test_value = test_values[i];
// Check that Number::New preserves non-NaNs and quiets SNaNs.
- v8::Handle<v8::Value> number = v8::Number::New(isolate, test_value);
+ v8::Local<v8::Value> number = v8::Number::New(isolate, test_value);
double stored_number = number->NumberValue();
if (!std::isnan(test_value)) {
CHECK_EQ(test_value, stored_number);
@@ -15952,8 +17435,7 @@ THREADED_TEST(QuietSignalingNaNs) {
// Check that Date::New preserves non-NaNs in the date range and
// quiets SNaNs.
- v8::Handle<v8::Value> date =
- v8::Date::New(isolate, test_value);
+ v8::Local<v8::Value> date = v8::Date::New(isolate, test_value);
double expected_stored_date = DoubleToDateTime(test_value);
double stored_date = date->NumberValue();
if (!std::isnan(expected_stored_date)) {
@@ -15979,7 +17461,7 @@ static void SpaghettiIncident(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::HandleScope scope(args.GetIsolate());
v8::TryCatch tc(args.GetIsolate());
- v8::Handle<v8::String> str(args[0]->ToString(args.GetIsolate()));
+ v8::Local<v8::String> str(args[0]->ToString(args.GetIsolate()));
USE(str);
if (tc.HasCaught())
tc.ReThrow();
@@ -15992,9 +17474,10 @@ THREADED_TEST(SpaghettiStackReThrow) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
LocalContext context;
- context->Global()->Set(
- v8::String::NewFromUtf8(isolate, "s"),
- v8::FunctionTemplate::New(isolate, SpaghettiIncident)->GetFunction());
+ context->Global()->Set(v8_str("s"),
+ v8::FunctionTemplate::New(isolate, SpaghettiIncident)
+ ->GetFunction(context.local())
+ .ToLocalChecked());
v8::TryCatch try_catch(isolate);
CompileRun(
"var i = 0;"
@@ -16035,7 +17518,7 @@ TEST(Regress528) {
v8::Local<Context> context = Context::New(isolate);
context->Enter();
- Local<v8::String> obj = v8::String::NewFromUtf8(isolate, "");
+ Local<v8::String> obj = v8_str("");
context->SetEmbedderData(0, obj);
CompileRun(source_simple);
context->Exit();
@@ -16084,7 +17567,7 @@ TEST(Regress528) {
v8::TryCatch try_catch(isolate);
CompileRun(source_exception);
CHECK(try_catch.HasCaught());
- v8::Handle<v8::Message> message = try_catch.Message();
+ v8::Local<v8::Message> message = try_catch.Message();
CHECK(!message.IsEmpty());
CHECK_EQ(1, message->GetLineNumber());
context->Exit();
@@ -16108,24 +17591,23 @@ THREADED_TEST(ScriptOrigin) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::ScriptOrigin origin = v8::ScriptOrigin(
- v8::String::NewFromUtf8(env->GetIsolate(), "test"),
- v8::Integer::New(env->GetIsolate(), 1),
+ v8_str("test"), v8::Integer::New(env->GetIsolate(), 1),
v8::Integer::New(env->GetIsolate(), 1), v8::True(env->GetIsolate()),
- v8::Handle<v8::Integer>(), v8::True(env->GetIsolate()),
- v8::String::NewFromUtf8(env->GetIsolate(), "http://sourceMapUrl"),
- v8::True(env->GetIsolate()));
- v8::Handle<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(), "function f() {}\n\nfunction g() {}");
+ v8::Local<v8::Integer>(), v8::True(env->GetIsolate()),
+ v8_str("http://sourceMapUrl"), v8::True(env->GetIsolate()));
+ v8::Local<v8::String> script = v8_str("function f() {}\n\nfunction g() {}");
v8::Script::Compile(script, &origin)->Run();
- 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")));
+ v8::Local<v8::Function> f =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("f")));
+ v8::Local<v8::Function> g =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("g")));
v8::ScriptOrigin script_origin_f = f->GetScriptOrigin();
CHECK_EQ(0, strcmp("test",
*v8::String::Utf8Value(script_origin_f.ResourceName())));
- CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value());
+ CHECK_EQ(
+ 1,
+ script_origin_f.ResourceLineOffset()->Int32Value(env.local()).FromJust());
CHECK(script_origin_f.Options().IsSharedCrossOrigin());
CHECK(script_origin_f.Options().IsEmbedderDebugScript());
CHECK(script_origin_f.Options().IsOpaque());
@@ -16137,7 +17619,9 @@ THREADED_TEST(ScriptOrigin) {
v8::ScriptOrigin script_origin_g = g->GetScriptOrigin();
CHECK_EQ(0, strcmp("test",
*v8::String::Utf8Value(script_origin_g.ResourceName())));
- CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value());
+ CHECK_EQ(
+ 1,
+ script_origin_g.ResourceLineOffset()->Int32Value(env.local()).FromJust());
CHECK(script_origin_g.Options().IsSharedCrossOrigin());
CHECK(script_origin_g.Options().IsEmbedderDebugScript());
CHECK(script_origin_g.Options().IsOpaque());
@@ -16149,14 +17633,12 @@ THREADED_TEST(ScriptOrigin) {
THREADED_TEST(FunctionGetInferredName) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Handle<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
- "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;");
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
+ v8::Local<v8::String> script =
+ v8_str("var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;");
v8::Script::Compile(script, &origin)->Run();
- v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ v8::Local<v8::Function> f =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("f")));
CHECK_EQ(0,
strcmp("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName())));
}
@@ -16270,26 +17752,23 @@ THREADED_TEST(FunctionGetDisplayName) {
"var g = function() {"
" arguments.callee.displayName = 'set_in_runtime';"
"}; g();";
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), code), &origin)
- ->Run();
- v8::Local<v8::Value> error =
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "error"));
- v8::Local<v8::Function> a = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "a")));
- v8::Local<v8::Function> b = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "b")));
- v8::Local<v8::Function> c = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "c")));
- v8::Local<v8::Function> d = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "d")));
- v8::Local<v8::Function> e = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "e")));
- 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")));
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
+ v8::Script::Compile(v8_str(code), &origin)->Run();
+ v8::Local<v8::Value> error = env->Global()->Get(v8_str("error"));
+ v8::Local<v8::Function> a =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("a")));
+ v8::Local<v8::Function> b =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("b")));
+ v8::Local<v8::Function> c =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("c")));
+ v8::Local<v8::Function> d =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("d")));
+ v8::Local<v8::Function> e =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("e")));
+ v8::Local<v8::Function> f =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("f")));
+ v8::Local<v8::Function> g =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("g")));
CHECK_EQ(false, error->BooleanValue());
CHECK_EQ(0, strcmp("display_a", *v8::String::Utf8Value(a->GetDisplayName())));
CHECK_EQ(0, strcmp("display_b", *v8::String::Utf8Value(b->GetDisplayName())));
@@ -16305,15 +17784,13 @@ THREADED_TEST(FunctionGetDisplayName) {
THREADED_TEST(ScriptLineNumber) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
- v8::Handle<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(), "function f() {}\n\nfunction g() {}");
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
+ v8::Local<v8::String> script = v8_str("function f() {}\n\nfunction g() {}");
v8::Script::Compile(script, &origin)->Run();
- 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")));
+ v8::Local<v8::Function> f =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("f")));
+ v8::Local<v8::Function> g =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("g")));
CHECK_EQ(0, f->GetScriptLineNumber());
CHECK_EQ(2, g->GetScriptLineNumber());
}
@@ -16324,16 +17801,15 @@ THREADED_TEST(ScriptColumnNumber) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "test"),
- v8::Integer::New(isolate, 3),
+ v8::ScriptOrigin(v8_str("test"), v8::Integer::New(isolate, 3),
v8::Integer::New(isolate, 2));
- v8::Handle<v8::String> script = v8::String::NewFromUtf8(
- isolate, "function foo() {}\n\n function bar() {}");
+ v8::Local<v8::String> script =
+ v8_str("function foo() {}\n\n function bar() {}");
v8::Script::Compile(script, &origin)->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(isolate, "foo")));
- v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(isolate, "bar")));
+ v8::Local<v8::Function> foo =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("foo")));
+ v8::Local<v8::Function> bar =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("bar")));
CHECK_EQ(14, foo->GetScriptColumnNumber());
CHECK_EQ(17, bar->GetScriptColumnNumber());
}
@@ -16362,17 +17838,16 @@ THREADED_TEST(FunctionGetScriptId) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "test"),
- v8::Integer::New(isolate, 3),
+ v8::ScriptOrigin(v8_str("test"), v8::Integer::New(isolate, 3),
v8::Integer::New(isolate, 2));
- v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8(
- isolate, "function foo() {}\n\n function bar() {}");
+ v8::Local<v8::String> scriptSource =
+ v8_str("function foo() {}\n\n function bar() {}");
v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin));
script->Run();
- v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(isolate, "foo")));
- v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(isolate, "bar")));
+ v8::Local<v8::Function> foo =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("foo")));
+ v8::Local<v8::Function> bar =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("bar")));
CHECK_EQ(script->GetUnboundScript()->GetId(), foo->ScriptId());
CHECK_EQ(script->GetUnboundScript()->GetId(), bar->ScriptId());
}
@@ -16381,20 +17856,18 @@ THREADED_TEST(FunctionGetScriptId) {
THREADED_TEST(FunctionGetBoundFunction) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::NewFromUtf8(
- env->GetIsolate(), "test"));
- v8::Handle<v8::String> script = v8::String::NewFromUtf8(
- env->GetIsolate(),
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
+ v8::Local<v8::String> script = v8_str(
"var a = new Object();\n"
"a.x = 1;\n"
"function f () { return this.x };\n"
"var g = f.bind(a);\n"
"var b = g();");
v8::Script::Compile(script, &origin)->Run();
- 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")));
+ v8::Local<v8::Function> f =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("f")));
+ v8::Local<v8::Function> g =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("g")));
CHECK(g->GetBoundFunction()->IsFunction());
Local<v8::Function> original_function = Local<v8::Function>::Cast(
g->GetBoundFunction());
@@ -16450,7 +17923,10 @@ TEST(SetterOnConstructorPrototype) {
templ->SetAccessor(v8_str("x"), GetterWhichReturns42,
SetterWhichSetsYOnThisTo23);
LocalContext context;
- context->Global()->Set(v8_str("P"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("P"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun("function C1() {"
" this.x = 23;"
"};"
@@ -16464,16 +17940,16 @@ TEST(SetterOnConstructorPrototype) {
v8::Local<v8::Script> script;
script = v8_compile("new C1();");
for (int i = 0; i < 10; i++) {
- v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
- CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value());
+ v8::Local<v8::Object> c1 = v8::Local<v8::Object>::Cast(script->Run());
+ CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value(context.local()).FromJust());
}
-script = v8_compile("new C2();");
+ script = v8_compile("new C2();");
for (int i = 0; i < 10; i++) {
- v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run());
- CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(23, c2->Get(v8_str("y"))->Int32Value());
+ v8::Local<v8::Object> c2 = v8::Local<v8::Object>::Cast(script->Run());
+ CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(23, c2->Get(v8_str("y"))->Int32Value(context.local()).FromJust());
}
}
@@ -16501,7 +17977,10 @@ THREADED_TEST(InterceptorOnConstructorPrototype) {
NamedPropertyGetterWhichReturns42,
NamedPropertySetterWhichSetsYOnThisTo23));
LocalContext context;
- context->Global()->Set(v8_str("P"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("P"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun("function C1() {"
" this.x = 23;"
"};"
@@ -16515,16 +17994,16 @@ THREADED_TEST(InterceptorOnConstructorPrototype) {
v8::Local<v8::Script> script;
script = v8_compile("new C1();");
for (int i = 0; i < 10; i++) {
- v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
- CHECK_EQ(23, c1->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(42, c1->Get(v8_str("y"))->Int32Value());
+ v8::Local<v8::Object> c1 = v8::Local<v8::Object>::Cast(script->Run());
+ CHECK_EQ(23, c1->Get(v8_str("x"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(42, c1->Get(v8_str("y"))->Int32Value(context.local()).FromJust());
}
script = v8_compile("new C2();");
for (int i = 0; i < 10; i++) {
- v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run());
- CHECK_EQ(23, c2->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(42, c2->Get(v8_str("y"))->Int32Value());
+ v8::Local<v8::Object> c2 = v8::Local<v8::Object>::Cast(script->Run());
+ CHECK_EQ(23, c2->Get(v8_str("x"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(42, c2->Get(v8_str("y"))->Int32Value(context.local()).FromJust());
}
}
@@ -16543,7 +18022,9 @@ TEST(Regress618) {
// Use a simple object as prototype.
v8::Local<v8::Object> prototype = v8::Object::New(isolate);
prototype->Set(v8_str("y"), v8_num(42));
- context->Global()->Set(v8_str("P"), prototype);
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("P"), prototype)
+ .FromJust());
// This compile will add the code to the compilation cache.
CompileRun(source);
@@ -16552,25 +18033,28 @@ TEST(Regress618) {
// Allow enough iterations for the inobject slack tracking logic
// to finalize instance size and install the fast construct stub.
for (int i = 0; i < 256; i++) {
- v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
- CHECK_EQ(23, c1->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(42, c1->Get(v8_str("y"))->Int32Value());
+ v8::Local<v8::Object> c1 = v8::Local<v8::Object>::Cast(script->Run());
+ CHECK_EQ(23, c1->Get(v8_str("x"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(42, c1->Get(v8_str("y"))->Int32Value(context.local()).FromJust());
}
// Use an API object with accessors as prototype.
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetAccessor(v8_str("x"), GetterWhichReturns42,
SetterWhichSetsYOnThisTo23);
- context->Global()->Set(v8_str("P"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("P"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
// This compile will get the code from the compilation cache.
CompileRun(source);
script = v8_compile("new C1();");
for (int i = 0; i < 10; i++) {
- v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
- CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value());
+ v8::Local<v8::Object> c1 = v8::Local<v8::Object>::Cast(script->Run());
+ CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value(context.local()).FromJust());
}
}
@@ -16814,17 +18298,17 @@ THREADED_TEST(TwoByteStringInOneByteCons) {
// Atom RegExp.
Local<Value> reresult = CompileRun("str2.match(/abel/g).length;");
- CHECK_EQ(6, reresult->Int32Value());
+ CHECK_EQ(6, reresult->Int32Value(context.local()).FromJust());
// Nonatom RegExp.
reresult = CompileRun("str2.match(/abe./g).length;");
- CHECK_EQ(6, reresult->Int32Value());
+ CHECK_EQ(6, reresult->Int32Value(context.local()).FromJust());
reresult = CompileRun("str2.search(/bel/g);");
- CHECK_EQ(1, reresult->Int32Value());
+ CHECK_EQ(1, reresult->Int32Value(context.local()).FromJust());
reresult = CompileRun("str2.search(/be./g);");
- CHECK_EQ(1, reresult->Int32Value());
+ CHECK_EQ(1, reresult->Int32Value(context.local()).FromJust());
ExpectTrue("/bel/g.test(str2);");
@@ -16847,7 +18331,8 @@ THREADED_TEST(TwoByteStringInOneByteCons) {
ExpectObject("str2.lastIndexOf('dab');", lastindexof);
reresult = CompileRun("str2.charCodeAt(2);");
- CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value());
+ CHECK_EQ(static_cast<int32_t>('e'),
+ reresult->Int32Value(context.local()).FromJust());
}
@@ -16869,27 +18354,25 @@ TEST(ContainsOnlyOneByte) {
}
string_contents[length-1] = 0;
// Simple case.
- Handle<String> string =
- String::NewExternal(isolate,
- new TestResource(string_contents, NULL, false));
+ Local<String> string = String::NewExternal(
+ isolate, new TestResource(string_contents, NULL, false));
CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte());
// Counter example.
string = String::NewFromTwoByte(isolate, string_contents);
CHECK(string->IsOneByte() && string->ContainsOnlyOneByte());
// Test left right and balanced cons strings.
- Handle<String> base = String::NewFromUtf8(isolate, "a");
- Handle<String> left = base;
- Handle<String> right = base;
+ Local<String> base = v8_str("a");
+ Local<String> left = base;
+ Local<String> right = base;
for (int i = 0; i < 1000; i++) {
left = String::Concat(base, left);
right = String::Concat(right, base);
}
- Handle<String> balanced = String::Concat(left, base);
+ Local<String> balanced = String::Concat(left, base);
balanced = String::Concat(balanced, right);
- Handle<String> cons_strings[] = {left, balanced, right};
- Handle<String> two_byte =
- String::NewExternal(isolate,
- new TestResource(string_contents, NULL, false));
+ Local<String> cons_strings[] = {left, balanced, right};
+ Local<String> two_byte = String::NewExternal(
+ isolate, new TestResource(string_contents, NULL, false));
USE(two_byte); USE(cons_strings);
for (size_t i = 0; i < arraysize(cons_strings); i++) {
// Base assumptions.
@@ -16945,19 +18428,23 @@ TEST(GCInFailedAccessCheckCallback) {
// Create an ObjectTemplate for global objects and install access
// check callbacks that will block access.
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
global_template->SetAccessCheckCallback(AccessAlwaysBlocked);
// Create a context and set an x property on it's global object.
LocalContext context0(NULL, global_template);
- context0->Global()->Set(v8_str("x"), v8_num(42));
- v8::Handle<v8::Object> global0 = context0->Global();
+ CHECK(context0->Global()
+ ->Set(context0.local(), v8_str("x"), v8_num(42))
+ .FromJust());
+ v8::Local<v8::Object> global0 = context0->Global();
// Create a context with a different security token so that the
// failed access check callback will be called on each access.
LocalContext context1(NULL, global_template);
- context1->Global()->Set(v8_str("other"), global0);
+ CHECK(context1->Global()
+ ->Set(context1.local(), v8_str("other"), global0)
+ .FromJust());
v8::TryCatch try_catch(isolate);
@@ -17550,11 +19037,10 @@ class Visitor42 : public v8::PersistentHandleVisitor {
CHECK_EQ(42, value->WrapperClassId());
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::Value> handle = v8::Local<v8::Value>::New(isolate, *value);
- v8::Handle<v8::Value> object =
- v8::Local<v8::Object>::New(isolate, *object_);
+ v8::Local<v8::Value> handle = v8::Local<v8::Value>::New(isolate, *value);
+ v8::Local<v8::Value> object = v8::Local<v8::Object>::New(isolate, *object_);
CHECK(handle->IsObject());
- CHECK(Handle<Object>::Cast(handle)->Equals(object));
+ CHECK(Local<Object>::Cast(handle)->Equals(object));
++counter_;
}
@@ -17624,7 +19110,7 @@ TEST(RegExp) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone);
+ v8::Local<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone);
CHECK(re->IsRegExp());
CHECK(re->GetSource()->Equals(v8_str("foo")));
CHECK_EQ(v8::RegExp::kNone, re->GetFlags());
@@ -17681,19 +19167,21 @@ TEST(RegExp) {
CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline,
static_cast<int>(re->GetFlags()));
- context->Global()->Set(v8_str("re"), re);
+ CHECK(context->Global()->Set(context.local(), v8_str("re"), re).FromJust());
ExpectTrue("re.test('FoobarbaZ')");
// RegExps are objects on which you can set properties.
re->Set(v8_str("property"), v8::Integer::New(context->GetIsolate(), 32));
- v8::Handle<v8::Value> value(CompileRun("re.property"));
- CHECK_EQ(32, value->Int32Value());
+ v8::Local<v8::Value> value(CompileRun("re.property"));
+ CHECK_EQ(32, value->Int32Value(context.local()).FromJust());
v8::TryCatch try_catch(context->GetIsolate());
re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone);
CHECK(re.IsEmpty());
CHECK(try_catch.HasCaught());
- context->Global()->Set(v8_str("ex"), try_catch.Exception());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("ex"), try_catch.Exception())
+ .FromJust());
ExpectTrue("ex instanceof SyntaxError");
}
@@ -17702,8 +19190,8 @@ THREADED_TEST(Equals) {
LocalContext localContext;
v8::HandleScope handleScope(localContext->GetIsolate());
- v8::Handle<v8::Object> globalProxy = localContext->Global();
- v8::Handle<Value> global = globalProxy->GetPrototype();
+ v8::Local<v8::Object> globalProxy = localContext->Global();
+ v8::Local<Value> global = globalProxy->GetPrototype();
CHECK(global->StrictEquals(global));
CHECK(!global->StrictEquals(globalProxy));
@@ -17724,7 +19212,7 @@ static void Getter(v8::Local<v8::Name> property,
static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) {
- v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate());
+ v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate());
result->Set(0, v8_str("universalAnswer"));
info.GetReturnValue().Set(result);
}
@@ -17736,12 +19224,15 @@ TEST(NamedEnumeratorAndForIn) {
v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(context.local());
- v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(isolate);
tmpl->SetHandler(v8::NamedPropertyHandlerConfiguration(Getter, NULL, NULL,
NULL, Enumerator));
- context->Global()->Set(v8_str("o"), tmpl->NewInstance());
- v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
- "var result = []; for (var k in o) result.push(k); result"));
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("o"),
+ tmpl->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
+ v8::Local<v8::Array> result = v8::Local<v8::Array>::Cast(
+ CompileRun("var result = []; for (var k in o) result.push(k); result"));
CHECK_EQ(1u, result->Length());
CHECK(v8_str("universalAnswer")->Equals(result->Get(0)));
}
@@ -17750,39 +19241,46 @@ TEST(NamedEnumeratorAndForIn) {
TEST(DefinePropertyPostDetach) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- v8::Handle<v8::Object> proxy = context->Global();
- v8::Handle<v8::Function> define_property =
- CompileRun("(function() {"
- " Object.defineProperty("
- " this,"
- " 1,"
- " { configurable: true, enumerable: true, value: 3 });"
- "})").As<Function>();
+ v8::Local<v8::Object> proxy = context->Global();
+ v8::Local<v8::Function> define_property =
+ CompileRun(
+ "(function() {"
+ " Object.defineProperty("
+ " this,"
+ " 1,"
+ " { configurable: true, enumerable: true, value: 3 });"
+ "})")
+ .As<Function>();
context->DetachGlobal();
define_property->Call(proxy, 0, NULL);
}
-static void InstallContextId(v8::Handle<Context> context, int id) {
+static void InstallContextId(v8::Local<Context> context, int id) {
Context::Scope scope(context);
- CompileRun("Object.prototype").As<Object>()->
- Set(v8_str("context_id"), v8::Integer::New(context->GetIsolate(), id));
+ CHECK(CompileRun("Object.prototype")
+ .As<Object>()
+ ->Set(context, v8_str("context_id"),
+ v8::Integer::New(context->GetIsolate(), id))
+ .FromJust());
}
-static void CheckContextId(v8::Handle<Object> object, int expected) {
- CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value());
+static void CheckContextId(v8::Local<Object> object, int expected) {
+ CHECK_EQ(expected, object->Get(v8_str("context_id"))
+ ->Int32Value(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
}
THREADED_TEST(CreationContext) {
v8::Isolate* isolate = CcTest::isolate();
HandleScope handle_scope(isolate);
- Handle<Context> context1 = Context::New(isolate);
+ Local<Context> context1 = Context::New(isolate);
InstallContextId(context1, 1);
- Handle<Context> context2 = Context::New(isolate);
+ Local<Context> context2 = Context::New(isolate);
InstallContextId(context2, 2);
- Handle<Context> context3 = Context::New(isolate);
+ Local<Context> context3 = Context::New(isolate);
InstallContextId(context3, 3);
Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(isolate);
@@ -17792,7 +19290,7 @@ THREADED_TEST(CreationContext) {
{
Context::Scope scope(context1);
object1 = Object::New(isolate);
- func1 = tmpl->GetFunction();
+ func1 = tmpl->GetFunction(context1).ToLocalChecked();
}
Local<Object> object2;
@@ -17800,7 +19298,7 @@ THREADED_TEST(CreationContext) {
{
Context::Scope scope(context2);
object2 = Object::New(isolate);
- func2 = tmpl->GetFunction();
+ func2 = tmpl->GetFunction(context2).ToLocalChecked();
}
Local<Object> instance1;
@@ -17808,12 +19306,12 @@ THREADED_TEST(CreationContext) {
{
Context::Scope scope(context3);
- instance1 = func1->NewInstance();
- instance2 = func2->NewInstance();
+ instance1 = func1->NewInstance(context3).ToLocalChecked();
+ instance2 = func2->NewInstance(context3).ToLocalChecked();
}
{
- Handle<Context> other_context = Context::New(isolate);
+ Local<Context> other_context = Context::New(isolate);
Context::Scope scope(other_context);
CHECK(object1->CreationContext() == context1);
CheckContextId(object1, 1);
@@ -17865,7 +19363,7 @@ THREADED_TEST(CreationContext) {
THREADED_TEST(CreationContextOfJsFunction) {
HandleScope handle_scope(CcTest::isolate());
- Handle<Context> context = Context::New(CcTest::isolate());
+ Local<Context> context = Context::New(CcTest::isolate());
InstallContextId(context, 1);
Local<Object> function;
@@ -17874,7 +19372,7 @@ THREADED_TEST(CreationContextOfJsFunction) {
function = CompileRun("function foo() {}; foo").As<Object>();
}
- Handle<Context> other_context = Context::New(CcTest::isolate());
+ Local<Context> other_context = Context::New(CcTest::isolate());
Context::Scope scope(other_context);
CHECK(function->CreationContext() == context);
CheckContextId(function, 1);
@@ -17924,7 +19422,7 @@ TEST(HasOwnProperty) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
{ // Check normal properties and defined getters.
- Handle<Value> value = CompileRun(
+ Local<Value> value = CompileRun(
"function Foo() {"
" this.foo = 11;"
" this.__defineGetter__('baz', function() { return 1; });"
@@ -17936,7 +19434,7 @@ TEST(HasOwnProperty) {
"Bar.prototype = new Foo();"
"new Bar();");
CHECK(value->IsObject());
- Handle<Object> object = value->ToObject(isolate);
+ Local<Object> object = value->ToObject(isolate);
CHECK(object->Has(v8_str("foo")));
CHECK(!object->HasOwnProperty(v8_str("foo")));
CHECK(object->HasOwnProperty(v8_str("bar")));
@@ -17945,52 +19443,52 @@ TEST(HasOwnProperty) {
CHECK(object->HasOwnProperty(v8_str("bla")));
}
{ // Check named getter interceptors.
- Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
HasOwnPropertyNamedPropertyGetter));
- Handle<Object> instance = templ->NewInstance();
+ Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
CHECK(!instance->HasOwnProperty(v8_str("42")));
CHECK(instance->HasOwnProperty(v8_str("foo")));
CHECK(!instance->HasOwnProperty(v8_str("bar")));
}
{ // Check indexed getter interceptors.
- Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetHandler(v8::IndexedPropertyHandlerConfiguration(
HasOwnPropertyIndexedPropertyGetter));
- Handle<Object> instance = templ->NewInstance();
+ Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
CHECK(instance->HasOwnProperty(v8_str("42")));
CHECK(!instance->HasOwnProperty(v8_str("43")));
CHECK(!instance->HasOwnProperty(v8_str("foo")));
}
{ // Check named query interceptors.
- Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
0, 0, HasOwnPropertyNamedPropertyQuery));
- Handle<Object> instance = templ->NewInstance();
+ Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
CHECK(instance->HasOwnProperty(v8_str("foo")));
CHECK(!instance->HasOwnProperty(v8_str("bar")));
}
{ // Check indexed query interceptors.
- Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetHandler(v8::IndexedPropertyHandlerConfiguration(
0, 0, HasOwnPropertyIndexedPropertyQuery));
- Handle<Object> instance = templ->NewInstance();
+ Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
CHECK(instance->HasOwnProperty(v8_str("42")));
CHECK(!instance->HasOwnProperty(v8_str("41")));
}
{ // Check callbacks.
- Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetAccessor(v8_str("foo"), HasOwnPropertyAccessorGetter);
- Handle<Object> instance = templ->NewInstance();
+ Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
CHECK(instance->HasOwnProperty(v8_str("foo")));
CHECK(!instance->HasOwnProperty(v8_str("bar")));
}
{ // Check that query wins on disagreement.
- Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
HasOwnPropertyNamedPropertyGetter, 0,
HasOwnPropertyNamedPropertyQuery2));
- Handle<Object> instance = templ->NewInstance();
+ Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
CHECK(!instance->HasOwnProperty(v8_str("foo")));
CHECK(instance->HasOwnProperty(v8_str("bar")));
}
@@ -18000,11 +19498,14 @@ TEST(HasOwnProperty) {
TEST(IndexedInterceptorWithStringProto) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetHandler(v8::IndexedPropertyHandlerConfiguration(
NULL, NULL, HasOwnPropertyIndexedPropertyQuery));
LocalContext context;
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun("var s = new String('foobar'); obj.__proto__ = s;");
// These should be intercepted.
CHECK(CompileRun("42 in obj")->BooleanValue());
@@ -18019,19 +19520,20 @@ TEST(IndexedInterceptorWithStringProto) {
void CheckCodeGenerationAllowed() {
- Handle<Value> result = CompileRun("eval('42')");
- CHECK_EQ(42, result->Int32Value());
+ Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
+ Local<Value> result = CompileRun("eval('42')");
+ CHECK_EQ(42, result->Int32Value(context).FromJust());
result = CompileRun("(function(e) { return e('42'); })(eval)");
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(42, result->Int32Value(context).FromJust());
result = CompileRun("var f = new Function('return 42'); f()");
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(42, result->Int32Value(context).FromJust());
}
void CheckCodeGenerationDisallowed() {
TryCatch try_catch(CcTest::isolate());
- Handle<Value> result = CompileRun("eval('42')");
+ Local<Value> result = CompileRun("eval('42')");
CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
try_catch.Reset();
@@ -18094,15 +19596,15 @@ TEST(SetErrorMessageForCodeGenFromStrings) {
v8::HandleScope scope(context->GetIsolate());
TryCatch try_catch(context->GetIsolate());
- Handle<String> message = v8_str("Message");
- Handle<String> expected_message = v8_str("Uncaught EvalError: Message");
+ Local<String> message = v8_str("Message");
+ Local<String> expected_message = v8_str("Uncaught EvalError: Message");
V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed);
context->AllowCodeGenerationFromStrings(false);
context->SetErrorMessageForCodeGenerationFromStrings(message);
- Handle<Value> result = CompileRun("eval('42')");
+ Local<Value> result = CompileRun("eval('42')");
CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
- Handle<String> actual_message = try_catch.Message()->Get();
+ Local<String> actual_message = try_catch.Message()->Get();
CHECK(expected_message->Equals(actual_message));
}
@@ -18115,10 +19617,13 @@ THREADED_TEST(CallAPIFunctionOnNonObject) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- Handle<FunctionTemplate> templ =
+ Local<FunctionTemplate> templ =
v8::FunctionTemplate::New(isolate, NonObjectThis);
- Handle<Function> function = templ->GetFunction();
- context->Global()->Set(v8_str("f"), function);
+ Local<Function> function =
+ templ->GetFunction(context.local()).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("f"), function)
+ .FromJust());
TryCatch try_catch(isolate);
CompileRun("f.call(2)");
}
@@ -18131,8 +19636,8 @@ THREADED_TEST(ReadOnlyIndexedProperties) {
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
LocalContext context;
- Local<v8::Object> obj = templ->NewInstance();
- context->Global()->Set(v8_str("obj"), obj);
+ Local<v8::Object> obj = templ->NewInstance(context.local()).ToLocalChecked();
+ CHECK(context->Global()->Set(context.local(), v8_str("obj"), obj).FromJust());
obj->ForceSet(v8_str("1"), v8_str("DONT_CHANGE"), v8::ReadOnly);
obj->Set(v8_str("1"), v8_str("foobar"));
CHECK(v8_str("DONT_CHANGE")->Equals(obj->Get(v8_str("1"))));
@@ -18211,7 +19716,8 @@ THREADED_TEST(Regress93759) {
Local<Object> simple_object = Object::New(isolate);
// Object with explicit security check.
- Local<Object> protected_object = no_proto_template->NewInstance();
+ Local<Object> protected_object =
+ no_proto_template->NewInstance(context).ToLocalChecked();
// JSGlobalProxy object, always have security check.
Local<Object> proxy_object = context->Global();
@@ -18220,8 +19726,10 @@ THREADED_TEST(Regress93759) {
Local<Object> global_object = proxy_object->GetPrototype()->ToObject(isolate);
// Hidden prototype without security check.
- Local<Object> hidden_prototype =
- hidden_proto_template->GetFunction()->NewInstance();
+ Local<Object> hidden_prototype = hidden_proto_template->GetFunction(context)
+ .ToLocalChecked()
+ ->NewInstance(context)
+ .ToLocalChecked();
Local<Object> object_with_hidden =
Object::New(isolate);
object_with_hidden->SetPrototype(hidden_prototype);
@@ -18312,7 +19820,9 @@ THREADED_TEST(ForeignFunctionReceiver) {
"}"
"var id = 'o';"
"ownfunc");
- context->Global()->Set(v8_str("func"), foreign_function);
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("func"), foreign_function)
+ .FromJust());
// Sanity check the contexts.
CHECK(i->Equals(foreign_context->Global()->Get(id)));
@@ -18375,7 +19885,8 @@ void CallCompletedCallback2() {
void RecursiveCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
- int32_t level = args[0]->Int32Value();
+ int32_t level =
+ args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust();
if (level < 3) {
level++;
v8::base::OS::Print("Entering recursion level %d.\n", level);
@@ -18395,17 +19906,17 @@ void RecursiveCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(CallCompletedCallback) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Handle<v8::FunctionTemplate> recursive_runtime =
+ v8::Local<v8::FunctionTemplate> recursive_runtime =
v8::FunctionTemplate::New(env->GetIsolate(), RecursiveCall);
- env->Global()->Set(v8_str("recursion"),
- recursive_runtime->GetFunction());
+ env->Global()->Set(
+ v8_str("recursion"),
+ recursive_runtime->GetFunction(env.local()).ToLocalChecked());
// Adding the same callback a second time has no effect.
env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback1);
env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback1);
env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback2);
v8::base::OS::Print("--- Script (1) ---\n");
- Local<Script> script = v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), "recursion(0)"));
+ Local<Script> script = v8::Script::Compile(v8_str("recursion(0)"));
script->Run();
CHECK_EQ(3, callback_fired);
@@ -18419,7 +19930,7 @@ TEST(CallCompletedCallback) {
callback_fired = 0;
Local<Function> recursive_function =
Local<Function>::Cast(env->Global()->Get(v8_str("recursion")));
- v8::Handle<Value> args[] = { v8_num(0) };
+ v8::Local<Value> args[] = {v8_num(0)};
recursive_function->Call(env->Global(), 1, args);
CHECK_EQ(2, callback_fired);
}
@@ -18480,39 +19991,39 @@ TEST(EnqueueMicrotask) {
"var ext1Calls = 0;"
"var ext2Calls = 0;");
CompileRun("1+1;");
- CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->EnqueueMicrotask(
Function::New(env->GetIsolate(), MicrotaskOne));
CompileRun("1+1;");
- CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->EnqueueMicrotask(
Function::New(env->GetIsolate(), MicrotaskOne));
env->GetIsolate()->EnqueueMicrotask(
Function::New(env->GetIsolate(), MicrotaskTwo));
CompileRun("1+1;");
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->EnqueueMicrotask(
Function::New(env->GetIsolate(), MicrotaskTwo));
CompileRun("1+1;");
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
CompileRun("1+1;");
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
g_passed_to_three = NULL;
env->GetIsolate()->EnqueueMicrotask(MicrotaskThree);
CompileRun("1+1;");
CHECK(!g_passed_to_three);
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
int dummy;
env->GetIsolate()->EnqueueMicrotask(
@@ -18522,8 +20033,8 @@ TEST(EnqueueMicrotask) {
Function::New(env->GetIsolate(), MicrotaskTwo));
CompileRun("1+1;");
CHECK_EQ(&dummy, g_passed_to_three);
- CHECK_EQ(3, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(3, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
g_passed_to_three = NULL;
}
@@ -18560,8 +20071,10 @@ TEST(RunMicrotasksIgnoresThrownExceptions) {
TryCatch try_catch(isolate);
CompileRun("1+1;");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(1, CompileRun("exception1Calls")->Int32Value());
- CHECK_EQ(1, CompileRun("exception2Calls")->Int32Value());
+ CHECK_EQ(1,
+ CompileRun("exception1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(1,
+ CompileRun("exception2Calls")->Int32Value(env.local()).FromJust());
}
@@ -18572,14 +20085,14 @@ TEST(SetAutorunMicrotasks) {
"var ext1Calls = 0;"
"var ext2Calls = 0;");
CompileRun("1+1;");
- CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->EnqueueMicrotask(
Function::New(env->GetIsolate(), MicrotaskOne));
CompileRun("1+1;");
- CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->SetAutorunMicrotasks(false);
env->GetIsolate()->EnqueueMicrotask(
@@ -18587,42 +20100,42 @@ TEST(SetAutorunMicrotasks) {
env->GetIsolate()->EnqueueMicrotask(
Function::New(env->GetIsolate(), MicrotaskTwo));
CompileRun("1+1;");
- CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->RunMicrotasks();
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->EnqueueMicrotask(
Function::New(env->GetIsolate(), MicrotaskTwo));
CompileRun("1+1;");
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->RunMicrotasks();
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->SetAutorunMicrotasks(true);
env->GetIsolate()->EnqueueMicrotask(
Function::New(env->GetIsolate(), MicrotaskTwo));
CompileRun("1+1;");
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
env->GetIsolate()->EnqueueMicrotask(
Function::New(env->GetIsolate(), MicrotaskTwo));
{
v8::Isolate::SuppressMicrotaskExecutionScope scope(env->GetIsolate());
CompileRun("1+1;");
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
}
CompileRun("1+1;");
- CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
- CHECK_EQ(4, CompileRun("ext2Calls")->Int32Value());
+ CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
+ CHECK_EQ(4, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
}
@@ -18630,7 +20143,7 @@ TEST(RunMicrotasksWithoutEnteringContext) {
v8::Isolate* isolate = CcTest::isolate();
HandleScope handle_scope(isolate);
isolate->SetAutorunMicrotasks(false);
- Handle<Context> context = Context::New(isolate);
+ Local<Context> context = Context::New(isolate);
{
Context::Scope context_scope(context);
CompileRun("var ext1Calls = 0;");
@@ -18639,7 +20152,7 @@ TEST(RunMicrotasksWithoutEnteringContext) {
isolate->RunMicrotasks();
{
Context::Scope context_scope(context);
- CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
+ CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(context).FromJust());
}
isolate->SetAutorunMicrotasks(true);
}
@@ -18648,11 +20161,11 @@ TEST(RunMicrotasksWithoutEnteringContext) {
static void DebugEventInObserver(const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
if (event != v8::Break) return;
- Handle<Object> exec_state = event_details.GetExecutionState();
- Handle<Value> break_id = exec_state->Get(v8_str("break_id"));
+ Local<Object> exec_state = event_details.GetExecutionState();
+ Local<Value> break_id = exec_state->Get(v8_str("break_id"));
CompileRun("function f(id) { new FrameDetails(id, 0); }");
- Handle<Function> fun =
- Handle<Function>::Cast(CcTest::global()->Get(v8_str("f")));
+ Local<Function> fun =
+ Local<Function>::Cast(CcTest::global()->Get(v8_str("f")));
fun->Call(CcTest::global(), 1, &break_id);
}
@@ -18662,7 +20175,7 @@ TEST(Regress385349) {
v8::Isolate* isolate = CcTest::isolate();
HandleScope handle_scope(isolate);
isolate->SetAutorunMicrotasks(false);
- Handle<Context> context = Context::New(isolate);
+ Local<Context> context = Context::New(isolate);
v8::Debug::SetDebugEventListener(DebugEventInObserver);
{
Context::Scope context_scope(context);
@@ -18925,13 +20438,13 @@ THREADED_TEST(InstanceCheckOnInstanceAccessor) {
Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
Local<ObjectTemplate> inst = templ->InstanceTemplate();
- inst->SetAccessor(v8_str("foo"),
- InstanceCheckedGetter, InstanceCheckedSetter,
- Handle<Value>(),
- v8::DEFAULT,
- v8::None,
+ inst->SetAccessor(v8_str("foo"), InstanceCheckedGetter, InstanceCheckedSetter,
+ Local<Value>(), v8::DEFAULT, v8::None,
v8::AccessorSignature::New(context->GetIsolate(), templ));
- context->Global()->Set(v8_str("f"), templ->GetFunction());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("f"),
+ templ->GetFunction(context.local()).ToLocalChecked())
+ .FromJust());
printf("Testing positive ...\n");
CompileRun("var obj = new f();");
@@ -18964,13 +20477,13 @@ THREADED_TEST(InstanceCheckOnInstanceAccessorWithInterceptor) {
Local<ObjectTemplate> inst = templ->InstanceTemplate();
templ->InstanceTemplate()->SetNamedPropertyHandler(EmptyInterceptorGetter,
EmptyInterceptorSetter);
- inst->SetAccessor(v8_str("foo"),
- InstanceCheckedGetter, InstanceCheckedSetter,
- Handle<Value>(),
- v8::DEFAULT,
- v8::None,
+ inst->SetAccessor(v8_str("foo"), InstanceCheckedGetter, InstanceCheckedSetter,
+ Local<Value>(), v8::DEFAULT, v8::None,
v8::AccessorSignature::New(context->GetIsolate(), templ));
- context->Global()->Set(v8_str("f"), templ->GetFunction());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("f"),
+ templ->GetFunction(context.local()).ToLocalChecked())
+ .FromJust());
printf("Testing positive ...\n");
CompileRun("var obj = new f();");
@@ -18993,10 +20506,13 @@ THREADED_TEST(InstanceCheckOnPrototypeAccessor) {
Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
Local<ObjectTemplate> proto = templ->PrototypeTemplate();
proto->SetAccessor(v8_str("foo"), InstanceCheckedGetter,
- InstanceCheckedSetter, Handle<Value>(), v8::DEFAULT,
+ InstanceCheckedSetter, Local<Value>(), v8::DEFAULT,
v8::None,
v8::AccessorSignature::New(context->GetIsolate(), templ));
- context->Global()->Set(v8_str("f"), templ->GetFunction());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("f"),
+ templ->GetFunction(context.local()).ToLocalChecked())
+ .FromJust());
printf("Testing positive ...\n");
CompileRun("var obj = new f();");
@@ -19076,7 +20592,10 @@ static void Helper137002(bool do_store,
GetterWhichReturns42,
SetterWhichSetsYOnThisTo23);
}
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
// Turn monomorphic on slow object with native accessor, then turn
// polymorphic, finally optimize to create negative lookup and fail.
@@ -19104,8 +20623,10 @@ static void Helper137002(bool do_store,
if (remove_accessor && !interceptor) {
CHECK(context->Global()->Get(v8_str("result"))->IsUndefined());
} else {
- CHECK_EQ(do_store ? 23 : 42,
- context->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(do_store ? 23 : 42, context->Global()
+ ->Get(v8_str("result"))
+ ->Int32Value(context.local())
+ .FromJust());
}
}
@@ -19129,7 +20650,10 @@ THREADED_TEST(Regress137002b) {
templ->SetAccessor(v8_str("foo"),
GetterWhichReturns42,
SetterWhichSetsYOnThisTo23);
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
// Turn monomorphic on slow object with native accessor, then just
// delete the property and fail.
@@ -19198,7 +20722,10 @@ THREADED_TEST(Regress142088) {
templ->SetAccessor(v8_str("foo"),
GetterWhichReturns42,
SetterWhichSetsYOnThisTo23);
- context->Global()->Set(v8_str("obj"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("obj"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun("function load(x) { return x.foo; }"
"var o = Object.create(obj);"
@@ -19226,7 +20753,7 @@ THREADED_TEST(Regress157124) {
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
- Local<Object> obj = templ->NewInstance();
+ Local<Object> obj = templ->NewInstance(context.local()).ToLocalChecked();
obj->GetIdentityHash();
obj->DeletePrivate(context.local(),
v8::Private::ForApi(isolate, v8_str("Bug")))
@@ -19267,7 +20794,8 @@ THREADED_TEST(Regress260106) {
Local<FunctionTemplate> templ = FunctionTemplate::New(isolate,
DummyCallHandler);
CompileRun("for (var i = 0; i < 128; i++) Object.prototype[i] = 0;");
- Local<Function> function = templ->GetFunction();
+ Local<Function> function =
+ templ->GetFunction(context.local()).ToLocalChecked();
CHECK(!function.IsEmpty());
CHECK(function->IsFunction());
}
@@ -19277,7 +20805,7 @@ THREADED_TEST(JSONParseObject) {
LocalContext context;
HandleScope scope(context->GetIsolate());
Local<Value> obj = v8::JSON::Parse(v8_str("{\"x\":42}"));
- Handle<Object> global = context->Global();
+ Local<Object> global = context->Global();
global->Set(v8_str("obj"), obj);
ExpectString("JSON.stringify(obj)", "{\"x\":42}");
}
@@ -19287,7 +20815,7 @@ THREADED_TEST(JSONParseNumber) {
LocalContext context;
HandleScope scope(context->GetIsolate());
Local<Value> obj = v8::JSON::Parse(v8_str("42"));
- Handle<Object> global = context->Global();
+ Local<Object> global = context->Global();
global->Set(v8_str("obj"), obj);
ExpectString("JSON.stringify(obj)", "42");
}
@@ -19369,28 +20897,31 @@ TEST(JSONStringifyAccessCheck) {
// Create an ObjectTemplate for global objects and install access
// check callbacks that will block access.
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
global_template->SetAccessCheckCallback(AccessAlwaysBlocked);
// Create a context and set an x property on it's global object.
LocalContext context0(NULL, global_template);
- v8::Handle<v8::Object> global0 = context0->Global();
+ v8::Local<v8::Object> global0 = context0->Global();
global0->Set(v8_str("x"), v8_num(42));
ExpectString("JSON.stringify(this)", "{\"x\":42}");
for (int i = 0; i < 2; i++) {
if (i == 1) {
// Install a toJSON function on the second run.
- v8::Handle<v8::FunctionTemplate> toJSON =
+ v8::Local<v8::FunctionTemplate> toJSON =
v8::FunctionTemplate::New(isolate, UnreachableCallback);
- global0->Set(v8_str("toJSON"), toJSON->GetFunction());
+ global0->Set(v8_str("toJSON"),
+ toJSON->GetFunction(context0.local()).ToLocalChecked());
}
// Create a context with a different security token so that the
// failed access check callback will be called on each access.
LocalContext context1(NULL, global_template);
- context1->Global()->Set(v8_str("other"), global0);
+ CHECK(context1->Global()
+ ->Set(context1.local(), v8_str("other"), global0)
+ .FromJust());
CHECK(CompileRun("JSON.stringify(other)").IsEmpty());
CHECK(CompileRun("JSON.stringify({ 'a' : other, 'b' : ['c'] })").IsEmpty());
@@ -19457,27 +20988,35 @@ TEST(AccessCheckThrows) {
// Create an ObjectTemplate for global objects and install access
// check callbacks that will block access.
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
global_template->SetAccessCheckCallback(AccessAlwaysBlocked);
// Create a context and set an x property on it's global object.
LocalContext context0(NULL, global_template);
- v8::Handle<v8::Object> global0 = context0->Global();
+ v8::Local<v8::Object> global0 = context0->Global();
// Create a context with a different security token so that the
// failed access check callback will be called on each access.
LocalContext context1(NULL, global_template);
- context1->Global()->Set(v8_str("other"), global0);
+ CHECK(context1->Global()
+ ->Set(context1.local(), v8_str("other"), global0)
+ .FromJust());
- v8::Handle<v8::FunctionTemplate> catcher_fun =
+ v8::Local<v8::FunctionTemplate> catcher_fun =
v8::FunctionTemplate::New(isolate, CatcherCallback);
- context1->Global()->Set(v8_str("catcher"), catcher_fun->GetFunction());
+ CHECK(context1->Global()
+ ->Set(context1.local(), v8_str("catcher"),
+ catcher_fun->GetFunction(context1.local()).ToLocalChecked())
+ .FromJust());
- v8::Handle<v8::FunctionTemplate> has_own_property_fun =
+ v8::Local<v8::FunctionTemplate> has_own_property_fun =
v8::FunctionTemplate::New(isolate, HasOwnPropertyCallback);
- context1->Global()->Set(v8_str("has_own_property"),
- has_own_property_fun->GetFunction());
+ CHECK(context1->Global()
+ ->Set(context1.local(), v8_str("has_own_property"),
+ has_own_property_fun->GetFunction(context1.local())
+ .ToLocalChecked())
+ .FromJust());
{
v8::TryCatch try_catch(isolate);
@@ -19610,7 +21149,9 @@ class RequestInterruptTestWithFunctionCall
virtual void TestBody() {
Local<Function> func = Function::New(
isolate_, ShouldContinueCallback, v8::External::New(isolate_, this));
- env_->Global()->Set(v8_str("ShouldContinue"), func);
+ CHECK(env_->Global()
+ ->Set(env_.local(), v8_str("ShouldContinue"), func)
+ .FromJust());
CompileRun("while (ShouldContinue()) { }");
}
@@ -19625,7 +21166,10 @@ class RequestInterruptTestWithMethodCall
v8::Local<v8::Template> proto = t->PrototypeTemplate();
proto->Set(v8_str("shouldContinue"), Function::New(
isolate_, ShouldContinueCallback, v8::External::New(isolate_, this)));
- env_->Global()->Set(v8_str("Klass"), t->GetFunction());
+ CHECK(env_->Global()
+ ->Set(env_.local(), v8_str("Klass"),
+ t->GetFunction(env_.local()).ToLocalChecked())
+ .FromJust());
CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }");
}
@@ -19640,7 +21184,10 @@ class RequestInterruptTestWithAccessor
v8::Local<v8::Template> proto = t->PrototypeTemplate();
proto->SetAccessorProperty(v8_str("shouldContinue"), FunctionTemplate::New(
isolate_, ShouldContinueCallback, v8::External::New(isolate_, this)));
- env_->Global()->Set(v8_str("Klass"), t->GetFunction());
+ CHECK(env_->Global()
+ ->Set(env_.local(), v8_str("Klass"),
+ t->GetFunction(env_.local()).ToLocalChecked())
+ .FromJust());
CompileRun("var obj = new Klass; while (obj.shouldContinue) { }");
}
@@ -19657,7 +21204,10 @@ class RequestInterruptTestWithNativeAccessor
&ShouldContinueNativeGetter,
NULL,
v8::External::New(isolate_, this));
- env_->Global()->Set(v8_str("Klass"), t->GetFunction());
+ CHECK(env_->Global()
+ ->Set(env_.local(), v8_str("Klass"),
+ t->GetFunction(env_.local()).ToLocalChecked())
+ .FromJust());
CompileRun("var obj = new Klass; while (obj.shouldContinue) { }");
}
@@ -19686,7 +21236,10 @@ class RequestInterruptTestWithMethodCallAndInterceptor
instance_template->SetHandler(
v8::NamedPropertyHandlerConfiguration(EmptyInterceptor));
- env_->Global()->Set(v8_str("Klass"), t->GetFunction());
+ CHECK(env_->Global()
+ ->Set(env_.local(), v8_str("Klass"),
+ t->GetFunction(env_.local()).ToLocalChecked())
+ .FromJust());
CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }");
}
@@ -19793,7 +21346,9 @@ class RequestMultipleInterrupts : public RequestInterruptTestBase {
virtual void TestBody() {
Local<Function> func = Function::New(
isolate_, ShouldContinueCallback, v8::External::New(isolate_, this));
- env_->Global()->Set(v8_str("ShouldContinue"), func);
+ CHECK(env_->Global()
+ ->Set(env_.local(), v8_str("ShouldContinue"), func)
+ .FromJust());
CompileRun("while (ShouldContinue()) { }");
}
@@ -19864,7 +21419,7 @@ THREADED_TEST(FunctionNew) {
Local<Object> data = v8::Object::New(isolate);
function_new_expected_env = data;
Local<Function> func = Function::New(isolate, FunctionNewCallback, data);
- env->Global()->Set(v8_str("func"), func);
+ CHECK(env->Global()->Set(env.local(), v8_str("func"), func).FromJust());
Local<Value> result = CompileRun("func();");
CHECK(v8::Integer::New(isolate, 17)->Equals(result));
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
@@ -19883,7 +21438,7 @@ THREADED_TEST(FunctionNew) {
Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2);
CHECK(!func2->IsNull());
CHECK(!func->Equals(func2));
- env->Global()->Set(v8_str("func2"), func2);
+ CHECK(env->Global()->Set(env.local(), v8_str("func2"), func2).FromJust());
Local<Value> result2 = CompileRun("func2();");
CHECK(v8::Integer::New(isolate, 17)->Equals(result2));
}
@@ -19923,7 +21478,10 @@ TEST(Regress239669) {
v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetAccessor(v8_str("x"), 0, SetterWhichExpectsThisAndHolderToDiffer);
- context->Global()->Set(v8_str("P"), templ->NewInstance());
+ CHECK(context->Global()
+ ->Set(context.local(), v8_str("P"),
+ templ->NewInstance(context.local()).ToLocalChecked())
+ .FromJust());
CompileRun(
"function C1() {"
" this.x = 23;"
@@ -20007,8 +21565,11 @@ class ApiCallOptimizationChecker {
v8::Context::New(isolate, NULL, signature_template);
v8::Context::Scope context_scope(context);
// Install regular object that can pass signature checks.
- Local<Object> function_receiver = signature_template->NewInstance();
- context->Global()->Set(v8_str("function_receiver"), function_receiver);
+ Local<Object> function_receiver =
+ signature_template->NewInstance(context).ToLocalChecked();
+ CHECK(context->Global()
+ ->Set(context, v8_str("function_receiver"), function_receiver)
+ .FromJust());
// Get the holder objects.
Local<Object> inner_global =
Local<Object>::Cast(context->Global()->GetPrototype());
@@ -20016,7 +21577,8 @@ class ApiCallOptimizationChecker {
data = Object::New(isolate);
Local<FunctionTemplate> function_template = FunctionTemplate::New(
isolate, OptimizationCallback, data, signature);
- Local<Function> function = function_template->GetFunction();
+ Local<Function> function =
+ function_template->GetFunction(context).ToLocalChecked();
Local<Object> global_holder = inner_global;
Local<Object> function_holder = function_receiver;
if (signature_type == kSignatureOnPrototype) {
@@ -20124,7 +21686,7 @@ TEST(FunctionCallOptimizationMultipleArgs) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- Handle<Object> global = context->Global();
+ Local<Object> global = context->Global();
Local<v8::Function> function = Function::New(isolate, Returns42);
global->Set(v8_str("x"), function);
CompileRun(
@@ -20150,7 +21712,7 @@ TEST(ApiCallbackCanReturnSymbols) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- Handle<Object> global = context->Global();
+ Local<Object> global = context->Global();
Local<v8::Function> function = Function::New(isolate, ReturnsSymbolCallback);
global->Set(v8_str("x"), function);
CompileRun(
@@ -20170,7 +21732,9 @@ TEST(EmptyApiCallback) {
auto isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
auto global = context->Global();
- auto function = FunctionTemplate::New(isolate)->GetFunction();
+ auto function = FunctionTemplate::New(isolate)
+ ->GetFunction(context.local())
+ .ToLocalChecked();
global->Set(v8_str("x"), function);
auto result = CompileRun("x()");
@@ -20181,11 +21745,11 @@ TEST(EmptyApiCallback) {
result = CompileRun("7 + x.call(3) + 11");
CHECK(result->IsInt32());
- CHECK_EQ(21, result->Int32Value());
+ CHECK_EQ(21, result->Int32Value(context.local()).FromJust());
result = CompileRun("7 + x.call(3, 101, 102, 103, 104) + 11");
CHECK(result->IsInt32());
- CHECK_EQ(21, result->Int32Value());
+ CHECK_EQ(21, result->Int32Value(context.local()).FromJust());
result = CompileRun("var y = []; x.call(y)");
CHECK(result->IsArray());
@@ -20202,9 +21766,10 @@ TEST(SimpleSignatureCheck) {
auto global = context->Global();
auto sig_obj = FunctionTemplate::New(isolate);
auto sig = v8::Signature::New(isolate, sig_obj);
- auto x = FunctionTemplate::New(isolate, Returns42, Handle<Value>(), sig);
- global->Set(v8_str("sig_obj"), sig_obj->GetFunction());
- global->Set(v8_str("x"), x->GetFunction());
+ auto x = FunctionTemplate::New(isolate, Returns42, Local<Value>(), sig);
+ global->Set(v8_str("sig_obj"),
+ sig_obj->GetFunction(context.local()).ToLocalChecked());
+ global->Set(v8_str("x"), x->GetFunction(context.local()).ToLocalChecked());
CompileRun("var s = new sig_obj();");
{
TryCatch try_catch(isolate);
@@ -20220,13 +21785,13 @@ TEST(SimpleSignatureCheck) {
TryCatch try_catch(isolate);
auto result = CompileRun("s.x = x; s.x()");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(42, result->Int32Value(context.local()).FromJust());
}
{
TryCatch try_catch(isolate);
auto result = CompileRun("x.call(s)");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(42, result->Int32Value(context.local()).FromJust());
}
}
@@ -20243,9 +21808,10 @@ TEST(ChainSignatureCheck) {
temp->Inherit(sig_obj);
sig_obj = temp;
}
- auto x = FunctionTemplate::New(isolate, Returns42, Handle<Value>(), sig);
- global->Set(v8_str("sig_obj"), sig_obj->GetFunction());
- global->Set(v8_str("x"), x->GetFunction());
+ auto x = FunctionTemplate::New(isolate, Returns42, Local<Value>(), sig);
+ global->Set(v8_str("sig_obj"),
+ sig_obj->GetFunction(context.local()).ToLocalChecked());
+ global->Set(v8_str("x"), x->GetFunction(context.local()).ToLocalChecked());
CompileRun("var s = new sig_obj();");
{
TryCatch try_catch(isolate);
@@ -20261,13 +21827,13 @@ TEST(ChainSignatureCheck) {
TryCatch try_catch(isolate);
auto result = CompileRun("s.x = x; s.x()");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(42, result->Int32Value(context.local()).FromJust());
}
{
TryCatch try_catch(isolate);
auto result = CompileRun("x.call(s)");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(42, result->Int32Value(context.local()).FromJust());
}
}
@@ -20280,9 +21846,10 @@ TEST(PrototypeSignatureCheck) {
auto sig_obj = FunctionTemplate::New(isolate);
sig_obj->SetHiddenPrototype(true);
auto sig = v8::Signature::New(isolate, sig_obj);
- auto x = FunctionTemplate::New(isolate, Returns42, Handle<Value>(), sig);
- global->Set(v8_str("sig_obj"), sig_obj->GetFunction());
- global->Set(v8_str("x"), x->GetFunction());
+ auto x = FunctionTemplate::New(isolate, Returns42, Local<Value>(), sig);
+ global->Set(v8_str("sig_obj"),
+ sig_obj->GetFunction(context.local()).ToLocalChecked());
+ global->Set(v8_str("x"), x->GetFunction(context.local()).ToLocalChecked());
CompileRun("s = {}; s.__proto__ = new sig_obj();");
{
TryCatch try_catch(isolate);
@@ -20298,13 +21865,13 @@ TEST(PrototypeSignatureCheck) {
TryCatch try_catch(isolate);
auto result = CompileRun("s.x = x; s.x()");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(42, result->Int32Value(context.local()).FromJust());
}
{
TryCatch try_catch(isolate);
auto result = CompileRun("x.call(s)");
CHECK(!try_catch.HasCaught());
- CHECK_EQ(42, result->Int32Value());
+ CHECK_EQ(42, result->Int32Value(context.local()).FromJust());
}
}
@@ -20336,19 +21903,19 @@ TEST(Promises) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- Handle<Object> global = context->Global();
+ Local<Object> global = context->Global();
// Creation.
- Handle<v8::Promise::Resolver> pr = v8::Promise::Resolver::New(isolate);
- Handle<v8::Promise::Resolver> rr = v8::Promise::Resolver::New(isolate);
- Handle<v8::Promise> p = pr->GetPromise();
- Handle<v8::Promise> r = rr->GetPromise();
+ Local<v8::Promise::Resolver> pr = v8::Promise::Resolver::New(isolate);
+ Local<v8::Promise::Resolver> rr = v8::Promise::Resolver::New(isolate);
+ Local<v8::Promise> p = pr->GetPromise();
+ Local<v8::Promise> r = rr->GetPromise();
CHECK_EQ(isolate, p->GetIsolate());
// IsPromise predicate.
CHECK(p->IsPromise());
CHECK(r->IsPromise());
- Handle<Value> o = v8::Object::New(isolate);
+ Local<Value> o = v8::Object::New(isolate);
CHECK(!o->IsPromise());
// Resolution and rejection.
@@ -20363,26 +21930,32 @@ TEST(Promises) {
"var x2 = 0;\n"
"function f1(x) { x1 = x; return x+1 };\n"
"function f2(x) { x2 = x; return x+1 };\n");
- Handle<Function> f1 = Handle<Function>::Cast(global->Get(v8_str("f1")));
- Handle<Function> f2 = Handle<Function>::Cast(global->Get(v8_str("f2")));
+ Local<Function> f1 = Local<Function>::Cast(global->Get(v8_str("f1")));
+ Local<Function> f2 = Local<Function>::Cast(global->Get(v8_str("f2")));
p->Chain(f1);
- CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
isolate->RunMicrotasks();
- CHECK_EQ(1, global->Get(v8_str("x1"))->Int32Value());
+ CHECK_EQ(1,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
p->Catch(f2);
isolate->RunMicrotasks();
- CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
r->Catch(f2);
- CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
isolate->RunMicrotasks();
- CHECK_EQ(2, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(2,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
r->Chain(f1);
isolate->RunMicrotasks();
- CHECK_EQ(1, global->Get(v8_str("x1"))->Int32Value());
+ CHECK_EQ(1,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
// Chaining pending promises.
CompileRun("x1 = x2 = 0;");
@@ -20392,38 +21965,52 @@ TEST(Promises) {
pr->GetPromise()->Chain(f1);
rr->GetPromise()->Catch(f2);
isolate->RunMicrotasks();
- CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(0,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
pr->Resolve(v8::Integer::New(isolate, 1));
rr->Reject(v8::Integer::New(isolate, 2));
- CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(0,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
isolate->RunMicrotasks();
- CHECK_EQ(1, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(2, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(1,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(2,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
// Multi-chaining.
CompileRun("x1 = x2 = 0;");
pr = v8::Promise::Resolver::New(isolate);
pr->GetPromise()->Chain(f1)->Chain(f2);
pr->Resolve(v8::Integer::New(isolate, 3));
- CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(0,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
isolate->RunMicrotasks();
- CHECK_EQ(3, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(4, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(3,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(4,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
CompileRun("x1 = x2 = 0;");
rr = v8::Promise::Resolver::New(isolate);
rr->GetPromise()->Catch(f1)->Chain(f2);
rr->Reject(v8::Integer::New(isolate, 3));
- CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(0,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
isolate->RunMicrotasks();
- CHECK_EQ(3, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(4, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(3,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(4,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
}
@@ -20431,13 +22018,13 @@ TEST(PromiseThen) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
- Handle<Object> global = context->Global();
+ Local<Object> global = context->Global();
// Creation.
- Handle<v8::Promise::Resolver> pr = v8::Promise::Resolver::New(isolate);
- Handle<v8::Promise::Resolver> qr = v8::Promise::Resolver::New(isolate);
- Handle<v8::Promise> p = pr->GetPromise();
- Handle<v8::Promise> q = qr->GetPromise();
+ Local<v8::Promise::Resolver> pr = v8::Promise::Resolver::New(isolate);
+ Local<v8::Promise::Resolver> qr = v8::Promise::Resolver::New(isolate);
+ Local<v8::Promise> p = pr->GetPromise();
+ Local<v8::Promise> q = qr->GetPromise();
CHECK(p->IsPromise());
CHECK(q->IsPromise());
@@ -20451,8 +22038,8 @@ TEST(PromiseThen) {
"var x2 = 0;\n"
"function f1(x) { x1 = x; return x+1 };\n"
"function f2(x) { x2 = x; return x+1 };\n");
- Handle<Function> f1 = Handle<Function>::Cast(global->Get(v8_str("f1")));
- Handle<Function> f2 = Handle<Function>::Cast(global->Get(v8_str("f2")));
+ Local<Function> f1 = Local<Function>::Cast(global->Get(v8_str("f1")));
+ Local<Function> f2 = Local<Function>::Cast(global->Get(v8_str("f2")));
// TODO(caitp): remove tests once PromiseChain is removed, per bug 3237
/* q->Chain(f1);
@@ -20465,9 +22052,11 @@ TEST(PromiseThen) {
// Then
CompileRun("x1 = x2 = 0;");
q->Then(f1);
- CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
isolate->RunMicrotasks();
- CHECK_EQ(1, global->Get(v8_str("x1"))->Int32Value());
+ CHECK_EQ(1,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
// Then
CompileRun("x1 = x2 = 0;");
@@ -20477,19 +22066,27 @@ TEST(PromiseThen) {
qr->Resolve(pr);
qr->GetPromise()->Then(f1)->Then(f2);
- CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(0,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
isolate->RunMicrotasks();
- CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(0,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
pr->Resolve(v8::Integer::New(isolate, 3));
- CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(0,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(0,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
isolate->RunMicrotasks();
- CHECK_EQ(3, global->Get(v8_str("x1"))->Int32Value());
- CHECK_EQ(4, global->Get(v8_str("x2"))->Int32Value());
+ CHECK_EQ(3,
+ global->Get(v8_str("x1"))->Int32Value(context.local()).FromJust());
+ CHECK_EQ(4,
+ global->Get(v8_str("x2"))->Int32Value(context.local()).FromJust());
}
@@ -20534,9 +22131,12 @@ TEST(Regress354123) {
v8::Isolate* isolate = current->GetIsolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
templ->SetAccessCheckCallback(AccessCounter);
- current->Global()->Set(v8_str("friend"), templ->NewInstance());
+ CHECK(current->Global()
+ ->Set(current.local(), v8_str("friend"),
+ templ->NewInstance(current.local()).ToLocalChecked())
+ .FromJust());
// Test access using __proto__ from the prototype chain.
access_count = 0;
@@ -20605,7 +22205,7 @@ TEST(ScriptNameAndLineNumber) {
CHECK_EQ(13, line_number);
}
-void CheckMagicComments(Handle<Script> script, const char* expected_source_url,
+void CheckMagicComments(Local<Script> script, const char* expected_source_url,
const char* expected_source_mapping_url) {
if (expected_source_url != NULL) {
v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL());
@@ -20714,7 +22314,7 @@ TEST(GetOwnPropertyDescriptor) {
Local<Function> get =
Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get")));
CHECK(v8_num(13)->Equals(get->Call(x, 0, NULL)));
- Handle<Value> args[] = { v8_num(14) };
+ Local<Value> args[] = {v8_num(14)};
set->Call(x, 1, args);
CHECK(v8_num(14)->Equals(get->Call(x, 0, NULL)));
}
@@ -20723,14 +22323,17 @@ TEST(GetOwnPropertyDescriptor) {
TEST(Regress411877) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> object_template =
+ v8::Local<v8::ObjectTemplate> object_template =
v8::ObjectTemplate::New(isolate);
object_template->SetAccessCheckCallback(AccessCounter);
- v8::Handle<Context> context = Context::New(isolate);
+ v8::Local<Context> context = Context::New(isolate);
v8::Context::Scope context_scope(context);
- context->Global()->Set(v8_str("o"), object_template->NewInstance());
+ CHECK(context->Global()
+ ->Set(context, v8_str("o"),
+ object_template->NewInstance(context).ToLocalChecked())
+ .FromJust());
CompileRun("Object.getOwnPropertyNames(o)");
}
@@ -20738,14 +22341,15 @@ TEST(Regress411877) {
TEST(GetHiddenPropertyTableAfterAccessCheck) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> object_template =
+ v8::Local<v8::ObjectTemplate> object_template =
v8::ObjectTemplate::New(isolate);
object_template->SetAccessCheckCallback(AccessCounter);
- v8::Handle<Context> context = Context::New(isolate);
+ v8::Local<Context> context = Context::New(isolate);
v8::Context::Scope context_scope(context);
- v8::Handle<v8::Object> obj = object_template->NewInstance();
+ v8::Local<v8::Object> obj =
+ object_template->NewInstance(context).ToLocalChecked();
obj->Set(v8_str("key"), v8_str("value"));
obj->Delete(v8_str("key"));
@@ -20758,14 +22362,17 @@ TEST(GetHiddenPropertyTableAfterAccessCheck) {
TEST(Regress411793) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> object_template =
+ v8::Local<v8::ObjectTemplate> object_template =
v8::ObjectTemplate::New(isolate);
object_template->SetAccessCheckCallback(AccessCounter);
- v8::Handle<Context> context = Context::New(isolate);
+ v8::Local<Context> context = Context::New(isolate);
v8::Context::Scope context_scope(context);
- context->Global()->Set(v8_str("o"), object_template->NewInstance());
+ CHECK(context->Global()
+ ->Set(context, v8_str("o"),
+ object_template->NewInstance(context).ToLocalChecked())
+ .FromJust());
CompileRun(
"Object.defineProperty(o, 'key', "
" { get: function() {}, set: function() {} });");
@@ -20841,13 +22448,13 @@ void RunStreamingTest(const char** chunks,
v8::ScriptOrigin origin(v8_str("http://foo.com"));
char* full_source = TestSourceStream::FullSourceString(chunks);
- v8::Handle<Script> script = v8::ScriptCompiler::Compile(
+ v8::Local<Script> script = v8::ScriptCompiler::Compile(
isolate, &source, v8_str(full_source), origin);
if (expected_success) {
CHECK(!script.IsEmpty());
- v8::Handle<Value> result(script->Run());
+ v8::Local<Value> result(script->Run());
// All scripts are supposed to return the fixed value 13 when ran.
- CHECK_EQ(13, result->Int32Value());
+ CHECK_EQ(13, result->Int32Value(env.local()).FromJust());
CheckMagicComments(script, expected_source_url,
expected_source_mapping_url);
} else {
@@ -21116,7 +22723,7 @@ TEST(StreamingWithDebuggingEnabledLate) {
EnableDebugger();
- v8::Handle<Script> script = v8::ScriptCompiler::Compile(
+ v8::Local<Script> script = v8::ScriptCompiler::Compile(
isolate, &source, v8_str(full_source), origin);
Maybe<uint32_t> result =
@@ -21220,13 +22827,13 @@ TEST(StreamingWithHarmonyScopes) {
v8::ScriptOrigin origin(v8_str("http://foo.com"));
char* full_source = TestSourceStream::FullSourceString(chunks);
- v8::Handle<Script> script = v8::ScriptCompiler::Compile(
+ v8::Local<Script> script = v8::ScriptCompiler::Compile(
isolate, &source, v8_str(full_source), origin);
CHECK(!script.IsEmpty());
CHECK_EQ(false, try_catch.HasCaught());
// Running the script exposes the error.
- v8::Handle<Value> result(script->Run());
+ v8::Local<Value> result(script->Run());
CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
delete[] full_source;
@@ -21279,7 +22886,8 @@ TEST(CodeCache) {
script = v8::ScriptCompiler::Compile(context, &source, option)
.ToLocalChecked();
}
- CHECK_EQ(2, script->Run()->ToInt32(isolate2)->Int32Value());
+ CHECK_EQ(2,
+ script->Run()->ToInt32(isolate2)->Int32Value(context).FromJust());
}
isolate2->Dispose();
}
@@ -21294,10 +22902,12 @@ void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) {
DCHECK(!cached_data->rejected);
v8::ScriptOrigin origin(v8_str("origin"));
v8::ScriptCompiler::Source source(v8_str("42"), origin, cached_data);
- v8::Handle<v8::Script> script =
+ v8::Local<v8::Script> script =
v8::ScriptCompiler::Compile(CcTest::isolate(), &source, option);
CHECK(cached_data->rejected);
- CHECK_EQ(42, script->Run()->Int32Value());
+ CHECK_EQ(42, script->Run()
+ ->Int32Value(CcTest::isolate()->GetCurrentContext())
+ .FromJust());
}
@@ -21319,7 +22929,7 @@ TEST(ParserCacheRejectedGracefully) {
v8::ScriptOrigin origin(v8_str("origin"));
v8::Local<v8::String> source_str = v8_str("function foo() {}");
v8::ScriptCompiler::Source source(source_str, origin);
- v8::Handle<v8::Script> script = v8::ScriptCompiler::Compile(
+ v8::Local<v8::Script> script = v8::ScriptCompiler::Compile(
CcTest::isolate(), &source, v8::ScriptCompiler::kProduceParserCache);
CHECK(!script.IsEmpty());
const v8::ScriptCompiler::CachedData* original_cached_data =
@@ -21334,7 +22944,7 @@ TEST(ParserCacheRejectedGracefully) {
source_str, origin,
new v8::ScriptCompiler::CachedData(original_cached_data->data,
original_cached_data->length));
- v8::Handle<v8::Script> script =
+ v8::Local<v8::Script> script =
v8::ScriptCompiler::Compile(CcTest::isolate(), &source_with_cached_data,
v8::ScriptCompiler::kConsumeParserCache);
CHECK(!script.IsEmpty());
@@ -21353,7 +22963,7 @@ TEST(ParserCacheRejectedGracefully) {
incompatible_source_str, origin,
new v8::ScriptCompiler::CachedData(original_cached_data->data,
original_cached_data->length));
- v8::Handle<v8::Script> script =
+ v8::Local<v8::Script> script =
v8::ScriptCompiler::Compile(CcTest::isolate(), &source_with_cached_data,
v8::ScriptCompiler::kConsumeParserCache);
CHECK(!script.IsEmpty());
@@ -21422,11 +23032,13 @@ TEST(GetPrototypeAccessControl) {
v8::HandleScope handle_scope(isolate);
LocalContext env;
- v8::Handle<v8::ObjectTemplate> obj_template =
- v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
obj_template->SetAccessCheckCallback(AccessAlwaysBlocked);
- env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("prohibited"),
+ obj_template->NewInstance(env.local()).ToLocalChecked())
+ .FromJust());
CHECK(CompileRun(
"function f() { return %_GetPrototype(prohibited); }"
@@ -21441,19 +23053,22 @@ TEST(GetPrototypeHidden) {
v8::HandleScope handle_scope(isolate);
LocalContext env;
- Handle<FunctionTemplate> t = FunctionTemplate::New(isolate);
+ Local<FunctionTemplate> t = FunctionTemplate::New(isolate);
t->SetHiddenPrototype(true);
- Handle<Object> proto = t->GetFunction()->NewInstance();
- Handle<Object> object = Object::New(isolate);
- Handle<Object> proto2 = Object::New(isolate);
+ Local<Object> proto = t->GetFunction(env.local())
+ .ToLocalChecked()
+ ->NewInstance(env.local())
+ .ToLocalChecked();
+ Local<Object> object = Object::New(isolate);
+ Local<Object> proto2 = Object::New(isolate);
object->SetPrototype(proto);
proto->SetPrototype(proto2);
- env->Global()->Set(v8_str("object"), object);
- env->Global()->Set(v8_str("proto"), proto);
- env->Global()->Set(v8_str("proto2"), proto2);
+ CHECK(env->Global()->Set(env.local(), v8_str("object"), object).FromJust());
+ CHECK(env->Global()->Set(env.local(), v8_str("proto"), proto).FromJust());
+ CHECK(env->Global()->Set(env.local(), v8_str("proto2"), proto2).FromJust());
- v8::Handle<v8::Value> result = CompileRun("%_GetPrototype(object)");
+ v8::Local<v8::Value> result = CompileRun("%_GetPrototype(object)");
CHECK(result->Equals(proto2));
result = CompileRun(
@@ -21469,7 +23084,7 @@ TEST(ClassPrototypeCreationContext) {
v8::HandleScope handle_scope(isolate);
LocalContext env;
- Handle<Object> result = Handle<Object>::Cast(
+ Local<Object> result = Local<Object>::Cast(
CompileRun("'use strict'; class Example { }; Example.prototype"));
CHECK(env.local() == result->CreationContext());
}
@@ -21510,22 +23125,25 @@ TEST(NewStringRangeError) {
{
v8::TryCatch try_catch(isolate);
char* data = reinterpret_cast<char*>(buffer);
- CHECK(v8::String::NewFromUtf8(isolate, data, v8::String::kNormalString,
- length).IsEmpty());
+ CHECK(v8::String::NewFromUtf8(isolate, data, v8::NewStringType::kNormal,
+ length)
+ .IsEmpty());
CHECK(!try_catch.HasCaught());
}
{
v8::TryCatch try_catch(isolate);
uint8_t* data = reinterpret_cast<uint8_t*>(buffer);
- CHECK(v8::String::NewFromOneByte(isolate, data, v8::String::kNormalString,
- length).IsEmpty());
+ CHECK(v8::String::NewFromOneByte(isolate, data, v8::NewStringType::kNormal,
+ length)
+ .IsEmpty());
CHECK(!try_catch.HasCaught());
}
{
v8::TryCatch try_catch(isolate);
uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
- CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString,
- length).IsEmpty());
+ CHECK(v8::String::NewFromTwoByte(isolate, data, v8::NewStringType::kNormal,
+ length)
+ .IsEmpty());
CHECK(!try_catch.HasCaught());
}
free(buffer);
@@ -21585,11 +23203,10 @@ TEST(StrongModeAccessCheckAllowed) {
i::FLAG_strong_mode = true;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<Value> value;
+ v8::Local<Value> value;
access_was_called = false;
- v8::Handle<v8::ObjectTemplate> obj_template =
- v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42));
obj_template->SetAccessCheckCallback(AccessAlwaysAllowedWithFlag);
@@ -21597,14 +23214,15 @@ TEST(StrongModeAccessCheckAllowed) {
// Create an environment
v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template);
context0->Enter();
- v8::Handle<v8::Object> global0 = context0->Global();
- global0->Set(v8_str("object"), obj_template->NewInstance());
+ v8::Local<v8::Object> global0 = context0->Global();
+ global0->Set(v8_str("object"),
+ obj_template->NewInstance(context0).ToLocalChecked());
{
v8::TryCatch try_catch(isolate);
value = CompileRun("'use strong'; object.x");
CHECK(!try_catch.HasCaught());
CHECK(!access_was_called);
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context0).FromJust());
}
{
v8::TryCatch try_catch(isolate);
@@ -21622,14 +23240,15 @@ TEST(StrongModeAccessCheckAllowed) {
// Create an environment
v8::Local<Context> context1 = Context::New(isolate);
context1->Enter();
- v8::Handle<v8::Object> global1 = context1->Global();
- global1->Set(v8_str("object"), obj_template->NewInstance());
+ v8::Local<v8::Object> global1 = context1->Global();
+ global1->Set(v8_str("object"),
+ obj_template->NewInstance(context1).ToLocalChecked());
{
v8::TryCatch try_catch(isolate);
value = CompileRun("'use strong'; object.x");
CHECK(!try_catch.HasCaught());
CHECK(access_was_called);
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context1).FromJust());
}
access_was_called = false;
{
@@ -21655,11 +23274,10 @@ TEST(StrongModeAccessCheckBlocked) {
i::FLAG_strong_mode = true;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<Value> value;
+ v8::Local<Value> value;
access_was_called = false;
- v8::Handle<v8::ObjectTemplate> obj_template =
- v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42));
obj_template->SetAccessCheckCallback(AccessAlwaysBlockedWithFlag);
@@ -21667,14 +23285,15 @@ TEST(StrongModeAccessCheckBlocked) {
// Create an environment
v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template);
context0->Enter();
- v8::Handle<v8::Object> global0 = context0->Global();
- global0->Set(v8_str("object"), obj_template->NewInstance());
+ v8::Local<v8::Object> global0 = context0->Global();
+ global0->Set(v8_str("object"),
+ obj_template->NewInstance(context0).ToLocalChecked());
{
v8::TryCatch try_catch(isolate);
value = CompileRun("'use strong'; object.x");
CHECK(!try_catch.HasCaught());
CHECK(!access_was_called);
- CHECK_EQ(42, value->Int32Value());
+ CHECK_EQ(42, value->Int32Value(context0).FromJust());
}
{
v8::TryCatch try_catch(isolate);
@@ -21692,8 +23311,9 @@ TEST(StrongModeAccessCheckBlocked) {
// Create an environment
v8::Local<Context> context1 = Context::New(isolate);
context1->Enter();
- v8::Handle<v8::Object> global1 = context1->Global();
- global1->Set(v8_str("object"), obj_template->NewInstance());
+ v8::Local<v8::Object> global1 = context1->Global();
+ global1->Set(v8_str("object"),
+ obj_template->NewInstance(context1).ToLocalChecked());
{
v8::TryCatch try_catch(isolate);
value = CompileRun("'use strong'; object.x");
@@ -21743,14 +23363,14 @@ TEST(StrongModeArityCallFromApi) {
{
v8::TryCatch try_catch(isolate);
- v8::Handle<Value> args[] = {v8_num(42)};
+ v8::Local<Value> args[] = {v8_num(42)};
fun->Call(v8::Undefined(isolate), arraysize(args), args);
CHECK(!try_catch.HasCaught());
}
{
v8::TryCatch try_catch(isolate);
- v8::Handle<Value> args[] = {v8_num(42), v8_num(555)};
+ v8::Local<Value> args[] = {v8_num(42), v8_num(555)};
fun->Call(v8::Undefined(isolate), arraysize(args), args);
CHECK(!try_catch.HasCaught());
}
@@ -21781,14 +23401,14 @@ TEST(StrongModeArityCallFromApi2) {
{
v8::TryCatch try_catch(isolate);
- v8::Handle<Value> args[] = {v8_num(42)};
+ v8::Local<Value> args[] = {v8_num(42)};
fun->Call(v8::Undefined(isolate), arraysize(args), args);
CHECK(!try_catch.HasCaught());
}
{
v8::TryCatch try_catch(isolate);
- v8::Handle<Value> args[] = {v8_num(42), v8_num(555)};
+ v8::Local<Value> args[] = {v8_num(42), v8_num(555)};
fun->Call(v8::Undefined(isolate), arraysize(args), args);
CHECK(!try_catch.HasCaught());
}
@@ -21819,7 +23439,9 @@ TEST(StrongObjectDelete) {
static void ExtrasBindingTestRuntimeFunction(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK_EQ(3, args[0]->Int32Value());
+ CHECK_EQ(
+ 3,
+ args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust());
args.GetReturnValue().Set(v8_num(7));
}
@@ -21837,15 +23459,16 @@ TEST(ExtrasBindingObject) {
binding->Get(v8_str("testExtraShouldReturnFive")).As<v8::Function>();
auto undefined = v8::Undefined(isolate);
auto result = func->Call(undefined, 0, {}).As<v8::Number>();
- CHECK_EQ(5, result->Int32Value());
+ CHECK_EQ(5, result->Int32Value(env.local()).FromJust());
- v8::Handle<v8::FunctionTemplate> runtimeFunction =
+ v8::Local<v8::FunctionTemplate> runtimeFunction =
v8::FunctionTemplate::New(isolate, ExtrasBindingTestRuntimeFunction);
- binding->Set(v8_str("runtime"), runtimeFunction->GetFunction());
+ binding->Set(v8_str("runtime"),
+ runtimeFunction->GetFunction(env.local()).ToLocalChecked());
func =
binding->Get(v8_str("testExtraShouldCallToRuntime")).As<v8::Function>();
result = func->Call(undefined, 0, {}).As<v8::Number>();
- CHECK_EQ(7, result->Int32Value());
+ CHECK_EQ(7, result->Int32Value(env.local()).FromJust());
}
@@ -21864,15 +23487,16 @@ TEST(ExperimentalExtras) {
.As<v8::Function>();
auto undefined = v8::Undefined(isolate);
auto result = func->Call(undefined, 0, {}).As<v8::Number>();
- CHECK_EQ(10, result->Int32Value());
+ CHECK_EQ(10, result->Int32Value(env.local()).FromJust());
- v8::Handle<v8::FunctionTemplate> runtimeFunction =
+ v8::Local<v8::FunctionTemplate> runtimeFunction =
v8::FunctionTemplate::New(isolate, ExtrasBindingTestRuntimeFunction);
- binding->Set(v8_str("runtime"), runtimeFunction->GetFunction());
+ binding->Set(v8_str("runtime"),
+ runtimeFunction->GetFunction(env.local()).ToLocalChecked());
func = binding->Get(v8_str("testExperimentalExtraShouldCallToRuntime"))
.As<v8::Function>();
result = func->Call(undefined, 0, {}).As<v8::Number>();
- CHECK_EQ(7, result->Int32Value());
+ CHECK_EQ(7, result->Int32Value(env.local()).FromJust());
}
@@ -21899,19 +23523,19 @@ TEST(ExtrasUtilsObject) {
result->Get(v8_str("fulfilledPromise")).As<v8::Promise>();
fulfilled_promise->Then(store);
isolate->RunMicrotasks();
- CHECK_EQ(1, CompileRun("result")->Int32Value());
+ CHECK_EQ(1, CompileRun("result")->Int32Value(env.local()).FromJust());
auto fulfilled_promise_2 =
result->Get(v8_str("fulfilledPromise2")).As<v8::Promise>();
fulfilled_promise_2->Then(store);
isolate->RunMicrotasks();
- CHECK_EQ(2, CompileRun("result")->Int32Value());
+ CHECK_EQ(2, CompileRun("result")->Int32Value(env.local()).FromJust());
auto rejected_promise =
result->Get(v8_str("rejectedPromise")).As<v8::Promise>();
rejected_promise->Catch(store);
isolate->RunMicrotasks();
- CHECK_EQ(3, CompileRun("result")->Int32Value());
+ CHECK_EQ(3, CompileRun("result")->Int32Value(env.local()).FromJust());
}
@@ -21948,10 +23572,12 @@ TEST(Map) {
CHECK_EQ(2, map->Get(env.local(), v8::Integer::New(isolate, 1))
.ToLocalChecked()
- ->Int32Value());
+ ->Int32Value(env.local())
+ .FromJust());
CHECK_EQ(4, map->Get(env.local(), v8::Integer::New(isolate, 3))
.ToLocalChecked()
- ->Int32Value());
+ ->Int32Value(env.local())
+ .FromJust());
CHECK(map->Get(env.local(), v8::Integer::New(isolate, 42))
.ToLocalChecked()
@@ -22025,7 +23651,10 @@ TEST(CompatibleReceiverCheckOnCachedICHandler) {
v8::Local<v8::FunctionTemplate> child = v8::FunctionTemplate::New(isolate);
child->Inherit(parent);
LocalContext env;
- env->Global()->Set(v8_str("Child"), child->GetFunction());
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("Child"),
+ child->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
// Make sure there's a compiled stub for "Child.prototype.age" in the cache.
CompileRun(
@@ -22108,7 +23737,7 @@ bool NoAbortOnUncaughtException(v8::Isolate* isolate) {
TEST(AbortOnUncaughtExceptionNoAbort) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> global_template =
+ v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
LocalContext env(NULL, global_template);
@@ -22138,10 +23767,11 @@ TEST(AccessCheckedIsConcatSpreadable) {
spreadable_template->SetAccessCheckCallback(AccessBlocker);
spreadable_template->Set(v8::Symbol::GetIsConcatSpreadable(isolate),
v8::Boolean::New(isolate, true));
- Local<Object> object = spreadable_template->NewInstance();
+ Local<Object> object =
+ spreadable_template->NewInstance(env.local()).ToLocalChecked();
allowed_access = true;
- env->Global()->Set(v8_str("object"), object);
+ CHECK(env->Global()->Set(env.local(), v8_str("object"), object).FromJust());
object->Set(v8_str("length"), v8_num(2));
object->Set(0U, v8_str("a"));
object->Set(1U, v8_str("b"));
@@ -22210,9 +23840,10 @@ TEST(ObjectTemplateIntrinsics) {
Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate);
object_template->SetIntrinsicDataProperty(v8_str("values"),
v8::kArrayProto_values);
- Local<Object> object = object_template->NewInstance();
+ Local<Object> object =
+ object_template->NewInstance(env.local()).ToLocalChecked();
- env->Global()->Set(v8_str("obj1"), object);
+ CHECK(env->Global()->Set(env.local(), v8_str("obj1"), object).FromJust());
ExpectString("typeof obj1.values", "function");
auto values = Local<Function>::Cast(object->Get(v8_str("values")));
@@ -22222,8 +23853,10 @@ TEST(ObjectTemplateIntrinsics) {
{
LocalContext env2;
- Local<Object> object2 = object_template->NewInstance();
- env2->Global()->Set(v8_str("obj2"), object2);
+ Local<Object> object2 =
+ object_template->NewInstance(env2.local()).ToLocalChecked();
+ CHECK(
+ env2->Global()->Set(env2.local(), v8_str("obj2"), object2).FromJust());
ExpectString("typeof obj2.values", "function");
CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values")));
« no previous file with comments | « test/cctest/cctest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698