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 8680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8691 CHECK(trouble->IsFunction()); | 8691 CHECK(trouble->IsFunction()); |
8692 Local<Value> trouble_callee = global->Get(v8_str("trouble_callee")); | 8692 Local<Value> trouble_callee = global->Get(v8_str("trouble_callee")); |
8693 CHECK(trouble_callee->IsFunction()); | 8693 CHECK(trouble_callee->IsFunction()); |
8694 Local<Value> trouble_caller = global->Get(v8_str("trouble_caller")); | 8694 Local<Value> trouble_caller = global->Get(v8_str("trouble_caller")); |
8695 CHECK(trouble_caller->IsFunction()); | 8695 CHECK(trouble_caller->IsFunction()); |
8696 Function::Cast(*trouble_caller)->Call(global, 0, NULL); | 8696 Function::Cast(*trouble_caller)->Call(global, 0, NULL); |
8697 CHECK_EQ(1, report_count); | 8697 CHECK_EQ(1, report_count); |
8698 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); | 8698 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); |
8699 } | 8699 } |
8700 | 8700 |
| 8701 |
| 8702 TEST(ApiUncaughtExceptionInObjectObserve) { |
| 8703 v8::internal::FLAG_stack_size = 150; |
| 8704 report_count = 0; |
| 8705 LocalContext env; |
| 8706 v8::Isolate* isolate = env->GetIsolate(); |
| 8707 v8::HandleScope scope(isolate); |
| 8708 v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener); |
| 8709 CompileRun( |
| 8710 "var obj = {};" |
| 8711 "var observe_count = 0;" |
| 8712 "function observer1() { ++observe_count; };" |
| 8713 "function observer2() { ++observe_count; };" |
| 8714 "function observer_throws() { throw new Error(); };" |
| 8715 "function stack_overflow() { return (function f(x) { f(x+1); })(0); };" |
| 8716 "Object.observe(obj, observer_throws.bind());" |
| 8717 "Object.observe(obj, observer1);" |
| 8718 "Object.observe(obj, stack_overflow);" |
| 8719 "Object.observe(obj, observer2);" |
| 8720 "Object.observe(obj, observer_throws.bind());" |
| 8721 "obj.foo = 'bar';"); |
| 8722 CHECK_EQ(3, report_count); |
| 8723 ExpectInt32("observe_count", 2); |
| 8724 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); |
| 8725 } |
| 8726 |
| 8727 |
8701 static const char* script_resource_name = "ExceptionInNativeScript.js"; | 8728 static const char* script_resource_name = "ExceptionInNativeScript.js"; |
8702 static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message, | 8729 static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message, |
8703 v8::Handle<Value>) { | 8730 v8::Handle<Value>) { |
8704 v8::Handle<v8::Value> name_val = message->GetScriptOrigin().ResourceName(); | 8731 v8::Handle<v8::Value> name_val = message->GetScriptOrigin().ResourceName(); |
8705 CHECK(!name_val.IsEmpty() && name_val->IsString()); | 8732 CHECK(!name_val.IsEmpty() && name_val->IsString()); |
8706 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName()); | 8733 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName()); |
8707 CHECK_EQ(script_resource_name, *name); | 8734 CHECK_EQ(script_resource_name, *name); |
8708 CHECK_EQ(3, message->GetLineNumber()); | 8735 CHECK_EQ(3, message->GetLineNumber()); |
8709 v8::String::Utf8Value source_line(message->GetSourceLine()); | 8736 v8::String::Utf8Value source_line(message->GetSourceLine()); |
8710 CHECK_EQ(" new o.foo();", *source_line); | 8737 CHECK_EQ(" new o.foo();", *source_line); |
(...skipping 15334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24045 char chunk2[] = | 24072 char chunk2[] = |
24046 "XX\xec\x92\x81r = 13;\n" | 24073 "XX\xec\x92\x81r = 13;\n" |
24047 " return foob\xec\x92\x81\xec\x92\x81r;\n" | 24074 " return foob\xec\x92\x81\xec\x92\x81r;\n" |
24048 "}\n"; | 24075 "}\n"; |
24049 chunk1[strlen(chunk1) - 1] = reference[0]; | 24076 chunk1[strlen(chunk1) - 1] = reference[0]; |
24050 chunk2[0] = reference[1]; | 24077 chunk2[0] = reference[1]; |
24051 chunk2[1] = reference[2]; | 24078 chunk2[1] = reference[2]; |
24052 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; | 24079 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; |
24053 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); | 24080 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); |
24054 } | 24081 } |
OLD | NEW |