| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 v8::Isolate* isolate) { | 183 v8::Isolate* isolate) { |
| 184 i::ScopedVector<char> source(200); | 184 i::ScopedVector<char> source(200); |
| 185 i::SNPrintF(source, | 185 i::SNPrintF(source, |
| 186 "for (var i = 0; i < 10; i++) {" | 186 "for (var i = 0; i < 10; i++) {" |
| 187 " %s" | 187 " %s" |
| 188 "}", | 188 "}", |
| 189 loop_js); | 189 loop_js); |
| 190 signature_callback_count = 0; | 190 signature_callback_count = 0; |
| 191 signature_expected_receiver = receiver; | 191 signature_expected_receiver = receiver; |
| 192 bool expected_to_throw = receiver.IsEmpty(); | 192 bool expected_to_throw = receiver.IsEmpty(); |
| 193 v8::TryCatch try_catch; | 193 v8::TryCatch try_catch(isolate); |
| 194 CompileRun(source.start()); | 194 CompileRun(source.start()); |
| 195 CHECK_EQ(expected_to_throw, try_catch.HasCaught()); | 195 CHECK_EQ(expected_to_throw, try_catch.HasCaught()); |
| 196 if (!expected_to_throw) { | 196 if (!expected_to_throw) { |
| 197 CHECK_EQ(10, signature_callback_count); | 197 CHECK_EQ(10, signature_callback_count); |
| 198 } else { | 198 } else { |
| 199 CHECK(v8_str("TypeError: Illegal invocation") | 199 CHECK(v8_str("TypeError: Illegal invocation") |
| 200 ->Equals(try_catch.Exception()->ToString(isolate))); | 200 ->Equals(try_catch.Exception()->ToString(isolate))); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 private: | 690 private: |
| 691 char string_[10]; | 691 char string_[10]; |
| 692 int length_; | 692 int length_; |
| 693 }; | 693 }; |
| 694 | 694 |
| 695 | 695 |
| 696 THREADED_TEST(NewExternalForVeryLongString) { | 696 THREADED_TEST(NewExternalForVeryLongString) { |
| 697 auto isolate = CcTest::isolate(); | 697 auto isolate = CcTest::isolate(); |
| 698 { | 698 { |
| 699 v8::HandleScope scope(isolate); | 699 v8::HandleScope scope(isolate); |
| 700 v8::TryCatch try_catch; | 700 v8::TryCatch try_catch(isolate); |
| 701 RandomLengthOneByteResource r(1 << 30); | 701 RandomLengthOneByteResource r(1 << 30); |
| 702 v8::Local<v8::String> str = v8::String::NewExternal(isolate, &r); | 702 v8::Local<v8::String> str = v8::String::NewExternal(isolate, &r); |
| 703 CHECK(str.IsEmpty()); | 703 CHECK(str.IsEmpty()); |
| 704 CHECK(!try_catch.HasCaught()); | 704 CHECK(!try_catch.HasCaught()); |
| 705 } | 705 } |
| 706 | 706 |
| 707 { | 707 { |
| 708 v8::HandleScope scope(isolate); | 708 v8::HandleScope scope(isolate); |
| 709 v8::TryCatch try_catch; | 709 v8::TryCatch try_catch(isolate); |
| 710 RandomLengthResource r(1 << 30); | 710 RandomLengthResource r(1 << 30); |
| 711 v8::Local<v8::String> str = v8::String::NewExternal(isolate, &r); | 711 v8::Local<v8::String> str = v8::String::NewExternal(isolate, &r); |
| 712 CHECK(str.IsEmpty()); | 712 CHECK(str.IsEmpty()); |
| 713 CHECK(!try_catch.HasCaught()); | 713 CHECK(!try_catch.HasCaught()); |
| 714 } | 714 } |
| 715 } | 715 } |
| 716 | 716 |
| 717 | 717 |
| 718 THREADED_TEST(ScavengeExternalString) { | 718 THREADED_TEST(ScavengeExternalString) { |
| 719 i::FLAG_stress_compaction = false; | 719 i::FLAG_stress_compaction = false; |
| (...skipping 3285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4005 | 4005 |
| 4006 // All objects should be gone. 7 global handles in total. | 4006 // All objects should be gone. 7 global handles in total. |
| 4007 CHECK_EQ(7, counter.NumberOfWeakCalls()); | 4007 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
| 4008 } | 4008 } |
| 4009 | 4009 |
| 4010 | 4010 |
| 4011 THREADED_TEST(ScriptException) { | 4011 THREADED_TEST(ScriptException) { |
| 4012 LocalContext env; | 4012 LocalContext env; |
| 4013 v8::HandleScope scope(env->GetIsolate()); | 4013 v8::HandleScope scope(env->GetIsolate()); |
| 4014 Local<Script> script = v8_compile("throw 'panama!';"); | 4014 Local<Script> script = v8_compile("throw 'panama!';"); |
| 4015 v8::TryCatch try_catch; | 4015 v8::TryCatch try_catch(env->GetIsolate()); |
| 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::Utf8Value exception_value(try_catch.Exception()); | 4019 String::Utf8Value exception_value(try_catch.Exception()); |
| 4020 CHECK_EQ(0, strcmp(*exception_value, "panama!")); | 4020 CHECK_EQ(0, strcmp(*exception_value, "panama!")); |
| 4021 } | 4021 } |
| 4022 | 4022 |
| 4023 | 4023 |
| 4024 TEST(TryCatchCustomException) { | 4024 TEST(TryCatchCustomException) { |
| 4025 LocalContext env; | 4025 LocalContext env; |
| 4026 v8::Isolate* isolate = env->GetIsolate(); | 4026 v8::Isolate* isolate = env->GetIsolate(); |
| 4027 v8::HandleScope scope(isolate); | 4027 v8::HandleScope scope(isolate); |
| 4028 v8::TryCatch try_catch; | 4028 v8::TryCatch try_catch(isolate); |
| 4029 CompileRun( | 4029 CompileRun( |
| 4030 "function CustomError() { this.a = 'b'; }" | 4030 "function CustomError() { this.a = 'b'; }" |
| 4031 "(function f() { throw new CustomError(); })();"); | 4031 "(function f() { throw new CustomError(); })();"); |
| 4032 CHECK(try_catch.HasCaught()); | 4032 CHECK(try_catch.HasCaught()); |
| 4033 CHECK(try_catch.Exception() | 4033 CHECK(try_catch.Exception() |
| 4034 ->ToObject(isolate) | 4034 ->ToObject(isolate) |
| 4035 ->Get(v8_str("a")) | 4035 ->Get(v8_str("a")) |
| 4036 ->Equals(v8_str("b"))); | 4036 ->Equals(v8_str("b"))); |
| 4037 } | 4037 } |
| 4038 | 4038 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4350 // dont-enum | 4350 // dont-enum |
| 4351 prop = v8_str("dont_enum"); | 4351 prop = v8_str("dont_enum"); |
| 4352 context->Global()->ForceSet(prop, v8_num(28), v8::DontEnum); | 4352 context->Global()->ForceSet(prop, v8_num(28), v8::DontEnum); |
| 4353 CHECK_EQ(v8::DontEnum, context->Global()->GetPropertyAttributes(prop)); | 4353 CHECK_EQ(v8::DontEnum, context->Global()->GetPropertyAttributes(prop)); |
| 4354 // absent | 4354 // absent |
| 4355 prop = v8_str("absent"); | 4355 prop = v8_str("absent"); |
| 4356 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop)); | 4356 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop)); |
| 4357 Local<Value> fake_prop = v8_num(1); | 4357 Local<Value> fake_prop = v8_num(1); |
| 4358 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(fake_prop)); | 4358 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(fake_prop)); |
| 4359 // exception | 4359 // exception |
| 4360 TryCatch try_catch; | 4360 TryCatch try_catch(context->GetIsolate()); |
| 4361 Local<Value> exception = | 4361 Local<Value> exception = |
| 4362 CompileRun("({ toString: function() { throw 'exception';} })"); | 4362 CompileRun("({ toString: function() { throw 'exception';} })"); |
| 4363 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(exception)); | 4363 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(exception)); |
| 4364 CHECK(try_catch.HasCaught()); | 4364 CHECK(try_catch.HasCaught()); |
| 4365 String::Utf8Value exception_value(try_catch.Exception()); | 4365 String::Utf8Value exception_value(try_catch.Exception()); |
| 4366 CHECK_EQ(0, strcmp("exception", *exception_value)); | 4366 CHECK_EQ(0, strcmp("exception", *exception_value)); |
| 4367 try_catch.Reset(); | 4367 try_catch.Reset(); |
| 4368 } | 4368 } |
| 4369 | 4369 |
| 4370 | 4370 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4745 args.GetIsolate()->ThrowException(v8_str("konto")); | 4745 args.GetIsolate()->ThrowException(v8_str("konto")); |
| 4746 } | 4746 } |
| 4747 | 4747 |
| 4748 | 4748 |
| 4749 void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4749 void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4750 if (args.Length() < 1) { | 4750 if (args.Length() < 1) { |
| 4751 args.GetReturnValue().Set(false); | 4751 args.GetReturnValue().Set(false); |
| 4752 return; | 4752 return; |
| 4753 } | 4753 } |
| 4754 v8::HandleScope scope(args.GetIsolate()); | 4754 v8::HandleScope scope(args.GetIsolate()); |
| 4755 v8::TryCatch try_catch; | 4755 v8::TryCatch try_catch(args.GetIsolate()); |
| 4756 Local<Value> result = CompileRun(args[0]->ToString(args.GetIsolate())); | 4756 Local<Value> result = CompileRun(args[0]->ToString(args.GetIsolate())); |
| 4757 CHECK(!try_catch.HasCaught() || result.IsEmpty()); | 4757 CHECK(!try_catch.HasCaught() || result.IsEmpty()); |
| 4758 args.GetReturnValue().Set(try_catch.HasCaught()); | 4758 args.GetReturnValue().Set(try_catch.HasCaught()); |
| 4759 } | 4759 } |
| 4760 | 4760 |
| 4761 | 4761 |
| 4762 THREADED_TEST(APICatch) { | 4762 THREADED_TEST(APICatch) { |
| 4763 v8::Isolate* isolate = CcTest::isolate(); | 4763 v8::Isolate* isolate = CcTest::isolate(); |
| 4764 v8::HandleScope scope(isolate); | 4764 v8::HandleScope scope(isolate); |
| 4765 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 4765 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4778 } | 4778 } |
| 4779 | 4779 |
| 4780 | 4780 |
| 4781 THREADED_TEST(APIThrowTryCatch) { | 4781 THREADED_TEST(APIThrowTryCatch) { |
| 4782 v8::Isolate* isolate = CcTest::isolate(); | 4782 v8::Isolate* isolate = CcTest::isolate(); |
| 4783 v8::HandleScope scope(isolate); | 4783 v8::HandleScope scope(isolate); |
| 4784 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 4784 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 4785 templ->Set(v8_str("ThrowFromC"), | 4785 templ->Set(v8_str("ThrowFromC"), |
| 4786 v8::FunctionTemplate::New(isolate, ThrowFromC)); | 4786 v8::FunctionTemplate::New(isolate, ThrowFromC)); |
| 4787 LocalContext context(0, templ); | 4787 LocalContext context(0, templ); |
| 4788 v8::TryCatch try_catch; | 4788 v8::TryCatch try_catch(isolate); |
| 4789 CompileRun("ThrowFromC();"); | 4789 CompileRun("ThrowFromC();"); |
| 4790 CHECK(try_catch.HasCaught()); | 4790 CHECK(try_catch.HasCaught()); |
| 4791 } | 4791 } |
| 4792 | 4792 |
| 4793 | 4793 |
| 4794 // Test that a try-finally block doesn't shadow a try-catch block | 4794 // Test that a try-finally block doesn't shadow a try-catch block |
| 4795 // when setting up an external handler. | 4795 // when setting up an external handler. |
| 4796 // | 4796 // |
| 4797 // BUG(271): Some of the exception propagation does not work on the | 4797 // BUG(271): Some of the exception propagation does not work on the |
| 4798 // ARM simulator because the simulator separates the C++ stack and the | 4798 // ARM simulator because the simulator separates the C++ stack and the |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4994 | 4994 |
| 4995 TEST(APIThrowMessageAndVerboseTryCatch) { | 4995 TEST(APIThrowMessageAndVerboseTryCatch) { |
| 4996 message_received = false; | 4996 message_received = false; |
| 4997 v8::Isolate* isolate = CcTest::isolate(); | 4997 v8::Isolate* isolate = CcTest::isolate(); |
| 4998 v8::HandleScope scope(isolate); | 4998 v8::HandleScope scope(isolate); |
| 4999 v8::V8::AddMessageListener(receive_message); | 4999 v8::V8::AddMessageListener(receive_message); |
| 5000 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5000 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 5001 templ->Set(v8_str("ThrowFromC"), | 5001 templ->Set(v8_str("ThrowFromC"), |
| 5002 v8::FunctionTemplate::New(isolate, ThrowFromC)); | 5002 v8::FunctionTemplate::New(isolate, ThrowFromC)); |
| 5003 LocalContext context(0, templ); | 5003 LocalContext context(0, templ); |
| 5004 v8::TryCatch try_catch; | 5004 v8::TryCatch try_catch(isolate); |
| 5005 try_catch.SetVerbose(true); | 5005 try_catch.SetVerbose(true); |
| 5006 Local<Value> result = CompileRun("ThrowFromC();"); | 5006 Local<Value> result = CompileRun("ThrowFromC();"); |
| 5007 CHECK(try_catch.HasCaught()); | 5007 CHECK(try_catch.HasCaught()); |
| 5008 CHECK(result.IsEmpty()); | 5008 CHECK(result.IsEmpty()); |
| 5009 CHECK(message_received); | 5009 CHECK(message_received); |
| 5010 v8::V8::RemoveMessageListeners(receive_message); | 5010 v8::V8::RemoveMessageListeners(receive_message); |
| 5011 } | 5011 } |
| 5012 | 5012 |
| 5013 | 5013 |
| 5014 TEST(APIStackOverflowAndVerboseTryCatch) { | 5014 TEST(APIStackOverflowAndVerboseTryCatch) { |
| 5015 message_received = false; | 5015 message_received = false; |
| 5016 LocalContext context; | 5016 LocalContext context; |
| 5017 v8::HandleScope scope(context->GetIsolate()); | 5017 v8::HandleScope scope(context->GetIsolate()); |
| 5018 v8::V8::AddMessageListener(receive_message); | 5018 v8::V8::AddMessageListener(receive_message); |
| 5019 v8::TryCatch try_catch; | 5019 v8::TryCatch try_catch(context->GetIsolate()); |
| 5020 try_catch.SetVerbose(true); | 5020 try_catch.SetVerbose(true); |
| 5021 Local<Value> result = CompileRun("function foo() { foo(); } foo();"); | 5021 Local<Value> result = CompileRun("function foo() { foo(); } foo();"); |
| 5022 CHECK(try_catch.HasCaught()); | 5022 CHECK(try_catch.HasCaught()); |
| 5023 CHECK(result.IsEmpty()); | 5023 CHECK(result.IsEmpty()); |
| 5024 CHECK(message_received); | 5024 CHECK(message_received); |
| 5025 v8::V8::RemoveMessageListeners(receive_message); | 5025 v8::V8::RemoveMessageListeners(receive_message); |
| 5026 } | 5026 } |
| 5027 | 5027 |
| 5028 | 5028 |
| 5029 THREADED_TEST(ExternalScriptException) { | 5029 THREADED_TEST(ExternalScriptException) { |
| 5030 v8::Isolate* isolate = CcTest::isolate(); | 5030 v8::Isolate* isolate = CcTest::isolate(); |
| 5031 v8::HandleScope scope(isolate); | 5031 v8::HandleScope scope(isolate); |
| 5032 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5032 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 5033 templ->Set(v8_str("ThrowFromC"), | 5033 templ->Set(v8_str("ThrowFromC"), |
| 5034 v8::FunctionTemplate::New(isolate, ThrowFromC)); | 5034 v8::FunctionTemplate::New(isolate, ThrowFromC)); |
| 5035 LocalContext context(0, templ); | 5035 LocalContext context(0, templ); |
| 5036 | 5036 |
| 5037 v8::TryCatch try_catch; | 5037 v8::TryCatch try_catch(isolate); |
| 5038 Local<Value> result = CompileRun("ThrowFromC(); throw 'panama';"); | 5038 Local<Value> result = CompileRun("ThrowFromC(); throw 'panama';"); |
| 5039 CHECK(result.IsEmpty()); | 5039 CHECK(result.IsEmpty()); |
| 5040 CHECK(try_catch.HasCaught()); | 5040 CHECK(try_catch.HasCaught()); |
| 5041 String::Utf8Value exception_value(try_catch.Exception()); | 5041 String::Utf8Value exception_value(try_catch.Exception()); |
| 5042 CHECK_EQ(0, strcmp("konto", *exception_value)); | 5042 CHECK_EQ(0, strcmp("konto", *exception_value)); |
| 5043 } | 5043 } |
| 5044 | 5044 |
| 5045 | 5045 |
| 5046 void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5046 void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5047 ApiTestFuzzer::Fuzz(); | 5047 ApiTestFuzzer::Fuzz(); |
| 5048 CHECK_EQ(4, args.Length()); | 5048 CHECK_EQ(4, args.Length()); |
| 5049 int count = args[0]->Int32Value(); | 5049 int count = args[0]->Int32Value(); |
| 5050 int cInterval = args[2]->Int32Value(); | 5050 int cInterval = args[2]->Int32Value(); |
| 5051 if (count == 0) { | 5051 if (count == 0) { |
| 5052 args.GetIsolate()->ThrowException(v8_str("FromC")); | 5052 args.GetIsolate()->ThrowException(v8_str("FromC")); |
| 5053 return; | 5053 return; |
| 5054 } else { | 5054 } else { |
| 5055 Local<v8::Object> global = args.GetIsolate()->GetCurrentContext()->Global(); | 5055 Local<v8::Object> global = args.GetIsolate()->GetCurrentContext()->Global(); |
| 5056 Local<Value> fun = global->Get(v8_str("JSThrowCountDown")); | 5056 Local<Value> fun = global->Get(v8_str("JSThrowCountDown")); |
| 5057 v8::Handle<Value> argv[] = {v8_num(count - 1), args[1], args[2], args[3]}; | 5057 v8::Handle<Value> argv[] = {v8_num(count - 1), args[1], args[2], args[3]}; |
| 5058 if (count % cInterval == 0) { | 5058 if (count % cInterval == 0) { |
| 5059 v8::TryCatch try_catch; | 5059 v8::TryCatch try_catch(args.GetIsolate()); |
| 5060 Local<Value> result = fun.As<Function>()->Call(global, 4, argv); | 5060 Local<Value> result = fun.As<Function>()->Call(global, 4, argv); |
| 5061 int expected = args[3]->Int32Value(); | 5061 int expected = args[3]->Int32Value(); |
| 5062 if (try_catch.HasCaught()) { | 5062 if (try_catch.HasCaught()) { |
| 5063 CHECK_EQ(expected, count); | 5063 CHECK_EQ(expected, count); |
| 5064 CHECK(result.IsEmpty()); | 5064 CHECK(result.IsEmpty()); |
| 5065 CHECK(!CcTest::i_isolate()->has_scheduled_exception()); | 5065 CHECK(!CcTest::i_isolate()->has_scheduled_exception()); |
| 5066 } else { | 5066 } else { |
| 5067 CHECK_NE(expected, count); | 5067 CHECK_NE(expected, count); |
| 5068 } | 5068 } |
| 5069 args.GetReturnValue().Set(result); | 5069 args.GetReturnValue().Set(result); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5086 CHECK_EQ(count, expected); | 5086 CHECK_EQ(count, expected); |
| 5087 } else { | 5087 } else { |
| 5088 CHECK_NE(count, expected); | 5088 CHECK_NE(count, expected); |
| 5089 } | 5089 } |
| 5090 } | 5090 } |
| 5091 | 5091 |
| 5092 | 5092 |
| 5093 THREADED_TEST(EvalInTryFinally) { | 5093 THREADED_TEST(EvalInTryFinally) { |
| 5094 LocalContext context; | 5094 LocalContext context; |
| 5095 v8::HandleScope scope(context->GetIsolate()); | 5095 v8::HandleScope scope(context->GetIsolate()); |
| 5096 v8::TryCatch try_catch; | 5096 v8::TryCatch try_catch(context->GetIsolate()); |
| 5097 CompileRun( | 5097 CompileRun( |
| 5098 "(function() {" | 5098 "(function() {" |
| 5099 " try {" | 5099 " try {" |
| 5100 " eval('asldkf (*&^&*^');" | 5100 " eval('asldkf (*&^&*^');" |
| 5101 " } finally {" | 5101 " } finally {" |
| 5102 " return;" | 5102 " return;" |
| 5103 " }" | 5103 " }" |
| 5104 "})()"); | 5104 "})()"); |
| 5105 CHECK(!try_catch.HasCaught()); | 5105 CHECK(!try_catch.HasCaught()); |
| 5106 } | 5106 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5214 CHECK(result->Get(v8::Integer::New(isolate, 2))->IsNumber()); | 5214 CHECK(result->Get(v8::Integer::New(isolate, 2))->IsNumber()); |
| 5215 CHECK_EQ(0, result->Get(v8::Integer::New(isolate, 2))->Int32Value()); | 5215 CHECK_EQ(0, result->Get(v8::Integer::New(isolate, 2))->Int32Value()); |
| 5216 CHECK(result->Get(v8::Integer::New(isolate, 3))->IsNull()); | 5216 CHECK(result->Get(v8::Integer::New(isolate, 3))->IsNull()); |
| 5217 CHECK(result->Get(v8::Integer::New(isolate, 4))->IsUndefined()); | 5217 CHECK(result->Get(v8::Integer::New(isolate, 4))->IsUndefined()); |
| 5218 } | 5218 } |
| 5219 | 5219 |
| 5220 | 5220 |
| 5221 THREADED_TEST(CatchZero) { | 5221 THREADED_TEST(CatchZero) { |
| 5222 LocalContext context; | 5222 LocalContext context; |
| 5223 v8::HandleScope scope(context->GetIsolate()); | 5223 v8::HandleScope scope(context->GetIsolate()); |
| 5224 v8::TryCatch try_catch; | 5224 v8::TryCatch try_catch(context->GetIsolate()); |
| 5225 CHECK(!try_catch.HasCaught()); | 5225 CHECK(!try_catch.HasCaught()); |
| 5226 CompileRun("throw 10"); | 5226 CompileRun("throw 10"); |
| 5227 CHECK(try_catch.HasCaught()); | 5227 CHECK(try_catch.HasCaught()); |
| 5228 CHECK_EQ(10, try_catch.Exception()->Int32Value()); | 5228 CHECK_EQ(10, try_catch.Exception()->Int32Value()); |
| 5229 try_catch.Reset(); | 5229 try_catch.Reset(); |
| 5230 CHECK(!try_catch.HasCaught()); | 5230 CHECK(!try_catch.HasCaught()); |
| 5231 CompileRun("throw 0"); | 5231 CompileRun("throw 0"); |
| 5232 CHECK(try_catch.HasCaught()); | 5232 CHECK(try_catch.HasCaught()); |
| 5233 CHECK_EQ(0, try_catch.Exception()->Int32Value()); | 5233 CHECK_EQ(0, try_catch.Exception()->Int32Value()); |
| 5234 } | 5234 } |
| 5235 | 5235 |
| 5236 | 5236 |
| 5237 THREADED_TEST(CatchExceptionFromWith) { | 5237 THREADED_TEST(CatchExceptionFromWith) { |
| 5238 LocalContext context; | 5238 LocalContext context; |
| 5239 v8::HandleScope scope(context->GetIsolate()); | 5239 v8::HandleScope scope(context->GetIsolate()); |
| 5240 v8::TryCatch try_catch; | 5240 v8::TryCatch try_catch(context->GetIsolate()); |
| 5241 CHECK(!try_catch.HasCaught()); | 5241 CHECK(!try_catch.HasCaught()); |
| 5242 CompileRun("var o = {}; with (o) { throw 42; }"); | 5242 CompileRun("var o = {}; with (o) { throw 42; }"); |
| 5243 CHECK(try_catch.HasCaught()); | 5243 CHECK(try_catch.HasCaught()); |
| 5244 } | 5244 } |
| 5245 | 5245 |
| 5246 | 5246 |
| 5247 THREADED_TEST(TryCatchAndFinallyHidingException) { | 5247 THREADED_TEST(TryCatchAndFinallyHidingException) { |
| 5248 LocalContext context; | 5248 LocalContext context; |
| 5249 v8::HandleScope scope(context->GetIsolate()); | 5249 v8::HandleScope scope(context->GetIsolate()); |
| 5250 v8::TryCatch try_catch; | 5250 v8::TryCatch try_catch(context->GetIsolate()); |
| 5251 CHECK(!try_catch.HasCaught()); | 5251 CHECK(!try_catch.HasCaught()); |
| 5252 CompileRun("function f(k) { try { this[k]; } finally { return 0; } };"); | 5252 CompileRun("function f(k) { try { this[k]; } finally { return 0; } };"); |
| 5253 CompileRun("f({toString: function() { throw 42; }});"); | 5253 CompileRun("f({toString: function() { throw 42; }});"); |
| 5254 CHECK(!try_catch.HasCaught()); | 5254 CHECK(!try_catch.HasCaught()); |
| 5255 } | 5255 } |
| 5256 | 5256 |
| 5257 | 5257 |
| 5258 void WithTryCatch(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5258 void WithTryCatch(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5259 v8::TryCatch try_catch; | 5259 v8::TryCatch try_catch(args.GetIsolate()); |
| 5260 } | 5260 } |
| 5261 | 5261 |
| 5262 | 5262 |
| 5263 THREADED_TEST(TryCatchAndFinally) { | 5263 THREADED_TEST(TryCatchAndFinally) { |
| 5264 LocalContext context; | 5264 LocalContext context; |
| 5265 v8::Isolate* isolate = context->GetIsolate(); | 5265 v8::Isolate* isolate = context->GetIsolate(); |
| 5266 v8::HandleScope scope(isolate); | 5266 v8::HandleScope scope(isolate); |
| 5267 context->Global()->Set( | 5267 context->Global()->Set( |
| 5268 v8_str("native_with_try_catch"), | 5268 v8_str("native_with_try_catch"), |
| 5269 v8::FunctionTemplate::New(isolate, WithTryCatch)->GetFunction()); | 5269 v8::FunctionTemplate::New(isolate, WithTryCatch)->GetFunction()); |
| 5270 v8::TryCatch try_catch; | 5270 v8::TryCatch try_catch(isolate); |
| 5271 CHECK(!try_catch.HasCaught()); | 5271 CHECK(!try_catch.HasCaught()); |
| 5272 CompileRun( | 5272 CompileRun( |
| 5273 "try {\n" | 5273 "try {\n" |
| 5274 " throw new Error('a');\n" | 5274 " throw new Error('a');\n" |
| 5275 "} finally {\n" | 5275 "} finally {\n" |
| 5276 " native_with_try_catch();\n" | 5276 " native_with_try_catch();\n" |
| 5277 "}\n"); | 5277 "}\n"); |
| 5278 CHECK(try_catch.HasCaught()); | 5278 CHECK(try_catch.HasCaught()); |
| 5279 } | 5279 } |
| 5280 | 5280 |
| 5281 | 5281 |
| 5282 static void TryCatchNested1Helper(int depth) { | 5282 static void TryCatchNested1Helper(int depth) { |
| 5283 if (depth > 0) { | 5283 if (depth > 0) { |
| 5284 v8::TryCatch try_catch; | 5284 v8::TryCatch try_catch(CcTest::isolate()); |
| 5285 try_catch.SetVerbose(true); | 5285 try_catch.SetVerbose(true); |
| 5286 TryCatchNested1Helper(depth - 1); | 5286 TryCatchNested1Helper(depth - 1); |
| 5287 CHECK(try_catch.HasCaught()); | 5287 CHECK(try_catch.HasCaught()); |
| 5288 try_catch.ReThrow(); | 5288 try_catch.ReThrow(); |
| 5289 } else { | 5289 } else { |
| 5290 CcTest::isolate()->ThrowException(v8_str("E1")); | 5290 CcTest::isolate()->ThrowException(v8_str("E1")); |
| 5291 } | 5291 } |
| 5292 } | 5292 } |
| 5293 | 5293 |
| 5294 | 5294 |
| 5295 static void TryCatchNested2Helper(int depth) { | 5295 static void TryCatchNested2Helper(int depth) { |
| 5296 if (depth > 0) { | 5296 if (depth > 0) { |
| 5297 v8::TryCatch try_catch; | 5297 v8::TryCatch try_catch(CcTest::isolate()); |
| 5298 try_catch.SetVerbose(true); | 5298 try_catch.SetVerbose(true); |
| 5299 TryCatchNested2Helper(depth - 1); | 5299 TryCatchNested2Helper(depth - 1); |
| 5300 CHECK(try_catch.HasCaught()); | 5300 CHECK(try_catch.HasCaught()); |
| 5301 try_catch.ReThrow(); | 5301 try_catch.ReThrow(); |
| 5302 } else { | 5302 } else { |
| 5303 CompileRun("throw 'E2';"); | 5303 CompileRun("throw 'E2';"); |
| 5304 } | 5304 } |
| 5305 } | 5305 } |
| 5306 | 5306 |
| 5307 | 5307 |
| 5308 TEST(TryCatchNested) { | 5308 TEST(TryCatchNested) { |
| 5309 v8::V8::Initialize(); | 5309 v8::V8::Initialize(); |
| 5310 LocalContext context; | 5310 LocalContext context; |
| 5311 v8::HandleScope scope(context->GetIsolate()); | 5311 v8::HandleScope scope(context->GetIsolate()); |
| 5312 | 5312 |
| 5313 { | 5313 { |
| 5314 // Test nested try-catch with a native throw in the end. | 5314 // Test nested try-catch with a native throw in the end. |
| 5315 v8::TryCatch try_catch; | 5315 v8::TryCatch try_catch(context->GetIsolate()); |
| 5316 TryCatchNested1Helper(5); | 5316 TryCatchNested1Helper(5); |
| 5317 CHECK(try_catch.HasCaught()); | 5317 CHECK(try_catch.HasCaught()); |
| 5318 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "E1")); | 5318 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "E1")); |
| 5319 } | 5319 } |
| 5320 | 5320 |
| 5321 { | 5321 { |
| 5322 // Test nested try-catch with a JavaScript throw in the end. | 5322 // Test nested try-catch with a JavaScript throw in the end. |
| 5323 v8::TryCatch try_catch; | 5323 v8::TryCatch try_catch(context->GetIsolate()); |
| 5324 TryCatchNested2Helper(5); | 5324 TryCatchNested2Helper(5); |
| 5325 CHECK(try_catch.HasCaught()); | 5325 CHECK(try_catch.HasCaught()); |
| 5326 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "E2")); | 5326 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "E2")); |
| 5327 } | 5327 } |
| 5328 } | 5328 } |
| 5329 | 5329 |
| 5330 | 5330 |
| 5331 void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) { | 5331 void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) { |
| 5332 CHECK(try_catch->HasCaught()); | 5332 CHECK(try_catch->HasCaught()); |
| 5333 Handle<Message> message = try_catch->Message(); | 5333 Handle<Message> message = try_catch->Message(); |
| 5334 Handle<Value> resource = message->GetScriptOrigin().ResourceName(); | 5334 Handle<Value> resource = message->GetScriptOrigin().ResourceName(); |
| 5335 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner")); | 5335 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner")); |
| 5336 CHECK_EQ(0, | 5336 CHECK_EQ(0, |
| 5337 strcmp(*v8::String::Utf8Value(message->Get()), "Uncaught Error: a")); | 5337 strcmp(*v8::String::Utf8Value(message->Get()), "Uncaught Error: a")); |
| 5338 CHECK_EQ(1, message->GetLineNumber()); | 5338 CHECK_EQ(1, message->GetLineNumber()); |
| 5339 CHECK_EQ(0, message->GetStartColumn()); | 5339 CHECK_EQ(0, message->GetStartColumn()); |
| 5340 } | 5340 } |
| 5341 | 5341 |
| 5342 | 5342 |
| 5343 void TryCatchMixedNestingHelper( | 5343 void TryCatchMixedNestingHelper( |
| 5344 const v8::FunctionCallbackInfo<v8::Value>& args) { | 5344 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5345 ApiTestFuzzer::Fuzz(); | 5345 ApiTestFuzzer::Fuzz(); |
| 5346 v8::TryCatch try_catch; | 5346 v8::TryCatch try_catch(args.GetIsolate()); |
| 5347 CompileRunWithOrigin("throw new Error('a');\n", "inner", 0, 0); | 5347 CompileRunWithOrigin("throw new Error('a');\n", "inner", 0, 0); |
| 5348 CHECK(try_catch.HasCaught()); | 5348 CHECK(try_catch.HasCaught()); |
| 5349 TryCatchMixedNestingCheck(&try_catch); | 5349 TryCatchMixedNestingCheck(&try_catch); |
| 5350 try_catch.ReThrow(); | 5350 try_catch.ReThrow(); |
| 5351 } | 5351 } |
| 5352 | 5352 |
| 5353 | 5353 |
| 5354 // This test ensures that an outer TryCatch in the following situation: | 5354 // This test ensures that an outer TryCatch in the following situation: |
| 5355 // C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError | 5355 // C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError |
| 5356 // does not clobber the Message object generated for the inner TryCatch. | 5356 // does not clobber the Message object generated for the inner TryCatch. |
| 5357 // This exercises the ability of TryCatch.ReThrow() to restore the | 5357 // This exercises the ability of TryCatch.ReThrow() to restore the |
| 5358 // inner pending Message before throwing the exception again. | 5358 // inner pending Message before throwing the exception again. |
| 5359 TEST(TryCatchMixedNesting) { | 5359 TEST(TryCatchMixedNesting) { |
| 5360 v8::Isolate* isolate = CcTest::isolate(); | 5360 v8::Isolate* isolate = CcTest::isolate(); |
| 5361 v8::HandleScope scope(isolate); | 5361 v8::HandleScope scope(isolate); |
| 5362 v8::V8::Initialize(); | 5362 v8::V8::Initialize(); |
| 5363 v8::TryCatch try_catch; | 5363 v8::TryCatch try_catch(isolate); |
| 5364 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5364 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 5365 templ->Set(v8_str("TryCatchMixedNestingHelper"), | 5365 templ->Set(v8_str("TryCatchMixedNestingHelper"), |
| 5366 v8::FunctionTemplate::New(isolate, TryCatchMixedNestingHelper)); | 5366 v8::FunctionTemplate::New(isolate, TryCatchMixedNestingHelper)); |
| 5367 LocalContext context(0, templ); | 5367 LocalContext context(0, templ); |
| 5368 CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1); | 5368 CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1); |
| 5369 TryCatchMixedNestingCheck(&try_catch); | 5369 TryCatchMixedNestingCheck(&try_catch); |
| 5370 } | 5370 } |
| 5371 | 5371 |
| 5372 | 5372 |
| 5373 void TryCatchNativeHelper(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5373 void TryCatchNativeHelper(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5374 ApiTestFuzzer::Fuzz(); | 5374 ApiTestFuzzer::Fuzz(); |
| 5375 v8::TryCatch try_catch; | 5375 v8::TryCatch try_catch(args.GetIsolate()); |
| 5376 args.GetIsolate()->ThrowException(v8_str("boom")); | 5376 args.GetIsolate()->ThrowException(v8_str("boom")); |
| 5377 CHECK(try_catch.HasCaught()); | 5377 CHECK(try_catch.HasCaught()); |
| 5378 } | 5378 } |
| 5379 | 5379 |
| 5380 | 5380 |
| 5381 TEST(TryCatchNative) { | 5381 TEST(TryCatchNative) { |
| 5382 v8::Isolate* isolate = CcTest::isolate(); | 5382 v8::Isolate* isolate = CcTest::isolate(); |
| 5383 v8::HandleScope scope(isolate); | 5383 v8::HandleScope scope(isolate); |
| 5384 v8::V8::Initialize(); | 5384 v8::V8::Initialize(); |
| 5385 v8::TryCatch try_catch; | 5385 v8::TryCatch try_catch(isolate); |
| 5386 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5386 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 5387 templ->Set(v8_str("TryCatchNativeHelper"), | 5387 templ->Set(v8_str("TryCatchNativeHelper"), |
| 5388 v8::FunctionTemplate::New(isolate, TryCatchNativeHelper)); | 5388 v8::FunctionTemplate::New(isolate, TryCatchNativeHelper)); |
| 5389 LocalContext context(0, templ); | 5389 LocalContext context(0, templ); |
| 5390 CompileRun("TryCatchNativeHelper();"); | 5390 CompileRun("TryCatchNativeHelper();"); |
| 5391 CHECK(!try_catch.HasCaught()); | 5391 CHECK(!try_catch.HasCaught()); |
| 5392 } | 5392 } |
| 5393 | 5393 |
| 5394 | 5394 |
| 5395 void TryCatchNativeResetHelper( | 5395 void TryCatchNativeResetHelper( |
| 5396 const v8::FunctionCallbackInfo<v8::Value>& args) { | 5396 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5397 ApiTestFuzzer::Fuzz(); | 5397 ApiTestFuzzer::Fuzz(); |
| 5398 v8::TryCatch try_catch; | 5398 v8::TryCatch try_catch(args.GetIsolate()); |
| 5399 args.GetIsolate()->ThrowException(v8_str("boom")); | 5399 args.GetIsolate()->ThrowException(v8_str("boom")); |
| 5400 CHECK(try_catch.HasCaught()); | 5400 CHECK(try_catch.HasCaught()); |
| 5401 try_catch.Reset(); | 5401 try_catch.Reset(); |
| 5402 CHECK(!try_catch.HasCaught()); | 5402 CHECK(!try_catch.HasCaught()); |
| 5403 } | 5403 } |
| 5404 | 5404 |
| 5405 | 5405 |
| 5406 TEST(TryCatchNativeReset) { | 5406 TEST(TryCatchNativeReset) { |
| 5407 v8::Isolate* isolate = CcTest::isolate(); | 5407 v8::Isolate* isolate = CcTest::isolate(); |
| 5408 v8::HandleScope scope(isolate); | 5408 v8::HandleScope scope(isolate); |
| 5409 v8::V8::Initialize(); | 5409 v8::V8::Initialize(); |
| 5410 v8::TryCatch try_catch; | 5410 v8::TryCatch try_catch(isolate); |
| 5411 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5411 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 5412 templ->Set(v8_str("TryCatchNativeResetHelper"), | 5412 templ->Set(v8_str("TryCatchNativeResetHelper"), |
| 5413 v8::FunctionTemplate::New(isolate, TryCatchNativeResetHelper)); | 5413 v8::FunctionTemplate::New(isolate, TryCatchNativeResetHelper)); |
| 5414 LocalContext context(0, templ); | 5414 LocalContext context(0, templ); |
| 5415 CompileRun("TryCatchNativeResetHelper();"); | 5415 CompileRun("TryCatchNativeResetHelper();"); |
| 5416 CHECK(!try_catch.HasCaught()); | 5416 CHECK(!try_catch.HasCaught()); |
| 5417 } | 5417 } |
| 5418 | 5418 |
| 5419 | 5419 |
| 5420 THREADED_TEST(Equality) { | 5420 THREADED_TEST(Equality) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5526 "var desc = { get: function(){return 43; }," | 5526 "var desc = { get: function(){return 43; }," |
| 5527 " configurable: false };" | 5527 " configurable: false };" |
| 5528 "Object.defineProperty(obj, 'x', desc);" | 5528 "Object.defineProperty(obj, 'x', desc);" |
| 5529 "obj.x"); | 5529 "obj.x"); |
| 5530 result = script_define->Run(); | 5530 result = script_define->Run(); |
| 5531 CHECK(result->Equals(v8_num(43))); | 5531 CHECK(result->Equals(v8_num(43))); |
| 5532 result = script_desc->Run(); | 5532 result = script_desc->Run(); |
| 5533 CHECK_EQ(result->BooleanValue(), false); | 5533 CHECK_EQ(result->BooleanValue(), false); |
| 5534 | 5534 |
| 5535 // Make sure that it is not possible to redefine again | 5535 // Make sure that it is not possible to redefine again |
| 5536 v8::TryCatch try_catch; | 5536 v8::TryCatch try_catch(isolate); |
| 5537 result = script_define->Run(); | 5537 result = script_define->Run(); |
| 5538 CHECK(try_catch.HasCaught()); | 5538 CHECK(try_catch.HasCaught()); |
| 5539 String::Utf8Value exception_value(try_catch.Exception()); | 5539 String::Utf8Value exception_value(try_catch.Exception()); |
| 5540 CHECK_EQ(0, | 5540 CHECK_EQ(0, |
| 5541 strcmp(*exception_value, "TypeError: Cannot redefine property: x")); | 5541 strcmp(*exception_value, "TypeError: Cannot redefine property: x")); |
| 5542 } | 5542 } |
| 5543 | 5543 |
| 5544 | 5544 |
| 5545 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { | 5545 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { |
| 5546 v8::Isolate* isolate = CcTest::isolate(); | 5546 v8::Isolate* isolate = CcTest::isolate(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5575 "var desc = {get: function(){return 43; }," | 5575 "var desc = {get: function(){return 43; }," |
| 5576 " configurable: false };" | 5576 " configurable: false };" |
| 5577 "Object.defineProperty(obj, 'x', desc);" | 5577 "Object.defineProperty(obj, 'x', desc);" |
| 5578 "obj.x"); | 5578 "obj.x"); |
| 5579 result = script_define->Run(); | 5579 result = script_define->Run(); |
| 5580 CHECK(result->Equals(v8_num(43))); | 5580 CHECK(result->Equals(v8_num(43))); |
| 5581 result = script_desc->Run(); | 5581 result = script_desc->Run(); |
| 5582 | 5582 |
| 5583 CHECK_EQ(result->BooleanValue(), false); | 5583 CHECK_EQ(result->BooleanValue(), false); |
| 5584 | 5584 |
| 5585 v8::TryCatch try_catch; | 5585 v8::TryCatch try_catch(isolate); |
| 5586 result = script_define->Run(); | 5586 result = script_define->Run(); |
| 5587 CHECK(try_catch.HasCaught()); | 5587 CHECK(try_catch.HasCaught()); |
| 5588 String::Utf8Value exception_value(try_catch.Exception()); | 5588 String::Utf8Value exception_value(try_catch.Exception()); |
| 5589 CHECK_EQ(0, | 5589 CHECK_EQ(0, |
| 5590 strcmp(*exception_value, "TypeError: Cannot redefine property: x")); | 5590 strcmp(*exception_value, "TypeError: Cannot redefine property: x")); |
| 5591 } | 5591 } |
| 5592 | 5592 |
| 5593 | 5593 |
| 5594 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, | 5594 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, |
| 5595 char const* name) { | 5595 char const* name) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5697 | 5697 |
| 5698 ExpectTrue("!Object.getOwnPropertyDescriptor(obj1, 'x').configurable"); | 5698 ExpectTrue("!Object.getOwnPropertyDescriptor(obj1, 'x').configurable"); |
| 5699 ExpectTrue("!Object.getOwnPropertyDescriptor(obj2, 'x').configurable"); | 5699 ExpectTrue("!Object.getOwnPropertyDescriptor(obj2, 'x').configurable"); |
| 5700 | 5700 |
| 5701 CHECK(!GetGlobalProperty(&context, "obj1") | 5701 CHECK(!GetGlobalProperty(&context, "obj1") |
| 5702 ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); | 5702 ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); |
| 5703 CHECK(!GetGlobalProperty(&context, "obj2") | 5703 CHECK(!GetGlobalProperty(&context, "obj2") |
| 5704 ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); | 5704 ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); |
| 5705 | 5705 |
| 5706 { | 5706 { |
| 5707 v8::TryCatch try_catch; | 5707 v8::TryCatch try_catch(isolate); |
| 5708 CompileRun( | 5708 CompileRun( |
| 5709 "Object.defineProperty(obj1, 'x'," | 5709 "Object.defineProperty(obj1, 'x'," |
| 5710 "{get: function() { return 'func'; }})"); | 5710 "{get: function() { return 'func'; }})"); |
| 5711 CHECK(try_catch.HasCaught()); | 5711 CHECK(try_catch.HasCaught()); |
| 5712 String::Utf8Value exception_value(try_catch.Exception()); | 5712 String::Utf8Value exception_value(try_catch.Exception()); |
| 5713 CHECK_EQ( | 5713 CHECK_EQ( |
| 5714 0, strcmp(*exception_value, "TypeError: Cannot redefine property: x")); | 5714 0, strcmp(*exception_value, "TypeError: Cannot redefine property: x")); |
| 5715 } | 5715 } |
| 5716 { | 5716 { |
| 5717 v8::TryCatch try_catch; | 5717 v8::TryCatch try_catch(isolate); |
| 5718 CompileRun( | 5718 CompileRun( |
| 5719 "Object.defineProperty(obj2, 'x'," | 5719 "Object.defineProperty(obj2, 'x'," |
| 5720 "{get: function() { return 'func'; }})"); | 5720 "{get: function() { return 'func'; }})"); |
| 5721 CHECK(try_catch.HasCaught()); | 5721 CHECK(try_catch.HasCaught()); |
| 5722 String::Utf8Value exception_value(try_catch.Exception()); | 5722 String::Utf8Value exception_value(try_catch.Exception()); |
| 5723 CHECK_EQ( | 5723 CHECK_EQ( |
| 5724 0, strcmp(*exception_value, "TypeError: Cannot redefine property: x")); | 5724 0, strcmp(*exception_value, "TypeError: Cannot redefine property: x")); |
| 5725 } | 5725 } |
| 5726 } | 5726 } |
| 5727 | 5727 |
| (...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7492 v8::Handle<String> foo_str = v8_str("foo"); | 7492 v8::Handle<String> foo_str = v8_str("foo"); |
| 7493 v8::Handle<String> message_str = v8_str("message"); | 7493 v8::Handle<String> message_str = v8_str("message"); |
| 7494 | 7494 |
| 7495 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); | 7495 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); |
| 7496 | 7496 |
| 7497 Local<v8::FunctionTemplate> fun = | 7497 Local<v8::FunctionTemplate> fun = |
| 7498 v8::FunctionTemplate::New(context->GetIsolate(), ThrowV8Exception); | 7498 v8::FunctionTemplate::New(context->GetIsolate(), ThrowV8Exception); |
| 7499 v8::Local<v8::Object> global = context->Global(); | 7499 v8::Local<v8::Object> global = context->Global(); |
| 7500 global->Set(v8_str("throwV8Exception"), fun->GetFunction()); | 7500 global->Set(v8_str("throwV8Exception"), fun->GetFunction()); |
| 7501 | 7501 |
| 7502 TryCatch try_catch; | 7502 TryCatch try_catch(context->GetIsolate()); |
| 7503 CompileRun( | 7503 CompileRun( |
| 7504 "function f1() {\n" | 7504 "function f1() {\n" |
| 7505 " throwV8Exception();\n" | 7505 " throwV8Exception();\n" |
| 7506 "};\n" | 7506 "};\n" |
| 7507 "f1();"); | 7507 "f1();"); |
| 7508 CHECK(try_catch.HasCaught()); | 7508 CHECK(try_catch.HasCaught()); |
| 7509 | 7509 |
| 7510 v8::Handle<v8::Value> error = try_catch.Exception(); | 7510 v8::Handle<v8::Value> error = try_catch.Exception(); |
| 7511 CHECK(error->IsObject()); | 7511 CHECK(error->IsObject()); |
| 7512 CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str)); | 7512 CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str)); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7726 Local<Value> trouble = global->Get(v8_str("trouble")); | 7726 Local<Value> trouble = global->Get(v8_str("trouble")); |
| 7727 CHECK(trouble->IsFunction()); | 7727 CHECK(trouble->IsFunction()); |
| 7728 Function::Cast(*trouble)->Call(global, 0, NULL); | 7728 Function::Cast(*trouble)->Call(global, 0, NULL); |
| 7729 v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener); | 7729 v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener); |
| 7730 } | 7730 } |
| 7731 | 7731 |
| 7732 | 7732 |
| 7733 TEST(CompilationErrorUsingTryCatchHandler) { | 7733 TEST(CompilationErrorUsingTryCatchHandler) { |
| 7734 LocalContext env; | 7734 LocalContext env; |
| 7735 v8::HandleScope scope(env->GetIsolate()); | 7735 v8::HandleScope scope(env->GetIsolate()); |
| 7736 v8::TryCatch try_catch; | 7736 v8::TryCatch try_catch(env->GetIsolate()); |
| 7737 v8_compile("This doesn't &*&@#$&*^ compile."); | 7737 v8_compile("This doesn't &*&@#$&*^ compile."); |
| 7738 CHECK(*try_catch.Exception()); | 7738 CHECK(*try_catch.Exception()); |
| 7739 CHECK(try_catch.HasCaught()); | 7739 CHECK(try_catch.HasCaught()); |
| 7740 } | 7740 } |
| 7741 | 7741 |
| 7742 | 7742 |
| 7743 TEST(TryCatchFinallyUsingTryCatchHandler) { | 7743 TEST(TryCatchFinallyUsingTryCatchHandler) { |
| 7744 LocalContext env; | 7744 LocalContext env; |
| 7745 v8::HandleScope scope(env->GetIsolate()); | 7745 v8::HandleScope scope(env->GetIsolate()); |
| 7746 v8::TryCatch try_catch; | 7746 v8::TryCatch try_catch(env->GetIsolate()); |
| 7747 CompileRun("try { throw ''; } catch (e) {}"); | 7747 CompileRun("try { throw ''; } catch (e) {}"); |
| 7748 CHECK(!try_catch.HasCaught()); | 7748 CHECK(!try_catch.HasCaught()); |
| 7749 CompileRun("try { throw ''; } finally {}"); | 7749 CompileRun("try { throw ''; } finally {}"); |
| 7750 CHECK(try_catch.HasCaught()); | 7750 CHECK(try_catch.HasCaught()); |
| 7751 try_catch.Reset(); | 7751 try_catch.Reset(); |
| 7752 CompileRun( | 7752 CompileRun( |
| 7753 "(function() {" | 7753 "(function() {" |
| 7754 "try { throw ''; } finally { return; }" | 7754 "try { throw ''; } finally { return; }" |
| 7755 "})()"); | 7755 "})()"); |
| 7756 CHECK(!try_catch.HasCaught()); | 7756 CHECK(!try_catch.HasCaught()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7768 } | 7768 } |
| 7769 | 7769 |
| 7770 | 7770 |
| 7771 TEST(TryCatchFinallyStoresMessageUsingTryCatchHandler) { | 7771 TEST(TryCatchFinallyStoresMessageUsingTryCatchHandler) { |
| 7772 v8::Isolate* isolate = CcTest::isolate(); | 7772 v8::Isolate* isolate = CcTest::isolate(); |
| 7773 v8::HandleScope scope(isolate); | 7773 v8::HandleScope scope(isolate); |
| 7774 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 7774 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 7775 templ->Set(v8_str("CEvaluate"), | 7775 templ->Set(v8_str("CEvaluate"), |
| 7776 v8::FunctionTemplate::New(isolate, CEvaluate)); | 7776 v8::FunctionTemplate::New(isolate, CEvaluate)); |
| 7777 LocalContext context(0, templ); | 7777 LocalContext context(0, templ); |
| 7778 v8::TryCatch try_catch; | 7778 v8::TryCatch try_catch(isolate); |
| 7779 CompileRun("try {" | 7779 CompileRun("try {" |
| 7780 " CEvaluate('throw 1;');" | 7780 " CEvaluate('throw 1;');" |
| 7781 "} finally {" | 7781 "} finally {" |
| 7782 "}"); | 7782 "}"); |
| 7783 CHECK(try_catch.HasCaught()); | 7783 CHECK(try_catch.HasCaught()); |
| 7784 CHECK(!try_catch.Message().IsEmpty()); | 7784 CHECK(!try_catch.Message().IsEmpty()); |
| 7785 String::Utf8Value exception_value(try_catch.Exception()); | 7785 String::Utf8Value exception_value(try_catch.Exception()); |
| 7786 CHECK_EQ(0, strcmp(*exception_value, "1")); | 7786 CHECK_EQ(0, strcmp(*exception_value, "1")); |
| 7787 try_catch.Reset(); | 7787 try_catch.Reset(); |
| 7788 CompileRun("try {" | 7788 CompileRun("try {" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7895 Context::Scope scope_env2(env2); | 7895 Context::Scope scope_env2(env2); |
| 7896 Local<Value> result = Function::Cast(*spy)->Call(env2->Global(), 0, NULL); | 7896 Local<Value> result = Function::Cast(*spy)->Call(env2->Global(), 0, NULL); |
| 7897 CHECK(result->IsFunction()); | 7897 CHECK(result->IsFunction()); |
| 7898 } | 7898 } |
| 7899 | 7899 |
| 7900 { | 7900 { |
| 7901 env2->SetSecurityToken(bar); | 7901 env2->SetSecurityToken(bar); |
| 7902 Context::Scope scope_env2(env2); | 7902 Context::Scope scope_env2(env2); |
| 7903 | 7903 |
| 7904 // Call cross_domain_call, it should throw an exception | 7904 // Call cross_domain_call, it should throw an exception |
| 7905 v8::TryCatch try_catch; | 7905 v8::TryCatch try_catch(env1->GetIsolate()); |
| 7906 Function::Cast(*spy2)->Call(env2->Global(), 0, NULL); | 7906 Function::Cast(*spy2)->Call(env2->Global(), 0, NULL); |
| 7907 CHECK(try_catch.HasCaught()); | 7907 CHECK(try_catch.HasCaught()); |
| 7908 } | 7908 } |
| 7909 } | 7909 } |
| 7910 | 7910 |
| 7911 | 7911 |
| 7912 // Regression test case for issue 1183439. | 7912 // Regression test case for issue 1183439. |
| 7913 THREADED_TEST(SecurityChecksForPrototypeChain) { | 7913 THREADED_TEST(SecurityChecksForPrototypeChain) { |
| 7914 LocalContext current; | 7914 LocalContext current; |
| 7915 v8::HandleScope scope(current->GetIsolate()); | 7915 v8::HandleScope scope(current->GetIsolate()); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8147 CHECK(global3->Get(v8_str("prop"))->IsUndefined()); | 8147 CHECK(global3->Get(v8_str("prop"))->IsUndefined()); |
| 8148 CHECK(global3->Get(v8_str("getProp"))->IsUndefined()); | 8148 CHECK(global3->Get(v8_str("getProp"))->IsUndefined()); |
| 8149 global3->Set(v8_str("prop"), v8::Integer::New(env3->GetIsolate(), -1)); | 8149 global3->Set(v8_str("prop"), v8::Integer::New(env3->GetIsolate(), -1)); |
| 8150 global3->Set(v8_str("prop2"), v8::Integer::New(env3->GetIsolate(), 2)); | 8150 global3->Set(v8_str("prop2"), v8::Integer::New(env3->GetIsolate(), 2)); |
| 8151 env3->Exit(); | 8151 env3->Exit(); |
| 8152 | 8152 |
| 8153 // Call getProp in env1, and it should return the value 1 | 8153 // Call getProp in env1, and it should return the value 1 |
| 8154 { | 8154 { |
| 8155 Local<Value> get_prop = global1->Get(v8_str("getProp")); | 8155 Local<Value> get_prop = global1->Get(v8_str("getProp")); |
| 8156 CHECK(get_prop->IsFunction()); | 8156 CHECK(get_prop->IsFunction()); |
| 8157 v8::TryCatch try_catch; | 8157 v8::TryCatch try_catch(env1->GetIsolate()); |
| 8158 Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL); | 8158 Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL); |
| 8159 CHECK(!try_catch.HasCaught()); | 8159 CHECK(!try_catch.HasCaught()); |
| 8160 CHECK_EQ(1, r->Int32Value()); | 8160 CHECK_EQ(1, r->Int32Value()); |
| 8161 } | 8161 } |
| 8162 | 8162 |
| 8163 // Check that env3 is not accessible from env1 | 8163 // Check that env3 is not accessible from env1 |
| 8164 { | 8164 { |
| 8165 Local<Value> r = global3->Get(v8_str("prop2")); | 8165 Local<Value> r = global3->Get(v8_str("prop2")); |
| 8166 CHECK(r.IsEmpty()); | 8166 CHECK(r.IsEmpty()); |
| 8167 } | 8167 } |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8692 i::FLAG_harmony_object_literals = true; | 8692 i::FLAG_harmony_object_literals = true; |
| 8693 v8::Isolate* isolate = CcTest::isolate(); | 8693 v8::Isolate* isolate = CcTest::isolate(); |
| 8694 v8::HandleScope handle_scope(isolate); | 8694 v8::HandleScope handle_scope(isolate); |
| 8695 v8::Handle<v8::ObjectTemplate> obj_template = | 8695 v8::Handle<v8::ObjectTemplate> obj_template = |
| 8696 v8::ObjectTemplate::New(isolate); | 8696 v8::ObjectTemplate::New(isolate); |
| 8697 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 8697 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); |
| 8698 LocalContext env; | 8698 LocalContext env; |
| 8699 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); | 8699 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); |
| 8700 | 8700 |
| 8701 { | 8701 { |
| 8702 v8::TryCatch try_catch; | 8702 v8::TryCatch try_catch(isolate); |
| 8703 CompileRun( | 8703 CompileRun( |
| 8704 "var f = { m() { return super.hasOwnProperty; } }.m;" | 8704 "var f = { m() { return super.hasOwnProperty; } }.m;" |
| 8705 "var m = %ToMethod(f, prohibited);" | 8705 "var m = %ToMethod(f, prohibited);" |
| 8706 "m();"); | 8706 "m();"); |
| 8707 CHECK(try_catch.HasCaught()); | 8707 CHECK(try_catch.HasCaught()); |
| 8708 } | 8708 } |
| 8709 | 8709 |
| 8710 { | 8710 { |
| 8711 v8::TryCatch try_catch; | 8711 v8::TryCatch try_catch(isolate); |
| 8712 CompileRun( | 8712 CompileRun( |
| 8713 "var f = {m() { return super[42]; } }.m;" | 8713 "var f = {m() { return super[42]; } }.m;" |
| 8714 "var m = %ToMethod(f, prohibited);" | 8714 "var m = %ToMethod(f, prohibited);" |
| 8715 "m();"); | 8715 "m();"); |
| 8716 CHECK(try_catch.HasCaught()); | 8716 CHECK(try_catch.HasCaught()); |
| 8717 } | 8717 } |
| 8718 | 8718 |
| 8719 { | 8719 { |
| 8720 v8::TryCatch try_catch; | 8720 v8::TryCatch try_catch(isolate); |
| 8721 CompileRun( | 8721 CompileRun( |
| 8722 "var f = {m() { super.hasOwnProperty = function () {}; } }.m;" | 8722 "var f = {m() { super.hasOwnProperty = function () {}; } }.m;" |
| 8723 "var m = %ToMethod(f, prohibited);" | 8723 "var m = %ToMethod(f, prohibited);" |
| 8724 "m();"); | 8724 "m();"); |
| 8725 CHECK(try_catch.HasCaught()); | 8725 CHECK(try_catch.HasCaught()); |
| 8726 } | 8726 } |
| 8727 | 8727 |
| 8728 { | 8728 { |
| 8729 v8::TryCatch try_catch; | 8729 v8::TryCatch try_catch(isolate); |
| 8730 CompileRun( | 8730 CompileRun( |
| 8731 "Object.defineProperty(Object.prototype, 'x', { set : function(){}});" | 8731 "Object.defineProperty(Object.prototype, 'x', { set : function(){}});" |
| 8732 "var f = {" | 8732 "var f = {" |
| 8733 " m() { " | 8733 " m() { " |
| 8734 " 'use strict';" | 8734 " 'use strict';" |
| 8735 " super.x = function () {};" | 8735 " super.x = function () {};" |
| 8736 " }" | 8736 " }" |
| 8737 "}.m;" | 8737 "}.m;" |
| 8738 "var m = %ToMethod(f, prohibited);" | 8738 "var m = %ToMethod(f, prohibited);" |
| 8739 "m();"); | 8739 "m();"); |
| 8740 CHECK(try_catch.HasCaught()); | 8740 CHECK(try_catch.HasCaught()); |
| 8741 } | 8741 } |
| 8742 } | 8742 } |
| 8743 | 8743 |
| 8744 | 8744 |
| 8745 TEST(Regress470113) { | 8745 TEST(Regress470113) { |
| 8746 i::FLAG_harmony_classes = true; | 8746 i::FLAG_harmony_classes = true; |
| 8747 i::FLAG_harmony_object_literals = true; | 8747 i::FLAG_harmony_object_literals = true; |
| 8748 v8::Isolate* isolate = CcTest::isolate(); | 8748 v8::Isolate* isolate = CcTest::isolate(); |
| 8749 v8::HandleScope handle_scope(isolate); | 8749 v8::HandleScope handle_scope(isolate); |
| 8750 v8::Handle<v8::ObjectTemplate> obj_template = | 8750 v8::Handle<v8::ObjectTemplate> obj_template = |
| 8751 v8::ObjectTemplate::New(isolate); | 8751 v8::ObjectTemplate::New(isolate); |
| 8752 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 8752 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); |
| 8753 LocalContext env; | 8753 LocalContext env; |
| 8754 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); | 8754 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); |
| 8755 | 8755 |
| 8756 { | 8756 { |
| 8757 v8::TryCatch try_catch; | 8757 v8::TryCatch try_catch(isolate); |
| 8758 CompileRun( | 8758 CompileRun( |
| 8759 "'use strict';\n" | 8759 "'use strict';\n" |
| 8760 "class C extends Object {\n" | 8760 "class C extends Object {\n" |
| 8761 " m() { super.powned = 'Powned!'; }\n" | 8761 " m() { super.powned = 'Powned!'; }\n" |
| 8762 "}\n" | 8762 "}\n" |
| 8763 "let c = new C();\n" | 8763 "let c = new C();\n" |
| 8764 "c.m.call(prohibited)"); | 8764 "c.m.call(prohibited)"); |
| 8765 | 8765 |
| 8766 CHECK(try_catch.HasCaught()); | 8766 CHECK(try_catch.HasCaught()); |
| 8767 } | 8767 } |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9488 v8::HandleScope handle_scope(isolate); | 9488 v8::HandleScope handle_scope(isolate); |
| 9489 | 9489 |
| 9490 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); | 9490 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 9491 | 9491 |
| 9492 Local<v8::Object> o0 = t->GetFunction()->NewInstance(); | 9492 Local<v8::Object> o0 = t->GetFunction()->NewInstance(); |
| 9493 Local<v8::Object> o1 = t->GetFunction()->NewInstance(); | 9493 Local<v8::Object> o1 = t->GetFunction()->NewInstance(); |
| 9494 | 9494 |
| 9495 CHECK(o0->SetPrototype(o1)); | 9495 CHECK(o0->SetPrototype(o1)); |
| 9496 // If setting the prototype leads to the cycle, SetPrototype should | 9496 // If setting the prototype leads to the cycle, SetPrototype should |
| 9497 // return false and keep VM in sane state. | 9497 // return false and keep VM in sane state. |
| 9498 v8::TryCatch try_catch; | 9498 v8::TryCatch try_catch(isolate); |
| 9499 CHECK(!o1->SetPrototype(o0)); | 9499 CHECK(!o1->SetPrototype(o0)); |
| 9500 CHECK(!try_catch.HasCaught()); | 9500 CHECK(!try_catch.HasCaught()); |
| 9501 DCHECK(!CcTest::i_isolate()->has_pending_exception()); | 9501 DCHECK(!CcTest::i_isolate()->has_pending_exception()); |
| 9502 | 9502 |
| 9503 CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")->Int32Value()); | 9503 CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")->Int32Value()); |
| 9504 } | 9504 } |
| 9505 | 9505 |
| 9506 | 9506 |
| 9507 THREADED_TEST(FunctionRemovePrototype) { | 9507 THREADED_TEST(FunctionRemovePrototype) { |
| 9508 LocalContext context; | 9508 LocalContext context; |
| 9509 v8::Isolate* isolate = context->GetIsolate(); | 9509 v8::Isolate* isolate = context->GetIsolate(); |
| 9510 v8::HandleScope handle_scope(isolate); | 9510 v8::HandleScope handle_scope(isolate); |
| 9511 | 9511 |
| 9512 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); | 9512 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 9513 t1->RemovePrototype(); | 9513 t1->RemovePrototype(); |
| 9514 Local<v8::Function> fun = t1->GetFunction(); | 9514 Local<v8::Function> fun = t1->GetFunction(); |
| 9515 context->Global()->Set(v8_str("fun"), fun); | 9515 context->Global()->Set(v8_str("fun"), fun); |
| 9516 CHECK(!CompileRun("'prototype' in fun")->BooleanValue()); | 9516 CHECK(!CompileRun("'prototype' in fun")->BooleanValue()); |
| 9517 | 9517 |
| 9518 v8::TryCatch try_catch; | 9518 v8::TryCatch try_catch(isolate); |
| 9519 CompileRun("new fun()"); | 9519 CompileRun("new fun()"); |
| 9520 CHECK(try_catch.HasCaught()); | 9520 CHECK(try_catch.HasCaught()); |
| 9521 | 9521 |
| 9522 try_catch.Reset(); | 9522 try_catch.Reset(); |
| 9523 fun->NewInstance(); | 9523 fun->NewInstance(); |
| 9524 CHECK(try_catch.HasCaught()); | 9524 CHECK(try_catch.HasCaught()); |
| 9525 } | 9525 } |
| 9526 | 9526 |
| 9527 | 9527 |
| 9528 THREADED_TEST(GetterSetterExceptions) { | 9528 THREADED_TEST(GetterSetterExceptions) { |
| 9529 LocalContext context; | 9529 LocalContext context; |
| 9530 v8::Isolate* isolate = context->GetIsolate(); | 9530 v8::Isolate* isolate = context->GetIsolate(); |
| 9531 v8::HandleScope handle_scope(isolate); | 9531 v8::HandleScope handle_scope(isolate); |
| 9532 CompileRun( | 9532 CompileRun( |
| 9533 "function Foo() { };" | 9533 "function Foo() { };" |
| 9534 "function Throw() { throw 5; };" | 9534 "function Throw() { throw 5; };" |
| 9535 "var x = { };" | 9535 "var x = { };" |
| 9536 "x.__defineSetter__('set', Throw);" | 9536 "x.__defineSetter__('set', Throw);" |
| 9537 "x.__defineGetter__('get', Throw);"); | 9537 "x.__defineGetter__('get', Throw);"); |
| 9538 Local<v8::Object> x = | 9538 Local<v8::Object> x = |
| 9539 Local<v8::Object>::Cast(context->Global()->Get(v8_str("x"))); | 9539 Local<v8::Object>::Cast(context->Global()->Get(v8_str("x"))); |
| 9540 v8::TryCatch try_catch; | 9540 v8::TryCatch try_catch(isolate); |
| 9541 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); | 9541 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
| 9542 x->Get(v8_str("get")); | 9542 x->Get(v8_str("get")); |
| 9543 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); | 9543 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
| 9544 x->Get(v8_str("get")); | 9544 x->Get(v8_str("get")); |
| 9545 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); | 9545 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
| 9546 x->Get(v8_str("get")); | 9546 x->Get(v8_str("get")); |
| 9547 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); | 9547 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
| 9548 x->Get(v8_str("get")); | 9548 x->Get(v8_str("get")); |
| 9549 } | 9549 } |
| 9550 | 9550 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9596 THREADED_TEST(ConstructorForObject) { | 9596 THREADED_TEST(ConstructorForObject) { |
| 9597 LocalContext context; | 9597 LocalContext context; |
| 9598 v8::Isolate* isolate = context->GetIsolate(); | 9598 v8::Isolate* isolate = context->GetIsolate(); |
| 9599 v8::HandleScope handle_scope(isolate); | 9599 v8::HandleScope handle_scope(isolate); |
| 9600 | 9600 |
| 9601 { | 9601 { |
| 9602 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 9602 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |
| 9603 instance_template->SetCallAsFunctionHandler(ConstructorCallback); | 9603 instance_template->SetCallAsFunctionHandler(ConstructorCallback); |
| 9604 Local<Object> instance = instance_template->NewInstance(); | 9604 Local<Object> instance = instance_template->NewInstance(); |
| 9605 context->Global()->Set(v8_str("obj"), instance); | 9605 context->Global()->Set(v8_str("obj"), instance); |
| 9606 v8::TryCatch try_catch; | 9606 v8::TryCatch try_catch(isolate); |
| 9607 Local<Value> value; | 9607 Local<Value> value; |
| 9608 CHECK(!try_catch.HasCaught()); | 9608 CHECK(!try_catch.HasCaught()); |
| 9609 | 9609 |
| 9610 // Call the Object's constructor with a 32-bit signed integer. | 9610 // Call the Object's constructor with a 32-bit signed integer. |
| 9611 value = CompileRun("(function() { var o = new obj(28); return o.a; })()"); | 9611 value = CompileRun("(function() { var o = new obj(28); return o.a; })()"); |
| 9612 CHECK(!try_catch.HasCaught()); | 9612 CHECK(!try_catch.HasCaught()); |
| 9613 CHECK(value->IsInt32()); | 9613 CHECK(value->IsInt32()); |
| 9614 CHECK_EQ(28, value->Int32Value()); | 9614 CHECK_EQ(28, value->Int32Value()); |
| 9615 | 9615 |
| 9616 Local<Value> args1[] = {v8_num(28)}; | 9616 Local<Value> args1[] = {v8_num(28)}; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9672 value = object5->Get(v8_str("a")); | 9672 value = object5->Get(v8_str("a")); |
| 9673 CHECK(!try_catch.HasCaught()); | 9673 CHECK(!try_catch.HasCaught()); |
| 9674 CHECK(value->IsNull()); | 9674 CHECK(value->IsNull()); |
| 9675 } | 9675 } |
| 9676 | 9676 |
| 9677 // Check exception handling when there is no constructor set for the Object. | 9677 // Check exception handling when there is no constructor set for the Object. |
| 9678 { | 9678 { |
| 9679 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 9679 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |
| 9680 Local<Object> instance = instance_template->NewInstance(); | 9680 Local<Object> instance = instance_template->NewInstance(); |
| 9681 context->Global()->Set(v8_str("obj2"), instance); | 9681 context->Global()->Set(v8_str("obj2"), instance); |
| 9682 v8::TryCatch try_catch; | 9682 v8::TryCatch try_catch(isolate); |
| 9683 Local<Value> value; | 9683 Local<Value> value; |
| 9684 CHECK(!try_catch.HasCaught()); | 9684 CHECK(!try_catch.HasCaught()); |
| 9685 | 9685 |
| 9686 value = CompileRun("new obj2(28)"); | 9686 value = CompileRun("new obj2(28)"); |
| 9687 CHECK(try_catch.HasCaught()); | 9687 CHECK(try_catch.HasCaught()); |
| 9688 String::Utf8Value exception_value1(try_catch.Exception()); | 9688 String::Utf8Value exception_value1(try_catch.Exception()); |
| 9689 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); | 9689 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); |
| 9690 try_catch.Reset(); | 9690 try_catch.Reset(); |
| 9691 | 9691 |
| 9692 Local<Value> args[] = {v8_num(29)}; | 9692 Local<Value> args[] = {v8_num(29)}; |
| 9693 value = instance->CallAsConstructor(1, args); | 9693 value = instance->CallAsConstructor(1, args); |
| 9694 CHECK(try_catch.HasCaught()); | 9694 CHECK(try_catch.HasCaught()); |
| 9695 String::Utf8Value exception_value2(try_catch.Exception()); | 9695 String::Utf8Value exception_value2(try_catch.Exception()); |
| 9696 CHECK_EQ( | 9696 CHECK_EQ( |
| 9697 0, strcmp("TypeError: #<Object> is not a function", *exception_value2)); | 9697 0, strcmp("TypeError: #<Object> is not a function", *exception_value2)); |
| 9698 try_catch.Reset(); | 9698 try_catch.Reset(); |
| 9699 } | 9699 } |
| 9700 | 9700 |
| 9701 // Check the case when constructor throws exception. | 9701 // Check the case when constructor throws exception. |
| 9702 { | 9702 { |
| 9703 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 9703 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |
| 9704 instance_template->SetCallAsFunctionHandler(ThrowValue); | 9704 instance_template->SetCallAsFunctionHandler(ThrowValue); |
| 9705 Local<Object> instance = instance_template->NewInstance(); | 9705 Local<Object> instance = instance_template->NewInstance(); |
| 9706 context->Global()->Set(v8_str("obj3"), instance); | 9706 context->Global()->Set(v8_str("obj3"), instance); |
| 9707 v8::TryCatch try_catch; | 9707 v8::TryCatch try_catch(isolate); |
| 9708 Local<Value> value; | 9708 Local<Value> value; |
| 9709 CHECK(!try_catch.HasCaught()); | 9709 CHECK(!try_catch.HasCaught()); |
| 9710 | 9710 |
| 9711 value = CompileRun("new obj3(22)"); | 9711 value = CompileRun("new obj3(22)"); |
| 9712 CHECK(try_catch.HasCaught()); | 9712 CHECK(try_catch.HasCaught()); |
| 9713 String::Utf8Value exception_value1(try_catch.Exception()); | 9713 String::Utf8Value exception_value1(try_catch.Exception()); |
| 9714 CHECK_EQ(0, strcmp("22", *exception_value1)); | 9714 CHECK_EQ(0, strcmp("22", *exception_value1)); |
| 9715 try_catch.Reset(); | 9715 try_catch.Reset(); |
| 9716 | 9716 |
| 9717 Local<Value> args[] = {v8_num(23)}; | 9717 Local<Value> args[] = {v8_num(23)}; |
| 9718 value = instance->CallAsConstructor(1, args); | 9718 value = instance->CallAsConstructor(1, args); |
| 9719 CHECK(try_catch.HasCaught()); | 9719 CHECK(try_catch.HasCaught()); |
| 9720 String::Utf8Value exception_value2(try_catch.Exception()); | 9720 String::Utf8Value exception_value2(try_catch.Exception()); |
| 9721 CHECK_EQ(0, strcmp("23", *exception_value2)); | 9721 CHECK_EQ(0, strcmp("23", *exception_value2)); |
| 9722 try_catch.Reset(); | 9722 try_catch.Reset(); |
| 9723 } | 9723 } |
| 9724 | 9724 |
| 9725 // Check whether constructor returns with an object or non-object. | 9725 // Check whether constructor returns with an object or non-object. |
| 9726 { | 9726 { |
| 9727 Local<FunctionTemplate> function_template = | 9727 Local<FunctionTemplate> function_template = |
| 9728 FunctionTemplate::New(isolate, FakeConstructorCallback); | 9728 FunctionTemplate::New(isolate, FakeConstructorCallback); |
| 9729 Local<Function> function = function_template->GetFunction(); | 9729 Local<Function> function = function_template->GetFunction(); |
| 9730 Local<Object> instance1 = function; | 9730 Local<Object> instance1 = function; |
| 9731 context->Global()->Set(v8_str("obj4"), instance1); | 9731 context->Global()->Set(v8_str("obj4"), instance1); |
| 9732 v8::TryCatch try_catch; | 9732 v8::TryCatch try_catch(isolate); |
| 9733 Local<Value> value; | 9733 Local<Value> value; |
| 9734 CHECK(!try_catch.HasCaught()); | 9734 CHECK(!try_catch.HasCaught()); |
| 9735 | 9735 |
| 9736 CHECK(instance1->IsObject()); | 9736 CHECK(instance1->IsObject()); |
| 9737 CHECK(instance1->IsFunction()); | 9737 CHECK(instance1->IsFunction()); |
| 9738 | 9738 |
| 9739 value = CompileRun("new obj4(28)"); | 9739 value = CompileRun("new obj4(28)"); |
| 9740 CHECK(!try_catch.HasCaught()); | 9740 CHECK(!try_catch.HasCaught()); |
| 9741 CHECK(value->IsObject()); | 9741 CHECK(value->IsObject()); |
| 9742 | 9742 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9806 "result1 = f(new Object());" | 9806 "result1 = f(new Object());" |
| 9807 "result2 = f(this);" | 9807 "result2 = f(this);" |
| 9808 "var x = new Object();" | 9808 "var x = new Object();" |
| 9809 "x.eval = function(x) { return 1; };" | 9809 "x.eval = function(x) { return 1; };" |
| 9810 "result3 = f(x);"); | 9810 "result3 = f(x);"); |
| 9811 script->Run(); | 9811 script->Run(); |
| 9812 CHECK_EQ(2, current->Global()->Get(v8_str("result1"))->Int32Value()); | 9812 CHECK_EQ(2, current->Global()->Get(v8_str("result1"))->Int32Value()); |
| 9813 CHECK_EQ(0, current->Global()->Get(v8_str("result2"))->Int32Value()); | 9813 CHECK_EQ(0, current->Global()->Get(v8_str("result2"))->Int32Value()); |
| 9814 CHECK_EQ(1, current->Global()->Get(v8_str("result3"))->Int32Value()); | 9814 CHECK_EQ(1, current->Global()->Get(v8_str("result3"))->Int32Value()); |
| 9815 | 9815 |
| 9816 v8::TryCatch try_catch; | 9816 v8::TryCatch try_catch(current->GetIsolate()); |
| 9817 script = v8_compile( | 9817 script = v8_compile( |
| 9818 "function f(x) { " | 9818 "function f(x) { " |
| 9819 " var bar = 2;" | 9819 " var bar = 2;" |
| 9820 " with (x) { return eval('bar'); }" | 9820 " with (x) { return eval('bar'); }" |
| 9821 "}" | 9821 "}" |
| 9822 "result4 = f(this)"); | 9822 "result4 = f(this)"); |
| 9823 script->Run(); | 9823 script->Run(); |
| 9824 CHECK(!try_catch.HasCaught()); | 9824 CHECK(!try_catch.HasCaught()); |
| 9825 CHECK_EQ(2, current->Global()->Get(v8_str("result4"))->Int32Value()); | 9825 CHECK_EQ(2, current->Global()->Get(v8_str("result4"))->Int32Value()); |
| 9826 | 9826 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 9849 | 9849 |
| 9850 // Check that writing to non-existing properties introduces them in | 9850 // Check that writing to non-existing properties introduces them in |
| 9851 // the other context. | 9851 // the other context. |
| 9852 script = v8_compile("other.eval('na = 1234')"); | 9852 script = v8_compile("other.eval('na = 1234')"); |
| 9853 script->Run(); | 9853 script->Run(); |
| 9854 CHECK_EQ(1234, other->Global()->Get(v8_str("na"))->Int32Value()); | 9854 CHECK_EQ(1234, other->Global()->Get(v8_str("na"))->Int32Value()); |
| 9855 CHECK(!current->Global()->Has(v8_str("na"))); | 9855 CHECK(!current->Global()->Has(v8_str("na"))); |
| 9856 | 9856 |
| 9857 // Check that global variables in current context are not visible in other | 9857 // Check that global variables in current context are not visible in other |
| 9858 // context. | 9858 // context. |
| 9859 v8::TryCatch try_catch; | 9859 v8::TryCatch try_catch(CcTest::isolate()); |
| 9860 script = v8_compile("var bar = 42; other.eval('bar');"); | 9860 script = v8_compile("var bar = 42; other.eval('bar');"); |
| 9861 Local<Value> result = script->Run(); | 9861 Local<Value> result = script->Run(); |
| 9862 CHECK(try_catch.HasCaught()); | 9862 CHECK(try_catch.HasCaught()); |
| 9863 try_catch.Reset(); | 9863 try_catch.Reset(); |
| 9864 | 9864 |
| 9865 // Check that local variables in current context are not visible in other | 9865 // Check that local variables in current context are not visible in other |
| 9866 // context. | 9866 // context. |
| 9867 script = v8_compile( | 9867 script = v8_compile( |
| 9868 "(function() { " | 9868 "(function() { " |
| 9869 " var baz = 87;" | 9869 " var baz = 87;" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9923 context0->Exit(); | 9923 context0->Exit(); |
| 9924 | 9924 |
| 9925 // Put the function into context1 and call it before and after | 9925 // Put the function into context1 and call it before and after |
| 9926 // detaching the global. Before detaching, the call succeeds and | 9926 // detaching the global. Before detaching, the call succeeds and |
| 9927 // after detaching and exception is thrown. | 9927 // after detaching and exception is thrown. |
| 9928 context1->Enter(); | 9928 context1->Enter(); |
| 9929 context1->Global()->Set(v8_str("fun"), fun); | 9929 context1->Global()->Set(v8_str("fun"), fun); |
| 9930 v8::Handle<v8::Value> x_value = CompileRun("fun('x')"); | 9930 v8::Handle<v8::Value> x_value = CompileRun("fun('x')"); |
| 9931 CHECK_EQ(42, x_value->Int32Value()); | 9931 CHECK_EQ(42, x_value->Int32Value()); |
| 9932 context0->DetachGlobal(); | 9932 context0->DetachGlobal(); |
| 9933 v8::TryCatch catcher; | 9933 v8::TryCatch catcher(isolate); |
| 9934 x_value = CompileRun("fun('x')"); | 9934 x_value = CompileRun("fun('x')"); |
| 9935 CHECK_EQ(42, x_value->Int32Value()); | 9935 CHECK_EQ(42, x_value->Int32Value()); |
| 9936 context1->Exit(); | 9936 context1->Exit(); |
| 9937 } | 9937 } |
| 9938 | 9938 |
| 9939 | 9939 |
| 9940 THREADED_TEST(CrossLazyLoad) { | 9940 THREADED_TEST(CrossLazyLoad) { |
| 9941 v8::HandleScope scope(CcTest::isolate()); | 9941 v8::HandleScope scope(CcTest::isolate()); |
| 9942 LocalContext other; | 9942 LocalContext other; |
| 9943 LocalContext current; | 9943 LocalContext current; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9981 LocalContext context; | 9981 LocalContext context; |
| 9982 v8::Isolate* isolate = context->GetIsolate(); | 9982 v8::Isolate* isolate = context->GetIsolate(); |
| 9983 v8::HandleScope scope(isolate); | 9983 v8::HandleScope scope(isolate); |
| 9984 | 9984 |
| 9985 { | 9985 { |
| 9986 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); | 9986 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 9987 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 9987 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
| 9988 instance_template->SetCallAsFunctionHandler(call_as_function); | 9988 instance_template->SetCallAsFunctionHandler(call_as_function); |
| 9989 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 9989 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
| 9990 context->Global()->Set(v8_str("obj"), instance); | 9990 context->Global()->Set(v8_str("obj"), instance); |
| 9991 v8::TryCatch try_catch; | 9991 v8::TryCatch try_catch(isolate); |
| 9992 Local<Value> value; | 9992 Local<Value> value; |
| 9993 CHECK(!try_catch.HasCaught()); | 9993 CHECK(!try_catch.HasCaught()); |
| 9994 | 9994 |
| 9995 value = CompileRun("obj(42)"); | 9995 value = CompileRun("obj(42)"); |
| 9996 CHECK(!try_catch.HasCaught()); | 9996 CHECK(!try_catch.HasCaught()); |
| 9997 CHECK_EQ(42, value->Int32Value()); | 9997 CHECK_EQ(42, value->Int32Value()); |
| 9998 | 9998 |
| 9999 value = CompileRun("(function(o){return o(49)})(obj)"); | 9999 value = CompileRun("(function(o){return o(49)})(obj)"); |
| 10000 CHECK(!try_catch.HasCaught()); | 10000 CHECK(!try_catch.HasCaught()); |
| 10001 CHECK_EQ(49, value->Int32Value()); | 10001 CHECK_EQ(49, value->Int32Value()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10036 CHECK(!try_catch.HasCaught()); | 10036 CHECK(!try_catch.HasCaught()); |
| 10037 CHECK_EQ(28, value->Int32Value()); | 10037 CHECK_EQ(28, value->Int32Value()); |
| 10038 } | 10038 } |
| 10039 | 10039 |
| 10040 { | 10040 { |
| 10041 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); | 10041 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 10042 Local<ObjectTemplate> instance_template(t->InstanceTemplate()); | 10042 Local<ObjectTemplate> instance_template(t->InstanceTemplate()); |
| 10043 USE(instance_template); | 10043 USE(instance_template); |
| 10044 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 10044 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
| 10045 context->Global()->Set(v8_str("obj2"), instance); | 10045 context->Global()->Set(v8_str("obj2"), instance); |
| 10046 v8::TryCatch try_catch; | 10046 v8::TryCatch try_catch(isolate); |
| 10047 Local<Value> value; | 10047 Local<Value> value; |
| 10048 CHECK(!try_catch.HasCaught()); | 10048 CHECK(!try_catch.HasCaught()); |
| 10049 | 10049 |
| 10050 // Call an object without call-as-function handler through the JS | 10050 // Call an object without call-as-function handler through the JS |
| 10051 value = CompileRun("obj2(28)"); | 10051 value = CompileRun("obj2(28)"); |
| 10052 CHECK(value.IsEmpty()); | 10052 CHECK(value.IsEmpty()); |
| 10053 CHECK(try_catch.HasCaught()); | 10053 CHECK(try_catch.HasCaught()); |
| 10054 String::Utf8Value exception_value1(try_catch.Exception()); | 10054 String::Utf8Value exception_value1(try_catch.Exception()); |
| 10055 // TODO(verwaest): Better message | 10055 // TODO(verwaest): Better message |
| 10056 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); | 10056 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 10067 *exception_value2)); | 10067 *exception_value2)); |
| 10068 try_catch.Reset(); | 10068 try_catch.Reset(); |
| 10069 } | 10069 } |
| 10070 | 10070 |
| 10071 { | 10071 { |
| 10072 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); | 10072 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 10073 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 10073 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
| 10074 instance_template->SetCallAsFunctionHandler(ThrowValue); | 10074 instance_template->SetCallAsFunctionHandler(ThrowValue); |
| 10075 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 10075 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
| 10076 context->Global()->Set(v8_str("obj3"), instance); | 10076 context->Global()->Set(v8_str("obj3"), instance); |
| 10077 v8::TryCatch try_catch; | 10077 v8::TryCatch try_catch(isolate); |
| 10078 Local<Value> value; | 10078 Local<Value> value; |
| 10079 CHECK(!try_catch.HasCaught()); | 10079 CHECK(!try_catch.HasCaught()); |
| 10080 | 10080 |
| 10081 // Catch the exception which is thrown by call-as-function handler | 10081 // Catch the exception which is thrown by call-as-function handler |
| 10082 value = CompileRun("obj3(22)"); | 10082 value = CompileRun("obj3(22)"); |
| 10083 CHECK(try_catch.HasCaught()); | 10083 CHECK(try_catch.HasCaught()); |
| 10084 String::Utf8Value exception_value1(try_catch.Exception()); | 10084 String::Utf8Value exception_value1(try_catch.Exception()); |
| 10085 CHECK_EQ(0, strcmp("22", *exception_value1)); | 10085 CHECK_EQ(0, strcmp("22", *exception_value1)); |
| 10086 try_catch.Reset(); | 10086 try_catch.Reset(); |
| 10087 | 10087 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10165 // Check whether a non-function object is callable. | 10165 // Check whether a non-function object is callable. |
| 10166 THREADED_TEST(CallableObject) { | 10166 THREADED_TEST(CallableObject) { |
| 10167 LocalContext context; | 10167 LocalContext context; |
| 10168 v8::Isolate* isolate = context->GetIsolate(); | 10168 v8::Isolate* isolate = context->GetIsolate(); |
| 10169 v8::HandleScope scope(isolate); | 10169 v8::HandleScope scope(isolate); |
| 10170 | 10170 |
| 10171 { | 10171 { |
| 10172 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 10172 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |
| 10173 instance_template->SetCallAsFunctionHandler(call_as_function); | 10173 instance_template->SetCallAsFunctionHandler(call_as_function); |
| 10174 Local<Object> instance = instance_template->NewInstance(); | 10174 Local<Object> instance = instance_template->NewInstance(); |
| 10175 v8::TryCatch try_catch; | 10175 v8::TryCatch try_catch(isolate); |
| 10176 | 10176 |
| 10177 CHECK(instance->IsCallable()); | 10177 CHECK(instance->IsCallable()); |
| 10178 CHECK(!try_catch.HasCaught()); | 10178 CHECK(!try_catch.HasCaught()); |
| 10179 } | 10179 } |
| 10180 | 10180 |
| 10181 { | 10181 { |
| 10182 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 10182 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |
| 10183 Local<Object> instance = instance_template->NewInstance(); | 10183 Local<Object> instance = instance_template->NewInstance(); |
| 10184 v8::TryCatch try_catch; | 10184 v8::TryCatch try_catch(isolate); |
| 10185 | 10185 |
| 10186 CHECK(!instance->IsCallable()); | 10186 CHECK(!instance->IsCallable()); |
| 10187 CHECK(!try_catch.HasCaught()); | 10187 CHECK(!try_catch.HasCaught()); |
| 10188 } | 10188 } |
| 10189 | 10189 |
| 10190 { | 10190 { |
| 10191 Local<FunctionTemplate> function_template = | 10191 Local<FunctionTemplate> function_template = |
| 10192 FunctionTemplate::New(isolate, call_as_function); | 10192 FunctionTemplate::New(isolate, call_as_function); |
| 10193 Local<Function> function = function_template->GetFunction(); | 10193 Local<Function> function = function_template->GetFunction(); |
| 10194 Local<Object> instance = function; | 10194 Local<Object> instance = function; |
| 10195 v8::TryCatch try_catch; | 10195 v8::TryCatch try_catch(isolate); |
| 10196 | 10196 |
| 10197 CHECK(instance->IsCallable()); | 10197 CHECK(instance->IsCallable()); |
| 10198 CHECK(!try_catch.HasCaught()); | 10198 CHECK(!try_catch.HasCaught()); |
| 10199 } | 10199 } |
| 10200 | 10200 |
| 10201 { | 10201 { |
| 10202 Local<FunctionTemplate> function_template = FunctionTemplate::New(isolate); | 10202 Local<FunctionTemplate> function_template = FunctionTemplate::New(isolate); |
| 10203 Local<Function> function = function_template->GetFunction(); | 10203 Local<Function> function = function_template->GetFunction(); |
| 10204 Local<Object> instance = function; | 10204 Local<Object> instance = function; |
| 10205 v8::TryCatch try_catch; | 10205 v8::TryCatch try_catch(isolate); |
| 10206 | 10206 |
| 10207 CHECK(instance->IsCallable()); | 10207 CHECK(instance->IsCallable()); |
| 10208 CHECK(!try_catch.HasCaught()); | 10208 CHECK(!try_catch.HasCaught()); |
| 10209 } | 10209 } |
| 10210 } | 10210 } |
| 10211 | 10211 |
| 10212 | 10212 |
| 10213 static int Recurse(v8::Isolate* isolate, int depth, int iterations) { | 10213 static int Recurse(v8::Isolate* isolate, int depth, int iterations) { |
| 10214 v8::HandleScope scope(isolate); | 10214 v8::HandleScope scope(isolate); |
| 10215 if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate); | 10215 if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10586 proto_templ->Set(v8_str("method"), method_templ); | 10586 proto_templ->Set(v8_str("method"), method_templ); |
| 10587 fun_templ->SetHiddenPrototype(true); | 10587 fun_templ->SetHiddenPrototype(true); |
| 10588 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 10588 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 10589 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( | 10589 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( |
| 10590 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 10590 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 10591 v8::External::New(isolate, &interceptor_call_count))); | 10591 v8::External::New(isolate, &interceptor_call_count))); |
| 10592 LocalContext context; | 10592 LocalContext context; |
| 10593 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10593 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 10594 GenerateSomeGarbage(); | 10594 GenerateSomeGarbage(); |
| 10595 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10595 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 10596 v8::TryCatch try_catch; | 10596 v8::TryCatch try_catch(isolate); |
| 10597 CompileRun( | 10597 CompileRun( |
| 10598 "o.foo = 17;" | 10598 "o.foo = 17;" |
| 10599 "var receiver = {};" | 10599 "var receiver = {};" |
| 10600 "receiver.__proto__ = o;" | 10600 "receiver.__proto__ = o;" |
| 10601 "var result = 0;" | 10601 "var result = 0;" |
| 10602 "var saved_result = 0;" | 10602 "var saved_result = 0;" |
| 10603 "for (var i = 0; i < 100; i++) {" | 10603 "for (var i = 0; i < 100; i++) {" |
| 10604 " result = receiver.method(41);" | 10604 " result = receiver.method(41);" |
| 10605 " if (i == 50) {" | 10605 " if (i == 50) {" |
| 10606 " saved_result = result;" | 10606 " saved_result = result;" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 10629 proto_templ->Set(v8_str("method"), method_templ); | 10629 proto_templ->Set(v8_str("method"), method_templ); |
| 10630 fun_templ->SetHiddenPrototype(true); | 10630 fun_templ->SetHiddenPrototype(true); |
| 10631 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 10631 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 10632 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( | 10632 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( |
| 10633 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 10633 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 10634 v8::External::New(isolate, &interceptor_call_count))); | 10634 v8::External::New(isolate, &interceptor_call_count))); |
| 10635 LocalContext context; | 10635 LocalContext context; |
| 10636 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10636 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 10637 GenerateSomeGarbage(); | 10637 GenerateSomeGarbage(); |
| 10638 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10638 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 10639 v8::TryCatch try_catch; | 10639 v8::TryCatch try_catch(isolate); |
| 10640 CompileRun( | 10640 CompileRun( |
| 10641 "o.foo = 17;" | 10641 "o.foo = 17;" |
| 10642 "var receiver = {};" | 10642 "var receiver = {};" |
| 10643 "receiver.__proto__ = o;" | 10643 "receiver.__proto__ = o;" |
| 10644 "var result = 0;" | 10644 "var result = 0;" |
| 10645 "var saved_result = 0;" | 10645 "var saved_result = 0;" |
| 10646 "for (var i = 0; i < 100; i++) {" | 10646 "for (var i = 0; i < 100; i++) {" |
| 10647 " result = receiver.method(41);" | 10647 " result = receiver.method(41);" |
| 10648 " if (i == 50) {" | 10648 " if (i == 50) {" |
| 10649 " saved_result = result;" | 10649 " saved_result = result;" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10761 v8::Signature::New(isolate, fun_templ)); | 10761 v8::Signature::New(isolate, fun_templ)); |
| 10762 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 10762 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 10763 proto_templ->Set(v8_str("method"), method_templ); | 10763 proto_templ->Set(v8_str("method"), method_templ); |
| 10764 fun_templ->SetHiddenPrototype(true); | 10764 fun_templ->SetHiddenPrototype(true); |
| 10765 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 10765 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 10766 CHECK(!templ.IsEmpty()); | 10766 CHECK(!templ.IsEmpty()); |
| 10767 LocalContext context; | 10767 LocalContext context; |
| 10768 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10768 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 10769 GenerateSomeGarbage(); | 10769 GenerateSomeGarbage(); |
| 10770 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10770 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 10771 v8::TryCatch try_catch; | 10771 v8::TryCatch try_catch(isolate); |
| 10772 CompileRun( | 10772 CompileRun( |
| 10773 "o.foo = 17;" | 10773 "o.foo = 17;" |
| 10774 "var receiver = {};" | 10774 "var receiver = {};" |
| 10775 "receiver.__proto__ = o;" | 10775 "receiver.__proto__ = o;" |
| 10776 "var result = 0;" | 10776 "var result = 0;" |
| 10777 "var saved_result = 0;" | 10777 "var saved_result = 0;" |
| 10778 "for (var i = 0; i < 100; i++) {" | 10778 "for (var i = 0; i < 100; i++) {" |
| 10779 " result = receiver.method(41);" | 10779 " result = receiver.method(41);" |
| 10780 " if (i == 50) {" | 10780 " if (i == 50) {" |
| 10781 " saved_result = result;" | 10781 " saved_result = result;" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 10800 v8::Signature::New(isolate, fun_templ)); | 10800 v8::Signature::New(isolate, fun_templ)); |
| 10801 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 10801 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 10802 proto_templ->Set(v8_str("method"), method_templ); | 10802 proto_templ->Set(v8_str("method"), method_templ); |
| 10803 fun_templ->SetHiddenPrototype(true); | 10803 fun_templ->SetHiddenPrototype(true); |
| 10804 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 10804 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 10805 CHECK(!templ.IsEmpty()); | 10805 CHECK(!templ.IsEmpty()); |
| 10806 LocalContext context; | 10806 LocalContext context; |
| 10807 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10807 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 10808 GenerateSomeGarbage(); | 10808 GenerateSomeGarbage(); |
| 10809 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10809 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 10810 v8::TryCatch try_catch; | 10810 v8::TryCatch try_catch(isolate); |
| 10811 CompileRun( | 10811 CompileRun( |
| 10812 "o.foo = 17;" | 10812 "o.foo = 17;" |
| 10813 "var receiver = {};" | 10813 "var receiver = {};" |
| 10814 "receiver.__proto__ = o;" | 10814 "receiver.__proto__ = o;" |
| 10815 "var result = 0;" | 10815 "var result = 0;" |
| 10816 "var saved_result = 0;" | 10816 "var saved_result = 0;" |
| 10817 "for (var i = 0; i < 100; i++) {" | 10817 "for (var i = 0; i < 100; i++) {" |
| 10818 " result = receiver.method(41);" | 10818 " result = receiver.method(41);" |
| 10819 " if (i == 50) {" | 10819 " if (i == 50) {" |
| 10820 " saved_result = result;" | 10820 " saved_result = result;" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 10848 | 10848 |
| 10849 Local<Object> another = Object::New(context->GetIsolate()); | 10849 Local<Object> another = Object::New(context->GetIsolate()); |
| 10850 another->SetPrototype(instance); | 10850 another->SetPrototype(instance); |
| 10851 | 10851 |
| 10852 Local<Object> with_js_getter = CompileRun( | 10852 Local<Object> with_js_getter = CompileRun( |
| 10853 "o = {};\n" | 10853 "o = {};\n" |
| 10854 "o.__defineGetter__('f', function() { throw undefined; });\n" | 10854 "o.__defineGetter__('f', function() { throw undefined; });\n" |
| 10855 "o\n").As<Object>(); | 10855 "o\n").As<Object>(); |
| 10856 CHECK(!with_js_getter.IsEmpty()); | 10856 CHECK(!with_js_getter.IsEmpty()); |
| 10857 | 10857 |
| 10858 TryCatch try_catch; | 10858 TryCatch try_catch(context->GetIsolate()); |
| 10859 | 10859 |
| 10860 Local<Value> result = instance->GetRealNamedProperty(v8_str("f")); | 10860 Local<Value> result = instance->GetRealNamedProperty(v8_str("f")); |
| 10861 CHECK(try_catch.HasCaught()); | 10861 CHECK(try_catch.HasCaught()); |
| 10862 try_catch.Reset(); | 10862 try_catch.Reset(); |
| 10863 CHECK(result.IsEmpty()); | 10863 CHECK(result.IsEmpty()); |
| 10864 | 10864 |
| 10865 Maybe<PropertyAttribute> attr = | 10865 Maybe<PropertyAttribute> attr = |
| 10866 instance->GetRealNamedPropertyAttributes(v8_str("f")); | 10866 instance->GetRealNamedPropertyAttributes(v8_str("f")); |
| 10867 CHECK(!try_catch.HasCaught()); | 10867 CHECK(!try_catch.HasCaught()); |
| 10868 CHECK(Just(None) == attr); | 10868 CHECK(Just(None) == attr); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10901 | 10901 |
| 10902 result = with_js_getter->Get(v8_str("f")); | 10902 result = with_js_getter->Get(v8_str("f")); |
| 10903 CHECK(try_catch.HasCaught()); | 10903 CHECK(try_catch.HasCaught()); |
| 10904 try_catch.Reset(); | 10904 try_catch.Reset(); |
| 10905 CHECK(result.IsEmpty()); | 10905 CHECK(result.IsEmpty()); |
| 10906 } | 10906 } |
| 10907 | 10907 |
| 10908 | 10908 |
| 10909 static void ThrowingCallbackWithTryCatch( | 10909 static void ThrowingCallbackWithTryCatch( |
| 10910 const v8::FunctionCallbackInfo<v8::Value>& args) { | 10910 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 10911 TryCatch try_catch; | 10911 TryCatch try_catch(args.GetIsolate()); |
| 10912 // Verboseness is important: it triggers message delivery which can call into | 10912 // Verboseness is important: it triggers message delivery which can call into |
| 10913 // external code. | 10913 // external code. |
| 10914 try_catch.SetVerbose(true); | 10914 try_catch.SetVerbose(true); |
| 10915 CompileRun("throw 'from JS';"); | 10915 CompileRun("throw 'from JS';"); |
| 10916 CHECK(try_catch.HasCaught()); | 10916 CHECK(try_catch.HasCaught()); |
| 10917 CHECK(!CcTest::i_isolate()->has_pending_exception()); | 10917 CHECK(!CcTest::i_isolate()->has_pending_exception()); |
| 10918 CHECK(!CcTest::i_isolate()->has_scheduled_exception()); | 10918 CHECK(!CcTest::i_isolate()->has_scheduled_exception()); |
| 10919 } | 10919 } |
| 10920 | 10920 |
| 10921 | 10921 |
| 10922 static int call_depth; | 10922 static int call_depth; |
| 10923 | 10923 |
| 10924 | 10924 |
| 10925 static void WithTryCatch(Handle<Message> message, Handle<Value> data) { | 10925 static void WithTryCatch(Handle<Message> message, Handle<Value> data) { |
| 10926 TryCatch try_catch; | 10926 TryCatch try_catch(CcTest::isolate()); |
| 10927 } | 10927 } |
| 10928 | 10928 |
| 10929 | 10929 |
| 10930 static void ThrowFromJS(Handle<Message> message, Handle<Value> data) { | 10930 static void ThrowFromJS(Handle<Message> message, Handle<Value> data) { |
| 10931 if (--call_depth) CompileRun("throw 'ThrowInJS';"); | 10931 if (--call_depth) CompileRun("throw 'ThrowInJS';"); |
| 10932 } | 10932 } |
| 10933 | 10933 |
| 10934 | 10934 |
| 10935 static void ThrowViaApi(Handle<Message> message, Handle<Value> data) { | 10935 static void ThrowViaApi(Handle<Message> message, Handle<Value> data) { |
| 10936 if (--call_depth) CcTest::isolate()->ThrowException(v8_str("ThrowViaApi")); | 10936 if (--call_depth) CcTest::isolate()->ThrowException(v8_str("ThrowViaApi")); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11205 TEST_TOSTRINGTAG_TYPES(valueNull); | 11205 TEST_TOSTRINGTAG_TYPES(valueNull); |
| 11206 TEST_TOSTRINGTAG_TYPES(valueUndef); | 11206 TEST_TOSTRINGTAG_TYPES(valueUndef); |
| 11207 | 11207 |
| 11208 #undef TEST_TOSTRINGTAG | 11208 #undef TEST_TOSTRINGTAG |
| 11209 #undef TEST_TOSTRINGTAG_TYPES | 11209 #undef TEST_TOSTRINGTAG_TYPES |
| 11210 | 11210 |
| 11211 // @@toStringTag getter throws | 11211 // @@toStringTag getter throws |
| 11212 Local<Value> obj = v8::Object::New(isolate); | 11212 Local<Value> obj = v8::Object::New(isolate); |
| 11213 obj.As<v8::Object>()->SetAccessor(toStringTag, ThrowingSymbolAccessorGetter); | 11213 obj.As<v8::Object>()->SetAccessor(toStringTag, ThrowingSymbolAccessorGetter); |
| 11214 { | 11214 { |
| 11215 TryCatch try_catch; | 11215 TryCatch try_catch(isolate); |
| 11216 value = obj.As<v8::Object>()->ObjectProtoToString(); | 11216 value = obj.As<v8::Object>()->ObjectProtoToString(); |
| 11217 CHECK(value.IsEmpty()); | 11217 CHECK(value.IsEmpty()); |
| 11218 CHECK(try_catch.HasCaught()); | 11218 CHECK(try_catch.HasCaught()); |
| 11219 } | 11219 } |
| 11220 | 11220 |
| 11221 // @@toStringTag getter does not throw | 11221 // @@toStringTag getter does not throw |
| 11222 obj = v8::Object::New(isolate); | 11222 obj = v8::Object::New(isolate); |
| 11223 obj.As<v8::Object>()->SetAccessor( | 11223 obj.As<v8::Object>()->SetAccessor( |
| 11224 toStringTag, SymbolAccessorGetterReturnsDefault, 0, v8_str("Test")); | 11224 toStringTag, SymbolAccessorGetterReturnsDefault, 0, v8_str("Test")); |
| 11225 { | 11225 { |
| 11226 TryCatch try_catch; | 11226 TryCatch try_catch(isolate); |
| 11227 value = obj.As<v8::Object>()->ObjectProtoToString(); | 11227 value = obj.As<v8::Object>()->ObjectProtoToString(); |
| 11228 CHECK(value->IsString() && value->Equals(v8_str("[object Test]"))); | 11228 CHECK(value->IsString() && value->Equals(v8_str("[object Test]"))); |
| 11229 CHECK(!try_catch.HasCaught()); | 11229 CHECK(!try_catch.HasCaught()); |
| 11230 } | 11230 } |
| 11231 | 11231 |
| 11232 // JS @@toStringTag value | 11232 // JS @@toStringTag value |
| 11233 obj = CompileRun("obj = {}; obj[Symbol.toStringTag] = 'Test'; obj"); | 11233 obj = CompileRun("obj = {}; obj[Symbol.toStringTag] = 'Test'; obj"); |
| 11234 { | 11234 { |
| 11235 TryCatch try_catch; | 11235 TryCatch try_catch(isolate); |
| 11236 value = obj.As<v8::Object>()->ObjectProtoToString(); | 11236 value = obj.As<v8::Object>()->ObjectProtoToString(); |
| 11237 CHECK(value->IsString() && value->Equals(v8_str("[object Test]"))); | 11237 CHECK(value->IsString() && value->Equals(v8_str("[object Test]"))); |
| 11238 CHECK(!try_catch.HasCaught()); | 11238 CHECK(!try_catch.HasCaught()); |
| 11239 } | 11239 } |
| 11240 | 11240 |
| 11241 // JS @@toStringTag getter throws | 11241 // JS @@toStringTag getter throws |
| 11242 obj = CompileRun( | 11242 obj = CompileRun( |
| 11243 "obj = {}; Object.defineProperty(obj, Symbol.toStringTag, {" | 11243 "obj = {}; Object.defineProperty(obj, Symbol.toStringTag, {" |
| 11244 " get: function() { throw 'Test'; }" | 11244 " get: function() { throw 'Test'; }" |
| 11245 "}); obj"); | 11245 "}); obj"); |
| 11246 { | 11246 { |
| 11247 TryCatch try_catch; | 11247 TryCatch try_catch(isolate); |
| 11248 value = obj.As<v8::Object>()->ObjectProtoToString(); | 11248 value = obj.As<v8::Object>()->ObjectProtoToString(); |
| 11249 CHECK(value.IsEmpty()); | 11249 CHECK(value.IsEmpty()); |
| 11250 CHECK(try_catch.HasCaught()); | 11250 CHECK(try_catch.HasCaught()); |
| 11251 } | 11251 } |
| 11252 | 11252 |
| 11253 // JS @@toStringTag getter does not throw | 11253 // JS @@toStringTag getter does not throw |
| 11254 obj = CompileRun( | 11254 obj = CompileRun( |
| 11255 "obj = {}; Object.defineProperty(obj, Symbol.toStringTag, {" | 11255 "obj = {}; Object.defineProperty(obj, Symbol.toStringTag, {" |
| 11256 " get: function() { return 'Test'; }" | 11256 " get: function() { return 'Test'; }" |
| 11257 "}); obj"); | 11257 "}); obj"); |
| 11258 { | 11258 { |
| 11259 TryCatch try_catch; | 11259 TryCatch try_catch(isolate); |
| 11260 value = obj.As<v8::Object>()->ObjectProtoToString(); | 11260 value = obj.As<v8::Object>()->ObjectProtoToString(); |
| 11261 CHECK(value->IsString() && value->Equals(v8_str("[object Test]"))); | 11261 CHECK(value->IsString() && value->Equals(v8_str("[object Test]"))); |
| 11262 CHECK(!try_catch.HasCaught()); | 11262 CHECK(!try_catch.HasCaught()); |
| 11263 } | 11263 } |
| 11264 } | 11264 } |
| 11265 | 11265 |
| 11266 | 11266 |
| 11267 THREADED_TEST(ObjectGetConstructorName) { | 11267 THREADED_TEST(ObjectGetConstructorName) { |
| 11268 v8::Isolate* isolate = CcTest::isolate(); | 11268 v8::Isolate* isolate = CcTest::isolate(); |
| 11269 LocalContext context; | 11269 LocalContext context; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11463 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) { | 11463 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 11464 v8::Isolate* isolate = args.GetIsolate(); | 11464 v8::Isolate* isolate = args.GetIsolate(); |
| 11465 CHECK(v8::Locker::IsLocked(isolate)); | 11465 CHECK(v8::Locker::IsLocked(isolate)); |
| 11466 ApiTestFuzzer::Fuzz(); | 11466 ApiTestFuzzer::Fuzz(); |
| 11467 v8::Unlocker unlocker(isolate); | 11467 v8::Unlocker unlocker(isolate); |
| 11468 const char* code = "throw 7;"; | 11468 const char* code = "throw 7;"; |
| 11469 { | 11469 { |
| 11470 v8::Locker nested_locker(isolate); | 11470 v8::Locker nested_locker(isolate); |
| 11471 v8::HandleScope scope(isolate); | 11471 v8::HandleScope scope(isolate); |
| 11472 v8::Handle<Value> exception; | 11472 v8::Handle<Value> exception; |
| 11473 { v8::TryCatch try_catch; | 11473 { |
| 11474 v8::TryCatch try_catch(isolate); |
| 11474 v8::Handle<Value> value = CompileRun(code); | 11475 v8::Handle<Value> value = CompileRun(code); |
| 11475 CHECK(value.IsEmpty()); | 11476 CHECK(value.IsEmpty()); |
| 11476 CHECK(try_catch.HasCaught()); | 11477 CHECK(try_catch.HasCaught()); |
| 11477 // Make sure to wrap the exception in a new handle because | 11478 // Make sure to wrap the exception in a new handle because |
| 11478 // the handle returned from the TryCatch is destroyed | 11479 // the handle returned from the TryCatch is destroyed |
| 11479 // when the TryCatch is destroyed. | 11480 // when the TryCatch is destroyed. |
| 11480 exception = Local<Value>::New(isolate, try_catch.Exception()); | 11481 exception = Local<Value>::New(isolate, try_catch.Exception()); |
| 11481 } | 11482 } |
| 11482 args.GetIsolate()->ThrowException(exception); | 11483 args.GetIsolate()->ThrowException(exception); |
| 11483 } | 11484 } |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12489 v8::Local<v8::ObjectTemplate>::New(isolate, templ)->NewInstance(); | 12490 v8::Local<v8::ObjectTemplate>::New(isolate, templ)->NewInstance(); |
| 12490 CHECK_EQ(1, result->InternalFieldCount()); | 12491 CHECK_EQ(1, result->InternalFieldCount()); |
| 12491 } | 12492 } |
| 12492 | 12493 |
| 12493 | 12494 |
| 12494 // If part of the threaded tests, this test makes ThreadingTest fail | 12495 // If part of the threaded tests, this test makes ThreadingTest fail |
| 12495 // on mac. | 12496 // on mac. |
| 12496 TEST(CatchStackOverflow) { | 12497 TEST(CatchStackOverflow) { |
| 12497 LocalContext context; | 12498 LocalContext context; |
| 12498 v8::HandleScope scope(context->GetIsolate()); | 12499 v8::HandleScope scope(context->GetIsolate()); |
| 12499 v8::TryCatch try_catch; | 12500 v8::TryCatch try_catch(context->GetIsolate()); |
| 12500 v8::Handle<v8::Value> result = CompileRun( | 12501 v8::Handle<v8::Value> result = CompileRun( |
| 12501 "function f() {" | 12502 "function f() {" |
| 12502 " return f();" | 12503 " return f();" |
| 12503 "}" | 12504 "}" |
| 12504 "" | 12505 "" |
| 12505 "f();"); | 12506 "f();"); |
| 12506 CHECK(result.IsEmpty()); | 12507 CHECK(result.IsEmpty()); |
| 12507 } | 12508 } |
| 12508 | 12509 |
| 12509 | 12510 |
| 12510 static void CheckTryCatchSourceInfo(v8::Handle<v8::Script> script, | 12511 static void CheckTryCatchSourceInfo(v8::Handle<v8::Script> script, |
| 12511 const char* resource_name, | 12512 const char* resource_name, |
| 12512 int line_offset) { | 12513 int line_offset) { |
| 12513 v8::HandleScope scope(CcTest::isolate()); | 12514 v8::HandleScope scope(CcTest::isolate()); |
| 12514 v8::TryCatch try_catch; | 12515 v8::TryCatch try_catch(CcTest::isolate()); |
| 12515 v8::Handle<v8::Value> result = script->Run(); | 12516 v8::Handle<v8::Value> result = script->Run(); |
| 12516 CHECK(result.IsEmpty()); | 12517 CHECK(result.IsEmpty()); |
| 12517 CHECK(try_catch.HasCaught()); | 12518 CHECK(try_catch.HasCaught()); |
| 12518 v8::Handle<v8::Message> message = try_catch.Message(); | 12519 v8::Handle<v8::Message> message = try_catch.Message(); |
| 12519 CHECK(!message.IsEmpty()); | 12520 CHECK(!message.IsEmpty()); |
| 12520 CHECK_EQ(10 + line_offset, message->GetLineNumber()); | 12521 CHECK_EQ(10 + line_offset, message->GetLineNumber()); |
| 12521 CHECK_EQ(91, message->GetStartPosition()); | 12522 CHECK_EQ(91, message->GetStartPosition()); |
| 12522 CHECK_EQ(92, message->GetEndPosition()); | 12523 CHECK_EQ(92, message->GetEndPosition()); |
| 12523 CHECK_EQ(2, message->GetStartColumn()); | 12524 CHECK_EQ(2, message->GetStartColumn()); |
| 12524 CHECK_EQ(3, message->GetEndColumn()); | 12525 CHECK_EQ(3, message->GetEndColumn()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12564 v8::String::NewFromUtf8(context->GetIsolate(), resource_name), | 12565 v8::String::NewFromUtf8(context->GetIsolate(), resource_name), |
| 12565 v8::Integer::New(context->GetIsolate(), 7)); | 12566 v8::Integer::New(context->GetIsolate(), 7)); |
| 12566 script = v8::Script::Compile(source, &origin2); | 12567 script = v8::Script::Compile(source, &origin2); |
| 12567 CheckTryCatchSourceInfo(script, resource_name, 7); | 12568 CheckTryCatchSourceInfo(script, resource_name, 7); |
| 12568 } | 12569 } |
| 12569 | 12570 |
| 12570 | 12571 |
| 12571 THREADED_TEST(TryCatchSourceInfoForEOSError) { | 12572 THREADED_TEST(TryCatchSourceInfoForEOSError) { |
| 12572 LocalContext context; | 12573 LocalContext context; |
| 12573 v8::HandleScope scope(context->GetIsolate()); | 12574 v8::HandleScope scope(context->GetIsolate()); |
| 12574 v8::TryCatch try_catch; | 12575 v8::TryCatch try_catch(context->GetIsolate()); |
| 12575 v8::Script::Compile(v8_str("!\n")); | 12576 v8::Script::Compile(v8_str("!\n")); |
| 12576 CHECK(try_catch.HasCaught()); | 12577 CHECK(try_catch.HasCaught()); |
| 12577 v8::Handle<v8::Message> message = try_catch.Message(); | 12578 v8::Handle<v8::Message> message = try_catch.Message(); |
| 12578 CHECK_EQ(1, message->GetLineNumber()); | 12579 CHECK_EQ(1, message->GetLineNumber()); |
| 12579 CHECK_EQ(0, message->GetStartColumn()); | 12580 CHECK_EQ(0, message->GetStartColumn()); |
| 12580 } | 12581 } |
| 12581 | 12582 |
| 12582 | 12583 |
| 12583 THREADED_TEST(CompilationCache) { | 12584 THREADED_TEST(CompilationCache) { |
| 12584 LocalContext context; | 12585 LocalContext context; |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13148 v8::V8::AddGCPrologueCallback(RunBeforeGC); | 13149 v8::V8::AddGCPrologueCallback(RunBeforeGC); |
| 13149 static const char* one_byte_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | 13150 static const char* one_byte_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; |
| 13150 i::uc16* uc16_content = AsciiToTwoByteString(one_byte_content); | 13151 i::uc16* uc16_content = AsciiToTwoByteString(one_byte_content); |
| 13151 v8::Local<v8::String> string = v8_str(one_byte_content); | 13152 v8::Local<v8::String> string = v8_str(one_byte_content); |
| 13152 | 13153 |
| 13153 CcTest::global()->Set(v8_str("a"), string); | 13154 CcTest::global()->Set(v8_str("a"), string); |
| 13154 regexp_interruption_data.string.Reset(CcTest::isolate(), string); | 13155 regexp_interruption_data.string.Reset(CcTest::isolate(), string); |
| 13155 regexp_interruption_data.string_resource = new UC16VectorResource( | 13156 regexp_interruption_data.string_resource = new UC16VectorResource( |
| 13156 i::Vector<const i::uc16>(uc16_content, i::StrLength(one_byte_content))); | 13157 i::Vector<const i::uc16>(uc16_content, i::StrLength(one_byte_content))); |
| 13157 | 13158 |
| 13158 v8::TryCatch try_catch; | 13159 v8::TryCatch try_catch(CcTest::isolate()); |
| 13159 timeout_thread.Start(); | 13160 timeout_thread.Start(); |
| 13160 | 13161 |
| 13161 CompileRun("/((a*)*)*b/.exec(a)"); | 13162 CompileRun("/((a*)*)*b/.exec(a)"); |
| 13162 CHECK(try_catch.HasTerminated()); | 13163 CHECK(try_catch.HasTerminated()); |
| 13163 | 13164 |
| 13164 timeout_thread.Join(); | 13165 timeout_thread.Join(); |
| 13165 | 13166 |
| 13166 regexp_interruption_data.string.Reset(); | 13167 regexp_interruption_data.string.Reset(); |
| 13167 i::DeleteArray(uc16_content); | 13168 i::DeleteArray(uc16_content); |
| 13168 } | 13169 } |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14094 c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo"), | 14095 c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo"), |
| 14095 v8::Integer::New(c2->GetIsolate(), 101)); | 14096 v8::Integer::New(c2->GetIsolate(), 101)); |
| 14096 CHECK_EQ(dep->Run()->Int32Value(), 100); | 14097 CHECK_EQ(dep->Run()->Int32Value(), 100); |
| 14097 CHECK_EQ(indep->BindToCurrentContext()->Run()->Int32Value(), 101); | 14098 CHECK_EQ(indep->BindToCurrentContext()->Run()->Int32Value(), 101); |
| 14098 } | 14099 } |
| 14099 | 14100 |
| 14100 | 14101 |
| 14101 THREADED_TEST(StackTrace) { | 14102 THREADED_TEST(StackTrace) { |
| 14102 LocalContext context; | 14103 LocalContext context; |
| 14103 v8::HandleScope scope(context->GetIsolate()); | 14104 v8::HandleScope scope(context->GetIsolate()); |
| 14104 v8::TryCatch try_catch; | 14105 v8::TryCatch try_catch(context->GetIsolate()); |
| 14105 const char *source = "function foo() { FAIL.FAIL; }; foo();"; | 14106 const char *source = "function foo() { FAIL.FAIL; }; foo();"; |
| 14106 v8::Handle<v8::String> src = | 14107 v8::Handle<v8::String> src = |
| 14107 v8::String::NewFromUtf8(context->GetIsolate(), source); | 14108 v8::String::NewFromUtf8(context->GetIsolate(), source); |
| 14108 v8::Handle<v8::String> origin = | 14109 v8::Handle<v8::String> origin = |
| 14109 v8::String::NewFromUtf8(context->GetIsolate(), "stack-trace-test"); | 14110 v8::String::NewFromUtf8(context->GetIsolate(), "stack-trace-test"); |
| 14110 v8::ScriptCompiler::Source script_source(src, v8::ScriptOrigin(origin)); | 14111 v8::ScriptCompiler::Source script_source(src, v8::ScriptOrigin(origin)); |
| 14111 v8::ScriptCompiler::CompileUnbound(context->GetIsolate(), &script_source) | 14112 v8::ScriptCompiler::CompileUnbound(context->GetIsolate(), &script_source) |
| 14112 ->BindToCurrentContext() | 14113 ->BindToCurrentContext() |
| 14113 ->Run(); | 14114 ->Run(); |
| 14114 CHECK(try_catch.HasCaught()); | 14115 CHECK(try_catch.HasCaught()); |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15073 "function outer() {\n" | 15074 "function outer() {\n" |
| 15074 " function foo() {\n" | 15075 " function foo() {\n" |
| 15075 " FAIL.FAIL;\n" | 15076 " FAIL.FAIL;\n" |
| 15076 " }\n" | 15077 " }\n" |
| 15077 " foo();\n" | 15078 " foo();\n" |
| 15078 "}\n" | 15079 "}\n" |
| 15079 "outer()\n%s"; | 15080 "outer()\n%s"; |
| 15080 | 15081 |
| 15081 i::ScopedVector<char> code(1024); | 15082 i::ScopedVector<char> code(1024); |
| 15082 i::SNPrintF(code, source, "//# sourceURL=source_url"); | 15083 i::SNPrintF(code, source, "//# sourceURL=source_url"); |
| 15083 v8::TryCatch try_catch; | 15084 v8::TryCatch try_catch(context->GetIsolate()); |
| 15084 CompileRunWithOrigin(code.start(), "", 0, 0); | 15085 CompileRunWithOrigin(code.start(), "", 0, 0); |
| 15085 CHECK(try_catch.HasCaught()); | 15086 CHECK(try_catch.HasCaught()); |
| 15086 v8::String::Utf8Value stack(try_catch.StackTrace()); | 15087 v8::String::Utf8Value stack(try_catch.StackTrace()); |
| 15087 CHECK(strstr(*stack, "at foo (source_url:3:5)") != NULL); | 15088 CHECK(strstr(*stack, "at foo (source_url:3:5)") != NULL); |
| 15088 } | 15089 } |
| 15089 | 15090 |
| 15090 | 15091 |
| 15091 TEST(EvalWithSourceURLInMessageScriptResourceNameOrSourceURL) { | 15092 TEST(EvalWithSourceURLInMessageScriptResourceNameOrSourceURL) { |
| 15092 LocalContext context; | 15093 LocalContext context; |
| 15093 v8::HandleScope scope(context->GetIsolate()); | 15094 v8::HandleScope scope(context->GetIsolate()); |
| 15094 | 15095 |
| 15095 const char *source = | 15096 const char *source = |
| 15096 "function outer() {\n" | 15097 "function outer() {\n" |
| 15097 " var scriptContents = \"function foo() { FAIL.FAIL; }\\\n" | 15098 " var scriptContents = \"function foo() { FAIL.FAIL; }\\\n" |
| 15098 " //# sourceURL=source_url\";\n" | 15099 " //# sourceURL=source_url\";\n" |
| 15099 " eval(scriptContents);\n" | 15100 " eval(scriptContents);\n" |
| 15100 " foo(); }\n" | 15101 " foo(); }\n" |
| 15101 "outer();\n" | 15102 "outer();\n" |
| 15102 "//# sourceURL=outer_url"; | 15103 "//# sourceURL=outer_url"; |
| 15103 | 15104 |
| 15104 v8::TryCatch try_catch; | 15105 v8::TryCatch try_catch(context->GetIsolate()); |
| 15105 CompileRun(source); | 15106 CompileRun(source); |
| 15106 CHECK(try_catch.HasCaught()); | 15107 CHECK(try_catch.HasCaught()); |
| 15107 | 15108 |
| 15108 Local<v8::Message> message = try_catch.Message(); | 15109 Local<v8::Message> message = try_catch.Message(); |
| 15109 Handle<Value> sourceURL = | 15110 Handle<Value> sourceURL = |
| 15110 message->GetScriptOrigin().ResourceName(); | 15111 message->GetScriptOrigin().ResourceName(); |
| 15111 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url")); | 15112 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url")); |
| 15112 } | 15113 } |
| 15113 | 15114 |
| 15114 | 15115 |
| 15115 TEST(RecursionWithSourceURLInMessageScriptResourceNameOrSourceURL) { | 15116 TEST(RecursionWithSourceURLInMessageScriptResourceNameOrSourceURL) { |
| 15116 LocalContext context; | 15117 LocalContext context; |
| 15117 v8::HandleScope scope(context->GetIsolate()); | 15118 v8::HandleScope scope(context->GetIsolate()); |
| 15118 | 15119 |
| 15119 const char *source = | 15120 const char *source = |
| 15120 "function outer() {\n" | 15121 "function outer() {\n" |
| 15121 " var scriptContents = \"function boo(){ boo(); }\\\n" | 15122 " var scriptContents = \"function boo(){ boo(); }\\\n" |
| 15122 " //# sourceURL=source_url\";\n" | 15123 " //# sourceURL=source_url\";\n" |
| 15123 " eval(scriptContents);\n" | 15124 " eval(scriptContents);\n" |
| 15124 " boo(); }\n" | 15125 " boo(); }\n" |
| 15125 "outer();\n" | 15126 "outer();\n" |
| 15126 "//# sourceURL=outer_url"; | 15127 "//# sourceURL=outer_url"; |
| 15127 | 15128 |
| 15128 v8::TryCatch try_catch; | 15129 v8::TryCatch try_catch(context->GetIsolate()); |
| 15129 CompileRun(source); | 15130 CompileRun(source); |
| 15130 CHECK(try_catch.HasCaught()); | 15131 CHECK(try_catch.HasCaught()); |
| 15131 | 15132 |
| 15132 Local<v8::Message> message = try_catch.Message(); | 15133 Local<v8::Message> message = try_catch.Message(); |
| 15133 Handle<Value> sourceURL = | 15134 Handle<Value> sourceURL = |
| 15134 message->GetScriptOrigin().ResourceName(); | 15135 message->GetScriptOrigin().ResourceName(); |
| 15135 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url")); | 15136 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url")); |
| 15136 } | 15137 } |
| 15137 | 15138 |
| 15138 | 15139 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15484 // split them into two 32-bit constants and combine them programmatically. | 15485 // split them into two 32-bit constants and combine them programmatically. |
| 15485 static double DoubleFromBits(uint32_t high_bits, uint32_t low_bits) { | 15486 static double DoubleFromBits(uint32_t high_bits, uint32_t low_bits) { |
| 15486 return DoubleFromBits((static_cast<uint64_t>(high_bits) << 32) | low_bits); | 15487 return DoubleFromBits((static_cast<uint64_t>(high_bits) << 32) | low_bits); |
| 15487 } | 15488 } |
| 15488 | 15489 |
| 15489 | 15490 |
| 15490 THREADED_TEST(QuietSignalingNaNs) { | 15491 THREADED_TEST(QuietSignalingNaNs) { |
| 15491 LocalContext context; | 15492 LocalContext context; |
| 15492 v8::Isolate* isolate = context->GetIsolate(); | 15493 v8::Isolate* isolate = context->GetIsolate(); |
| 15493 v8::HandleScope scope(isolate); | 15494 v8::HandleScope scope(isolate); |
| 15494 v8::TryCatch try_catch; | 15495 v8::TryCatch try_catch(isolate); |
| 15495 | 15496 |
| 15496 // Special double values. | 15497 // Special double values. |
| 15497 double snan = DoubleFromBits(0x7ff00000, 0x00000001); | 15498 double snan = DoubleFromBits(0x7ff00000, 0x00000001); |
| 15498 double qnan = DoubleFromBits(0x7ff80000, 0x00000000); | 15499 double qnan = DoubleFromBits(0x7ff80000, 0x00000000); |
| 15499 double infinity = DoubleFromBits(0x7ff00000, 0x00000000); | 15500 double infinity = DoubleFromBits(0x7ff00000, 0x00000000); |
| 15500 double max_normal = DoubleFromBits(0x7fefffff, 0xffffffffu); | 15501 double max_normal = DoubleFromBits(0x7fefffff, 0xffffffffu); |
| 15501 double min_normal = DoubleFromBits(0x00100000, 0x00000000); | 15502 double min_normal = DoubleFromBits(0x00100000, 0x00000000); |
| 15502 double max_denormal = DoubleFromBits(0x000fffff, 0xffffffffu); | 15503 double max_denormal = DoubleFromBits(0x000fffff, 0xffffffffu); |
| 15503 double min_denormal = DoubleFromBits(0x00000000, 0x00000001); | 15504 double min_denormal = DoubleFromBits(0x00000000, 0x00000001); |
| 15504 | 15505 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15571 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); | 15572 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); |
| 15572 #endif | 15573 #endif |
| 15573 } | 15574 } |
| 15574 } | 15575 } |
| 15575 } | 15576 } |
| 15576 | 15577 |
| 15577 | 15578 |
| 15578 static void SpaghettiIncident( | 15579 static void SpaghettiIncident( |
| 15579 const v8::FunctionCallbackInfo<v8::Value>& args) { | 15580 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 15580 v8::HandleScope scope(args.GetIsolate()); | 15581 v8::HandleScope scope(args.GetIsolate()); |
| 15581 v8::TryCatch tc; | 15582 v8::TryCatch tc(args.GetIsolate()); |
| 15582 v8::Handle<v8::String> str(args[0]->ToString(args.GetIsolate())); | 15583 v8::Handle<v8::String> str(args[0]->ToString(args.GetIsolate())); |
| 15583 USE(str); | 15584 USE(str); |
| 15584 if (tc.HasCaught()) | 15585 if (tc.HasCaught()) |
| 15585 tc.ReThrow(); | 15586 tc.ReThrow(); |
| 15586 } | 15587 } |
| 15587 | 15588 |
| 15588 | 15589 |
| 15589 // Test that an exception can be propagated down through a spaghetti | 15590 // Test that an exception can be propagated down through a spaghetti |
| 15590 // stack using ReThrow. | 15591 // stack using ReThrow. |
| 15591 THREADED_TEST(SpaghettiStackReThrow) { | 15592 THREADED_TEST(SpaghettiStackReThrow) { |
| 15592 v8::Isolate* isolate = CcTest::isolate(); | 15593 v8::Isolate* isolate = CcTest::isolate(); |
| 15593 v8::HandleScope scope(isolate); | 15594 v8::HandleScope scope(isolate); |
| 15594 LocalContext context; | 15595 LocalContext context; |
| 15595 context->Global()->Set( | 15596 context->Global()->Set( |
| 15596 v8::String::NewFromUtf8(isolate, "s"), | 15597 v8::String::NewFromUtf8(isolate, "s"), |
| 15597 v8::FunctionTemplate::New(isolate, SpaghettiIncident)->GetFunction()); | 15598 v8::FunctionTemplate::New(isolate, SpaghettiIncident)->GetFunction()); |
| 15598 v8::TryCatch try_catch; | 15599 v8::TryCatch try_catch(isolate); |
| 15599 CompileRun( | 15600 CompileRun( |
| 15600 "var i = 0;" | 15601 "var i = 0;" |
| 15601 "var o = {" | 15602 "var o = {" |
| 15602 " toString: function () {" | 15603 " toString: function () {" |
| 15603 " if (i == 10) {" | 15604 " if (i == 10) {" |
| 15604 " throw 'Hey!';" | 15605 " throw 'Hey!';" |
| 15605 " } else {" | 15606 " } else {" |
| 15606 " i++;" | 15607 " i++;" |
| 15607 " return s(o);" | 15608 " return s(o);" |
| 15608 " }" | 15609 " }" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15674 CHECK_EQ(1, GetGlobalObjectsCount()); | 15675 CHECK_EQ(1, GetGlobalObjectsCount()); |
| 15675 | 15676 |
| 15676 // Looking up the line number for an exception creates reference from the | 15677 // Looking up the line number for an exception creates reference from the |
| 15677 // compilation cache to the global object. | 15678 // compilation cache to the global object. |
| 15678 const char* source_exception = "function f(){throw 1;} f()"; | 15679 const char* source_exception = "function f(){throw 1;} f()"; |
| 15679 { | 15680 { |
| 15680 v8::HandleScope scope(isolate); | 15681 v8::HandleScope scope(isolate); |
| 15681 v8::Local<Context> context = Context::New(isolate); | 15682 v8::Local<Context> context = Context::New(isolate); |
| 15682 | 15683 |
| 15683 context->Enter(); | 15684 context->Enter(); |
| 15684 v8::TryCatch try_catch; | 15685 v8::TryCatch try_catch(isolate); |
| 15685 CompileRun(source_exception); | 15686 CompileRun(source_exception); |
| 15686 CHECK(try_catch.HasCaught()); | 15687 CHECK(try_catch.HasCaught()); |
| 15687 v8::Handle<v8::Message> message = try_catch.Message(); | 15688 v8::Handle<v8::Message> message = try_catch.Message(); |
| 15688 CHECK(!message.IsEmpty()); | 15689 CHECK(!message.IsEmpty()); |
| 15689 CHECK_EQ(1, message->GetLineNumber()); | 15690 CHECK_EQ(1, message->GetLineNumber()); |
| 15690 context->Exit(); | 15691 context->Exit(); |
| 15691 } | 15692 } |
| 15692 isolate->ContextDisposedNotification(); | 15693 isolate->ContextDisposedNotification(); |
| 15693 for (gc_count = 1; gc_count < 10; gc_count++) { | 15694 for (gc_count = 1; gc_count < 10; gc_count++) { |
| 15694 other_context->Enter(); | 15695 other_context->Enter(); |
| (...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17287 static_cast<int>(re->GetFlags())); | 17288 static_cast<int>(re->GetFlags())); |
| 17288 | 17289 |
| 17289 context->Global()->Set(v8_str("re"), re); | 17290 context->Global()->Set(v8_str("re"), re); |
| 17290 ExpectTrue("re.test('FoobarbaZ')"); | 17291 ExpectTrue("re.test('FoobarbaZ')"); |
| 17291 | 17292 |
| 17292 // RegExps are objects on which you can set properties. | 17293 // RegExps are objects on which you can set properties. |
| 17293 re->Set(v8_str("property"), v8::Integer::New(context->GetIsolate(), 32)); | 17294 re->Set(v8_str("property"), v8::Integer::New(context->GetIsolate(), 32)); |
| 17294 v8::Handle<v8::Value> value(CompileRun("re.property")); | 17295 v8::Handle<v8::Value> value(CompileRun("re.property")); |
| 17295 CHECK_EQ(32, value->Int32Value()); | 17296 CHECK_EQ(32, value->Int32Value()); |
| 17296 | 17297 |
| 17297 v8::TryCatch try_catch; | 17298 v8::TryCatch try_catch(context->GetIsolate()); |
| 17298 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone); | 17299 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone); |
| 17299 CHECK(re.IsEmpty()); | 17300 CHECK(re.IsEmpty()); |
| 17300 CHECK(try_catch.HasCaught()); | 17301 CHECK(try_catch.HasCaught()); |
| 17301 context->Global()->Set(v8_str("ex"), try_catch.Exception()); | 17302 context->Global()->Set(v8_str("ex"), try_catch.Exception()); |
| 17302 ExpectTrue("ex instanceof SyntaxError"); | 17303 ExpectTrue("ex instanceof SyntaxError"); |
| 17303 } | 17304 } |
| 17304 | 17305 |
| 17305 | 17306 |
| 17306 THREADED_TEST(Equals) { | 17307 THREADED_TEST(Equals) { |
| 17307 LocalContext localContext; | 17308 LocalContext localContext; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17627 Handle<Value> result = CompileRun("eval('42')"); | 17628 Handle<Value> result = CompileRun("eval('42')"); |
| 17628 CHECK_EQ(42, result->Int32Value()); | 17629 CHECK_EQ(42, result->Int32Value()); |
| 17629 result = CompileRun("(function(e) { return e('42'); })(eval)"); | 17630 result = CompileRun("(function(e) { return e('42'); })(eval)"); |
| 17630 CHECK_EQ(42, result->Int32Value()); | 17631 CHECK_EQ(42, result->Int32Value()); |
| 17631 result = CompileRun("var f = new Function('return 42'); f()"); | 17632 result = CompileRun("var f = new Function('return 42'); f()"); |
| 17632 CHECK_EQ(42, result->Int32Value()); | 17633 CHECK_EQ(42, result->Int32Value()); |
| 17633 } | 17634 } |
| 17634 | 17635 |
| 17635 | 17636 |
| 17636 void CheckCodeGenerationDisallowed() { | 17637 void CheckCodeGenerationDisallowed() { |
| 17637 TryCatch try_catch; | 17638 TryCatch try_catch(CcTest::isolate()); |
| 17638 | 17639 |
| 17639 Handle<Value> result = CompileRun("eval('42')"); | 17640 Handle<Value> result = CompileRun("eval('42')"); |
| 17640 CHECK(result.IsEmpty()); | 17641 CHECK(result.IsEmpty()); |
| 17641 CHECK(try_catch.HasCaught()); | 17642 CHECK(try_catch.HasCaught()); |
| 17642 try_catch.Reset(); | 17643 try_catch.Reset(); |
| 17643 | 17644 |
| 17644 result = CompileRun("(function(e) { return e('42'); })(eval)"); | 17645 result = CompileRun("(function(e) { return e('42'); })(eval)"); |
| 17645 CHECK(result.IsEmpty()); | 17646 CHECK(result.IsEmpty()); |
| 17646 CHECK(try_catch.HasCaught()); | 17647 CHECK(try_catch.HasCaught()); |
| 17647 try_catch.Reset(); | 17648 try_catch.Reset(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17690 // Set a callback that disallows the code generation. | 17691 // Set a callback that disallows the code generation. |
| 17691 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); | 17692 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); |
| 17692 CHECK(!context->IsCodeGenerationFromStringsAllowed()); | 17693 CHECK(!context->IsCodeGenerationFromStringsAllowed()); |
| 17693 CheckCodeGenerationDisallowed(); | 17694 CheckCodeGenerationDisallowed(); |
| 17694 } | 17695 } |
| 17695 | 17696 |
| 17696 | 17697 |
| 17697 TEST(SetErrorMessageForCodeGenFromStrings) { | 17698 TEST(SetErrorMessageForCodeGenFromStrings) { |
| 17698 LocalContext context; | 17699 LocalContext context; |
| 17699 v8::HandleScope scope(context->GetIsolate()); | 17700 v8::HandleScope scope(context->GetIsolate()); |
| 17700 TryCatch try_catch; | 17701 TryCatch try_catch(context->GetIsolate()); |
| 17701 | 17702 |
| 17702 Handle<String> message = v8_str("Message") ; | 17703 Handle<String> message = v8_str("Message") ; |
| 17703 Handle<String> expected_message = v8_str("Uncaught EvalError: Message"); | 17704 Handle<String> expected_message = v8_str("Uncaught EvalError: Message"); |
| 17704 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); | 17705 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); |
| 17705 context->AllowCodeGenerationFromStrings(false); | 17706 context->AllowCodeGenerationFromStrings(false); |
| 17706 context->SetErrorMessageForCodeGenerationFromStrings(message); | 17707 context->SetErrorMessageForCodeGenerationFromStrings(message); |
| 17707 Handle<Value> result = CompileRun("eval('42')"); | 17708 Handle<Value> result = CompileRun("eval('42')"); |
| 17708 CHECK(result.IsEmpty()); | 17709 CHECK(result.IsEmpty()); |
| 17709 CHECK(try_catch.HasCaught()); | 17710 CHECK(try_catch.HasCaught()); |
| 17710 Handle<String> actual_message = try_catch.Message()->Get(); | 17711 Handle<String> actual_message = try_catch.Message()->Get(); |
| 17711 CHECK(expected_message->Equals(actual_message)); | 17712 CHECK(expected_message->Equals(actual_message)); |
| 17712 } | 17713 } |
| 17713 | 17714 |
| 17714 | 17715 |
| 17715 static void NonObjectThis(const v8::FunctionCallbackInfo<v8::Value>& args) { | 17716 static void NonObjectThis(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 17716 } | 17717 } |
| 17717 | 17718 |
| 17718 | 17719 |
| 17719 THREADED_TEST(CallAPIFunctionOnNonObject) { | 17720 THREADED_TEST(CallAPIFunctionOnNonObject) { |
| 17720 LocalContext context; | 17721 LocalContext context; |
| 17721 v8::Isolate* isolate = context->GetIsolate(); | 17722 v8::Isolate* isolate = context->GetIsolate(); |
| 17722 v8::HandleScope scope(isolate); | 17723 v8::HandleScope scope(isolate); |
| 17723 Handle<FunctionTemplate> templ = | 17724 Handle<FunctionTemplate> templ = |
| 17724 v8::FunctionTemplate::New(isolate, NonObjectThis); | 17725 v8::FunctionTemplate::New(isolate, NonObjectThis); |
| 17725 Handle<Function> function = templ->GetFunction(); | 17726 Handle<Function> function = templ->GetFunction(); |
| 17726 context->Global()->Set(v8_str("f"), function); | 17727 context->Global()->Set(v8_str("f"), function); |
| 17727 TryCatch try_catch; | 17728 TryCatch try_catch(isolate); |
| 17728 CompileRun("f.call(2)"); | 17729 CompileRun("f.call(2)"); |
| 17729 } | 17730 } |
| 17730 | 17731 |
| 17731 | 17732 |
| 17732 // Regression test for issue 1470. | 17733 // Regression test for issue 1470. |
| 17733 THREADED_TEST(ReadOnlyIndexedProperties) { | 17734 THREADED_TEST(ReadOnlyIndexedProperties) { |
| 17734 v8::Isolate* isolate = CcTest::isolate(); | 17735 v8::Isolate* isolate = CcTest::isolate(); |
| 17735 v8::HandleScope scope(isolate); | 17736 v8::HandleScope scope(isolate); |
| 17736 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 17737 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 17737 | 17738 |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18166 LocalContext env; | 18167 LocalContext env; |
| 18167 v8::Isolate* isolate = env->GetIsolate(); | 18168 v8::Isolate* isolate = env->GetIsolate(); |
| 18168 v8::HandleScope scope(isolate); | 18169 v8::HandleScope scope(isolate); |
| 18169 CompileRun( | 18170 CompileRun( |
| 18170 "var exception1Calls = 0;" | 18171 "var exception1Calls = 0;" |
| 18171 "var exception2Calls = 0;"); | 18172 "var exception2Calls = 0;"); |
| 18172 isolate->EnqueueMicrotask( | 18173 isolate->EnqueueMicrotask( |
| 18173 Function::New(isolate, MicrotaskExceptionOne)); | 18174 Function::New(isolate, MicrotaskExceptionOne)); |
| 18174 isolate->EnqueueMicrotask( | 18175 isolate->EnqueueMicrotask( |
| 18175 Function::New(isolate, MicrotaskExceptionTwo)); | 18176 Function::New(isolate, MicrotaskExceptionTwo)); |
| 18176 TryCatch try_catch; | 18177 TryCatch try_catch(isolate); |
| 18177 CompileRun("1+1;"); | 18178 CompileRun("1+1;"); |
| 18178 CHECK(!try_catch.HasCaught()); | 18179 CHECK(!try_catch.HasCaught()); |
| 18179 CHECK_EQ(1, CompileRun("exception1Calls")->Int32Value()); | 18180 CHECK_EQ(1, CompileRun("exception1Calls")->Int32Value()); |
| 18180 CHECK_EQ(1, CompileRun("exception2Calls")->Int32Value()); | 18181 CHECK_EQ(1, CompileRun("exception2Calls")->Int32Value()); |
| 18181 } | 18182 } |
| 18182 | 18183 |
| 18183 | 18184 |
| 18184 TEST(SetAutorunMicrotasks) { | 18185 TEST(SetAutorunMicrotasks) { |
| 18185 LocalContext env; | 18186 LocalContext env; |
| 18186 v8::HandleScope scope(env->GetIsolate()); | 18187 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18487 CHECK_EQ(0, instance_checked_getter_count); | 18488 CHECK_EQ(0, instance_checked_getter_count); |
| 18488 CHECK_EQ(0, instance_checked_setter_count); | 18489 CHECK_EQ(0, instance_checked_setter_count); |
| 18489 } | 18490 } |
| 18490 try_catch->Reset(); | 18491 try_catch->Reset(); |
| 18491 } | 18492 } |
| 18492 | 18493 |
| 18493 | 18494 |
| 18494 static void CheckInstanceCheckedAccessors(bool expects_callbacks) { | 18495 static void CheckInstanceCheckedAccessors(bool expects_callbacks) { |
| 18495 instance_checked_getter_count = 0; | 18496 instance_checked_getter_count = 0; |
| 18496 instance_checked_setter_count = 0; | 18497 instance_checked_setter_count = 0; |
| 18497 TryCatch try_catch; | 18498 TryCatch try_catch(CcTest::isolate()); |
| 18498 | 18499 |
| 18499 // Test path through generic runtime code. | 18500 // Test path through generic runtime code. |
| 18500 CompileRun("obj.foo"); | 18501 CompileRun("obj.foo"); |
| 18501 CheckInstanceCheckedResult(1, 0, expects_callbacks, &try_catch); | 18502 CheckInstanceCheckedResult(1, 0, expects_callbacks, &try_catch); |
| 18502 CompileRun("obj.foo = 23"); | 18503 CompileRun("obj.foo = 23"); |
| 18503 CheckInstanceCheckedResult(1, 1, expects_callbacks, &try_catch); | 18504 CheckInstanceCheckedResult(1, 1, expects_callbacks, &try_catch); |
| 18504 | 18505 |
| 18505 // Test path through generated LoadIC and StoredIC. | 18506 // Test path through generated LoadIC and StoredIC. |
| 18506 CompileRun("function test_get(o) { o.foo; }" | 18507 CompileRun("function test_get(o) { o.foo; }" |
| 18507 "test_get(obj);"); | 18508 "test_get(obj);"); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18635 } | 18636 } |
| 18636 | 18637 |
| 18637 | 18638 |
| 18638 TEST(TryFinallyMessage) { | 18639 TEST(TryFinallyMessage) { |
| 18639 LocalContext context; | 18640 LocalContext context; |
| 18640 v8::HandleScope scope(context->GetIsolate()); | 18641 v8::HandleScope scope(context->GetIsolate()); |
| 18641 { | 18642 { |
| 18642 // Test that the original error message is not lost if there is a | 18643 // Test that the original error message is not lost if there is a |
| 18643 // recursive call into Javascript is done in the finally block, e.g. to | 18644 // recursive call into Javascript is done in the finally block, e.g. to |
| 18644 // initialize an IC. (crbug.com/129171) | 18645 // initialize an IC. (crbug.com/129171) |
| 18645 TryCatch try_catch; | 18646 TryCatch try_catch(context->GetIsolate()); |
| 18646 const char* trigger_ic = | 18647 const char* trigger_ic = |
| 18647 "try { \n" | 18648 "try { \n" |
| 18648 " throw new Error('test'); \n" | 18649 " throw new Error('test'); \n" |
| 18649 "} finally { \n" | 18650 "} finally { \n" |
| 18650 " var x = 0; \n" | 18651 " var x = 0; \n" |
| 18651 " x++; \n" // Trigger an IC initialization here. | 18652 " x++; \n" // Trigger an IC initialization here. |
| 18652 "} \n"; | 18653 "} \n"; |
| 18653 CompileRun(trigger_ic); | 18654 CompileRun(trigger_ic); |
| 18654 CHECK(try_catch.HasCaught()); | 18655 CHECK(try_catch.HasCaught()); |
| 18655 Local<Message> message = try_catch.Message(); | 18656 Local<Message> message = try_catch.Message(); |
| 18656 CHECK(!message.IsEmpty()); | 18657 CHECK(!message.IsEmpty()); |
| 18657 CHECK_EQ(2, message->GetLineNumber()); | 18658 CHECK_EQ(2, message->GetLineNumber()); |
| 18658 } | 18659 } |
| 18659 | 18660 |
| 18660 { | 18661 { |
| 18661 // Test that the original exception message is indeed overwritten if | 18662 // Test that the original exception message is indeed overwritten if |
| 18662 // a new error is thrown in the finally block. | 18663 // a new error is thrown in the finally block. |
| 18663 TryCatch try_catch; | 18664 TryCatch try_catch(context->GetIsolate()); |
| 18664 const char* throw_again = | 18665 const char* throw_again = |
| 18665 "try { \n" | 18666 "try { \n" |
| 18666 " throw new Error('test'); \n" | 18667 " throw new Error('test'); \n" |
| 18667 "} finally { \n" | 18668 "} finally { \n" |
| 18668 " var x = 0; \n" | 18669 " var x = 0; \n" |
| 18669 " x++; \n" | 18670 " x++; \n" |
| 18670 " throw new Error('again'); \n" // This is the new uncaught error. | 18671 " throw new Error('again'); \n" // This is the new uncaught error. |
| 18671 "} \n"; | 18672 "} \n"; |
| 18672 CompileRun(throw_again); | 18673 CompileRun(throw_again); |
| 18673 CHECK(try_catch.HasCaught()); | 18674 CHECK(try_catch.HasCaught()); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18823 } | 18824 } |
| 18824 | 18825 |
| 18825 | 18826 |
| 18826 THREADED_TEST(Regress137496) { | 18827 THREADED_TEST(Regress137496) { |
| 18827 i::FLAG_expose_gc = true; | 18828 i::FLAG_expose_gc = true; |
| 18828 LocalContext context; | 18829 LocalContext context; |
| 18829 v8::HandleScope scope(context->GetIsolate()); | 18830 v8::HandleScope scope(context->GetIsolate()); |
| 18830 | 18831 |
| 18831 // Compile a try-finally clause where the finally block causes a GC | 18832 // Compile a try-finally clause where the finally block causes a GC |
| 18832 // while there still is a message pending for external reporting. | 18833 // while there still is a message pending for external reporting. |
| 18833 TryCatch try_catch; | 18834 TryCatch try_catch(context->GetIsolate()); |
| 18834 try_catch.SetVerbose(true); | 18835 try_catch.SetVerbose(true); |
| 18835 CompileRun("try { throw new Error(); } finally { gc(); }"); | 18836 CompileRun("try { throw new Error(); } finally { gc(); }"); |
| 18836 CHECK(try_catch.HasCaught()); | 18837 CHECK(try_catch.HasCaught()); |
| 18837 } | 18838 } |
| 18838 | 18839 |
| 18839 | 18840 |
| 18840 THREADED_TEST(Regress157124) { | 18841 THREADED_TEST(Regress157124) { |
| 18841 LocalContext context; | 18842 LocalContext context; |
| 18842 v8::Isolate* isolate = context->GetIsolate(); | 18843 v8::Isolate* isolate = context->GetIsolate(); |
| 18843 v8::HandleScope scope(isolate); | 18844 v8::HandleScope scope(isolate); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19095 | 19096 |
| 19096 v8::Handle<v8::FunctionTemplate> catcher_fun = | 19097 v8::Handle<v8::FunctionTemplate> catcher_fun = |
| 19097 v8::FunctionTemplate::New(isolate, CatcherCallback); | 19098 v8::FunctionTemplate::New(isolate, CatcherCallback); |
| 19098 context1->Global()->Set(v8_str("catcher"), catcher_fun->GetFunction()); | 19099 context1->Global()->Set(v8_str("catcher"), catcher_fun->GetFunction()); |
| 19099 | 19100 |
| 19100 v8::Handle<v8::FunctionTemplate> has_own_property_fun = | 19101 v8::Handle<v8::FunctionTemplate> has_own_property_fun = |
| 19101 v8::FunctionTemplate::New(isolate, HasOwnPropertyCallback); | 19102 v8::FunctionTemplate::New(isolate, HasOwnPropertyCallback); |
| 19102 context1->Global()->Set(v8_str("has_own_property"), | 19103 context1->Global()->Set(v8_str("has_own_property"), |
| 19103 has_own_property_fun->GetFunction()); | 19104 has_own_property_fun->GetFunction()); |
| 19104 | 19105 |
| 19105 { v8::TryCatch try_catch; | 19106 { |
| 19107 v8::TryCatch try_catch(isolate); |
| 19106 access_check_fail_thrown = false; | 19108 access_check_fail_thrown = false; |
| 19107 CompileRun("other.x;"); | 19109 CompileRun("other.x;"); |
| 19108 CHECK(access_check_fail_thrown); | 19110 CHECK(access_check_fail_thrown); |
| 19109 CHECK(try_catch.HasCaught()); | 19111 CHECK(try_catch.HasCaught()); |
| 19110 } | 19112 } |
| 19111 | 19113 |
| 19112 CheckCorrectThrow("other.x"); | 19114 CheckCorrectThrow("other.x"); |
| 19113 CheckCorrectThrow("other[1]"); | 19115 CheckCorrectThrow("other[1]"); |
| 19114 CheckCorrectThrow("JSON.stringify(other)"); | 19116 CheckCorrectThrow("JSON.stringify(other)"); |
| 19115 CheckCorrectThrow("has_own_property(other, 'x')"); | 19117 CheckCorrectThrow("has_own_property(other, 'x')"); |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19712 "check(wrap_get());\n" | 19714 "check(wrap_get());\n" |
| 19713 "\n" | 19715 "\n" |
| 19714 "check = function(returned) {\n" | 19716 "check = function(returned) {\n" |
| 19715 " if (returned !== 1) { throw returned; }\n" | 19717 " if (returned !== 1) { throw returned; }\n" |
| 19716 "}\n" | 19718 "}\n" |
| 19717 "check(wrap_set());\n" | 19719 "check(wrap_set());\n" |
| 19718 "check(wrap_set());\n" | 19720 "check(wrap_set());\n" |
| 19719 "%%OptimizeFunctionOnNextCall(wrap_set_%d);\n" | 19721 "%%OptimizeFunctionOnNextCall(wrap_set_%d);\n" |
| 19720 "check(wrap_set());\n", | 19722 "check(wrap_set());\n", |
| 19721 wrap_function.start(), key, key, key, key, key, key); | 19723 wrap_function.start(), key, key, key, key, key, key); |
| 19722 v8::TryCatch try_catch; | 19724 v8::TryCatch try_catch(isolate); |
| 19723 CompileRun(source.start()); | 19725 CompileRun(source.start()); |
| 19724 DCHECK(!try_catch.HasCaught()); | 19726 DCHECK(!try_catch.HasCaught()); |
| 19725 CHECK_EQ(9, count); | 19727 CHECK_EQ(9, count); |
| 19726 } | 19728 } |
| 19727 }; | 19729 }; |
| 19728 | 19730 |
| 19729 | 19731 |
| 19730 Local<Object> ApiCallOptimizationChecker::data; | 19732 Local<Object> ApiCallOptimizationChecker::data; |
| 19731 Local<Object> ApiCallOptimizationChecker::receiver; | 19733 Local<Object> ApiCallOptimizationChecker::receiver; |
| 19732 Local<Object> ApiCallOptimizationChecker::holder; | 19734 Local<Object> ApiCallOptimizationChecker::holder; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20136 { v8::Isolate::AllowJavascriptExecutionScope yes_js(isolate); | 20138 { v8::Isolate::AllowJavascriptExecutionScope yes_js(isolate); |
| 20137 CompileRun("1+1"); | 20139 CompileRun("1+1"); |
| 20138 } | 20140 } |
| 20139 } | 20141 } |
| 20140 | 20142 |
| 20141 | 20143 |
| 20142 TEST(ThrowOnJavascriptExecution) { | 20144 TEST(ThrowOnJavascriptExecution) { |
| 20143 LocalContext context; | 20145 LocalContext context; |
| 20144 v8::Isolate* isolate = context->GetIsolate(); | 20146 v8::Isolate* isolate = context->GetIsolate(); |
| 20145 v8::HandleScope scope(isolate); | 20147 v8::HandleScope scope(isolate); |
| 20146 v8::TryCatch try_catch; | 20148 v8::TryCatch try_catch(isolate); |
| 20147 v8::Isolate::DisallowJavascriptExecutionScope throw_js( | 20149 v8::Isolate::DisallowJavascriptExecutionScope throw_js( |
| 20148 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); | 20150 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); |
| 20149 CompileRun("1+1"); | 20151 CompileRun("1+1"); |
| 20150 CHECK(try_catch.HasCaught()); | 20152 CHECK(try_catch.HasCaught()); |
| 20151 } | 20153 } |
| 20152 | 20154 |
| 20153 | 20155 |
| 20154 TEST(Regress354123) { | 20156 TEST(Regress354123) { |
| 20155 LocalContext current; | 20157 LocalContext current; |
| 20156 v8::Isolate* isolate = current->GetIsolate(); | 20158 v8::Isolate* isolate = current->GetIsolate(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20196 } | 20198 } |
| 20197 | 20199 |
| 20198 | 20200 |
| 20199 TEST(CaptureStackTraceForStackOverflow) { | 20201 TEST(CaptureStackTraceForStackOverflow) { |
| 20200 v8::internal::FLAG_stack_size = 150; | 20202 v8::internal::FLAG_stack_size = 150; |
| 20201 LocalContext current; | 20203 LocalContext current; |
| 20202 v8::Isolate* isolate = current->GetIsolate(); | 20204 v8::Isolate* isolate = current->GetIsolate(); |
| 20203 v8::HandleScope scope(isolate); | 20205 v8::HandleScope scope(isolate); |
| 20204 V8::SetCaptureStackTraceForUncaughtExceptions( | 20206 V8::SetCaptureStackTraceForUncaughtExceptions( |
| 20205 true, 10, v8::StackTrace::kDetailed); | 20207 true, 10, v8::StackTrace::kDetailed); |
| 20206 v8::TryCatch try_catch; | 20208 v8::TryCatch try_catch(isolate); |
| 20207 CompileRun("(function f(x) { f(x+1); })(0)"); | 20209 CompileRun("(function f(x) { f(x+1); })(0)"); |
| 20208 CHECK(try_catch.HasCaught()); | 20210 CHECK(try_catch.HasCaught()); |
| 20209 } | 20211 } |
| 20210 | 20212 |
| 20211 | 20213 |
| 20212 TEST(ScriptNameAndLineNumber) { | 20214 TEST(ScriptNameAndLineNumber) { |
| 20213 LocalContext env; | 20215 LocalContext env; |
| 20214 v8::Isolate* isolate = env->GetIsolate(); | 20216 v8::Isolate* isolate = env->GetIsolate(); |
| 20215 v8::HandleScope scope(isolate); | 20217 v8::HandleScope scope(isolate); |
| 20216 const char* url = "http://www.foo.com/foo.js"; | 20218 const char* url = "http://www.foo.com/foo.js"; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20437 // Helper function for running streaming tests. | 20439 // Helper function for running streaming tests. |
| 20438 void RunStreamingTest(const char** chunks, | 20440 void RunStreamingTest(const char** chunks, |
| 20439 v8::ScriptCompiler::StreamedSource::Encoding encoding = | 20441 v8::ScriptCompiler::StreamedSource::Encoding encoding = |
| 20440 v8::ScriptCompiler::StreamedSource::ONE_BYTE, | 20442 v8::ScriptCompiler::StreamedSource::ONE_BYTE, |
| 20441 bool expected_success = true, | 20443 bool expected_success = true, |
| 20442 const char* expected_source_url = NULL, | 20444 const char* expected_source_url = NULL, |
| 20443 const char* expected_source_mapping_url = NULL) { | 20445 const char* expected_source_mapping_url = NULL) { |
| 20444 LocalContext env; | 20446 LocalContext env; |
| 20445 v8::Isolate* isolate = env->GetIsolate(); | 20447 v8::Isolate* isolate = env->GetIsolate(); |
| 20446 v8::HandleScope scope(isolate); | 20448 v8::HandleScope scope(isolate); |
| 20447 v8::TryCatch try_catch; | 20449 v8::TryCatch try_catch(isolate); |
| 20448 | 20450 |
| 20449 v8::ScriptCompiler::StreamedSource source(new TestSourceStream(chunks), | 20451 v8::ScriptCompiler::StreamedSource source(new TestSourceStream(chunks), |
| 20450 encoding); | 20452 encoding); |
| 20451 v8::ScriptCompiler::ScriptStreamingTask* task = | 20453 v8::ScriptCompiler::ScriptStreamingTask* task = |
| 20452 v8::ScriptCompiler::StartStreamingScript(isolate, &source); | 20454 v8::ScriptCompiler::StartStreamingScript(isolate, &source); |
| 20453 | 20455 |
| 20454 // TestSourceStream::GetMoreData won't block, so it's OK to just run the | 20456 // TestSourceStream::GetMoreData won't block, so it's OK to just run the |
| 20455 // task here in the main thread. | 20457 // task here in the main thread. |
| 20456 task->Run(); | 20458 task->Run(); |
| 20457 delete task; | 20459 delete task; |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20809 v8::Isolate* isolate = env->GetIsolate(); | 20811 v8::Isolate* isolate = env->GetIsolate(); |
| 20810 v8::HandleScope scope(isolate); | 20812 v8::HandleScope scope(isolate); |
| 20811 | 20813 |
| 20812 // First, run a script with a let variable. | 20814 // First, run a script with a let variable. |
| 20813 CompileRun("\"use strict\"; let x = 1;"); | 20815 CompileRun("\"use strict\"; let x = 1;"); |
| 20814 | 20816 |
| 20815 // Then stream a script which (erroneously) tries to introduce the same | 20817 // Then stream a script which (erroneously) tries to introduce the same |
| 20816 // variable again. | 20818 // variable again. |
| 20817 const char* chunks[] = {"\"use strict\"; let x = 2;", NULL}; | 20819 const char* chunks[] = {"\"use strict\"; let x = 2;", NULL}; |
| 20818 | 20820 |
| 20819 v8::TryCatch try_catch; | 20821 v8::TryCatch try_catch(isolate); |
| 20820 v8::ScriptCompiler::StreamedSource source( | 20822 v8::ScriptCompiler::StreamedSource source( |
| 20821 new TestSourceStream(chunks), | 20823 new TestSourceStream(chunks), |
| 20822 v8::ScriptCompiler::StreamedSource::ONE_BYTE); | 20824 v8::ScriptCompiler::StreamedSource::ONE_BYTE); |
| 20823 v8::ScriptCompiler::ScriptStreamingTask* task = | 20825 v8::ScriptCompiler::ScriptStreamingTask* task = |
| 20824 v8::ScriptCompiler::StartStreamingScript(isolate, &source); | 20826 v8::ScriptCompiler::StartStreamingScript(isolate, &source); |
| 20825 task->Run(); | 20827 task->Run(); |
| 20826 delete task; | 20828 delete task; |
| 20827 | 20829 |
| 20828 // Parsing should succeed (the script will be parsed and compiled in a context | 20830 // Parsing should succeed (the script will be parsed and compiled in a context |
| 20829 // independent way, so the error is not detected). | 20831 // independent way, so the error is not detected). |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20924 } | 20926 } |
| 20925 | 20927 |
| 20926 | 20928 |
| 20927 TEST(StringConcatOverflow) { | 20929 TEST(StringConcatOverflow) { |
| 20928 v8::V8::Initialize(); | 20930 v8::V8::Initialize(); |
| 20929 v8::HandleScope scope(CcTest::isolate()); | 20931 v8::HandleScope scope(CcTest::isolate()); |
| 20930 RandomLengthOneByteResource* r = | 20932 RandomLengthOneByteResource* r = |
| 20931 new RandomLengthOneByteResource(i::String::kMaxLength); | 20933 new RandomLengthOneByteResource(i::String::kMaxLength); |
| 20932 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), r); | 20934 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), r); |
| 20933 CHECK(!str.IsEmpty()); | 20935 CHECK(!str.IsEmpty()); |
| 20934 v8::TryCatch try_catch; | 20936 v8::TryCatch try_catch(CcTest::isolate()); |
| 20935 v8::Local<v8::String> result = v8::String::Concat(str, str); | 20937 v8::Local<v8::String> result = v8::String::Concat(str, str); |
| 20936 CHECK(result.IsEmpty()); | 20938 CHECK(result.IsEmpty()); |
| 20937 CHECK(!try_catch.HasCaught()); | 20939 CHECK(!try_catch.HasCaught()); |
| 20938 } | 20940 } |
| 20939 | 20941 |
| 20940 | 20942 |
| 20941 TEST(TurboAsmDisablesNeuter) { | 20943 TEST(TurboAsmDisablesNeuter) { |
| 20942 v8::V8::Initialize(); | 20944 v8::V8::Initialize(); |
| 20943 v8::HandleScope scope(CcTest::isolate()); | 20945 v8::HandleScope scope(CcTest::isolate()); |
| 20944 LocalContext context; | 20946 LocalContext context; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20985 v8::HandleScope handle_scope(isolate); | 20987 v8::HandleScope handle_scope(isolate); |
| 20986 LocalContext env; | 20988 LocalContext env; |
| 20987 | 20989 |
| 20988 v8::Handle<v8::ObjectTemplate> obj_template = | 20990 v8::Handle<v8::ObjectTemplate> obj_template = |
| 20989 v8::ObjectTemplate::New(isolate); | 20991 v8::ObjectTemplate::New(isolate); |
| 20990 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); | 20992 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); |
| 20991 | 20993 |
| 20992 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); | 20994 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); |
| 20993 | 20995 |
| 20994 { | 20996 { |
| 20995 v8::TryCatch try_catch; | 20997 v8::TryCatch try_catch(isolate); |
| 20996 CompileRun( | 20998 CompileRun( |
| 20997 "function f() { %_GetPrototype(prohibited); }" | 20999 "function f() { %_GetPrototype(prohibited); }" |
| 20998 "%OptimizeFunctionOnNextCall(f);" | 21000 "%OptimizeFunctionOnNextCall(f);" |
| 20999 "f();"); | 21001 "f();"); |
| 21000 CHECK(try_catch.HasCaught()); | 21002 CHECK(try_catch.HasCaught()); |
| 21001 } | 21003 } |
| 21002 } | 21004 } |
| 21003 | 21005 |
| 21004 | 21006 |
| 21005 TEST(GetPrototypeHidden) { | 21007 TEST(GetPrototypeHidden) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21069 | 21071 |
| 21070 TEST(NewStringRangeError) { | 21072 TEST(NewStringRangeError) { |
| 21071 v8::Isolate* isolate = CcTest::isolate(); | 21073 v8::Isolate* isolate = CcTest::isolate(); |
| 21072 v8::HandleScope handle_scope(isolate); | 21074 v8::HandleScope handle_scope(isolate); |
| 21073 const int length = i::String::kMaxLength + 1; | 21075 const int length = i::String::kMaxLength + 1; |
| 21074 const int buffer_size = length * sizeof(uint16_t); | 21076 const int buffer_size = length * sizeof(uint16_t); |
| 21075 void* buffer = malloc(buffer_size); | 21077 void* buffer = malloc(buffer_size); |
| 21076 if (buffer == NULL) return; | 21078 if (buffer == NULL) return; |
| 21077 memset(buffer, 'A', buffer_size); | 21079 memset(buffer, 'A', buffer_size); |
| 21078 { | 21080 { |
| 21079 v8::TryCatch try_catch; | 21081 v8::TryCatch try_catch(isolate); |
| 21080 char* data = reinterpret_cast<char*>(buffer); | 21082 char* data = reinterpret_cast<char*>(buffer); |
| 21081 CHECK(v8::String::NewFromUtf8(isolate, data, v8::String::kNormalString, | 21083 CHECK(v8::String::NewFromUtf8(isolate, data, v8::String::kNormalString, |
| 21082 length).IsEmpty()); | 21084 length).IsEmpty()); |
| 21083 CHECK(!try_catch.HasCaught()); | 21085 CHECK(!try_catch.HasCaught()); |
| 21084 } | 21086 } |
| 21085 { | 21087 { |
| 21086 v8::TryCatch try_catch; | 21088 v8::TryCatch try_catch(isolate); |
| 21087 uint8_t* data = reinterpret_cast<uint8_t*>(buffer); | 21089 uint8_t* data = reinterpret_cast<uint8_t*>(buffer); |
| 21088 CHECK(v8::String::NewFromOneByte(isolate, data, v8::String::kNormalString, | 21090 CHECK(v8::String::NewFromOneByte(isolate, data, v8::String::kNormalString, |
| 21089 length).IsEmpty()); | 21091 length).IsEmpty()); |
| 21090 CHECK(!try_catch.HasCaught()); | 21092 CHECK(!try_catch.HasCaught()); |
| 21091 } | 21093 } |
| 21092 { | 21094 { |
| 21093 v8::TryCatch try_catch; | 21095 v8::TryCatch try_catch(isolate); |
| 21094 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); | 21096 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |
| 21095 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, | 21097 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |
| 21096 length).IsEmpty()); | 21098 length).IsEmpty()); |
| 21097 CHECK(!try_catch.HasCaught()); | 21099 CHECK(!try_catch.HasCaught()); |
| 21098 } | 21100 } |
| 21099 free(buffer); | 21101 free(buffer); |
| 21100 } | 21102 } |
| 21101 | 21103 |
| 21102 | 21104 |
| 21103 TEST(SealHandleScope) { | 21105 TEST(SealHandleScope) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 21132 } | 21134 } |
| 21133 | 21135 |
| 21134 | 21136 |
| 21135 TEST(StrongModeArityCallFromApi) { | 21137 TEST(StrongModeArityCallFromApi) { |
| 21136 i::FLAG_strong_mode = true; | 21138 i::FLAG_strong_mode = true; |
| 21137 LocalContext env; | 21139 LocalContext env; |
| 21138 v8::Isolate* isolate = env->GetIsolate(); | 21140 v8::Isolate* isolate = env->GetIsolate(); |
| 21139 v8::HandleScope scope(isolate); | 21141 v8::HandleScope scope(isolate); |
| 21140 Local<Function> fun; | 21142 Local<Function> fun; |
| 21141 { | 21143 { |
| 21142 v8::TryCatch try_catch; | 21144 v8::TryCatch try_catch(isolate); |
| 21143 fun = Local<Function>::Cast(CompileRun( | 21145 fun = Local<Function>::Cast(CompileRun( |
| 21144 "function f(x) { 'use strong'; }" | 21146 "function f(x) { 'use strong'; }" |
| 21145 "f")); | 21147 "f")); |
| 21146 | 21148 |
| 21147 CHECK(!try_catch.HasCaught()); | 21149 CHECK(!try_catch.HasCaught()); |
| 21148 } | 21150 } |
| 21149 | 21151 |
| 21150 { | 21152 { |
| 21151 v8::TryCatch try_catch; | 21153 v8::TryCatch try_catch(isolate); |
| 21152 fun->Call(v8::Undefined(isolate), 0, nullptr); | 21154 fun->Call(v8::Undefined(isolate), 0, nullptr); |
| 21153 CHECK(try_catch.HasCaught()); | 21155 CHECK(try_catch.HasCaught()); |
| 21154 } | 21156 } |
| 21155 | 21157 |
| 21156 { | 21158 { |
| 21157 v8::TryCatch try_catch; | 21159 v8::TryCatch try_catch(isolate); |
| 21158 v8::Handle<Value> args[] = {v8_num(42)}; | 21160 v8::Handle<Value> args[] = {v8_num(42)}; |
| 21159 fun->Call(v8::Undefined(isolate), arraysize(args), args); | 21161 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21160 CHECK(!try_catch.HasCaught()); | 21162 CHECK(!try_catch.HasCaught()); |
| 21161 } | 21163 } |
| 21162 | 21164 |
| 21163 { | 21165 { |
| 21164 v8::TryCatch try_catch; | 21166 v8::TryCatch try_catch(isolate); |
| 21165 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; | 21167 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; |
| 21166 fun->Call(v8::Undefined(isolate), arraysize(args), args); | 21168 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21167 CHECK(!try_catch.HasCaught()); | 21169 CHECK(!try_catch.HasCaught()); |
| 21168 } | 21170 } |
| 21169 } | 21171 } |
| 21170 | 21172 |
| 21171 | 21173 |
| 21172 TEST(StrongModeArityCallFromApi2) { | 21174 TEST(StrongModeArityCallFromApi2) { |
| 21173 i::FLAG_strong_mode = true; | 21175 i::FLAG_strong_mode = true; |
| 21174 LocalContext env; | 21176 LocalContext env; |
| 21175 v8::Isolate* isolate = env->GetIsolate(); | 21177 v8::Isolate* isolate = env->GetIsolate(); |
| 21176 v8::HandleScope scope(isolate); | 21178 v8::HandleScope scope(isolate); |
| 21177 Local<Function> fun; | 21179 Local<Function> fun; |
| 21178 { | 21180 { |
| 21179 v8::TryCatch try_catch; | 21181 v8::TryCatch try_catch(isolate); |
| 21180 fun = Local<Function>::Cast(CompileRun( | 21182 fun = Local<Function>::Cast(CompileRun( |
| 21181 "'use strong';" | 21183 "'use strong';" |
| 21182 "function f(x) {}" | 21184 "function f(x) {}" |
| 21183 "f")); | 21185 "f")); |
| 21184 | 21186 |
| 21185 CHECK(!try_catch.HasCaught()); | 21187 CHECK(!try_catch.HasCaught()); |
| 21186 } | 21188 } |
| 21187 | 21189 |
| 21188 { | 21190 { |
| 21189 v8::TryCatch try_catch; | 21191 v8::TryCatch try_catch(isolate); |
| 21190 fun->Call(v8::Undefined(isolate), 0, nullptr); | 21192 fun->Call(v8::Undefined(isolate), 0, nullptr); |
| 21191 CHECK(try_catch.HasCaught()); | 21193 CHECK(try_catch.HasCaught()); |
| 21192 } | 21194 } |
| 21193 | 21195 |
| 21194 { | 21196 { |
| 21195 v8::TryCatch try_catch; | 21197 v8::TryCatch try_catch(isolate); |
| 21196 v8::Handle<Value> args[] = {v8_num(42)}; | 21198 v8::Handle<Value> args[] = {v8_num(42)}; |
| 21197 fun->Call(v8::Undefined(isolate), arraysize(args), args); | 21199 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21198 CHECK(!try_catch.HasCaught()); | 21200 CHECK(!try_catch.HasCaught()); |
| 21199 } | 21201 } |
| 21200 | 21202 |
| 21201 { | 21203 { |
| 21202 v8::TryCatch try_catch; | 21204 v8::TryCatch try_catch(isolate); |
| 21203 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; | 21205 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; |
| 21204 fun->Call(v8::Undefined(isolate), arraysize(args), args); | 21206 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21205 CHECK(!try_catch.HasCaught()); | 21207 CHECK(!try_catch.HasCaught()); |
| 21206 } | 21208 } |
| 21207 } | 21209 } |
| 21208 | 21210 |
| 21209 | 21211 |
| 21210 TEST(ExtrasExportsObject) { | 21212 TEST(ExtrasExportsObject) { |
| 21211 v8::Isolate* isolate = CcTest::isolate(); | 21213 v8::Isolate* isolate = CcTest::isolate(); |
| 21212 v8::HandleScope handle_scope(isolate); | 21214 v8::HandleScope handle_scope(isolate); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21272 CHECK_EQ(2, set->Size()); | 21274 CHECK_EQ(2, set->Size()); |
| 21273 | 21275 |
| 21274 v8::Local<v8::Array> keys = set->AsArray(); | 21276 v8::Local<v8::Array> keys = set->AsArray(); |
| 21275 CHECK_EQ(2, keys->Length()); | 21277 CHECK_EQ(2, keys->Length()); |
| 21276 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); | 21278 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); |
| 21277 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); | 21279 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); |
| 21278 | 21280 |
| 21279 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked(); | 21281 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked(); |
| 21280 CHECK_EQ(2, set->Size()); | 21282 CHECK_EQ(2, set->Size()); |
| 21281 } | 21283 } |
| OLD | NEW |