Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp |
| index ed8c7ae5521982cc79eee3da2d2a1244d3bf390b..bc4db2d51b173d0945bed41fa64ad8455a6abe24 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp |
| +++ b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp |
| @@ -34,6 +34,8 @@ |
| #include "bindings/core/v8/DOMDataStore.h" |
| #include "bindings/core/v8/DOMWrapperWorld.h" |
| #include "bindings/core/v8/ExceptionState.h" |
| +#include "bindings/core/v8/IDLTypes.h" |
| +#include "bindings/core/v8/NativeValueTraitsImpl.h" |
| #include "bindings/core/v8/ScriptState.h" |
| #include "bindings/core/v8/SerializationTag.h" |
| #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| @@ -373,25 +375,13 @@ bool SerializedScriptValue::ExtractTransferables( |
| if (value.IsEmpty() || value->IsUndefined()) |
| return true; |
| - uint32_t length = 0; |
| - if (value->IsArray()) { |
| - v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value); |
| - length = array->Length(); |
| - } else if (!ToV8Sequence(value, length, isolate, exception_state)) { |
| - if (!exception_state.HadException()) |
| - exception_state.ThrowTypeError( |
| - ExceptionMessages::NotAnArrayTypeArgumentOrValue(argument_index + 1)); |
| - return false; |
| - } |
| - |
| - v8::Local<v8::Object> transferable_array = v8::Local<v8::Object>::Cast(value); |
| + Vector<v8::Local<v8::Value>> transferable_array = |
| + NativeValueTraits<IDLSequence<v8::Local<v8::Value>>>::NativeValue( |
| + isolate, value, exception_state); |
|
Yuki
2017/04/21 07:02:54
Should return |false| if |exception_state.HadExcep
Raphael Kubo da Costa (rakuco)
2017/04/21 10:30:21
Done.
|
| // Validate the passed array of transferables. |
| - for (unsigned i = 0; i < length; ++i) { |
| - v8::Local<v8::Value> transferable_object; |
| - if (!transferable_array->Get(isolate->GetCurrentContext(), i) |
| - .ToLocal(&transferable_object)) |
| - return false; |
| + uint32_t i = 0; |
| + for (const auto& transferable_object : transferable_array) { |
| // Validation of non-null objects, per HTML5 spec 10.3.3. |
| if (IsUndefinedOrNull(transferable_object)) { |
| exception_state.ThrowTypeError( |
| @@ -459,6 +449,7 @@ bool SerializedScriptValue::ExtractTransferables( |
| " does not have a transferable type."); |
| return false; |
| } |
| + i++; |
| } |
| return true; |
| } |