| Index: third_party/WebKit/Source/bindings/core/v8/SerializedScriptValueFactory.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValueFactory.cpp b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValueFactory.cpp
|
| index a3fd0a5591e92f7d5f8cea3fe12ef782c9e1367a..aa804eb1d44affd7b69ec372c03f5a0b26b72b8a 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValueFactory.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValueFactory.cpp
|
| @@ -7,6 +7,10 @@
|
| #include "bindings/core/v8/ExceptionState.h"
|
| #include "bindings/core/v8/ScriptValueSerializer.h"
|
| #include "bindings/core/v8/Transferables.h"
|
| +#include "bindings/core/v8/V8ArrayBuffer.h"
|
| +#include "bindings/core/v8/V8ImageBitmap.h"
|
| +#include "bindings/core/v8/V8MessagePort.h"
|
| +#include "bindings/core/v8/V8SharedArrayBuffer.h"
|
| #include "core/dom/DOMArrayBuffer.h"
|
| #include "core/dom/MessagePort.h"
|
| #include "core/frame/ImageBitmap.h"
|
| @@ -155,5 +159,47 @@ v8::Local<v8::Value> SerializedScriptValueFactory::deserialize(String& data, Blo
|
| return deserializer.deserialize();
|
| }
|
|
|
| +bool SerializedScriptValueFactory::extractTransferables(v8::Isolate* isolate, Transferables& transferables, ExceptionState& exceptionState, v8::Local<v8::Value>& transferableObject, unsigned i)
|
| +{
|
| + // Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
|
| + if (V8MessagePort::hasInstance(transferableObject, isolate)) {
|
| + MessagePort* port = V8MessagePort::toImpl(v8::Local<v8::Object>::Cast(transferableObject));
|
| + // Check for duplicate MessagePorts.
|
| + if (transferables.messagePorts.contains(port)) {
|
| + exceptionState.throwDOMException(DataCloneError, "Message port at index " + String::number(i) + " is a duplicate of an earlier port.");
|
| + return false;
|
| + }
|
| + transferables.messagePorts.append(port);
|
| + return true;
|
| + }
|
| + if (V8ArrayBuffer::hasInstance(transferableObject, isolate)) {
|
| + DOMArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(v8::Local<v8::Object>::Cast(transferableObject));
|
| + if (transferables.arrayBuffers.contains(arrayBuffer)) {
|
| + exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer.");
|
| + return false;
|
| + }
|
| + transferables.arrayBuffers.append(arrayBuffer);
|
| + return true;
|
| + }
|
| + if (V8SharedArrayBuffer::hasInstance(transferableObject, isolate)) {
|
| + DOMSharedArrayBuffer* sharedArrayBuffer = V8SharedArrayBuffer::toImpl(v8::Local<v8::Object>::Cast(transferableObject));
|
| + if (transferables.arrayBuffers.contains(sharedArrayBuffer)) {
|
| + exceptionState.throwDOMException(DataCloneError, "SharedArrayBuffer at index " + String::number(i) + " is a duplicate of an earlier SharedArrayBuffer.");
|
| + return false;
|
| + }
|
| + transferables.arrayBuffers.append(sharedArrayBuffer);
|
| + return true;
|
| + }
|
| + if (V8ImageBitmap::hasInstance(transferableObject, isolate)) {
|
| + ImageBitmap* imageBitmap = V8ImageBitmap::toImpl(v8::Local<v8::Object>::Cast(transferableObject));
|
| + if (transferables.imageBitmaps.contains(imageBitmap)) {
|
| + exceptionState.throwDOMException(DataCloneError, "ImageBitmap at index " + String::number(i) + " is a duplicate of an earlier ImageBitmap.");
|
| + return false;
|
| + }
|
| + transferables.imageBitmaps.append(imageBitmap);
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
|
|
| } // namespace blink
|
|
|