Index: test/cctest/test-accessors.cc |
diff --git a/test/cctest/test-accessors.cc b/test/cctest/test-accessors.cc |
index fd620a95a613608167b23403933e73f03148edc9..8df044467940ae4edf6856d63d0a40a224707629 100644 |
--- a/test/cctest/test-accessors.cc |
+++ b/test/cctest/test-accessors.cc |
@@ -25,6 +25,9 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+// TODO(jochen): Remove this after the setting is turned on globally. |
+#define V8_IMMINENT_DEPRECATION_WARNINGS |
+ |
#include <stdlib.h> |
#include "src/v8.h" |
@@ -78,24 +81,42 @@ THREADED_TEST(PropertyHandler) { |
fun_templ->InstanceTemplate()-> |
SetNativeDataProperty(v8_str("instance_foo"), handle_property); |
fun_templ->SetNativeDataProperty(v8_str("object_foo"), handle_property_2); |
- Local<Function> fun = fun_templ->GetFunction(); |
- env->Global()->Set(v8_str("Fun"), fun); |
+ Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked(); |
+ CHECK(env->Global()->Set(env.local(), v8_str("Fun"), fun).FromJust()); |
Local<Script> getter; |
Local<Script> setter; |
// check function instance accessors |
getter = v8_compile("var obj = new Fun(); obj.instance_foo;"); |
- CHECK_EQ(900, getter->Run()->Int32Value()); |
+ CHECK_EQ(900, getter->Run(env.local()) |
+ .ToLocalChecked() |
+ ->Int32Value(env.local()) |
+ .FromJust()); |
setter = v8_compile("obj.instance_foo = 901;"); |
- CHECK_EQ(901, setter->Run()->Int32Value()); |
+ CHECK_EQ(901, setter->Run(env.local()) |
+ .ToLocalChecked() |
+ ->Int32Value(env.local()) |
+ .FromJust()); |
getter = v8_compile("obj.bar;"); |
- CHECK_EQ(907, getter->Run()->Int32Value()); |
+ CHECK_EQ(907, getter->Run(env.local()) |
+ .ToLocalChecked() |
+ ->Int32Value(env.local()) |
+ .FromJust()); |
setter = v8_compile("obj.bar = 908;"); |
- CHECK_EQ(908, setter->Run()->Int32Value()); |
+ CHECK_EQ(908, setter->Run(env.local()) |
+ .ToLocalChecked() |
+ ->Int32Value(env.local()) |
+ .FromJust()); |
// check function static accessors |
getter = v8_compile("Fun.object_foo;"); |
- CHECK_EQ(902, getter->Run()->Int32Value()); |
+ CHECK_EQ(902, getter->Run(env.local()) |
+ .ToLocalChecked() |
+ ->Int32Value(env.local()) |
+ .FromJust()); |
setter = v8_compile("Fun.object_foo = 903;"); |
- CHECK_EQ(903, setter->Run()->Int32Value()); |
+ CHECK_EQ(903, setter->Run(env.local()) |
+ .ToLocalChecked() |
+ ->Int32Value(env.local()) |
+ .FromJust()); |
} |
@@ -103,7 +124,7 @@ static void GetIntValue(Local<String> property, |
const v8::PropertyCallbackInfo<v8::Value>& info) { |
ApiTestFuzzer::Fuzz(); |
int* value = |
- static_cast<int*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); |
+ static_cast<int*>(v8::Local<v8::External>::Cast(info.Data())->Value()); |
info.GetReturnValue().Set(v8_num(*value)); |
} |
@@ -112,8 +133,8 @@ static void SetIntValue(Local<String> property, |
Local<Value> value, |
const v8::PropertyCallbackInfo<void>& info) { |
int* field = |
- static_cast<int*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); |
- *field = value->Int32Value(); |
+ static_cast<int*>(v8::Local<v8::External>::Cast(info.Data())->Value()); |
+ *field = value->Int32Value(info.GetIsolate()->GetCurrentContext()).FromJust(); |
} |
int foo, bar, baz; |
@@ -124,7 +145,7 @@ THREADED_TEST(GlobalVariableAccess) { |
baz = 10; |
v8::Isolate* isolate = CcTest::isolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
+ v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
templ->InstanceTemplate()->SetAccessor( |
v8_str("foo"), GetIntValue, SetIntValue, |
v8::External::New(isolate, &foo)); |
@@ -135,35 +156,39 @@ THREADED_TEST(GlobalVariableAccess) { |
v8_str("baz"), GetIntValue, SetIntValue, |
v8::External::New(isolate, &baz)); |
LocalContext env(0, templ->InstanceTemplate()); |
- v8_compile("foo = (++bar) + baz")->Run(); |
+ v8_compile("foo = (++bar) + baz")->Run(env.local()).ToLocalChecked(); |
CHECK_EQ(bar, -3); |
CHECK_EQ(foo, 7); |
} |
static int x_register[2] = {0, 0}; |
-static v8::Handle<v8::Object> x_receiver; |
-static v8::Handle<v8::Object> x_holder; |
+static v8::Local<v8::Object> x_receiver; |
+static v8::Local<v8::Object> x_holder; |
template<class Info> |
static void XGetter(const Info& info, int offset) { |
ApiTestFuzzer::Fuzz(); |
v8::Isolate* isolate = CcTest::isolate(); |
CHECK_EQ(isolate, info.GetIsolate()); |
- CHECK(x_receiver->Equals(info.This())); |
+ CHECK( |
+ x_receiver->Equals(isolate->GetCurrentContext(), info.This()).FromJust()); |
info.GetReturnValue().Set(v8_num(x_register[offset])); |
} |
static void XGetter(Local<String> name, |
const v8::PropertyCallbackInfo<v8::Value>& info) { |
- CHECK(x_holder->Equals(info.Holder())); |
+ CHECK(x_holder->Equals(info.GetIsolate()->GetCurrentContext(), info.Holder()) |
+ .FromJust()); |
XGetter(info, 0); |
} |
static void XGetter(const v8::FunctionCallbackInfo<v8::Value>& info) { |
- CHECK(x_receiver->Equals(info.Holder())); |
+ CHECK( |
+ x_receiver->Equals(info.GetIsolate()->GetCurrentContext(), info.Holder()) |
+ .FromJust()); |
XGetter(info, 1); |
} |
@@ -172,9 +197,12 @@ template<class Info> |
static void XSetter(Local<Value> value, const Info& info, int offset) { |
v8::Isolate* isolate = CcTest::isolate(); |
CHECK_EQ(isolate, info.GetIsolate()); |
- CHECK(x_holder->Equals(info.This())); |
- CHECK(x_holder->Equals(info.Holder())); |
- x_register[offset] = value->Int32Value(); |
+ CHECK(x_holder->Equals(info.GetIsolate()->GetCurrentContext(), info.This()) |
+ .FromJust()); |
+ CHECK(x_holder->Equals(info.GetIsolate()->GetCurrentContext(), info.Holder()) |
+ .FromJust()); |
+ x_register[offset] = |
+ value->Int32Value(info.GetIsolate()->GetCurrentContext()).FromJust(); |
info.GetReturnValue().Set(v8_num(-1)); |
} |
@@ -196,36 +224,44 @@ THREADED_TEST(AccessorIC) { |
LocalContext context; |
v8::Isolate* isolate = context->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
obj->SetAccessor(v8_str("x0"), XGetter, XSetter); |
obj->SetAccessorProperty(v8_str("x1"), |
v8::FunctionTemplate::New(isolate, XGetter), |
v8::FunctionTemplate::New(isolate, XSetter)); |
- x_holder = obj->NewInstance(); |
- context->Global()->Set(v8_str("holder"), x_holder); |
+ x_holder = obj->NewInstance(context.local()).ToLocalChecked(); |
+ CHECK(context->Global() |
+ ->Set(context.local(), v8_str("holder"), x_holder) |
+ .FromJust()); |
x_receiver = v8::Object::New(isolate); |
- context->Global()->Set(v8_str("obj"), x_receiver); |
- v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(CompileRun( |
- "obj.__proto__ = holder;" |
- "var result = [];" |
- "var key_0 = 'x0';" |
- "var key_1 = 'x1';" |
- "for (var j = 0; j < 10; j++) {" |
- " var i = 4*j;" |
- " result.push(holder.x0 = i);" |
- " result.push(obj.x0);" |
- " result.push(holder.x1 = i + 1);" |
- " result.push(obj.x1);" |
- " result.push(holder[key_0] = i + 2);" |
- " result.push(obj[key_0]);" |
- " result.push(holder[key_1] = i + 3);" |
- " result.push(obj[key_1]);" |
- "}" |
- "result")); |
+ CHECK(context->Global() |
+ ->Set(context.local(), v8_str("obj"), x_receiver) |
+ .FromJust()); |
+ v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast( |
+ CompileRun("obj.__proto__ = holder;" |
+ "var result = [];" |
+ "var key_0 = 'x0';" |
+ "var key_1 = 'x1';" |
+ "for (var j = 0; j < 10; j++) {" |
+ " var i = 4*j;" |
+ " result.push(holder.x0 = i);" |
+ " result.push(obj.x0);" |
+ " result.push(holder.x1 = i + 1);" |
+ " result.push(obj.x1);" |
+ " result.push(holder[key_0] = i + 2);" |
+ " result.push(obj[key_0]);" |
+ " result.push(holder[key_1] = i + 3);" |
+ " result.push(obj[key_1]);" |
+ "}" |
+ "result")); |
CHECK_EQ(80u, array->Length()); |
for (int i = 0; i < 80; i++) { |
- v8::Handle<Value> entry = array->Get(v8::Integer::New(isolate, i)); |
- CHECK(v8::Integer::New(isolate, i / 2)->Equals(entry)); |
+ v8::Local<Value> entry = |
+ array->Get(context.local(), v8::Integer::New(isolate, i)) |
+ .ToLocalChecked(); |
+ CHECK(v8::Integer::New(isolate, i / 2) |
+ ->Equals(context.local(), entry) |
+ .FromJust()); |
} |
} |
@@ -235,9 +271,14 @@ static void HandleAllocatingGetter( |
Local<String> name, |
const v8::PropertyCallbackInfo<v8::Value>& info) { |
ApiTestFuzzer::Fuzz(); |
- for (int i = 0; i < C; i++) |
- v8::String::NewFromUtf8(info.GetIsolate(), "foo"); |
- info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "foo")); |
+ for (int i = 0; i < C; i++) { |
+ v8::String::NewFromUtf8(info.GetIsolate(), "foo", |
+ v8::NewStringType::kNormal) |
+ .ToLocalChecked(); |
+ } |
+ info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "foo", |
+ v8::NewStringType::kNormal) |
+ .ToLocalChecked()); |
} |
@@ -245,11 +286,13 @@ THREADED_TEST(HandleScopePop) { |
LocalContext context; |
v8::Isolate* isolate = context->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
obj->SetAccessor(v8_str("one"), HandleAllocatingGetter<1>); |
obj->SetAccessor(v8_str("many"), HandleAllocatingGetter<1024>); |
- v8::Handle<v8::Object> inst = obj->NewInstance(); |
- context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst); |
+ v8::Local<v8::Object> inst = |
+ obj->NewInstance(context.local()).ToLocalChecked(); |
+ CHECK( |
+ context->Global()->Set(context.local(), v8_str("obj"), inst).FromJust()); |
int count_before = |
i::HandleScope::NumberOfHandles(reinterpret_cast<i::Isolate*>(isolate)); |
{ |
@@ -270,18 +313,21 @@ static void CheckAccessorArgsCorrect( |
const v8::PropertyCallbackInfo<v8::Value>& info) { |
CHECK(info.GetIsolate() == CcTest::isolate()); |
CHECK(info.This() == info.Holder()); |
- CHECK( |
- info.Data()->Equals(v8::String::NewFromUtf8(CcTest::isolate(), "data"))); |
+ CHECK(info.Data() |
+ ->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("data")) |
+ .FromJust()); |
ApiTestFuzzer::Fuzz(); |
CHECK(info.GetIsolate() == CcTest::isolate()); |
CHECK(info.This() == info.Holder()); |
- CHECK( |
- info.Data()->Equals(v8::String::NewFromUtf8(CcTest::isolate(), "data"))); |
+ CHECK(info.Data() |
+ ->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("data")) |
+ .FromJust()); |
CcTest::heap()->CollectAllGarbage(); |
CHECK(info.GetIsolate() == CcTest::isolate()); |
CHECK(info.This() == info.Holder()); |
- CHECK( |
- info.Data()->Equals(v8::String::NewFromUtf8(CcTest::isolate(), "data"))); |
+ CHECK(info.Data() |
+ ->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("data")) |
+ .FromJust()); |
info.GetReturnValue().Set(17); |
} |
@@ -290,20 +336,19 @@ THREADED_TEST(DirectCall) { |
LocalContext context; |
v8::Isolate* isolate = context->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
- obj->SetAccessor(v8_str("xxx"), |
- CheckAccessorArgsCorrect, |
- NULL, |
- v8::String::NewFromUtf8(isolate, "data")); |
- v8::Handle<v8::Object> inst = obj->NewInstance(); |
- context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), |
- inst); |
- Local<Script> scr = v8::Script::Compile( |
- v8::String::NewFromUtf8(isolate, "obj.xxx")); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ obj->SetAccessor(v8_str("xxx"), CheckAccessorArgsCorrect, NULL, |
+ v8_str("data")); |
+ v8::Local<v8::Object> inst = |
+ obj->NewInstance(context.local()).ToLocalChecked(); |
+ CHECK( |
+ context->Global()->Set(context.local(), v8_str("obj"), inst).FromJust()); |
+ Local<Script> scr = |
+ v8::Script::Compile(context.local(), v8_str("obj.xxx")).ToLocalChecked(); |
for (int i = 0; i < 10; i++) { |
- Local<Value> result = scr->Run(); |
+ Local<Value> result = scr->Run(context.local()).ToLocalChecked(); |
CHECK(!result.IsEmpty()); |
- CHECK_EQ(17, result->Int32Value()); |
+ CHECK_EQ(17, result->Int32Value(context.local()).FromJust()); |
} |
} |
@@ -312,7 +357,7 @@ static void EmptyGetter(Local<String> name, |
CheckAccessorArgsCorrect(name, info); |
ApiTestFuzzer::Fuzz(); |
CheckAccessorArgsCorrect(name, info); |
- info.GetReturnValue().Set(v8::Handle<v8::Value>()); |
+ info.GetReturnValue().Set(v8::Local<v8::Value>()); |
} |
@@ -320,15 +365,16 @@ THREADED_TEST(EmptyResult) { |
LocalContext context; |
v8::Isolate* isolate = context->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
- obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, |
- v8::String::NewFromUtf8(isolate, "data")); |
- v8::Handle<v8::Object> inst = obj->NewInstance(); |
- context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8_str("data")); |
+ v8::Local<v8::Object> inst = |
+ obj->NewInstance(context.local()).ToLocalChecked(); |
+ CHECK( |
+ context->Global()->Set(context.local(), v8_str("obj"), inst).FromJust()); |
Local<Script> scr = |
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx")); |
+ v8::Script::Compile(context.local(), v8_str("obj.xxx")).ToLocalChecked(); |
for (int i = 0; i < 10; i++) { |
- Local<Value> result = scr->Run(); |
+ Local<Value> result = scr->Run(context.local()).ToLocalChecked(); |
CHECK(result == v8::Undefined(isolate)); |
} |
} |
@@ -340,34 +386,37 @@ THREADED_TEST(NoReuseRegress) { |
v8::Isolate* isolate = CcTest::isolate(); |
v8::HandleScope scope(isolate); |
{ |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
- obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, |
- v8::String::NewFromUtf8(isolate, "data")); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8_str("data")); |
LocalContext context; |
- v8::Handle<v8::Object> inst = obj->NewInstance(); |
- context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst); |
- Local<Script> scr = |
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx")); |
+ v8::Local<v8::Object> inst = |
+ obj->NewInstance(context.local()).ToLocalChecked(); |
+ CHECK(context->Global() |
+ ->Set(context.local(), v8_str("obj"), inst) |
+ .FromJust()); |
+ Local<Script> scr = v8::Script::Compile(context.local(), v8_str("obj.xxx")) |
+ .ToLocalChecked(); |
for (int i = 0; i < 2; i++) { |
- Local<Value> result = scr->Run(); |
+ Local<Value> result = scr->Run(context.local()).ToLocalChecked(); |
CHECK(result == v8::Undefined(isolate)); |
} |
} |
{ |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
- obj->SetAccessor(v8_str("xxx"), |
- CheckAccessorArgsCorrect, |
- NULL, |
- v8::String::NewFromUtf8(isolate, "data")); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ obj->SetAccessor(v8_str("xxx"), CheckAccessorArgsCorrect, NULL, |
+ v8_str("data")); |
LocalContext context; |
- v8::Handle<v8::Object> inst = obj->NewInstance(); |
- context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst); |
- Local<Script> scr = |
- v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx")); |
+ v8::Local<v8::Object> inst = |
+ obj->NewInstance(context.local()).ToLocalChecked(); |
+ CHECK(context->Global() |
+ ->Set(context.local(), v8_str("obj"), inst) |
+ .FromJust()); |
+ Local<Script> scr = v8::Script::Compile(context.local(), v8_str("obj.xxx")) |
+ .ToLocalChecked(); |
for (int i = 0; i < 10; i++) { |
- Local<Value> result = scr->Run(); |
+ Local<Value> result = scr->Run(context.local()).ToLocalChecked(); |
CHECK(!result.IsEmpty()); |
- CHECK_EQ(17, result->Int32Value()); |
+ CHECK_EQ(17, result->Int32Value(context.local()).FromJust()); |
} |
} |
} |
@@ -391,31 +440,40 @@ THREADED_TEST(Regress1054726) { |
LocalContext env; |
v8::Isolate* isolate = env->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
obj->SetAccessor(v8_str("x"), |
ThrowingGetAccessor, |
ThrowingSetAccessor, |
Local<Value>()); |
- env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
+ CHECK(env->Global() |
+ ->Set(env.local(), v8_str("obj"), |
+ obj->NewInstance(env.local()).ToLocalChecked()) |
+ .FromJust()); |
// Use the throwing property setter/getter in a loop to force |
// the accessor ICs to be initialized. |
- v8::Handle<Value> result; |
- result = Script::Compile(v8_str( |
- "var result = '';" |
- "for (var i = 0; i < 5; i++) {" |
- " try { obj.x; } catch (e) { result += e; }" |
- "}; result"))->Run(); |
- CHECK(v8_str("ggggg")->Equals(result)); |
- |
- result = Script::Compile(String::NewFromUtf8( |
- isolate, |
- "var result = '';" |
- "for (var i = 0; i < 5; i++) {" |
- " try { obj.x = i; } catch (e) { result += e; }" |
- "}; result"))->Run(); |
- CHECK(v8_str("01234")->Equals(result)); |
+ v8::Local<Value> result; |
+ result = Script::Compile(env.local(), |
+ v8_str("var result = '';" |
+ "for (var i = 0; i < 5; i++) {" |
+ " try { obj.x; } catch (e) { result += e; }" |
+ "}; result")) |
+ .ToLocalChecked() |
+ ->Run(env.local()) |
+ .ToLocalChecked(); |
+ CHECK(v8_str("ggggg")->Equals(env.local(), result).FromJust()); |
+ |
+ result = |
+ Script::Compile(env.local(), |
+ v8_str("var result = '';" |
+ "for (var i = 0; i < 5; i++) {" |
+ " try { obj.x = i; } catch (e) { result += e; }" |
+ "}; result")) |
+ .ToLocalChecked() |
+ ->Run(env.local()) |
+ .ToLocalChecked(); |
+ CHECK(v8_str("01234")->Equals(env.local(), result).FromJust()); |
} |
@@ -430,17 +488,21 @@ THREADED_TEST(Gc) { |
LocalContext env; |
v8::Isolate* isolate = env->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
obj->SetAccessor(v8_str("xxx"), AllocGetter); |
- env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
- Script::Compile(String::NewFromUtf8( |
- isolate, |
- "var last = [];" |
- "for (var i = 0; i < 2048; i++) {" |
- " var result = obj.xxx;" |
- " result[0] = last;" |
- " last = result;" |
- "}"))->Run(); |
+ CHECK(env->Global() |
+ ->Set(env.local(), v8_str("obj"), |
+ obj->NewInstance(env.local()).ToLocalChecked()) |
+ .FromJust()); |
+ Script::Compile(env.local(), v8_str("var last = [];" |
+ "for (var i = 0; i < 2048; i++) {" |
+ " var result = obj.xxx;" |
+ " result[0] = last;" |
+ " last = result;" |
+ "}")) |
+ .ToLocalChecked() |
+ ->Run(env.local()) |
+ .ToLocalChecked(); |
} |
@@ -463,19 +525,23 @@ THREADED_TEST(StackIteration) { |
LocalContext env; |
v8::Isolate* isolate = env->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
i::StringStream::ClearMentionedObjectCache( |
reinterpret_cast<i::Isolate*>(isolate)); |
obj->SetAccessor(v8_str("xxx"), StackCheck); |
- env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
- Script::Compile(String::NewFromUtf8( |
- isolate, |
- "function foo() {" |
- " return obj.xxx;" |
- "}" |
- "for (var i = 0; i < 100; i++) {" |
- " foo();" |
- "}"))->Run(); |
+ CHECK(env->Global() |
+ ->Set(env.local(), v8_str("obj"), |
+ obj->NewInstance(env.local()).ToLocalChecked()) |
+ .FromJust()); |
+ Script::Compile(env.local(), v8_str("function foo() {" |
+ " return obj.xxx;" |
+ "}" |
+ "for (var i = 0; i < 100; i++) {" |
+ " foo();" |
+ "}")) |
+ .ToLocalChecked() |
+ ->Run(env.local()) |
+ .ToLocalChecked(); |
} |
@@ -494,22 +560,28 @@ THREADED_TEST(HandleScopeSegment) { |
LocalContext env; |
v8::Isolate* isolate = env->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
obj->SetAccessor(v8_str("xxx"), AllocateHandles); |
- env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
- v8::Handle<v8::Value> result = Script::Compile(String::NewFromUtf8( |
- isolate, |
- "var result;" |
- "for (var i = 0; i < 4; i++)" |
- " result = obj.xxx;" |
- "result;"))->Run(); |
- CHECK_EQ(100, result->Int32Value()); |
+ CHECK(env->Global() |
+ ->Set(env.local(), v8_str("obj"), |
+ obj->NewInstance(env.local()).ToLocalChecked()) |
+ .FromJust()); |
+ v8::Local<v8::Value> result = |
+ Script::Compile(env.local(), v8_str("var result;" |
+ "for (var i = 0; i < 4; i++)" |
+ " result = obj.xxx;" |
+ "result;")) |
+ .ToLocalChecked() |
+ ->Run(env.local()) |
+ .ToLocalChecked(); |
+ CHECK_EQ(100, result->Int32Value(env.local()).FromJust()); |
} |
void JSONStringifyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { |
- v8::Handle<v8::Array> array = v8::Array::New(info.GetIsolate(), 1); |
- array->Set(0, v8_str("regress")); |
+ v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), 1); |
+ CHECK(array->Set(info.GetIsolate()->GetCurrentContext(), 0, v8_str("regress")) |
+ .FromJust()); |
info.GetReturnValue().Set(array); |
} |
@@ -525,12 +597,17 @@ THREADED_TEST(JSONStringifyNamedInterceptorObject) { |
v8::Isolate* isolate = env->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
obj->SetHandler(v8::NamedPropertyHandlerConfiguration( |
JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator)); |
- env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
- v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); |
- CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); |
+ CHECK(env->Global() |
+ ->Set(env.local(), v8_str("obj"), |
+ obj->NewInstance(env.local()).ToLocalChecked()) |
+ .FromJust()); |
+ v8::Local<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); |
+ CHECK(CompileRun("JSON.stringify(obj)") |
+ ->Equals(env.local(), expected) |
+ .FromJust()); |
} |
@@ -549,9 +626,12 @@ THREADED_TEST(AccessorPropertyCrossContext) { |
LocalContext env; |
v8::Isolate* isolate = env->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::Function> fun = v8::Function::New(isolate, check_contexts); |
+ v8::Local<v8::Function> fun = |
+ v8::Function::New(env.local(), check_contexts).ToLocalChecked(); |
LocalContext switch_context; |
- switch_context->Global()->Set(v8_str("fun"), fun); |
+ CHECK(switch_context->Global() |
+ ->Set(switch_context.local(), v8_str("fun"), fun) |
+ .FromJust()); |
v8::TryCatch try_catch(isolate); |
expected_current_context = env.local(); |
expected_calling_context = switch_context.local(); |
@@ -597,10 +677,13 @@ THREADED_TEST(Regress433458) { |
LocalContext env; |
v8::Isolate* isolate = env->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
+ v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
obj->SetHandler(v8::NamedPropertyHandlerConfiguration(EmptyGetter)); |
obj->SetNativeDataProperty(v8_str("prop"), OneProperty); |
- env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
+ CHECK(env->Global() |
+ ->Set(env.local(), v8_str("obj"), |
+ obj->NewInstance(env.local()).ToLocalChecked()) |
+ .FromJust()); |
CompileRun( |
"Object.defineProperty(obj, 'prop', { writable: false });" |
"Object.defineProperty(obj, 'prop', { writable: true });"); |
@@ -628,9 +711,18 @@ TEST(PrototypeGetterAccessCheck) { |
getter_templ); |
auto obj_templ = v8::ObjectTemplate::New(isolate); |
obj_templ->SetAccessCheckCallback(SecurityTestCallback); |
- env->Global()->Set(v8_str("Fun"), fun_templ->GetFunction()); |
- env->Global()->Set(v8_str("obj"), obj_templ->NewInstance()); |
- env->Global()->Set(v8_str("obj2"), obj_templ->NewInstance()); |
+ CHECK(env->Global() |
+ ->Set(env.local(), v8_str("Fun"), |
+ fun_templ->GetFunction(env.local()).ToLocalChecked()) |
+ .FromJust()); |
+ CHECK(env->Global() |
+ ->Set(env.local(), v8_str("obj"), |
+ obj_templ->NewInstance(env.local()).ToLocalChecked()) |
+ .FromJust()); |
+ CHECK(env->Global() |
+ ->Set(env.local(), v8_str("obj2"), |
+ obj_templ->NewInstance(env.local()).ToLocalChecked()) |
+ .FromJust()); |
security_check_value = true; |
CompileRun("var proto = new Fun();"); |