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

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

Issue 1985004: Fixes bug with v8::StackTrace for non-zero script line offsets.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/top.cc ('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 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 9616 matching lines...) Expand 10 before | Expand all | Expand 10 after
9627 stackTrace->GetFrame(2)); 9627 stackTrace->GetFrame(2));
9628 // The last frame is an anonymous function that has the initial call. 9628 // The last frame is an anonymous function that has the initial call.
9629 checkStackFrame(origin, "", 8, 7, false, false, 9629 checkStackFrame(origin, "", 8, 7, false, false,
9630 stackTrace->GetFrame(3)); 9630 stackTrace->GetFrame(3));
9631 9631
9632 CHECK(stackTrace->AsArray()->IsArray()); 9632 CHECK(stackTrace->AsArray()->IsArray());
9633 } else if (testGroup == kDetailedTest) { 9633 } else if (testGroup == kDetailedTest) {
9634 v8::Handle<v8::StackTrace> stackTrace = 9634 v8::Handle<v8::StackTrace> stackTrace =
9635 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); 9635 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed);
9636 CHECK_EQ(4, stackTrace->GetFrameCount()); 9636 CHECK_EQ(4, stackTrace->GetFrameCount());
9637 checkStackFrame(origin, "bat", 2, 1, false, false, 9637 checkStackFrame(origin, "bat", 4, 22, false, false,
9638 stackTrace->GetFrame(0)); 9638 stackTrace->GetFrame(0));
9639 checkStackFrame(origin, "baz", 5, 3, false, true, 9639 checkStackFrame(origin, "baz", 8, 3, false, true,
9640 stackTrace->GetFrame(1)); 9640 stackTrace->GetFrame(1));
9641 checkStackFrame(NULL, "", 1, 1, true, false, 9641 checkStackFrame(NULL, "", 1, 1, true, false,
9642 stackTrace->GetFrame(2)); 9642 stackTrace->GetFrame(2));
9643 // The last frame is an anonymous function that has the initial call to foo. 9643 // The last frame is an anonymous function that has the initial call to foo.
9644 checkStackFrame(origin, "", 7, 1, false, false, 9644 checkStackFrame(origin, "", 10, 1, false, false,
9645 stackTrace->GetFrame(3)); 9645 stackTrace->GetFrame(3));
9646 9646
9647 CHECK(stackTrace->AsArray()->IsArray()); 9647 CHECK(stackTrace->AsArray()->IsArray());
9648 } 9648 }
9649 return v8::Undefined(); 9649 return v8::Undefined();
9650 } 9650 }
9651 9651
9652 9652
9653 // Tests the C++ StackTrace API. 9653 // Tests the C++ StackTrace API.
9654 THREADED_TEST(CaptureStackTrace) { 9654 THREADED_TEST(CaptureStackTrace) {
(...skipping 16 matching lines...) Expand all
9671 "}\n" 9671 "}\n"
9672 "var x;eval('new foo();');"; 9672 "var x;eval('new foo();');";
9673 v8::Handle<v8::String> overview_src = v8::String::New(overview_source); 9673 v8::Handle<v8::String> overview_src = v8::String::New(overview_source);
9674 v8::Handle<Value> overview_result = 9674 v8::Handle<Value> overview_result =
9675 v8::Script::New(overview_src, origin)->Run(); 9675 v8::Script::New(overview_src, origin)->Run();
9676 ASSERT(!overview_result.IsEmpty()); 9676 ASSERT(!overview_result.IsEmpty());
9677 ASSERT(overview_result->IsObject()); 9677 ASSERT(overview_result->IsObject());
9678 9678
9679 // Test getting DETAILED information. 9679 // Test getting DETAILED information.
9680 const char *detailed_source = 9680 const char *detailed_source =
9681 "function bat() {\n" 9681 "function bat() {AnalyzeStackInNativeCode(2);\n"
9682 "AnalyzeStackInNativeCode(2);\n"
9683 "}\n" 9682 "}\n"
9683 "\n"
9684 "function baz() {\n" 9684 "function baz() {\n"
9685 " bat();\n" 9685 " bat();\n"
9686 "}\n" 9686 "}\n"
9687 "eval('new baz();');"; 9687 "eval('new baz();');";
9688 v8::Handle<v8::String> detailed_src = v8::String::New(detailed_source); 9688 v8::Handle<v8::String> detailed_src = v8::String::New(detailed_source);
9689 v8::Handle<Value> detailed_result = 9689 // Make the script using a non-zero line and column offset.
9690 v8::Script::New(detailed_src, origin)->Run(); 9690 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3);
9691 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5);
9692 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset);
9693 v8::Handle<v8::Script> detailed_script(
9694 v8::Script::New(detailed_src, &detailed_origin));
9695 v8::Handle<Value> detailed_result = detailed_script->Run();
9691 ASSERT(!detailed_result.IsEmpty()); 9696 ASSERT(!detailed_result.IsEmpty());
9692 ASSERT(detailed_result->IsObject()); 9697 ASSERT(detailed_result->IsObject());
9693 } 9698 }
9694 9699
9695 9700
9696 // Test that idle notification can be handled and eventually returns true. 9701 // Test that idle notification can be handled and eventually returns true.
9697 THREADED_TEST(IdleNotification) { 9702 THREADED_TEST(IdleNotification) {
9698 bool rv = false; 9703 bool rv = false;
9699 for (int i = 0; i < 100; i++) { 9704 for (int i = 0; i < 100; i++) {
9700 rv = v8::V8::IdleNotification(); 9705 rv = v8::V8::IdleNotification();
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
10257 CHECK_EQ(2, prologue_call_count_second); 10262 CHECK_EQ(2, prologue_call_count_second);
10258 CHECK_EQ(2, epilogue_call_count_second); 10263 CHECK_EQ(2, epilogue_call_count_second);
10259 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond); 10264 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond);
10260 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond); 10265 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond);
10261 i::Heap::CollectAllGarbage(false); 10266 i::Heap::CollectAllGarbage(false);
10262 CHECK_EQ(2, prologue_call_count); 10267 CHECK_EQ(2, prologue_call_count);
10263 CHECK_EQ(2, epilogue_call_count); 10268 CHECK_EQ(2, epilogue_call_count);
10264 CHECK_EQ(2, prologue_call_count_second); 10269 CHECK_EQ(2, prologue_call_count_second);
10265 CHECK_EQ(2, epilogue_call_count_second); 10270 CHECK_EQ(2, epilogue_call_count_second);
10266 } 10271 }
OLDNEW
« no previous file with comments | « src/top.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698