Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 18025e14a076210b454a8cc4bcc2e7a3dd9d8f47..688dc6035fa30063e0f75a19d93e72decac8db63 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -14452,6 +14452,89 @@ TEST(SourceURLInStackTrace) { |
} |
+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; |