From: alph@chromium.org Date: Wed, 12 Feb 2014 15:50:23 +0000 (+0000) Subject: Stack trace string should use dynamic script sourceURL if present. X-Git-Tag: upstream/4.7.83~10744 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=887bd2850d1f99aa1970187fc8374aba84ad68b7;p=platform%2Fupstream%2Fv8.git Stack trace string should use dynamic script sourceURL if present. BUG=v8:2342 R=dcarney@chromium.org, yurys@chromium.org, yurys LOG=N Review URL: https://codereview.chromium.org/143283015 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19333 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/messages.js b/src/messages.js index e9f1ae4..cdf95b1 100644 --- a/src/messages.js +++ b/src/messages.js @@ -939,14 +939,10 @@ function CallSiteToString() { if (this.isNative()) { fileLocation = "native"; } else { - if (this.isEval()) { - fileName = this.getScriptNameOrSourceURL(); - if (!fileName) { - fileLocation = this.getEvalOrigin(); - fileLocation += ", "; // Expecting source position to follow. - } - } else { - fileName = this.getFileName(); + fileName = this.getScriptNameOrSourceURL(); + if (!fileName && this.isEval()) { + fileLocation = this.getEvalOrigin(); + fileLocation += ", "; // Expecting source position to follow. } if (fileName) { diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 2047370..835f770 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -17520,6 +17520,29 @@ TEST(DynamicWithSourceURLInStackTrace) { } +TEST(DynamicWithSourceURLInStackTraceString) { + LocalContext context; + v8::HandleScope scope(context->GetIsolate()); + + const char *source = + "function outer() {\n" + " function foo() {\n" + " FAIL.FAIL;\n" + " }\n" + " foo();\n" + "}\n" + "outer()\n%s"; + + i::ScopedVector code(1024); + i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); + v8::TryCatch try_catch; + CompileRunWithOrigin(code.start(), "", 0, 0); + CHECK(try_catch.HasCaught()); + v8::String::Utf8Value stack(try_catch.StackTrace()); + CHECK(strstr(*stack, "at foo (source_url:3:5)") != NULL); +} + + static void CreateGarbageInOldSpace() { i::Factory* factory = CcTest::i_isolate()->factory(); v8::HandleScope scope(CcTest::isolate());