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

Unified Diff: trunk/src/content/renderer/v8_value_converter_impl_unittest.cc

Issue 16511004: Revert 205184 "Revert 204057 "Recurse to a maximum depth of 10 i..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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 | « trunk/src/content/renderer/v8_value_converter_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/content/renderer/v8_value_converter_impl_unittest.cc
===================================================================
--- trunk/src/content/renderer/v8_value_converter_impl_unittest.cc (revision 205208)
+++ trunk/src/content/renderer/v8_value_converter_impl_unittest.cc (working copy)
@@ -447,49 +447,6 @@
EXPECT_TRUE(IsNull(list_result.get(), 1));
}
-// Do not try and convert any named callbacks including getters.
-TEST_F(V8ValueConverterImplTest, ObjectGetters) {
- v8::Context::Scope context_scope(context_);
- v8::HandleScope handle_scope;
-
- const char* source = "(function() {"
- "var a = {};"
- "a.__defineGetter__('foo', function() { return 'bar'; });"
- "return a;"
- "})();";
-
- v8::Handle<v8::Script> script(v8::Script::New(v8::String::New(source)));
- v8::Handle<v8::Object> object = script->Run().As<v8::Object>();
- ASSERT_FALSE(object.IsEmpty());
-
- V8ValueConverterImpl converter;
- scoped_ptr<base::DictionaryValue> result(
- static_cast<base::DictionaryValue*>(
- converter.FromV8Value(object, context_)));
- ASSERT_TRUE(result.get());
- EXPECT_EQ(0u, result->size());
-}
-
-// Do not try and convert any named callbacks including getters.
-TEST_F(V8ValueConverterImplTest, ObjectWithInternalFieldsGetters) {
- v8::Context::Scope context_scope(context_);
- v8::HandleScope handle_scope;
-
- v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New();
- object_template->SetInternalFieldCount(1);
- object_template->SetAccessor(v8::String::New("foo"), NamedCallbackGetter);
- v8::Handle<v8::Object> object = object_template->NewInstance();
- ASSERT_FALSE(object.IsEmpty());
- object->Set(v8::String::New("a"), v8::String::New("b"));
-
- V8ValueConverterImpl converter;
- scoped_ptr<base::DictionaryValue> result(
- static_cast<base::DictionaryValue*>(
- converter.FromV8Value(object, context_)));
- ASSERT_TRUE(result.get());
- EXPECT_EQ(1u, result->size());
-}
-
TEST_F(V8ValueConverterImplTest, WeirdProperties) {
v8::Context::Scope context_scope(context_);
v8::HandleScope handle_scope;
@@ -650,4 +607,40 @@
EXPECT_TRUE(expected_dictionary.Equals(actual_dictionary.get()));
}
+TEST_F(V8ValueConverterImplTest, MaxRecursionDepth) {
+ v8::Context::Scope context_scope(context_);
+ v8::HandleScope handle_scope;
+
+ // Must larger than kMaxRecursionDepth in v8_value_converter_impl.cc.
+ int kDepth = 100;
+ const char kKey[] = "key";
+
+ v8::Local<v8::Object> deep_object = v8::Object::New();
+
+ v8::Local<v8::Object> leaf = deep_object;
+ for (int i = 0; i < kDepth; ++i) {
+ v8::Local<v8::Object> new_object = v8::Object::New();
+ leaf->Set(v8::String::New(kKey), new_object);
+ leaf = new_object;
+ }
+
+ V8ValueConverterImpl converter;
+ scoped_ptr<base::Value> value(converter.FromV8Value(deep_object, context_));
+ ASSERT_TRUE(value);
+
+ // Expected depth is kMaxRecursionDepth in v8_value_converter_impl.cc.
+ int kExpectedDepth = 10;
+
+ base::Value* current = value.get();
+ for (int i = 1; i < kExpectedDepth; ++i) {
+ base::DictionaryValue* current_as_object = NULL;
+ ASSERT_TRUE(current->GetAsDictionary(&current_as_object)) << i;
+ ASSERT_TRUE(current_as_object->Get(kKey, &current)) << i;
+ }
+
+ // The leaf node shouldn't have any properties.
+ base::DictionaryValue empty;
+ EXPECT_TRUE(Value::Equals(&empty, current)) << *current;
+}
+
} // namespace content
« no previous file with comments | « trunk/src/content/renderer/v8_value_converter_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698