OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 using ::v8::TryCatch; | 73 using ::v8::TryCatch; |
74 using ::v8::Undefined; | 74 using ::v8::Undefined; |
75 using ::v8::UniqueId; | 75 using ::v8::UniqueId; |
76 using ::v8::V8; | 76 using ::v8::V8; |
77 using ::v8::Value; | 77 using ::v8::Value; |
78 | 78 |
79 | 79 |
80 static void ExpectString(const char* code, const char* expected) { | 80 static void ExpectString(const char* code, const char* expected) { |
81 Local<Value> result = CompileRun(code); | 81 Local<Value> result = CompileRun(code); |
82 CHECK(result->IsString()); | 82 CHECK(result->IsString()); |
83 String::AsciiValue ascii(result); | 83 String::Utf8Value utf8(result); |
84 CHECK_EQ(expected, *ascii); | 84 CHECK_EQ(expected, *utf8); |
85 } | 85 } |
86 | 86 |
87 static void ExpectInt32(const char* code, int expected) { | 87 static void ExpectInt32(const char* code, int expected) { |
88 Local<Value> result = CompileRun(code); | 88 Local<Value> result = CompileRun(code); |
89 CHECK(result->IsInt32()); | 89 CHECK(result->IsInt32()); |
90 CHECK_EQ(expected, result->Int32Value()); | 90 CHECK_EQ(expected, result->Int32Value()); |
91 } | 91 } |
92 | 92 |
93 static void ExpectBoolean(const char* code, bool expected) { | 93 static void ExpectBoolean(const char* code, bool expected) { |
94 Local<Value> result = CompileRun(code); | 94 Local<Value> result = CompileRun(code); |
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 | 1433 |
1434 Handle<Value> EmptyInterceptorSetter(Local<String> name, | 1434 Handle<Value> EmptyInterceptorSetter(Local<String> name, |
1435 Local<Value> value, | 1435 Local<Value> value, |
1436 const AccessorInfo& info) { | 1436 const AccessorInfo& info) { |
1437 return Handle<Value>(); | 1437 return Handle<Value>(); |
1438 } | 1438 } |
1439 | 1439 |
1440 Handle<Value> InterceptorGetter(Local<String> name, | 1440 Handle<Value> InterceptorGetter(Local<String> name, |
1441 const AccessorInfo& info) { | 1441 const AccessorInfo& info) { |
1442 // Intercept names that start with 'interceptor_'. | 1442 // Intercept names that start with 'interceptor_'. |
1443 String::AsciiValue ascii(name); | 1443 String::Utf8Value utf8(name); |
1444 char* name_str = *ascii; | 1444 char* name_str = *utf8; |
1445 char prefix[] = "interceptor_"; | 1445 char prefix[] = "interceptor_"; |
1446 int i; | 1446 int i; |
1447 for (i = 0; name_str[i] && prefix[i]; ++i) { | 1447 for (i = 0; name_str[i] && prefix[i]; ++i) { |
1448 if (name_str[i] != prefix[i]) return Handle<Value>(); | 1448 if (name_str[i] != prefix[i]) return Handle<Value>(); |
1449 } | 1449 } |
1450 Handle<Object> self = info.This(); | 1450 Handle<Object> self = info.This(); |
1451 return self->GetHiddenValue(v8_str(name_str + i)); | 1451 return self->GetHiddenValue(v8_str(name_str + i)); |
1452 } | 1452 } |
1453 | 1453 |
1454 Handle<Value> InterceptorSetter(Local<String> name, | 1454 Handle<Value> InterceptorSetter(Local<String> name, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 0, 0, 0, 0, | 1694 0, 0, 0, 0, |
1695 v8_str("data")); | 1695 v8_str("data")); |
1696 LocalContext env; | 1696 LocalContext env; |
1697 env->Global()->Set(v8_str("obj"), | 1697 env->Global()->Set(v8_str("obj"), |
1698 templ->GetFunction()->NewInstance()); | 1698 templ->GetFunction()->NewInstance()); |
1699 CHECK_EQ(echo_named_call_count, 0); | 1699 CHECK_EQ(echo_named_call_count, 0); |
1700 v8_compile("obj.x")->Run(); | 1700 v8_compile("obj.x")->Run(); |
1701 CHECK_EQ(echo_named_call_count, 1); | 1701 CHECK_EQ(echo_named_call_count, 1); |
1702 const char* code = "var str = 'oddle'; obj[str] + obj.poddle;"; | 1702 const char* code = "var str = 'oddle'; obj[str] + obj.poddle;"; |
1703 v8::Handle<Value> str = CompileRun(code); | 1703 v8::Handle<Value> str = CompileRun(code); |
1704 String::AsciiValue value(str); | 1704 String::Utf8Value value(str); |
1705 CHECK_EQ(*value, "oddlepoddle"); | 1705 CHECK_EQ(*value, "oddlepoddle"); |
1706 // Check default behavior | 1706 // Check default behavior |
1707 CHECK_EQ(v8_compile("obj.flob = 10;")->Run()->Int32Value(), 10); | 1707 CHECK_EQ(v8_compile("obj.flob = 10;")->Run()->Int32Value(), 10); |
1708 CHECK(v8_compile("'myProperty' in obj")->Run()->BooleanValue()); | 1708 CHECK(v8_compile("'myProperty' in obj")->Run()->BooleanValue()); |
1709 CHECK(v8_compile("delete obj.myProperty")->Run()->BooleanValue()); | 1709 CHECK(v8_compile("delete obj.myProperty")->Run()->BooleanValue()); |
1710 } | 1710 } |
1711 | 1711 |
1712 | 1712 |
1713 int echo_indexed_call_count = 0; | 1713 int echo_indexed_call_count = 0; |
1714 | 1714 |
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3179 | 3179 |
3180 | 3180 |
3181 THREADED_TEST(ScriptException) { | 3181 THREADED_TEST(ScriptException) { |
3182 LocalContext env; | 3182 LocalContext env; |
3183 v8::HandleScope scope(env->GetIsolate()); | 3183 v8::HandleScope scope(env->GetIsolate()); |
3184 Local<Script> script = Script::Compile(v8_str("throw 'panama!';")); | 3184 Local<Script> script = Script::Compile(v8_str("throw 'panama!';")); |
3185 v8::TryCatch try_catch; | 3185 v8::TryCatch try_catch; |
3186 Local<Value> result = script->Run(); | 3186 Local<Value> result = script->Run(); |
3187 CHECK(result.IsEmpty()); | 3187 CHECK(result.IsEmpty()); |
3188 CHECK(try_catch.HasCaught()); | 3188 CHECK(try_catch.HasCaught()); |
3189 String::AsciiValue exception_value(try_catch.Exception()); | 3189 String::Utf8Value exception_value(try_catch.Exception()); |
3190 CHECK_EQ(*exception_value, "panama!"); | 3190 CHECK_EQ(*exception_value, "panama!"); |
3191 } | 3191 } |
3192 | 3192 |
3193 | 3193 |
3194 TEST(TryCatchCustomException) { | 3194 TEST(TryCatchCustomException) { |
3195 LocalContext env; | 3195 LocalContext env; |
3196 v8::HandleScope scope(env->GetIsolate()); | 3196 v8::HandleScope scope(env->GetIsolate()); |
3197 v8::TryCatch try_catch; | 3197 v8::TryCatch try_catch; |
3198 CompileRun("function CustomError() { this.a = 'b'; }" | 3198 CompileRun("function CustomError() { this.a = 'b'; }" |
3199 "(function f() { throw new CustomError(); })();"); | 3199 "(function f() { throw new CustomError(); })();"); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3340 prop = v8_str("absent"); | 3340 prop = v8_str("absent"); |
3341 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop)); | 3341 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop)); |
3342 Local<Value> fake_prop = v8_num(1); | 3342 Local<Value> fake_prop = v8_num(1); |
3343 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(fake_prop)); | 3343 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(fake_prop)); |
3344 // exception | 3344 // exception |
3345 TryCatch try_catch; | 3345 TryCatch try_catch; |
3346 Local<Value> exception = | 3346 Local<Value> exception = |
3347 CompileRun("({ toString: function() { throw 'exception';} })"); | 3347 CompileRun("({ toString: function() { throw 'exception';} })"); |
3348 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(exception)); | 3348 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(exception)); |
3349 CHECK(try_catch.HasCaught()); | 3349 CHECK(try_catch.HasCaught()); |
3350 String::AsciiValue exception_value(try_catch.Exception()); | 3350 String::Utf8Value exception_value(try_catch.Exception()); |
3351 CHECK_EQ("exception", *exception_value); | 3351 CHECK_EQ("exception", *exception_value); |
3352 try_catch.Reset(); | 3352 try_catch.Reset(); |
3353 } | 3353 } |
3354 | 3354 |
3355 | 3355 |
3356 THREADED_TEST(Array) { | 3356 THREADED_TEST(Array) { |
3357 LocalContext context; | 3357 LocalContext context; |
3358 v8::HandleScope scope(context->GetIsolate()); | 3358 v8::HandleScope scope(context->GetIsolate()); |
3359 Local<v8::Array> array = v8::Array::New(); | 3359 Local<v8::Array> array = v8::Array::New(); |
3360 CHECK_EQ(0, array->Length()); | 3360 CHECK_EQ(0, array->Length()); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 CHECK_EQ(4, a4->Length()); | 3631 CHECK_EQ(4, a4->Length()); |
3632 CHECK_EQ(7.7, a4->Get(v8::Integer::New(0))->NumberValue()); | 3632 CHECK_EQ(7.7, a4->Get(v8::Integer::New(0))->NumberValue()); |
3633 CHECK_EQ(8.8, a4->Get(v8::Integer::New(1))->NumberValue()); | 3633 CHECK_EQ(8.8, a4->Get(v8::Integer::New(1))->NumberValue()); |
3634 CHECK_EQ(9.9, a4->Get(v8::Integer::New(2))->NumberValue()); | 3634 CHECK_EQ(9.9, a4->Get(v8::Integer::New(2))->NumberValue()); |
3635 CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue()); | 3635 CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue()); |
3636 } | 3636 } |
3637 | 3637 |
3638 | 3638 |
3639 static void CheckUncle(v8::TryCatch* try_catch) { | 3639 static void CheckUncle(v8::TryCatch* try_catch) { |
3640 CHECK(try_catch->HasCaught()); | 3640 CHECK(try_catch->HasCaught()); |
3641 String::AsciiValue str_value(try_catch->Exception()); | 3641 String::Utf8Value str_value(try_catch->Exception()); |
3642 CHECK_EQ(*str_value, "uncle?"); | 3642 CHECK_EQ(*str_value, "uncle?"); |
3643 try_catch->Reset(); | 3643 try_catch->Reset(); |
3644 } | 3644 } |
3645 | 3645 |
3646 | 3646 |
3647 THREADED_TEST(ConversionNumber) { | 3647 THREADED_TEST(ConversionNumber) { |
3648 LocalContext env; | 3648 LocalContext env; |
3649 v8::HandleScope scope(env->GetIsolate()); | 3649 v8::HandleScope scope(env->GetIsolate()); |
3650 // Very large number. | 3650 // Very large number. |
3651 CompileRun("var obj = Math.pow(2,32) * 1237;"); | 3651 CompileRun("var obj = Math.pow(2,32) * 1237;"); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4009 templ->Set(v8_str("ThrowFromC"), | 4009 templ->Set(v8_str("ThrowFromC"), |
4010 v8::FunctionTemplate::New(ThrowFromC)); | 4010 v8::FunctionTemplate::New(ThrowFromC)); |
4011 LocalContext context(0, templ); | 4011 LocalContext context(0, templ); |
4012 | 4012 |
4013 v8::TryCatch try_catch; | 4013 v8::TryCatch try_catch; |
4014 Local<Script> script | 4014 Local<Script> script |
4015 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); | 4015 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); |
4016 Local<Value> result = script->Run(); | 4016 Local<Value> result = script->Run(); |
4017 CHECK(result.IsEmpty()); | 4017 CHECK(result.IsEmpty()); |
4018 CHECK(try_catch.HasCaught()); | 4018 CHECK(try_catch.HasCaught()); |
4019 String::AsciiValue exception_value(try_catch.Exception()); | 4019 String::Utf8Value exception_value(try_catch.Exception()); |
4020 CHECK_EQ("konto", *exception_value); | 4020 CHECK_EQ("konto", *exception_value); |
4021 } | 4021 } |
4022 | 4022 |
4023 | 4023 |
4024 | 4024 |
4025 v8::Handle<Value> CThrowCountDown(const v8::Arguments& args) { | 4025 v8::Handle<Value> CThrowCountDown(const v8::Arguments& args) { |
4026 ApiTestFuzzer::Fuzz(); | 4026 ApiTestFuzzer::Fuzz(); |
4027 CHECK_EQ(4, args.Length()); | 4027 CHECK_EQ(4, args.Length()); |
4028 int count = args[0]->Int32Value(); | 4028 int count = args[0]->Int32Value(); |
4029 int cInterval = args[2]->Int32Value(); | 4029 int cInterval = args[2]->Int32Value(); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4381 "obj.x")); | 4381 "obj.x")); |
4382 result = script_define->Run(); | 4382 result = script_define->Run(); |
4383 CHECK_EQ(result, v8_num(43)); | 4383 CHECK_EQ(result, v8_num(43)); |
4384 result = script_desc->Run(); | 4384 result = script_desc->Run(); |
4385 CHECK_EQ(result->BooleanValue(), false); | 4385 CHECK_EQ(result->BooleanValue(), false); |
4386 | 4386 |
4387 // Make sure that it is not possible to redefine again | 4387 // Make sure that it is not possible to redefine again |
4388 v8::TryCatch try_catch; | 4388 v8::TryCatch try_catch; |
4389 result = script_define->Run(); | 4389 result = script_define->Run(); |
4390 CHECK(try_catch.HasCaught()); | 4390 CHECK(try_catch.HasCaught()); |
4391 String::AsciiValue exception_value(try_catch.Exception()); | 4391 String::Utf8Value exception_value(try_catch.Exception()); |
4392 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); | 4392 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
4393 } | 4393 } |
4394 | 4394 |
4395 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { | 4395 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { |
4396 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4396 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
4397 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4397 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4398 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); | 4398 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); |
4399 LocalContext context; | 4399 LocalContext context; |
4400 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 4400 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
4401 | 4401 |
(...skipping 24 matching lines...) Expand all Loading... |
4426 "obj.x")); | 4426 "obj.x")); |
4427 result = script_define->Run(); | 4427 result = script_define->Run(); |
4428 CHECK_EQ(result, v8_num(43)); | 4428 CHECK_EQ(result, v8_num(43)); |
4429 result = script_desc->Run(); | 4429 result = script_desc->Run(); |
4430 | 4430 |
4431 CHECK_EQ(result->BooleanValue(), false); | 4431 CHECK_EQ(result->BooleanValue(), false); |
4432 | 4432 |
4433 v8::TryCatch try_catch; | 4433 v8::TryCatch try_catch; |
4434 result = script_define->Run(); | 4434 result = script_define->Run(); |
4435 CHECK(try_catch.HasCaught()); | 4435 CHECK(try_catch.HasCaught()); |
4436 String::AsciiValue exception_value(try_catch.Exception()); | 4436 String::Utf8Value exception_value(try_catch.Exception()); |
4437 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); | 4437 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
4438 } | 4438 } |
4439 | 4439 |
4440 | 4440 |
4441 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, | 4441 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, |
4442 char const* name) { | 4442 char const* name) { |
4443 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name))); | 4443 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name))); |
4444 } | 4444 } |
4445 | 4445 |
4446 | 4446 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4544 CHECK(!GetGlobalProperty(&context, "obj1")-> | 4544 CHECK(!GetGlobalProperty(&context, "obj1")-> |
4545 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); | 4545 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); |
4546 CHECK(!GetGlobalProperty(&context, "obj2")-> | 4546 CHECK(!GetGlobalProperty(&context, "obj2")-> |
4547 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); | 4547 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); |
4548 | 4548 |
4549 { | 4549 { |
4550 v8::TryCatch try_catch; | 4550 v8::TryCatch try_catch; |
4551 CompileRun("Object.defineProperty(obj1, 'x'," | 4551 CompileRun("Object.defineProperty(obj1, 'x'," |
4552 "{get: function() { return 'func'; }})"); | 4552 "{get: function() { return 'func'; }})"); |
4553 CHECK(try_catch.HasCaught()); | 4553 CHECK(try_catch.HasCaught()); |
4554 String::AsciiValue exception_value(try_catch.Exception()); | 4554 String::Utf8Value exception_value(try_catch.Exception()); |
4555 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); | 4555 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
4556 } | 4556 } |
4557 { | 4557 { |
4558 v8::TryCatch try_catch; | 4558 v8::TryCatch try_catch; |
4559 CompileRun("Object.defineProperty(obj2, 'x'," | 4559 CompileRun("Object.defineProperty(obj2, 'x'," |
4560 "{get: function() { return 'func'; }})"); | 4560 "{get: function() { return 'func'; }})"); |
4561 CHECK(try_catch.HasCaught()); | 4561 CHECK(try_catch.HasCaught()); |
4562 String::AsciiValue exception_value(try_catch.Exception()); | 4562 String::Utf8Value exception_value(try_catch.Exception()); |
4563 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); | 4563 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
4564 } | 4564 } |
4565 } | 4565 } |
4566 | 4566 |
4567 | 4567 |
4568 static v8::Handle<Value> Get239Value(Local<String> name, | 4568 static v8::Handle<Value> Get239Value(Local<String> name, |
4569 const AccessorInfo& info) { | 4569 const AccessorInfo& info) { |
4570 ApiTestFuzzer::Fuzz(); | 4570 ApiTestFuzzer::Fuzz(); |
4571 CHECK_EQ(info.Data(), v8_str("donut")); | 4571 CHECK_EQ(info.Data(), v8_str("donut")); |
4572 CHECK_EQ(name, v8_str("239")); | 4572 CHECK_EQ(name, v8_str("239")); |
(...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7179 Function::Cast(*trouble_caller)->Call(global, 0, NULL); | 7179 Function::Cast(*trouble_caller)->Call(global, 0, NULL); |
7180 CHECK_EQ(1, report_count); | 7180 CHECK_EQ(1, report_count); |
7181 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); | 7181 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); |
7182 } | 7182 } |
7183 | 7183 |
7184 static const char* script_resource_name = "ExceptionInNativeScript.js"; | 7184 static const char* script_resource_name = "ExceptionInNativeScript.js"; |
7185 static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message, | 7185 static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message, |
7186 v8::Handle<Value>) { | 7186 v8::Handle<Value>) { |
7187 v8::Handle<v8::Value> name_val = message->GetScriptResourceName(); | 7187 v8::Handle<v8::Value> name_val = message->GetScriptResourceName(); |
7188 CHECK(!name_val.IsEmpty() && name_val->IsString()); | 7188 CHECK(!name_val.IsEmpty() && name_val->IsString()); |
7189 v8::String::AsciiValue name(message->GetScriptResourceName()); | 7189 v8::String::Utf8Value name(message->GetScriptResourceName()); |
7190 CHECK_EQ(script_resource_name, *name); | 7190 CHECK_EQ(script_resource_name, *name); |
7191 CHECK_EQ(3, message->GetLineNumber()); | 7191 CHECK_EQ(3, message->GetLineNumber()); |
7192 v8::String::AsciiValue source_line(message->GetSourceLine()); | 7192 v8::String::Utf8Value source_line(message->GetSourceLine()); |
7193 CHECK_EQ(" new o.foo();", *source_line); | 7193 CHECK_EQ(" new o.foo();", *source_line); |
7194 } | 7194 } |
7195 | 7195 |
7196 TEST(ExceptionInNativeScript) { | 7196 TEST(ExceptionInNativeScript) { |
7197 LocalContext env; | 7197 LocalContext env; |
7198 v8::HandleScope scope(env->GetIsolate()); | 7198 v8::HandleScope scope(env->GetIsolate()); |
7199 v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener); | 7199 v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener); |
7200 | 7200 |
7201 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback); | 7201 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback); |
7202 v8::Local<v8::Object> global = env->Global(); | 7202 v8::Local<v8::Object> global = env->Global(); |
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9041 value = object1->Get(v8_str("a")); | 9041 value = object1->Get(v8_str("a")); |
9042 CHECK(value->IsInt32()); | 9042 CHECK(value->IsInt32()); |
9043 CHECK(!try_catch.HasCaught()); | 9043 CHECK(!try_catch.HasCaught()); |
9044 CHECK_EQ(28, value->Int32Value()); | 9044 CHECK_EQ(28, value->Int32Value()); |
9045 | 9045 |
9046 // Call the Object's constructor with a String. | 9046 // Call the Object's constructor with a String. |
9047 value = CompileRun( | 9047 value = CompileRun( |
9048 "(function() { var o = new obj('tipli'); return o.a; })()"); | 9048 "(function() { var o = new obj('tipli'); return o.a; })()"); |
9049 CHECK(!try_catch.HasCaught()); | 9049 CHECK(!try_catch.HasCaught()); |
9050 CHECK(value->IsString()); | 9050 CHECK(value->IsString()); |
9051 String::AsciiValue string_value1(value->ToString()); | 9051 String::Utf8Value string_value1(value->ToString()); |
9052 CHECK_EQ("tipli", *string_value1); | 9052 CHECK_EQ("tipli", *string_value1); |
9053 | 9053 |
9054 Local<Value> args2[] = { v8_str("tipli") }; | 9054 Local<Value> args2[] = { v8_str("tipli") }; |
9055 Local<Value> value_obj2 = instance->CallAsConstructor(1, args2); | 9055 Local<Value> value_obj2 = instance->CallAsConstructor(1, args2); |
9056 CHECK(value_obj2->IsObject()); | 9056 CHECK(value_obj2->IsObject()); |
9057 Local<Object> object2 = Local<Object>::Cast(value_obj2); | 9057 Local<Object> object2 = Local<Object>::Cast(value_obj2); |
9058 value = object2->Get(v8_str("a")); | 9058 value = object2->Get(v8_str("a")); |
9059 CHECK(!try_catch.HasCaught()); | 9059 CHECK(!try_catch.HasCaught()); |
9060 CHECK(value->IsString()); | 9060 CHECK(value->IsString()); |
9061 String::AsciiValue string_value2(value->ToString()); | 9061 String::Utf8Value string_value2(value->ToString()); |
9062 CHECK_EQ("tipli", *string_value2); | 9062 CHECK_EQ("tipli", *string_value2); |
9063 | 9063 |
9064 // Call the Object's constructor with a Boolean. | 9064 // Call the Object's constructor with a Boolean. |
9065 value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); | 9065 value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); |
9066 CHECK(!try_catch.HasCaught()); | 9066 CHECK(!try_catch.HasCaught()); |
9067 CHECK(value->IsBoolean()); | 9067 CHECK(value->IsBoolean()); |
9068 CHECK_EQ(true, value->BooleanValue()); | 9068 CHECK_EQ(true, value->BooleanValue()); |
9069 | 9069 |
9070 Handle<Value> args3[] = { v8::True() }; | 9070 Handle<Value> args3[] = { v8::True() }; |
9071 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3); | 9071 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3); |
(...skipping 26 matching lines...) Expand all Loading... |
9098 // Check exception handling when there is no constructor set for the Object. | 9098 // Check exception handling when there is no constructor set for the Object. |
9099 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); | 9099 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); |
9100 Local<Object> instance = instance_template->NewInstance(); | 9100 Local<Object> instance = instance_template->NewInstance(); |
9101 context->Global()->Set(v8_str("obj2"), instance); | 9101 context->Global()->Set(v8_str("obj2"), instance); |
9102 v8::TryCatch try_catch; | 9102 v8::TryCatch try_catch; |
9103 Local<Value> value; | 9103 Local<Value> value; |
9104 CHECK(!try_catch.HasCaught()); | 9104 CHECK(!try_catch.HasCaught()); |
9105 | 9105 |
9106 value = CompileRun("new obj2(28)"); | 9106 value = CompileRun("new obj2(28)"); |
9107 CHECK(try_catch.HasCaught()); | 9107 CHECK(try_catch.HasCaught()); |
9108 String::AsciiValue exception_value1(try_catch.Exception()); | 9108 String::Utf8Value exception_value1(try_catch.Exception()); |
9109 CHECK_EQ("TypeError: object is not a function", *exception_value1); | 9109 CHECK_EQ("TypeError: object is not a function", *exception_value1); |
9110 try_catch.Reset(); | 9110 try_catch.Reset(); |
9111 | 9111 |
9112 Local<Value> args[] = { v8_num(29) }; | 9112 Local<Value> args[] = { v8_num(29) }; |
9113 value = instance->CallAsConstructor(1, args); | 9113 value = instance->CallAsConstructor(1, args); |
9114 CHECK(try_catch.HasCaught()); | 9114 CHECK(try_catch.HasCaught()); |
9115 String::AsciiValue exception_value2(try_catch.Exception()); | 9115 String::Utf8Value exception_value2(try_catch.Exception()); |
9116 CHECK_EQ("TypeError: #<Object> is not a function", *exception_value2); | 9116 CHECK_EQ("TypeError: #<Object> is not a function", *exception_value2); |
9117 try_catch.Reset(); | 9117 try_catch.Reset(); |
9118 } | 9118 } |
9119 | 9119 |
9120 // Check the case when constructor throws exception. | 9120 // Check the case when constructor throws exception. |
9121 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); | 9121 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); |
9122 instance_template->SetCallAsFunctionHandler(ThrowValue); | 9122 instance_template->SetCallAsFunctionHandler(ThrowValue); |
9123 Local<Object> instance = instance_template->NewInstance(); | 9123 Local<Object> instance = instance_template->NewInstance(); |
9124 context->Global()->Set(v8_str("obj3"), instance); | 9124 context->Global()->Set(v8_str("obj3"), instance); |
9125 v8::TryCatch try_catch; | 9125 v8::TryCatch try_catch; |
9126 Local<Value> value; | 9126 Local<Value> value; |
9127 CHECK(!try_catch.HasCaught()); | 9127 CHECK(!try_catch.HasCaught()); |
9128 | 9128 |
9129 value = CompileRun("new obj3(22)"); | 9129 value = CompileRun("new obj3(22)"); |
9130 CHECK(try_catch.HasCaught()); | 9130 CHECK(try_catch.HasCaught()); |
9131 String::AsciiValue exception_value1(try_catch.Exception()); | 9131 String::Utf8Value exception_value1(try_catch.Exception()); |
9132 CHECK_EQ("22", *exception_value1); | 9132 CHECK_EQ("22", *exception_value1); |
9133 try_catch.Reset(); | 9133 try_catch.Reset(); |
9134 | 9134 |
9135 Local<Value> args[] = { v8_num(23) }; | 9135 Local<Value> args[] = { v8_num(23) }; |
9136 value = instance->CallAsConstructor(1, args); | 9136 value = instance->CallAsConstructor(1, args); |
9137 CHECK(try_catch.HasCaught()); | 9137 CHECK(try_catch.HasCaught()); |
9138 String::AsciiValue exception_value2(try_catch.Exception()); | 9138 String::Utf8Value exception_value2(try_catch.Exception()); |
9139 CHECK_EQ("23", *exception_value2); | 9139 CHECK_EQ("23", *exception_value2); |
9140 try_catch.Reset(); | 9140 try_catch.Reset(); |
9141 } | 9141 } |
9142 | 9142 |
9143 // Check whether constructor returns with an object or non-object. | 9143 // Check whether constructor returns with an object or non-object. |
9144 { Local<FunctionTemplate> function_template = | 9144 { Local<FunctionTemplate> function_template = |
9145 FunctionTemplate::New(FakeConstructorCallback); | 9145 FunctionTemplate::New(FakeConstructorCallback); |
9146 Local<Function> function = function_template->GetFunction(); | 9146 Local<Function> function = function_template->GetFunction(); |
9147 Local<Object> instance1 = function; | 9147 Local<Object> instance1 = function; |
9148 context->Global()->Set(v8_str("obj4"), instance1); | 9148 context->Global()->Set(v8_str("obj4"), instance1); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9458 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 9458 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
9459 context->Global()->Set(v8_str("obj2"), instance); | 9459 context->Global()->Set(v8_str("obj2"), instance); |
9460 v8::TryCatch try_catch; | 9460 v8::TryCatch try_catch; |
9461 Local<Value> value; | 9461 Local<Value> value; |
9462 CHECK(!try_catch.HasCaught()); | 9462 CHECK(!try_catch.HasCaught()); |
9463 | 9463 |
9464 // Call an object without call-as-function handler through the JS | 9464 // Call an object without call-as-function handler through the JS |
9465 value = CompileRun("obj2(28)"); | 9465 value = CompileRun("obj2(28)"); |
9466 CHECK(value.IsEmpty()); | 9466 CHECK(value.IsEmpty()); |
9467 CHECK(try_catch.HasCaught()); | 9467 CHECK(try_catch.HasCaught()); |
9468 String::AsciiValue exception_value1(try_catch.Exception()); | 9468 String::Utf8Value exception_value1(try_catch.Exception()); |
9469 CHECK_EQ("TypeError: Property 'obj2' of object #<Object> is not a function", | 9469 CHECK_EQ("TypeError: Property 'obj2' of object #<Object> is not a function", |
9470 *exception_value1); | 9470 *exception_value1); |
9471 try_catch.Reset(); | 9471 try_catch.Reset(); |
9472 | 9472 |
9473 // Call an object without call-as-function handler through the API | 9473 // Call an object without call-as-function handler through the API |
9474 value = CompileRun("obj2(28)"); | 9474 value = CompileRun("obj2(28)"); |
9475 v8::Handle<Value> args[] = { v8_num(28) }; | 9475 v8::Handle<Value> args[] = { v8_num(28) }; |
9476 value = instance->CallAsFunction(instance, 1, args); | 9476 value = instance->CallAsFunction(instance, 1, args); |
9477 CHECK(value.IsEmpty()); | 9477 CHECK(value.IsEmpty()); |
9478 CHECK(try_catch.HasCaught()); | 9478 CHECK(try_catch.HasCaught()); |
9479 String::AsciiValue exception_value2(try_catch.Exception()); | 9479 String::Utf8Value exception_value2(try_catch.Exception()); |
9480 CHECK_EQ("TypeError: [object Object] is not a function", *exception_value2); | 9480 CHECK_EQ("TypeError: [object Object] is not a function", *exception_value2); |
9481 try_catch.Reset(); | 9481 try_catch.Reset(); |
9482 } | 9482 } |
9483 | 9483 |
9484 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 9484 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); |
9485 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 9485 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
9486 instance_template->SetCallAsFunctionHandler(ThrowValue); | 9486 instance_template->SetCallAsFunctionHandler(ThrowValue); |
9487 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 9487 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
9488 context->Global()->Set(v8_str("obj3"), instance); | 9488 context->Global()->Set(v8_str("obj3"), instance); |
9489 v8::TryCatch try_catch; | 9489 v8::TryCatch try_catch; |
9490 Local<Value> value; | 9490 Local<Value> value; |
9491 CHECK(!try_catch.HasCaught()); | 9491 CHECK(!try_catch.HasCaught()); |
9492 | 9492 |
9493 // Catch the exception which is thrown by call-as-function handler | 9493 // Catch the exception which is thrown by call-as-function handler |
9494 value = CompileRun("obj3(22)"); | 9494 value = CompileRun("obj3(22)"); |
9495 CHECK(try_catch.HasCaught()); | 9495 CHECK(try_catch.HasCaught()); |
9496 String::AsciiValue exception_value1(try_catch.Exception()); | 9496 String::Utf8Value exception_value1(try_catch.Exception()); |
9497 CHECK_EQ("22", *exception_value1); | 9497 CHECK_EQ("22", *exception_value1); |
9498 try_catch.Reset(); | 9498 try_catch.Reset(); |
9499 | 9499 |
9500 v8::Handle<Value> args[] = { v8_num(23) }; | 9500 v8::Handle<Value> args[] = { v8_num(23) }; |
9501 value = instance->CallAsFunction(instance, 1, args); | 9501 value = instance->CallAsFunction(instance, 1, args); |
9502 CHECK(try_catch.HasCaught()); | 9502 CHECK(try_catch.HasCaught()); |
9503 String::AsciiValue exception_value2(try_catch.Exception()); | 9503 String::Utf8Value exception_value2(try_catch.Exception()); |
9504 CHECK_EQ("23", *exception_value2); | 9504 CHECK_EQ("23", *exception_value2); |
9505 try_catch.Reset(); | 9505 try_catch.Reset(); |
9506 } | 9506 } |
9507 } | 9507 } |
9508 | 9508 |
9509 | 9509 |
9510 // Check whether a non-function object is callable. | 9510 // Check whether a non-function object is callable. |
9511 THREADED_TEST(CallableObject) { | 9511 THREADED_TEST(CallableObject) { |
9512 LocalContext context; | 9512 LocalContext context; |
9513 v8::HandleScope scope(context->GetIsolate()); | 9513 v8::HandleScope scope(context->GetIsolate()); |
(...skipping 2929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12443 v8::Handle<v8::Value> result = script->Run(); | 12443 v8::Handle<v8::Value> result = script->Run(); |
12444 CHECK(result.IsEmpty()); | 12444 CHECK(result.IsEmpty()); |
12445 CHECK(try_catch.HasCaught()); | 12445 CHECK(try_catch.HasCaught()); |
12446 v8::Handle<v8::Message> message = try_catch.Message(); | 12446 v8::Handle<v8::Message> message = try_catch.Message(); |
12447 CHECK(!message.IsEmpty()); | 12447 CHECK(!message.IsEmpty()); |
12448 CHECK_EQ(10 + line_offset, message->GetLineNumber()); | 12448 CHECK_EQ(10 + line_offset, message->GetLineNumber()); |
12449 CHECK_EQ(91, message->GetStartPosition()); | 12449 CHECK_EQ(91, message->GetStartPosition()); |
12450 CHECK_EQ(92, message->GetEndPosition()); | 12450 CHECK_EQ(92, message->GetEndPosition()); |
12451 CHECK_EQ(2, message->GetStartColumn()); | 12451 CHECK_EQ(2, message->GetStartColumn()); |
12452 CHECK_EQ(3, message->GetEndColumn()); | 12452 CHECK_EQ(3, message->GetEndColumn()); |
12453 v8::String::AsciiValue line(message->GetSourceLine()); | 12453 v8::String::Utf8Value line(message->GetSourceLine()); |
12454 CHECK_EQ(" throw 'nirk';", *line); | 12454 CHECK_EQ(" throw 'nirk';", *line); |
12455 v8::String::AsciiValue name(message->GetScriptResourceName()); | 12455 v8::String::Utf8Value name(message->GetScriptResourceName()); |
12456 CHECK_EQ(resource_name, *name); | 12456 CHECK_EQ(resource_name, *name); |
12457 } | 12457 } |
12458 | 12458 |
12459 | 12459 |
12460 THREADED_TEST(TryCatchSourceInfo) { | 12460 THREADED_TEST(TryCatchSourceInfo) { |
12461 LocalContext context; | 12461 LocalContext context; |
12462 v8::HandleScope scope(context->GetIsolate()); | 12462 v8::HandleScope scope(context->GetIsolate()); |
12463 v8::Handle<v8::String> source = v8::String::New( | 12463 v8::Handle<v8::String> source = v8::String::New( |
12464 "function Foo() {\n" | 12464 "function Foo() {\n" |
12465 " return Bar();\n" | 12465 " return Bar();\n" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12517 | 12517 |
12518 | 12518 |
12519 THREADED_TEST(CallbackFunctionName) { | 12519 THREADED_TEST(CallbackFunctionName) { |
12520 LocalContext context; | 12520 LocalContext context; |
12521 v8::HandleScope scope(context->GetIsolate()); | 12521 v8::HandleScope scope(context->GetIsolate()); |
12522 Local<ObjectTemplate> t = ObjectTemplate::New(); | 12522 Local<ObjectTemplate> t = ObjectTemplate::New(); |
12523 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback)); | 12523 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback)); |
12524 context->Global()->Set(v8_str("obj"), t->NewInstance()); | 12524 context->Global()->Set(v8_str("obj"), t->NewInstance()); |
12525 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); | 12525 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); |
12526 CHECK(value->IsString()); | 12526 CHECK(value->IsString()); |
12527 v8::String::AsciiValue name(value); | 12527 v8::String::Utf8Value name(value); |
12528 CHECK_EQ("asdf", *name); | 12528 CHECK_EQ("asdf", *name); |
12529 } | 12529 } |
12530 | 12530 |
12531 | 12531 |
12532 THREADED_TEST(DateAccess) { | 12532 THREADED_TEST(DateAccess) { |
12533 LocalContext context; | 12533 LocalContext context; |
12534 v8::HandleScope scope(context->GetIsolate()); | 12534 v8::HandleScope scope(context->GetIsolate()); |
12535 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0); | 12535 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0); |
12536 CHECK(date->IsDate()); | 12536 CHECK(date->IsDate()); |
12537 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->NumberValue()); | 12537 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->NumberValue()); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12989 unsigned* sd_data = | 12989 unsigned* sd_data = |
12990 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); | 12990 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); |
12991 | 12991 |
12992 // Overwrite function bar's end position with 0. | 12992 // Overwrite function bar's end position with 0. |
12993 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0; | 12993 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0; |
12994 v8::TryCatch try_catch; | 12994 v8::TryCatch try_catch; |
12995 | 12995 |
12996 Local<String> source = String::New(script); | 12996 Local<String> source = String::New(script); |
12997 Local<Script> compiled_script = Script::New(source, NULL, sd); | 12997 Local<Script> compiled_script = Script::New(source, NULL, sd); |
12998 CHECK(try_catch.HasCaught()); | 12998 CHECK(try_catch.HasCaught()); |
12999 String::AsciiValue exception_value(try_catch.Message()->Get()); | 12999 String::Utf8Value exception_value(try_catch.Message()->Get()); |
13000 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", | 13000 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", |
13001 *exception_value); | 13001 *exception_value); |
13002 | 13002 |
13003 try_catch.Reset(); | 13003 try_catch.Reset(); |
13004 | 13004 |
13005 // Overwrite function bar's start position with 200. The function entry | 13005 // Overwrite function bar's start position with 200. The function entry |
13006 // will not be found when searching for it by position and we should fall | 13006 // will not be found when searching for it by position and we should fall |
13007 // back on eager compilation. | 13007 // back on eager compilation. |
13008 sd = v8::ScriptData::PreCompile(script, i::StrLength(script)); | 13008 sd = v8::ScriptData::PreCompile(script, i::StrLength(script)); |
13009 sd_data = reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); | 13009 sd_data = reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); |
(...skipping 3248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16258 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 16258 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); |
16259 v8::Handle<v8::String> script = v8::String::New( | 16259 v8::Handle<v8::String> script = v8::String::New( |
16260 "function f() {}\n\nfunction g() {}"); | 16260 "function f() {}\n\nfunction g() {}"); |
16261 v8::Script::Compile(script, &origin)->Run(); | 16261 v8::Script::Compile(script, &origin)->Run(); |
16262 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 16262 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
16263 env->Global()->Get(v8::String::New("f"))); | 16263 env->Global()->Get(v8::String::New("f"))); |
16264 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 16264 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
16265 env->Global()->Get(v8::String::New("g"))); | 16265 env->Global()->Get(v8::String::New("g"))); |
16266 | 16266 |
16267 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); | 16267 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); |
16268 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_f.ResourceName())); | 16268 CHECK_EQ("test", *v8::String::Utf8Value(script_origin_f.ResourceName())); |
16269 CHECK_EQ(0, script_origin_f.ResourceLineOffset()->Int32Value()); | 16269 CHECK_EQ(0, script_origin_f.ResourceLineOffset()->Int32Value()); |
16270 | 16270 |
16271 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); | 16271 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); |
16272 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_g.ResourceName())); | 16272 CHECK_EQ("test", *v8::String::Utf8Value(script_origin_g.ResourceName())); |
16273 CHECK_EQ(0, script_origin_g.ResourceLineOffset()->Int32Value()); | 16273 CHECK_EQ(0, script_origin_g.ResourceLineOffset()->Int32Value()); |
16274 } | 16274 } |
16275 | 16275 |
16276 THREADED_TEST(FunctionGetInferredName) { | 16276 THREADED_TEST(FunctionGetInferredName) { |
16277 LocalContext env; | 16277 LocalContext env; |
16278 v8::HandleScope scope(env->GetIsolate()); | 16278 v8::HandleScope scope(env->GetIsolate()); |
16279 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 16279 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); |
16280 v8::Handle<v8::String> script = v8::String::New( | 16280 v8::Handle<v8::String> script = v8::String::New( |
16281 "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;"); | 16281 "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;"); |
16282 v8::Script::Compile(script, &origin)->Run(); | 16282 v8::Script::Compile(script, &origin)->Run(); |
16283 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 16283 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
16284 env->Global()->Get(v8::String::New("f"))); | 16284 env->Global()->Get(v8::String::New("f"))); |
16285 CHECK_EQ("foo.bar.baz", *v8::String::AsciiValue(f->GetInferredName())); | 16285 CHECK_EQ("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName())); |
16286 } | 16286 } |
16287 | 16287 |
16288 THREADED_TEST(ScriptLineNumber) { | 16288 THREADED_TEST(ScriptLineNumber) { |
16289 LocalContext env; | 16289 LocalContext env; |
16290 v8::HandleScope scope(env->GetIsolate()); | 16290 v8::HandleScope scope(env->GetIsolate()); |
16291 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 16291 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); |
16292 v8::Handle<v8::String> script = v8::String::New( | 16292 v8::Handle<v8::String> script = v8::String::New( |
16293 "function f() {}\n\nfunction g() {}"); | 16293 "function f() {}\n\nfunction g() {}"); |
16294 v8::Script::Compile(script, &origin)->Run(); | 16294 v8::Script::Compile(script, &origin)->Run(); |
16295 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 16295 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
(...skipping 2677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18973 i::Semaphore* sem_; | 18973 i::Semaphore* sem_; |
18974 volatile int sem_value_; | 18974 volatile int sem_value_; |
18975 }; | 18975 }; |
18976 | 18976 |
18977 | 18977 |
18978 THREADED_TEST(SemaphoreInterruption) { | 18978 THREADED_TEST(SemaphoreInterruption) { |
18979 ThreadInterruptTest().RunTest(); | 18979 ThreadInterruptTest().RunTest(); |
18980 } | 18980 } |
18981 | 18981 |
18982 #endif // WIN32 | 18982 #endif // WIN32 |
OLD | NEW |