Fix RegExp.source for uncompiled regexp.

R=jkummerow@chromium.org
BUG=435825
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#25476}
This commit is contained in:
yangguo 2014-11-24 03:21:45 -08:00 committed by Commit bot
parent 9b5c279b9f
commit 14a3b9188d
2 changed files with 20 additions and 6 deletions

View File

@ -385,14 +385,17 @@ void Accessors::RegExpSourceGetter(
Handle<Object> receiver =
Utils::OpenHandle(*v8::Local<v8::Value>(info.This()));
Handle<JSRegExp> regexp = Handle<JSRegExp>::cast(receiver);
Handle<String> result;
if (regexp->TypeTag() == JSRegExp::NOT_COMPILED) {
result = isolate->factory()->empty_string();
} else {
Handle<String> pattern(regexp->Pattern(), isolate);
MaybeHandle<String> maybe = EscapeRegExpSource(isolate, pattern);
Handle<String> result;
if (!maybe.ToHandle(&result)) {
isolate->OptionalRescheduleException(false);
return;
}
}
info.GetReturnValue().Set(Utils::ToLocal(result));
}

View File

@ -0,0 +1,11 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Error.prepareStackTrace = function (a,b) { return b; };
try {
/(invalid regexp/;
} catch (e) {
e.stack[0].getThis().toString();
}