OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 10332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10343 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5); | 10343 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5); |
10344 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); | 10344 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); |
10345 v8::Handle<v8::Script> detailed_script( | 10345 v8::Handle<v8::Script> detailed_script( |
10346 v8::Script::New(detailed_src, &detailed_origin)); | 10346 v8::Script::New(detailed_src, &detailed_origin)); |
10347 v8::Handle<Value> detailed_result = detailed_script->Run(); | 10347 v8::Handle<Value> detailed_result = detailed_script->Run(); |
10348 ASSERT(!detailed_result.IsEmpty()); | 10348 ASSERT(!detailed_result.IsEmpty()); |
10349 ASSERT(detailed_result->IsObject()); | 10349 ASSERT(detailed_result->IsObject()); |
10350 } | 10350 } |
10351 | 10351 |
10352 | 10352 |
| 10353 static void StackTraceForUncaughtExceptionListener( |
| 10354 v8::Handle<v8::Message> message, |
| 10355 v8::Handle<Value>) { |
| 10356 v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace(); |
| 10357 CHECK_EQ(2, stack_trace->GetFrameCount()); |
| 10358 checkStackFrame("origin", "foo", 2, 3, false, false, |
| 10359 stack_trace->GetFrame(0)); |
| 10360 checkStackFrame("origin", "bar", 5, 3, false, false, |
| 10361 stack_trace->GetFrame(1)); |
| 10362 } |
| 10363 |
| 10364 TEST(CaptureStackTraceForUncaughtException) { |
| 10365 report_count = 0; |
| 10366 v8::HandleScope scope; |
| 10367 LocalContext env; |
| 10368 v8::V8::AddMessageListener(StackTraceForUncaughtExceptionListener); |
| 10369 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); |
| 10370 |
| 10371 Script::Compile(v8_str("function foo() {\n" |
| 10372 " throw 1;\n" |
| 10373 "};\n" |
| 10374 "function bar() {\n" |
| 10375 " foo();\n" |
| 10376 "};"), |
| 10377 v8_str("origin"))->Run(); |
| 10378 v8::Local<v8::Object> global = env->Global(); |
| 10379 Local<Value> trouble = global->Get(v8_str("bar")); |
| 10380 CHECK(trouble->IsFunction()); |
| 10381 Function::Cast(*trouble)->Call(global, 0, NULL); |
| 10382 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); |
| 10383 v8::V8::RemoveMessageListeners(StackTraceForUncaughtExceptionListener); |
| 10384 } |
| 10385 |
| 10386 |
10353 // Test that idle notification can be handled and eventually returns true. | 10387 // Test that idle notification can be handled and eventually returns true. |
10354 THREADED_TEST(IdleNotification) { | 10388 THREADED_TEST(IdleNotification) { |
10355 bool rv = false; | 10389 bool rv = false; |
10356 for (int i = 0; i < 100; i++) { | 10390 for (int i = 0; i < 100; i++) { |
10357 rv = v8::V8::IdleNotification(); | 10391 rv = v8::V8::IdleNotification(); |
10358 if (rv) | 10392 if (rv) |
10359 break; | 10393 break; |
10360 } | 10394 } |
10361 CHECK(rv == true); | 10395 CHECK(rv == true); |
10362 } | 10396 } |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11112 | 11146 |
11113 ExpectString("str2.substring(2, 10);", "elspenda"); | 11147 ExpectString("str2.substring(2, 10);", "elspenda"); |
11114 | 11148 |
11115 ExpectString("str2.substring(2, 20);", "elspendabelabelspe"); | 11149 ExpectString("str2.substring(2, 20);", "elspendabelabelspe"); |
11116 | 11150 |
11117 ExpectString("str2.charAt(2);", "e"); | 11151 ExpectString("str2.charAt(2);", "e"); |
11118 | 11152 |
11119 reresult = CompileRun("str2.charCodeAt(2);"); | 11153 reresult = CompileRun("str2.charCodeAt(2);"); |
11120 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value()); | 11154 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value()); |
11121 } | 11155 } |
OLD | NEW |