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 8792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8803 CHECK(trouble->IsFunction()); | 8803 CHECK(trouble->IsFunction()); |
8804 Local<Value> trouble_callee = global->Get(v8_str("trouble_callee")); | 8804 Local<Value> trouble_callee = global->Get(v8_str("trouble_callee")); |
8805 CHECK(trouble_callee->IsFunction()); | 8805 CHECK(trouble_callee->IsFunction()); |
8806 Local<Value> trouble_caller = global->Get(v8_str("trouble_caller")); | 8806 Local<Value> trouble_caller = global->Get(v8_str("trouble_caller")); |
8807 CHECK(trouble_caller->IsFunction()); | 8807 CHECK(trouble_caller->IsFunction()); |
8808 Function::Cast(*trouble_caller)->Call(global, 0, NULL); | 8808 Function::Cast(*trouble_caller)->Call(global, 0, NULL); |
8809 CHECK_EQ(1, report_count); | 8809 CHECK_EQ(1, report_count); |
8810 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); | 8810 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); |
8811 } | 8811 } |
8812 | 8812 |
| 8813 |
| 8814 TEST(ApiUncaughtExceptionInObjectObserve) { |
| 8815 v8::internal::FLAG_stack_size = 150; |
| 8816 report_count = 0; |
| 8817 LocalContext env; |
| 8818 v8::Isolate* isolate = env->GetIsolate(); |
| 8819 v8::HandleScope scope(isolate); |
| 8820 v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener); |
| 8821 CompileRun( |
| 8822 "var obj = {};" |
| 8823 "var observe_count = 0;" |
| 8824 "function observer1() { ++observe_count; };" |
| 8825 "function observer2() { ++observe_count; };" |
| 8826 "function observer_throws() { throw new Error(); };" |
| 8827 "function stack_overflow() { return (function f(x) { f(x+1); })(0); };" |
| 8828 "Object.observe(obj, observer_throws.bind());" |
| 8829 "Object.observe(obj, observer1);" |
| 8830 "Object.observe(obj, stack_overflow);" |
| 8831 "Object.observe(obj, observer2);" |
| 8832 "Object.observe(obj, observer_throws.bind());" |
| 8833 "obj.foo = 'bar';"); |
| 8834 CHECK_EQ(3, report_count); |
| 8835 ExpectInt32("observe_count", 2); |
| 8836 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); |
| 8837 } |
| 8838 |
| 8839 |
8813 static const char* script_resource_name = "ExceptionInNativeScript.js"; | 8840 static const char* script_resource_name = "ExceptionInNativeScript.js"; |
8814 static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message, | 8841 static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message, |
8815 v8::Handle<Value>) { | 8842 v8::Handle<Value>) { |
8816 v8::Handle<v8::Value> name_val = message->GetScriptOrigin().ResourceName(); | 8843 v8::Handle<v8::Value> name_val = message->GetScriptOrigin().ResourceName(); |
8817 CHECK(!name_val.IsEmpty() && name_val->IsString()); | 8844 CHECK(!name_val.IsEmpty() && name_val->IsString()); |
8818 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName()); | 8845 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName()); |
8819 CHECK_EQ(script_resource_name, *name); | 8846 CHECK_EQ(script_resource_name, *name); |
8820 CHECK_EQ(3, message->GetLineNumber()); | 8847 CHECK_EQ(3, message->GetLineNumber()); |
8821 v8::String::Utf8Value source_line(message->GetSourceLine()); | 8848 v8::String::Utf8Value source_line(message->GetSourceLine()); |
8822 CHECK_EQ(" new o.foo();", *source_line); | 8849 CHECK_EQ(" new o.foo();", *source_line); |
(...skipping 15334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24157 char chunk2[] = | 24184 char chunk2[] = |
24158 "XX\xec\x92\x81r = 13;\n" | 24185 "XX\xec\x92\x81r = 13;\n" |
24159 " return foob\xec\x92\x81\xec\x92\x81r;\n" | 24186 " return foob\xec\x92\x81\xec\x92\x81r;\n" |
24160 "}\n"; | 24187 "}\n"; |
24161 chunk1[strlen(chunk1) - 1] = reference[0]; | 24188 chunk1[strlen(chunk1) - 1] = reference[0]; |
24162 chunk2[0] = reference[1]; | 24189 chunk2[0] = reference[1]; |
24163 chunk2[1] = reference[2]; | 24190 chunk2[1] = reference[2]; |
24164 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; | 24191 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; |
24165 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); | 24192 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); |
24166 } | 24193 } |
OLD | NEW |