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 17663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17674 i::ScopedVector<char> code(1024); | 17674 i::ScopedVector<char> code(1024); |
17675 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); | 17675 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); |
17676 v8::TryCatch try_catch; | 17676 v8::TryCatch try_catch; |
17677 CompileRunWithOrigin(code.start(), "", 0, 0); | 17677 CompileRunWithOrigin(code.start(), "", 0, 0); |
17678 CHECK(try_catch.HasCaught()); | 17678 CHECK(try_catch.HasCaught()); |
17679 v8::String::Utf8Value stack(try_catch.StackTrace()); | 17679 v8::String::Utf8Value stack(try_catch.StackTrace()); |
17680 CHECK(strstr(*stack, "at foo (source_url:3:5)") != NULL); | 17680 CHECK(strstr(*stack, "at foo (source_url:3:5)") != NULL); |
17681 } | 17681 } |
17682 | 17682 |
17683 | 17683 |
| 17684 TEST(EvalWithSourceURLInMessageScriptResourceNameOrSourceURL) { |
| 17685 LocalContext context; |
| 17686 v8::HandleScope scope(context->GetIsolate()); |
| 17687 |
| 17688 const char *source = |
| 17689 "function outer() {\n" |
| 17690 " var scriptContents = \"function foo() { FAIL.FAIL; }\\\n" |
| 17691 " //# sourceURL=source_url\";\n" |
| 17692 " eval(scriptContents);\n" |
| 17693 " foo(); }\n" |
| 17694 "outer();\n" |
| 17695 "//# sourceURL=outer_url"; |
| 17696 |
| 17697 v8::TryCatch try_catch; |
| 17698 CompileRun(source); |
| 17699 CHECK(try_catch.HasCaught()); |
| 17700 |
| 17701 Local<v8::Message> message = try_catch.Message(); |
| 17702 Handle<Value> sourceURL = message->GetScriptResourceNameOrSourceURL(); |
| 17703 CHECK_EQ(*v8::String::Utf8Value(sourceURL), "source_url"); |
| 17704 } |
| 17705 |
| 17706 |
| 17707 TEST(RecursionWithSourceURLInMessageScriptResourceNameOrSourceURL) { |
| 17708 LocalContext context; |
| 17709 v8::HandleScope scope(context->GetIsolate()); |
| 17710 |
| 17711 const char *source = |
| 17712 "function outer() {\n" |
| 17713 " var scriptContents = \"function boo(){ boo(); }\\\n" |
| 17714 " //# sourceURL=source_url\";\n" |
| 17715 " eval(scriptContents);\n" |
| 17716 " boo(); }\n" |
| 17717 "outer();\n" |
| 17718 "//# sourceURL=outer_url"; |
| 17719 |
| 17720 v8::TryCatch try_catch; |
| 17721 CompileRun(source); |
| 17722 CHECK(try_catch.HasCaught()); |
| 17723 |
| 17724 Local<v8::Message> message = try_catch.Message(); |
| 17725 Handle<Value> sourceURL = message->GetScriptResourceNameOrSourceURL(); |
| 17726 CHECK_EQ(*v8::String::Utf8Value(sourceURL), "source_url"); |
| 17727 } |
| 17728 |
| 17729 |
17684 static void CreateGarbageInOldSpace() { | 17730 static void CreateGarbageInOldSpace() { |
17685 i::Factory* factory = CcTest::i_isolate()->factory(); | 17731 i::Factory* factory = CcTest::i_isolate()->factory(); |
17686 v8::HandleScope scope(CcTest::isolate()); | 17732 v8::HandleScope scope(CcTest::isolate()); |
17687 i::AlwaysAllocateScope always_allocate(CcTest::i_isolate()); | 17733 i::AlwaysAllocateScope always_allocate(CcTest::i_isolate()); |
17688 for (int i = 0; i < 1000; i++) { | 17734 for (int i = 0; i < 1000; i++) { |
17689 factory->NewFixedArray(1000, i::TENURED); | 17735 factory->NewFixedArray(1000, i::TENURED); |
17690 } | 17736 } |
17691 } | 17737 } |
17692 | 17738 |
17693 | 17739 |
(...skipping 4792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22486 v8::internal::FLAG_stack_size = 150; | 22532 v8::internal::FLAG_stack_size = 150; |
22487 LocalContext current; | 22533 LocalContext current; |
22488 v8::Isolate* isolate = current->GetIsolate(); | 22534 v8::Isolate* isolate = current->GetIsolate(); |
22489 v8::HandleScope scope(isolate); | 22535 v8::HandleScope scope(isolate); |
22490 V8::SetCaptureStackTraceForUncaughtExceptions( | 22536 V8::SetCaptureStackTraceForUncaughtExceptions( |
22491 true, 10, v8::StackTrace::kDetailed); | 22537 true, 10, v8::StackTrace::kDetailed); |
22492 v8::TryCatch try_catch; | 22538 v8::TryCatch try_catch; |
22493 CompileRun("(function f(x) { f(x+1); })(0)"); | 22539 CompileRun("(function f(x) { f(x+1); })(0)"); |
22494 CHECK(try_catch.HasCaught()); | 22540 CHECK(try_catch.HasCaught()); |
22495 } | 22541 } |
OLD | NEW |