Reviewers: yurys, dcarney,

Message:
yurys@, could you please take a look?
dcarney@, could you please OWNER review this?

Description:
Stack trace string should use dynamic script sourceURL if present.

BUG=v8:2342
R=yurys

Please review this at https://codereview.chromium.org/143283015/

SVN Base: git://github.com/v8/v8.git@master

Affected files (+27, -8 lines):
  M src/messages.js
  M test/cctest/test-api.cc


Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index e9f1ae46c258470d28ed71b319239efe652f9f72..cdf95b1f2736d19ad0339d6de13953d19a8171cf 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) {
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 447cd261ce9daba049a74c8cb4797641f2a246fb..3c12f651c7aa2ca254764f74327ec3b2bff4394c 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<char> 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());


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to