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

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

Issue 711353002: Rename v8::Exception::GetMessage to CreateMessage. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
« include/v8.h ('K') | « src/api.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 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 8617 matching lines...) Expand 10 before | Expand all | Expand 10 after
8628 v8::Handle<String> foo = v8_str("foo"); 8628 v8::Handle<String> foo = v8_str("foo");
8629 v8::Handle<String> message = v8_str("message"); 8629 v8::Handle<String> message = v8_str("message");
8630 v8::Handle<Value> error = v8::Exception::Error(foo); 8630 v8::Handle<Value> error = v8::Exception::Error(foo);
8631 CHECK(error->IsObject()); 8631 CHECK(error->IsObject());
8632 CHECK(error.As<v8::Object>()->Get(message)->Equals(foo)); 8632 CHECK(error.As<v8::Object>()->Get(message)->Equals(foo));
8633 info.GetIsolate()->ThrowException(error); 8633 info.GetIsolate()->ThrowException(error);
8634 info.GetReturnValue().SetUndefined(); 8634 info.GetReturnValue().SetUndefined();
8635 } 8635 }
8636 8636
8637 8637
8638 THREADED_TEST(ExceptionGetMessage) { 8638 THREADED_TEST(ExceptionCreateMessage) {
8639 LocalContext context; 8639 LocalContext context;
8640 v8::HandleScope scope(context->GetIsolate()); 8640 v8::HandleScope scope(context->GetIsolate());
8641 v8::Handle<String> foo_str = v8_str("foo"); 8641 v8::Handle<String> foo_str = v8_str("foo");
8642 v8::Handle<String> message_str = v8_str("message"); 8642 v8::Handle<String> message_str = v8_str("message");
8643 8643
8644 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); 8644 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
8645 8645
8646 Local<v8::FunctionTemplate> fun = 8646 Local<v8::FunctionTemplate> fun =
8647 v8::FunctionTemplate::New(context->GetIsolate(), ThrowV8Exception); 8647 v8::FunctionTemplate::New(context->GetIsolate(), ThrowV8Exception);
8648 v8::Local<v8::Object> global = context->Global(); 8648 v8::Local<v8::Object> global = context->Global();
8649 global->Set(v8_str("throwV8Exception"), fun->GetFunction()); 8649 global->Set(v8_str("throwV8Exception"), fun->GetFunction());
8650 8650
8651 TryCatch try_catch; 8651 TryCatch try_catch;
8652 CompileRun( 8652 CompileRun(
8653 "function f1() {\n" 8653 "function f1() {\n"
8654 " throwV8Exception();\n" 8654 " throwV8Exception();\n"
8655 "};\n" 8655 "};\n"
8656 "f1();"); 8656 "f1();");
8657 CHECK(try_catch.HasCaught()); 8657 CHECK(try_catch.HasCaught());
8658 8658
8659 v8::Handle<v8::Value> error = try_catch.Exception(); 8659 v8::Handle<v8::Value> error = try_catch.Exception();
8660 CHECK(error->IsObject()); 8660 CHECK(error->IsObject());
8661 CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str)); 8661 CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str));
8662 8662
8663 v8::Handle<v8::Message> message = v8::Exception::GetMessage(error); 8663 v8::Handle<v8::Message> message = v8::Exception::CreateMessage(error);
8664 CHECK(!message.IsEmpty()); 8664 CHECK(!message.IsEmpty());
8665 CHECK_EQ(2, message->GetLineNumber()); 8665 CHECK_EQ(2, message->GetLineNumber());
8666 CHECK_EQ(2, message->GetStartColumn()); 8666 CHECK_EQ(2, message->GetStartColumn());
8667 8667
8668 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); 8668 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
8669 CHECK(!stackTrace.IsEmpty()); 8669 CHECK(!stackTrace.IsEmpty());
8670 CHECK_EQ(2, stackTrace->GetFrameCount()); 8670 CHECK_EQ(2, stackTrace->GetFrameCount());
8671 8671
8672 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); 8672 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
8673 8673
8674 // Now check message location when SetCaptureStackTraceForUncaughtExceptions 8674 // Now check message location when SetCaptureStackTraceForUncaughtExceptions
8675 // is false. 8675 // is false.
8676 try_catch.Reset(); 8676 try_catch.Reset();
8677 8677
8678 CompileRun( 8678 CompileRun(
8679 "function f2() {\n" 8679 "function f2() {\n"
8680 " return throwV8Exception();\n" 8680 " return throwV8Exception();\n"
8681 "};\n" 8681 "};\n"
8682 "f2();"); 8682 "f2();");
8683 CHECK(try_catch.HasCaught()); 8683 CHECK(try_catch.HasCaught());
8684 8684
8685 error = try_catch.Exception(); 8685 error = try_catch.Exception();
8686 CHECK(error->IsObject()); 8686 CHECK(error->IsObject());
8687 CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str)); 8687 CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str));
8688 8688
8689 message = v8::Exception::GetMessage(error); 8689 message = v8::Exception::CreateMessage(error);
8690 CHECK(!message.IsEmpty()); 8690 CHECK(!message.IsEmpty());
8691 CHECK_EQ(2, message->GetLineNumber()); 8691 CHECK_EQ(2, message->GetLineNumber());
8692 CHECK_EQ(9, message->GetStartColumn()); 8692 CHECK_EQ(9, message->GetStartColumn());
8693 8693
8694 // Should be empty stack trace. 8694 // Should be empty stack trace.
8695 stackTrace = message->GetStackTrace(); 8695 stackTrace = message->GetStackTrace();
8696 CHECK(stackTrace.IsEmpty()); 8696 CHECK(stackTrace.IsEmpty());
8697 } 8697 }
8698 8698
8699 8699
(...skipping 9315 matching lines...) Expand 10 before | Expand all | Expand 10 after
18015 int promise_revoke_counter = 0; 18015 int promise_revoke_counter = 0;
18016 int promise_reject_line_number = -1; 18016 int promise_reject_line_number = -1;
18017 int promise_reject_frame_count = -1; 18017 int promise_reject_frame_count = -1;
18018 18018
18019 void PromiseRejectCallback(v8::PromiseRejectMessage message) { 18019 void PromiseRejectCallback(v8::PromiseRejectMessage message) {
18020 if (message.GetEvent() == v8::kPromiseRejectWithNoHandler) { 18020 if (message.GetEvent() == v8::kPromiseRejectWithNoHandler) {
18021 promise_reject_counter++; 18021 promise_reject_counter++;
18022 CcTest::global()->Set(v8_str("rejected"), message.GetPromise()); 18022 CcTest::global()->Set(v8_str("rejected"), message.GetPromise());
18023 CcTest::global()->Set(v8_str("value"), message.GetValue()); 18023 CcTest::global()->Set(v8_str("value"), message.GetValue());
18024 v8::Handle<v8::StackTrace> stack_trace = 18024 v8::Handle<v8::StackTrace> stack_trace =
18025 v8::Exception::GetMessage(message.GetValue())->GetStackTrace(); 18025 v8::Exception::CreateMessage(message.GetValue())->GetStackTrace();
18026 if (!stack_trace.IsEmpty()) { 18026 if (!stack_trace.IsEmpty()) {
18027 promise_reject_frame_count = stack_trace->GetFrameCount(); 18027 promise_reject_frame_count = stack_trace->GetFrameCount();
18028 if (promise_reject_frame_count > 0) { 18028 if (promise_reject_frame_count > 0) {
18029 CHECK(stack_trace->GetFrame(0)->GetScriptName()->Equals(v8_str("pro"))); 18029 CHECK(stack_trace->GetFrame(0)->GetScriptName()->Equals(v8_str("pro")));
18030 promise_reject_line_number = stack_trace->GetFrame(0)->GetLineNumber(); 18030 promise_reject_line_number = stack_trace->GetFrame(0)->GetLineNumber();
18031 } else { 18031 } else {
18032 promise_reject_line_number = -1; 18032 promise_reject_line_number = -1;
18033 } 18033 }
18034 } 18034 }
18035 } else { 18035 } else {
(...skipping 6159 matching lines...) Expand 10 before | Expand all | Expand 10 after
24195 char chunk2[] = 24195 char chunk2[] =
24196 "XX\xec\x92\x81r = 13;\n" 24196 "XX\xec\x92\x81r = 13;\n"
24197 " return foob\xec\x92\x81\xec\x92\x81r;\n" 24197 " return foob\xec\x92\x81\xec\x92\x81r;\n"
24198 "}\n"; 24198 "}\n";
24199 chunk1[strlen(chunk1) - 1] = reference[0]; 24199 chunk1[strlen(chunk1) - 1] = reference[0];
24200 chunk2[0] = reference[1]; 24200 chunk2[0] = reference[1];
24201 chunk2[1] = reference[2]; 24201 chunk2[1] = reference[2];
24202 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; 24202 const char* chunks[] = {chunk1, chunk2, "foo();", NULL};
24203 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); 24203 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
24204 } 24204 }
OLDNEW
« include/v8.h ('K') | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698