Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 12571) |
+++ test/cctest/test-api.cc (working copy) |
@@ -14452,6 +14452,89 @@ |
} |
+v8::Handle<Value> AnalyzeStackOfInlineScriptWithSourceURL( |
+ const v8::Arguments& args) { |
+ v8::HandleScope scope; |
+ v8::Handle<v8::StackTrace> stackTrace = |
+ v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); |
+ CHECK_EQ(4, stackTrace->GetFrameCount()); |
+ v8::Handle<v8::String> url = v8_str("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(InlineScriptWithSourceURLInStackTrace) { |
+ v8::HandleScope scope; |
+ Local<ObjectTemplate> templ = ObjectTemplate::New(); |
+ templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), |
+ v8::FunctionTemplate::New( |
+ AnalyzeStackOfInlineScriptWithSourceURL)); |
+ LocalContext context(0, templ); |
+ |
+ const char *source = |
+ "function outer() {\n" |
+ "function bar() {\n" |
+ " AnalyzeStackOfInlineScriptWithSourceURL();\n" |
+ "}\n" |
+ "function foo() {\n" |
+ "\n" |
+ " bar();\n" |
+ "}\n" |
+ "foo();\n" |
+ "}\n" |
+ "outer()\n" |
+ "//@ sourceURL=source_url"; |
+ CHECK(CompileRunWithOrigin(source, "url", 0, 1)->IsUndefined()); |
+} |
+ |
+ |
+v8::Handle<Value> AnalyzeStackOfDynamicScriptWithSourceURL( |
+ const v8::Arguments& args) { |
+ v8::HandleScope scope; |
+ v8::Handle<v8::StackTrace> stackTrace = |
+ v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); |
+ CHECK_EQ(4, stackTrace->GetFrameCount()); |
+ v8::Handle<v8::String> url = v8_str("source_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(DynamicWithSourceURLInStackTrace) { |
+ v8::HandleScope scope; |
+ Local<ObjectTemplate> templ = ObjectTemplate::New(); |
+ templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), |
+ v8::FunctionTemplate::New( |
+ AnalyzeStackOfDynamicScriptWithSourceURL)); |
+ LocalContext context(0, templ); |
+ |
+ const char *source = |
+ "function outer() {\n" |
+ "function bar() {\n" |
+ " AnalyzeStackOfDynamicScriptWithSourceURL();\n" |
+ "}\n" |
+ "function foo() {\n" |
+ "\n" |
+ " bar();\n" |
+ "}\n" |
+ "foo();\n" |
+ "}\n" |
+ "outer()\n" |
+ "//@ sourceURL=source_url"; |
+ CHECK(CompileRunWithOrigin(source, "url", 0, 0)->IsUndefined()); |
+} |
+ |
static void CreateGarbageInOldSpace() { |
v8::HandleScope scope; |
i::AlwaysAllocateScope always_allocate; |