Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(801)

Unified Diff: test/cctest/test-api-interceptors.cc

Issue 1416873008: [runtime] Handle Exceptions from Indexed- and NamedInterceptor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: nit Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api-interceptors.cc
diff --git a/test/cctest/test-api-interceptors.cc b/test/cctest/test-api-interceptors.cc
index 39f9e901137e987c1bf1d7cda4949e9aaca0c5d2..61f88601926e55bd5a7bfb9a52bf46b6ab9feb49 100644
--- a/test/cctest/test-api-interceptors.cc
+++ b/test/cctest/test-api-interceptors.cc
@@ -2881,6 +2881,96 @@ THREADED_TEST(GetOwnPropertyNamesWithInterceptor) {
}
+static void IndexedPropertyEnumeratorException(
+ const v8::PropertyCallbackInfo<v8::Array>& info) {
+ info.GetIsolate()->ThrowException(v8_num(42));
+}
+
+
+THREADED_TEST(GetOwnPropertyNamesWithIndexedInterceptorExceptions_regress4026) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ v8::Handle<v8::ObjectTemplate> obj_template =
+ v8::ObjectTemplate::New(isolate);
+
+ obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7));
+ obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42));
+ // First just try a failing indexed interceptor.
+ obj_template->SetHandler(v8::IndexedPropertyHandlerConfiguration(
+ NULL, NULL, NULL, NULL, IndexedPropertyEnumeratorException));
+
+ LocalContext context;
+ v8::Handle<v8::Object> global = context->Global();
+ global->Set(v8_str("object"), obj_template->NewInstance());
+ v8::Handle<v8::Value> result = CompileRun(
+ "var result = []; "
+ "try { "
+ " for (var k in object) result .push(k);"
+ "} catch (e) {"
+ " result = e"
+ "}"
+ "result ");
+ CHECK(!result->IsArray());
+ CHECK(v8_num(42)->Equals(result));
+
+ result = CompileRun(
+ "var result = [];"
+ "try { "
+ " result = Object.keys(object);"
+ "} catch (e) {"
+ " result = e;"
+ "}"
+ "result");
+ CHECK(!result->IsArray());
+ CHECK(v8_num(42)->Equals(result));
+}
+
+
+static void NamedPropertyEnumeratorException(
+ const v8::PropertyCallbackInfo<v8::Array>& info) {
+ info.GetIsolate()->ThrowException(v8_num(43));
+}
+
+
+THREADED_TEST(GetOwnPropertyNamesWithNamedInterceptorExceptions_regress4026) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ v8::Handle<v8::ObjectTemplate> obj_template =
+ v8::ObjectTemplate::New(isolate);
+
+ obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7));
+ obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42));
+ // First just try a failing indexed interceptor.
+ obj_template->SetHandler(v8::NamedPropertyHandlerConfiguration(
+ NULL, NULL, NULL, NULL, NamedPropertyEnumeratorException));
+
+ LocalContext context;
+ v8::Handle<v8::Object> global = context->Global();
+ global->Set(v8_str("object"), obj_template->NewInstance());
+
+ v8::Handle<v8::Value> result = CompileRun(
+ "var result = []; "
+ "try { "
+ " for (var k in object) result.push(k);"
+ "} catch (e) {"
+ " result = e"
+ "}"
+ "result");
+ CHECK(!result->IsArray());
+ CHECK(v8_num(43)->Equals(result));
+
+ result = CompileRun(
+ "var result = [];"
+ "try { "
+ " result = Object.keys(object);"
+ "} catch (e) {"
+ " result = e;"
+ "}"
+ "result");
+ CHECK(!result->IsArray());
+ CHECK(v8_num(43)->Equals(result));
+}
+
namespace {
template <typename T>
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698