Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: test/cctest/test-api.cc

Issue 10966011: Supported sourceURL comments for scripts having a name. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Comments addressed: changed method comment and added a test. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/cctest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
14455 static void CreateGarbageInOldSpace() { 14538 static void CreateGarbageInOldSpace() {
14456 v8::HandleScope scope; 14539 v8::HandleScope scope;
14457 i::AlwaysAllocateScope always_allocate; 14540 i::AlwaysAllocateScope always_allocate;
14458 for (int i = 0; i < 1000; i++) { 14541 for (int i = 0; i < 1000; i++) {
14459 FACTORY->NewFixedArray(1000, i::TENURED); 14542 FACTORY->NewFixedArray(1000, i::TENURED);
14460 } 14543 }
14461 } 14544 }
14462 14545
14463 // Test that idle notification can be handled and eventually returns true. 14546 // Test that idle notification can be handled and eventually returns true.
14464 TEST(IdleNotification) { 14547 TEST(IdleNotification) {
(...skipping 3042 matching lines...) Expand 10 before | Expand all | Expand 10 after
17507 17590
17508 i::Semaphore* sem_; 17591 i::Semaphore* sem_;
17509 volatile int sem_value_; 17592 volatile int sem_value_;
17510 }; 17593 };
17511 17594
17512 17595
17513 THREADED_TEST(SemaphoreInterruption) { 17596 THREADED_TEST(SemaphoreInterruption) {
17514 ThreadInterruptTest().RunTest(); 17597 ThreadInterruptTest().RunTest();
17515 } 17598 }
17516 #endif // WIN32 17599 #endif // WIN32
OLDNEW
« no previous file with comments | « test/cctest/cctest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698