Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 5585) |
+++ test/cctest/test-api.cc (working copy) |
@@ -10555,6 +10555,45 @@ |
} |
+v8::Handle<Value> AnalyzeStackOfEvalWithSourceURL(const v8::Arguments& args) { |
+ v8::HandleScope scope; |
+ v8::Handle<v8::StackTrace> stackTrace = |
+ v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); |
+ CHECK_EQ(5, stackTrace->GetFrameCount()); |
+ v8::Handle<v8::String> url = v8_str("eval_url"); |
+ for (int i = 0; i < 3; i++) { |
+ v8::Handle<v8::String> name = |
+ stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
+ CHECK(!name.IsEmpty()); |
+ CHECK_EQ(url, name); |
+ } |
+ return v8::Undefined(); |
+} |
+ |
+ |
+TEST(SourceURLInStackTrace) { |
+ v8::HandleScope scope; |
+ Local<ObjectTemplate> templ = ObjectTemplate::New(); |
+ templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), |
+ v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL)); |
+ LocalContext context(0, templ); |
+ |
+ const char *source = |
+ "function outer() {\n" |
+ "function bar() {\n" |
+ " AnalyzeStackOfEvalWithSourceURL();\n" |
+ "}\n" |
+ "function foo() {\n" |
+ "\n" |
+ " bar();\n" |
+ "}\n" |
+ "foo();\n" |
+ "}\n" |
+ "eval('(' + outer +')()//@ sourceURL=eval_url');"; |
+ CHECK(CompileRun(source)->IsUndefined()); |
+} |
+ |
+ |
// Test that idle notification can be handled and eventually returns true. |
THREADED_TEST(IdleNotification) { |
bool rv = false; |