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 10537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10548 v8_str("origin"))->Run(); | 10548 v8_str("origin"))->Run(); |
10549 v8::Local<v8::Object> global = env->Global(); | 10549 v8::Local<v8::Object> global = env->Global(); |
10550 Local<Value> trouble = global->Get(v8_str("bar")); | 10550 Local<Value> trouble = global->Get(v8_str("bar")); |
10551 CHECK(trouble->IsFunction()); | 10551 CHECK(trouble->IsFunction()); |
10552 Function::Cast(*trouble)->Call(global, 0, NULL); | 10552 Function::Cast(*trouble)->Call(global, 0, NULL); |
10553 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); | 10553 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); |
10554 v8::V8::RemoveMessageListeners(StackTraceForUncaughtExceptionListener); | 10554 v8::V8::RemoveMessageListeners(StackTraceForUncaughtExceptionListener); |
10555 } | 10555 } |
10556 | 10556 |
10557 | 10557 |
| 10558 v8::Handle<Value> AnalyzeStackOfEvalWithSourceURL(const v8::Arguments& args) { |
| 10559 v8::HandleScope scope; |
| 10560 v8::Handle<v8::StackTrace> stackTrace = |
| 10561 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); |
| 10562 CHECK_EQ(5, stackTrace->GetFrameCount()); |
| 10563 v8::Handle<v8::String> url = v8_str("eval_url"); |
| 10564 for (int i = 0; i < 3; i++) { |
| 10565 v8::Handle<v8::String> name = |
| 10566 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 10567 CHECK(!name.IsEmpty()); |
| 10568 CHECK_EQ(url, name); |
| 10569 } |
| 10570 return v8::Undefined(); |
| 10571 } |
| 10572 |
| 10573 |
| 10574 TEST(SourceURLInStackTrace) { |
| 10575 v8::HandleScope scope; |
| 10576 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 10577 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), |
| 10578 v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL)); |
| 10579 LocalContext context(0, templ); |
| 10580 |
| 10581 const char *source = |
| 10582 "function outer() {\n" |
| 10583 "function bar() {\n" |
| 10584 " AnalyzeStackOfEvalWithSourceURL();\n" |
| 10585 "}\n" |
| 10586 "function foo() {\n" |
| 10587 "\n" |
| 10588 " bar();\n" |
| 10589 "}\n" |
| 10590 "foo();\n" |
| 10591 "}\n" |
| 10592 "eval('(' + outer +')()//@ sourceURL=eval_url');"; |
| 10593 CHECK(CompileRun(source)->IsUndefined()); |
| 10594 } |
| 10595 |
| 10596 |
10558 // Test that idle notification can be handled and eventually returns true. | 10597 // Test that idle notification can be handled and eventually returns true. |
10559 THREADED_TEST(IdleNotification) { | 10598 THREADED_TEST(IdleNotification) { |
10560 bool rv = false; | 10599 bool rv = false; |
10561 for (int i = 0; i < 100; i++) { | 10600 for (int i = 0; i < 100; i++) { |
10562 rv = v8::V8::IdleNotification(); | 10601 rv = v8::V8::IdleNotification(); |
10563 if (rv) | 10602 if (rv) |
10564 break; | 10603 break; |
10565 } | 10604 } |
10566 CHECK(rv == true); | 10605 CHECK(rv == true); |
10567 } | 10606 } |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11670 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | | 11709 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | |
11671 v8::RegExp::kMultiline)); | 11710 v8::RegExp::kMultiline)); |
11672 CHECK(re->IsRegExp()); | 11711 CHECK(re->IsRegExp()); |
11673 CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); | 11712 CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); |
11674 CHECK_EQ(static_cast<int>(re->GetFlags()), | 11713 CHECK_EQ(static_cast<int>(re->GetFlags()), |
11675 v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline); | 11714 v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline); |
11676 | 11715 |
11677 context->Global()->Set(v8_str("re"), re); | 11716 context->Global()->Set(v8_str("re"), re); |
11678 ExpectTrue("re.test('FoobarbaZ')"); | 11717 ExpectTrue("re.test('FoobarbaZ')"); |
11679 } | 11718 } |
OLD | NEW |