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

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

Issue 43070: Fix exception propagation problem where undefined was returned instead... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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
« src/top.h ('K') | « 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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) { 1715 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) {
1716 ApiTestFuzzer::Fuzz(); 1716 ApiTestFuzzer::Fuzz();
1717 return v8::ThrowException(v8_str("konto")); 1717 return v8::ThrowException(v8_str("konto"));
1718 } 1718 }
1719 1719
1720 1720
1721 v8::Handle<Value> CCatcher(const v8::Arguments& args) { 1721 v8::Handle<Value> CCatcher(const v8::Arguments& args) {
1722 if (args.Length() < 1) return v8::Boolean::New(false); 1722 if (args.Length() < 1) return v8::Boolean::New(false);
1723 v8::HandleScope scope; 1723 v8::HandleScope scope;
1724 v8::TryCatch try_catch; 1724 v8::TryCatch try_catch;
1725 v8::Script::Compile(args[0]->ToString())->Run(); 1725 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run();
1726 CHECK(!try_catch.HasCaught() || result.IsEmpty());
1726 return v8::Boolean::New(try_catch.HasCaught()); 1727 return v8::Boolean::New(try_catch.HasCaught());
1727 } 1728 }
1728 1729
1729 1730
1730 THREADED_TEST(APICatch) { 1731 THREADED_TEST(APICatch) {
1731 v8::HandleScope scope; 1732 v8::HandleScope scope;
1732 Local<ObjectTemplate> templ = ObjectTemplate::New(); 1733 Local<ObjectTemplate> templ = ObjectTemplate::New();
1733 templ->Set(v8_str("ThrowFromC"), 1734 templ->Set(v8_str("ThrowFromC"),
1734 v8::FunctionTemplate::New(ThrowFromC)); 1735 v8::FunctionTemplate::New(ThrowFromC));
1735 LocalContext context(0, templ); 1736 LocalContext context(0, templ);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 TEST(APIThrowMessageAndVerboseTryCatch) { 1800 TEST(APIThrowMessageAndVerboseTryCatch) {
1800 message_received = false; 1801 message_received = false;
1801 v8::HandleScope scope; 1802 v8::HandleScope scope;
1802 v8::V8::AddMessageListener(receive_message); 1803 v8::V8::AddMessageListener(receive_message);
1803 Local<ObjectTemplate> templ = ObjectTemplate::New(); 1804 Local<ObjectTemplate> templ = ObjectTemplate::New();
1804 templ->Set(v8_str("ThrowFromC"), 1805 templ->Set(v8_str("ThrowFromC"),
1805 v8::FunctionTemplate::New(ThrowFromC)); 1806 v8::FunctionTemplate::New(ThrowFromC));
1806 LocalContext context(0, templ); 1807 LocalContext context(0, templ);
1807 v8::TryCatch try_catch; 1808 v8::TryCatch try_catch;
1808 try_catch.SetVerbose(true); 1809 try_catch.SetVerbose(true);
1809 CompileRun("ThrowFromC();"); 1810 Local<Value> result = CompileRun("ThrowFromC();");
1810 CHECK(try_catch.HasCaught()); 1811 CHECK(try_catch.HasCaught());
1812 CHECK(result.IsEmpty());
1811 CHECK(message_received); 1813 CHECK(message_received);
1812 v8::V8::RemoveMessageListeners(check_message); 1814 v8::V8::RemoveMessageListeners(check_message);
1813 } 1815 }
1814 1816
1815 1817
1816 THREADED_TEST(ExternalScriptException) { 1818 THREADED_TEST(ExternalScriptException) {
1817 v8::HandleScope scope; 1819 v8::HandleScope scope;
1818 Local<ObjectTemplate> templ = ObjectTemplate::New(); 1820 Local<ObjectTemplate> templ = ObjectTemplate::New();
1819 templ->Set(v8_str("ThrowFromC"), 1821 templ->Set(v8_str("ThrowFromC"),
1820 v8::FunctionTemplate::New(ThrowFromC)); 1822 v8::FunctionTemplate::New(ThrowFromC));
(...skipping 25 matching lines...) Expand all
1846 args[1], 1848 args[1],
1847 args[2], 1849 args[2],
1848 args[3] }; 1850 args[3] };
1849 if (count % cInterval == 0) { 1851 if (count % cInterval == 0) {
1850 v8::TryCatch try_catch; 1852 v8::TryCatch try_catch;
1851 Local<Value> result = 1853 Local<Value> result =
1852 v8::Handle<Function>::Cast(fun)->Call(global, 4, argv); 1854 v8::Handle<Function>::Cast(fun)->Call(global, 4, argv);
1853 int expected = args[3]->Int32Value(); 1855 int expected = args[3]->Int32Value();
1854 if (try_catch.HasCaught()) { 1856 if (try_catch.HasCaught()) {
1855 CHECK_EQ(expected, count); 1857 CHECK_EQ(expected, count);
1858 CHECK(result.IsEmpty());
1856 CHECK(!i::Top::has_scheduled_exception()); 1859 CHECK(!i::Top::has_scheduled_exception());
1857 } else { 1860 } else {
1858 CHECK_NE(expected, count); 1861 CHECK_NE(expected, count);
1859 } 1862 }
1860 return result; 1863 return result;
1861 } else { 1864 } else {
1862 return v8::Handle<Function>::Cast(fun)->Call(global, 4, argv); 1865 return v8::Handle<Function>::Cast(fun)->Call(global, 4, argv);
1863 } 1866 }
1864 } 1867 }
1865 } 1868 }
(...skipping 3926 matching lines...) Expand 10 before | Expand all | Expand 10 after
5792 5795
5793 // Local context should still be live. 5796 // Local context should still be live.
5794 CHECK(!local_env.IsEmpty()); 5797 CHECK(!local_env.IsEmpty());
5795 local_env->Enter(); 5798 local_env->Enter();
5796 5799
5797 // Should complete without problems. 5800 // Should complete without problems.
5798 RegExpInterruptTest().RunTest(); 5801 RegExpInterruptTest().RunTest();
5799 5802
5800 local_env->Exit(); 5803 local_env->Exit();
5801 } 5804 }
OLDNEW
« src/top.h ('K') | « src/top.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698