Do not truncate message strings.

R=ishell@chromium.org
BUG=chromium:505539
LOG=N

Review URL: https://codereview.chromium.org/1214373005

Cr-Commit-Position: refs/heads/master@{#29481}
This commit is contained in:
yangguo 2015-07-06 03:25:50 -07:00 committed by Commit bot
parent 9e71cdba48
commit f7b0ee3425
2 changed files with 17 additions and 11 deletions

View File

@ -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,17 +360,8 @@ 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);
}
}
} else {
builder.AppendCharacter(*c);
}

View File

@ -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();