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 11335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11346 v8_str("origin"))->Run(); | 11346 v8_str("origin"))->Run(); |
11347 v8::Local<v8::Object> global = env->Global(); | 11347 v8::Local<v8::Object> global = env->Global(); |
11348 Local<Value> trouble = global->Get(v8_str("bar")); | 11348 Local<Value> trouble = global->Get(v8_str("bar")); |
11349 CHECK(trouble->IsFunction()); | 11349 CHECK(trouble->IsFunction()); |
11350 Function::Cast(*trouble)->Call(global, 0, NULL); | 11350 Function::Cast(*trouble)->Call(global, 0, NULL); |
11351 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); | 11351 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); |
11352 v8::V8::RemoveMessageListeners(StackTraceForUncaughtExceptionListener); | 11352 v8::V8::RemoveMessageListeners(StackTraceForUncaughtExceptionListener); |
11353 } | 11353 } |
11354 | 11354 |
11355 | 11355 |
| 11356 TEST(CaptureStackTraceForUncaughtExceptionAndSetters) { |
| 11357 v8::HandleScope scope; |
| 11358 LocalContext env; |
| 11359 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true, |
| 11360 1024, |
| 11361 v8::StackTrace::kDetailed); |
| 11362 |
| 11363 CompileRun( |
| 11364 "var setters = ['column', 'lineNumber', 'scriptName',\n" |
| 11365 " 'scriptNameOrSourceURL', 'functionName', 'isEval',\n" |
| 11366 " 'isConstructor'];\n" |
| 11367 "for (var i = 0; i < setters.length; i++) {\n" |
| 11368 " var prop = setters[i];\n" |
| 11369 " Object.prototype.__defineSetter__(prop, function() { throw prop; });\n" |
| 11370 "}\n"); |
| 11371 CompileRun("throw 'exception';"); |
| 11372 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); |
| 11373 } |
| 11374 |
| 11375 |
11356 v8::Handle<Value> AnalyzeStackOfEvalWithSourceURL(const v8::Arguments& args) { | 11376 v8::Handle<Value> AnalyzeStackOfEvalWithSourceURL(const v8::Arguments& args) { |
11357 v8::HandleScope scope; | 11377 v8::HandleScope scope; |
11358 v8::Handle<v8::StackTrace> stackTrace = | 11378 v8::Handle<v8::StackTrace> stackTrace = |
11359 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | 11379 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); |
11360 CHECK_EQ(5, stackTrace->GetFrameCount()); | 11380 CHECK_EQ(5, stackTrace->GetFrameCount()); |
11361 v8::Handle<v8::String> url = v8_str("eval_url"); | 11381 v8::Handle<v8::String> url = v8_str("eval_url"); |
11362 for (int i = 0; i < 3; i++) { | 11382 for (int i = 0; i < 3; i++) { |
11363 v8::Handle<v8::String> name = | 11383 v8::Handle<v8::String> name = |
11364 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 11384 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
11365 CHECK(!name.IsEmpty()); | 11385 CHECK(!name.IsEmpty()); |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12558 v8::Handle<v8::Function> define_property = | 12578 v8::Handle<v8::Function> define_property = |
12559 CompileRun("(function() {" | 12579 CompileRun("(function() {" |
12560 " Object.defineProperty(" | 12580 " Object.defineProperty(" |
12561 " this," | 12581 " this," |
12562 " 1," | 12582 " 1," |
12563 " { configurable: true, enumerable: true, value: 3 });" | 12583 " { configurable: true, enumerable: true, value: 3 });" |
12564 "})").As<Function>(); | 12584 "})").As<Function>(); |
12565 context->DetachGlobal(); | 12585 context->DetachGlobal(); |
12566 define_property->Call(proxy, 0, NULL); | 12586 define_property->Call(proxy, 0, NULL); |
12567 } | 12587 } |
OLD | NEW |