Revision: 19333
Author:   [email protected]
Date:     Wed Feb 12 15:50:23 2014 UTC
Log:      Stack trace string should use dynamic script sourceURL if present.

BUG=v8:2342
[email protected], [email protected], yurys
LOG=N

Review URL: https://codereview.chromium.org/143283015
http://code.google.com/p/v8/source/detail?r=19333

Modified:
 /branches/bleeding_edge/src/messages.js
 /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/src/messages.js     Thu Feb  6 16:09:45 2014 UTC
+++ /branches/bleeding_edge/src/messages.js     Wed Feb 12 15:50:23 2014 UTC
@@ -939,14 +939,10 @@
   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) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Tue Feb 11 12:49:15 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Wed Feb 12 15:50:23 2014 UTC
@@ -17518,6 +17518,29 @@
   i::OS::SNPrintF(code, source, "//@ sourceURL=source_url");
   CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
 }
+
+
+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() {

--
--
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