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

Unified Diff: Source/bindings/v8/V8Utilities.cpp

Issue 19765010: postMessage() should throw a DataCloneError on invalid transferables (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 | « Source/bindings/v8/V8Binding.h ('k') | Source/core/dom/MessagePort.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/bindings/v8/V8Binding.h ('k') | Source/core/dom/MessagePort.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698