From 4579ec60946f3694b9f436bb2ad2632f91141770 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 26 Aug 2016 09:26:58 -0700 Subject: [PATCH] Don't convert values with internal fields --- .../native_mate_converters/v8_value_converter.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/atom/common/native_mate_converters/v8_value_converter.cc b/atom/common/native_mate_converters/v8_value_converter.cc index 1f4ff7ccd3a1..9403f41ae832 100644 --- a/atom/common/native_mate_converters/v8_value_converter.cc +++ b/atom/common/native_mate_converters/v8_value_converter.cc @@ -393,6 +393,19 @@ base::Value* V8ValueConverter::FromV8Object( std::unique_ptr result(new base::DictionaryValue()); v8::Local property_names(val->GetOwnPropertyNames()); + // Don't consider DOM objects. This check matches isHostObject() in Blink's + // bindings/v8/V8Binding.h used in structured cloning. It reads: + // + // If the object has any internal fields, then we won't be able to serialize + // or deserialize them; conveniently, this is also a quick way to detect DOM + // wrapper objects, because the mechanism for these relies on data stored in + // these fields. + // + // ANOTHER NOTE: returning an empty dictionary here to minimise surprise. + // See also http://crbug.com/330559. + if (val->InternalFieldCount()) + return result.release(); + for (uint32_t i = 0; i < property_names->Length(); ++i) { v8::Local key(property_names->Get(i));