| 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 14434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14445 "\n" | 14445 "\n" |
| 14446 " bar();\n" | 14446 " bar();\n" |
| 14447 "}\n" | 14447 "}\n" |
| 14448 "foo();\n" | 14448 "foo();\n" |
| 14449 "}\n" | 14449 "}\n" |
| 14450 "eval('(' + outer +')()//@ sourceURL=eval_url');"; | 14450 "eval('(' + outer +')()//@ sourceURL=eval_url');"; |
| 14451 CHECK(CompileRun(source)->IsUndefined()); | 14451 CHECK(CompileRun(source)->IsUndefined()); |
| 14452 } | 14452 } |
| 14453 | 14453 |
| 14454 | 14454 |
| 14455 v8::Handle<Value> AnalyzeStackOfInlineScriptWithSourceURL( | |
| 14456 const v8::Arguments& args) { | |
| 14457 v8::HandleScope scope; | |
| 14458 v8::Handle<v8::StackTrace> stackTrace = | |
| 14459 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | |
| 14460 CHECK_EQ(4, stackTrace->GetFrameCount()); | |
| 14461 v8::Handle<v8::String> url = v8_str("url"); | |
| 14462 for (int i = 0; i < 3; i++) { | |
| 14463 v8::Handle<v8::String> name = | |
| 14464 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | |
| 14465 CHECK(!name.IsEmpty()); | |
| 14466 CHECK_EQ(url, name); | |
| 14467 } | |
| 14468 return v8::Undefined(); | |
| 14469 } | |
| 14470 | |
| 14471 | |
| 14472 TEST(InlineScriptWithSourceURLInStackTrace) { | |
| 14473 v8::HandleScope scope; | |
| 14474 Local<ObjectTemplate> templ = ObjectTemplate::New(); | |
| 14475 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), | |
| 14476 v8::FunctionTemplate::New( | |
| 14477 AnalyzeStackOfInlineScriptWithSourceURL)); | |
| 14478 LocalContext context(0, templ); | |
| 14479 | |
| 14480 const char *source = | |
| 14481 "function outer() {\n" | |
| 14482 "function bar() {\n" | |
| 14483 " AnalyzeStackOfInlineScriptWithSourceURL();\n" | |
| 14484 "}\n" | |
| 14485 "function foo() {\n" | |
| 14486 "\n" | |
| 14487 " bar();\n" | |
| 14488 "}\n" | |
| 14489 "foo();\n" | |
| 14490 "}\n" | |
| 14491 "outer()\n" | |
| 14492 "//@ sourceURL=source_url"; | |
| 14493 CHECK(CompileRunWithOrigin(source, "url", 0, 1)->IsUndefined()); | |
| 14494 } | |
| 14495 | |
| 14496 | |
| 14497 v8::Handle<Value> AnalyzeStackOfDynamicScriptWithSourceURL( | |
| 14498 const v8::Arguments& args) { | |
| 14499 v8::HandleScope scope; | |
| 14500 v8::Handle<v8::StackTrace> stackTrace = | |
| 14501 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | |
| 14502 CHECK_EQ(4, stackTrace->GetFrameCount()); | |
| 14503 v8::Handle<v8::String> url = v8_str("source_url"); | |
| 14504 for (int i = 0; i < 3; i++) { | |
| 14505 v8::Handle<v8::String> name = | |
| 14506 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | |
| 14507 CHECK(!name.IsEmpty()); | |
| 14508 CHECK_EQ(url, name); | |
| 14509 } | |
| 14510 return v8::Undefined(); | |
| 14511 } | |
| 14512 | |
| 14513 | |
| 14514 TEST(DynamicWithSourceURLInStackTrace) { | |
| 14515 v8::HandleScope scope; | |
| 14516 Local<ObjectTemplate> templ = ObjectTemplate::New(); | |
| 14517 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), | |
| 14518 v8::FunctionTemplate::New( | |
| 14519 AnalyzeStackOfDynamicScriptWithSourceURL)); | |
| 14520 LocalContext context(0, templ); | |
| 14521 | |
| 14522 const char *source = | |
| 14523 "function outer() {\n" | |
| 14524 "function bar() {\n" | |
| 14525 " AnalyzeStackOfDynamicScriptWithSourceURL();\n" | |
| 14526 "}\n" | |
| 14527 "function foo() {\n" | |
| 14528 "\n" | |
| 14529 " bar();\n" | |
| 14530 "}\n" | |
| 14531 "foo();\n" | |
| 14532 "}\n" | |
| 14533 "outer()\n" | |
| 14534 "//@ sourceURL=source_url"; | |
| 14535 CHECK(CompileRunWithOrigin(source, "url", 0, 0)->IsUndefined()); | |
| 14536 } | |
| 14537 | |
| 14538 static void CreateGarbageInOldSpace() { | 14455 static void CreateGarbageInOldSpace() { |
| 14539 v8::HandleScope scope; | 14456 v8::HandleScope scope; |
| 14540 i::AlwaysAllocateScope always_allocate; | 14457 i::AlwaysAllocateScope always_allocate; |
| 14541 for (int i = 0; i < 1000; i++) { | 14458 for (int i = 0; i < 1000; i++) { |
| 14542 FACTORY->NewFixedArray(1000, i::TENURED); | 14459 FACTORY->NewFixedArray(1000, i::TENURED); |
| 14543 } | 14460 } |
| 14544 } | 14461 } |
| 14545 | 14462 |
| 14546 // Test that idle notification can be handled and eventually returns true. | 14463 // Test that idle notification can be handled and eventually returns true. |
| 14547 TEST(IdleNotification) { | 14464 TEST(IdleNotification) { |
| (...skipping 2997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17545 | 17462 |
| 17546 // Compile a try-finally clause where the finally block causes a GC | 17463 // Compile a try-finally clause where the finally block causes a GC |
| 17547 // while there still is a message pending for external reporting. | 17464 // while there still is a message pending for external reporting. |
| 17548 TryCatch try_catch; | 17465 TryCatch try_catch; |
| 17549 try_catch.SetVerbose(true); | 17466 try_catch.SetVerbose(true); |
| 17550 CompileRun("try { throw new Error(); } finally { gc(); }"); | 17467 CompileRun("try { throw new Error(); } finally { gc(); }"); |
| 17551 CHECK(try_catch.HasCaught()); | 17468 CHECK(try_catch.HasCaught()); |
| 17552 } | 17469 } |
| 17553 | 17470 |
| 17554 | 17471 |
| 17555 THREADED_TEST(Regress149912) { | |
| 17556 v8::HandleScope scope; | |
| 17557 LocalContext context; | |
| 17558 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | |
| 17559 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); | |
| 17560 context->Global()->Set(v8_str("Bug"), templ->GetFunction()); | |
| 17561 CompileRun("Number.prototype.__proto__ = new Bug; var x = 0; x.foo();"); | |
| 17562 } | |
| 17563 | |
| 17564 | |
| 17565 #ifndef WIN32 | 17472 #ifndef WIN32 |
| 17566 class ThreadInterruptTest { | 17473 class ThreadInterruptTest { |
| 17567 public: | 17474 public: |
| 17568 ThreadInterruptTest() : sem_(NULL), sem_value_(0) { } | 17475 ThreadInterruptTest() : sem_(NULL), sem_value_(0) { } |
| 17569 ~ThreadInterruptTest() { delete sem_; } | 17476 ~ThreadInterruptTest() { delete sem_; } |
| 17570 | 17477 |
| 17571 void RunTest() { | 17478 void RunTest() { |
| 17572 sem_ = i::OS::CreateSemaphore(0); | 17479 sem_ = i::OS::CreateSemaphore(0); |
| 17573 | 17480 |
| 17574 InterruptThread i_thread(this); | 17481 InterruptThread i_thread(this); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17618 | 17525 |
| 17619 i::Semaphore* sem_; | 17526 i::Semaphore* sem_; |
| 17620 volatile int sem_value_; | 17527 volatile int sem_value_; |
| 17621 }; | 17528 }; |
| 17622 | 17529 |
| 17623 | 17530 |
| 17624 THREADED_TEST(SemaphoreInterruption) { | 17531 THREADED_TEST(SemaphoreInterruption) { |
| 17625 ThreadInterruptTest().RunTest(); | 17532 ThreadInterruptTest().RunTest(); |
| 17626 } | 17533 } |
| 17627 #endif // WIN32 | 17534 #endif // WIN32 |
| OLD | NEW |