Index: Source/bindings/v8/V8Utilities.cpp |
diff --git a/Source/bindings/v8/V8Utilities.cpp b/Source/bindings/v8/V8Utilities.cpp |
index f6cbd033159fe2ea7f93a89b4190df8561cf9f44..33c07f1415563cb3f89865b9ab1ab90ac2681a14 100644 |
--- a/Source/bindings/v8/V8Utilities.cpp |
+++ b/Source/bindings/v8/V8Utilities.cpp |
@@ -87,7 +87,7 @@ bool extractTransferables(v8::Local<v8::Value> value, MessagePortArray& ports, A |
v8::Local<v8::Value> transferrable = transferrables->Get(i); |
// Validation of non-null objects, per HTML5 spec 10.3.3. |
if (isUndefinedOrNull(transferrable)) { |
- setDOMException(InvalidStateError, isolate); |
+ setDOMException(DataCloneError, isolate); |
return false; |
} |
// Validation of Objects implementing an interface, per WebIDL spec 4.1.15. |
@@ -95,14 +95,14 @@ bool extractTransferables(v8::Local<v8::Value> value, MessagePortArray& ports, A |
RefPtr<MessagePort> port = V8MessagePort::toNative(v8::Handle<v8::Object>::Cast(transferrable)); |
// Check for duplicate MessagePorts. |
if (ports.contains(port)) { |
- setDOMException(InvalidStateError, isolate); |
+ setDOMException(DataCloneError, isolate); |
return false; |
} |
ports.append(port.release()); |
} else if (V8ArrayBuffer::HasInstance(transferrable, isolate, worldType(isolate))) |
arrayBuffers.append(V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(transferrable))); |
else { |
- throwTypeError(isolate); |
+ setDOMException(DataCloneError, isolate); |
return false; |
} |
} |
@@ -111,15 +111,17 @@ bool extractTransferables(v8::Local<v8::Value> value, MessagePortArray& ports, A |
bool getMessagePortArray(v8::Local<v8::Value> value, MessagePortArray& ports, v8::Isolate* isolate) |
{ |
- ArrayBufferArray arrayBuffers; |
- bool result = extractTransferables(value, ports, arrayBuffers, isolate); |
- if (!result) |
- return false; |
- if (arrayBuffers.size() > 0) { |
- throwTypeError("MessagePortArray argument must contain only MessagePorts", isolate); |
+ if (isUndefinedOrNull(value)) { |
+ ports.resize(0); |
+ return true; |
+ } |
+ if (!value->IsArray()) { |
+ throwTypeError(isolate); |
return false; |
} |
- return true; |
+ bool success = false; |
+ ports = toRefPtrNativeArray<MessagePort, V8MessagePort>(value, isolate, &success); |
+ return success; |
} |
void removeHiddenDependency(v8::Handle<v8::Object> object, v8::Local<v8::Value> value, int cacheIndex, v8::Isolate* isolate) |