Reviewers: Jakob,
Description:
Not mask exception thrown by toString in String::UtfValue etc.
[email protected]
BUG=v8:2317
Please review this at https://chromiumcodereview.appspot.com/10917236/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/api.cc
M test/cctest/test-api.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
e8ab5a7bce22ad1ee7906dc14a7f9fe510327904..88d9a7d3413e83c360d65b188a2293cb23863c5a
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5500,7 +5500,6 @@ String::Utf8Value::Utf8Value(v8::Handle<v8::Value>
obj)
if (obj.IsEmpty()) return;
ENTER_V8(isolate);
i::HandleScope scope(isolate);
- TryCatch try_catch;
Handle<String> str = obj->ToString();
if (str.IsEmpty()) return;
i::Handle<i::String> i_str = Utils::OpenHandle(*str);
@@ -5522,7 +5521,6 @@ String::AsciiValue::AsciiValue(v8::Handle<v8::Value>
obj)
if (obj.IsEmpty()) return;
ENTER_V8(isolate);
i::HandleScope scope(isolate);
- TryCatch try_catch;
Handle<String> str = obj->ToString();
if (str.IsEmpty()) return;
length_ = str->Length();
@@ -5543,7 +5541,6 @@ String::Value::Value(v8::Handle<v8::Value> obj)
if (obj.IsEmpty()) return;
ENTER_V8(isolate);
i::HandleScope scope(isolate);
- TryCatch try_catch;
Handle<String> str = obj->ToString();
if (str.IsEmpty()) return;
length_ = str->Length();
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
09125e1407c1ae84921005737437dc74f79ddf0d..1b240dc4e825942d9db2a72f4a50ca3cab962b1f
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -17478,4 +17478,37 @@ class ThreadInterruptTest {
THREADED_TEST(SemaphoreInterruption) {
ThreadInterruptTest().RunTest();
}
+
+
+TEST(Utf8ValueException) {
+ v8::HandleScope scope;
+ LocalContext context;
+
+ Handle<Value> object = CompileRun(
+ "var obj = { toString : function() { throw 'deadbeef'; } }; obj");
+
+ { v8::TryCatch try_catch;
+ v8::String::Utf8Value utf8_value(object);
+ CHECK(try_catch.HasCaught());
+ CHECK_EQ("deadbeef", *v8::String::Utf8Value(try_catch.Exception()));
+ }
+
+ { v8::TryCatch try_catch;
+ v8::String::AsciiValue ascii_value(object);
+ CHECK(try_catch.HasCaught());
+ CHECK_EQ("deadbeef", *v8::String::Utf8Value(try_catch.Exception()));
+ }
+
+ { v8::TryCatch try_catch;
+ v8::String::Value value(object);
+ CHECK(try_catch.HasCaught());
+ CHECK_EQ("deadbeef", *v8::String::Utf8Value(try_catch.Exception()));
+ }
+
+ // It should work fine without any TryCatch.
+ v8::String::Utf8Value utf8_value(object);
+ v8::String::AsciiValue ascii_value(object);
+ v8::String::Value value(object);
+}
+
#endif // WIN32
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev