Reviewers: Igor Sheludko,

Description:
Do not truncate message strings.

[email protected]
BUG=chromium:505539
LOG=N

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

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+17, -11 lines):
  M src/messages.cc
  M test/cctest/test-api.cc


Index: src/messages.cc
diff --git a/src/messages.cc b/src/messages.cc
index 5e050bd2909f17fcf4a27433c30f9ad15cc61093..7193392d9d1c30a196efb43407327c6d369e0348 100644
--- a/src/messages.cc
+++ b/src/messages.cc
@@ -332,7 +332,6 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
                                                    Handle<String> arg0,
                                                    Handle<String> arg1,
                                                    Handle<String> arg2) {
-  static const int kMaxArgLength = 256;
   Isolate* isolate = arg0->GetIsolate();
   const char* template_string;
   switch (template_index) {
@@ -361,16 +360,7 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
       } else {
         DCHECK(i < arraysize(args));
         Handle<String> arg = args[i++];
-        int length = arg->length();
-        if (length > kMaxArgLength) {
-          builder.AppendString(
-              isolate->factory()->NewSubString(arg, 0, kMaxArgLength - 6));
-          builder.AppendCString("...");
-          builder.AppendString(
-              isolate->factory()->NewSubString(arg, length - 3, length));
-        } else {
-          builder.AppendString(arg);
-        }
+        builder.AppendString(arg);
       }
     } else {
       builder.AppendCharacter(*c);
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 49ee96988d4f55d7477e55878d0e8cbc046baac8..357b8b2448ab77748b4b2af3ecc58e4598cae174 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -7553,6 +7553,22 @@ THREADED_TEST(ExceptionCreateMessage) {
 }


+THREADED_TEST(ExceptionCreateMessageLength) {
+  LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
+
+  // Test that the message is not truncated.
+  TryCatch try_catch(context->GetIsolate());
+  CompileRun(
+      "var message = 'm';"
+      "while (message.length < 1000) message += message;"
+      "throw message;");
+  CHECK(try_catch.HasCaught());
+
+  CHECK_LT(1000, try_catch.Message()->Get()->Length());
+}
+
+
 static void YGetter(Local<String> name,
                     const v8::PropertyCallbackInfo<v8::Value>& info) {
   ApiTestFuzzer::Fuzz();


--
--
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/d/optout.

Reply via email to