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

Unified Diff: test/cctest/test-api.cc

Issue 555170: Show user script source line that caused exception intead of a line in a nati... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/frames.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc (revision 3748)
+++ test/cctest/test-api.cc (working copy)
@@ -3602,7 +3602,38 @@
v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener);
}
+static const char* script_resource_name = "ExceptionInNativeScript.js";
+static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message,
+ v8::Handle<Value>) {
+ v8::Handle<v8::Value> name_val = message->GetScriptResourceName();
+ CHECK(!name_val.IsEmpty() && name_val->IsString());
+ v8::String::AsciiValue name(message->GetScriptResourceName());
+ CHECK_EQ(script_resource_name, *name);
+ CHECK_EQ(3, message->GetLineNumber());
+ v8::String::AsciiValue source_line(message->GetSourceLine());
+ CHECK_EQ(" new o.foo();", *source_line);
+}
+TEST(ExceptionInNativeScript) {
+ v8::HandleScope scope;
+ LocalContext env;
+ v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener);
+
+ Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback);
+ v8::Local<v8::Object> global = env->Global();
+ global->Set(v8_str("trouble"), fun->GetFunction());
+
+ Script::Compile(v8_str("function trouble() {\n"
+ " var o = {};\n"
+ " new o.foo();\n"
+ "};"), v8::String::New(script_resource_name))->Run();
+ Local<Value> trouble = global->Get(v8_str("trouble"));
+ CHECK(trouble->IsFunction());
+ Function::Cast(*trouble)->Call(global, 0, NULL);
+ v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener);
+}
+
+
TEST(CompilationErrorUsingTryCatchHandler) {
v8::HandleScope scope;
LocalContext env;
« no previous file with comments | « src/frames.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698