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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp

Issue 2316763002: Implement v8::ValueSerializer::Delegate to throw DOMException for DataCloneError. (Closed)
Patch Set: Created 4 years, 3 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
Index: third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
index e9cc6004379947a93fbd686d9120d4e16139dae5..5716f52574e7bf45dfbfb1f237c651cefa5f744d 100644
--- a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
@@ -7,13 +7,14 @@
#include "bindings/core/v8/ToV8.h"
#include "core/dom/DOMArrayBufferBase.h"
#include "platform/RuntimeEnabledFeatures.h"
+#include "wtf/AutoReset.h"
namespace blink {
V8ScriptValueSerializer::V8ScriptValueSerializer(RefPtr<ScriptState> scriptState)
: m_scriptState(std::move(scriptState))
, m_serializedScriptValue(SerializedScriptValue::create())
- , m_serializer(m_scriptState->isolate())
+ , m_serializer(m_scriptState->isolate(), this)
{
DCHECK(RuntimeEnabledFeatures::v8BasedStructuredCloneEnabled());
}
@@ -25,6 +26,7 @@ RefPtr<SerializedScriptValue> V8ScriptValueSerializer::serialize(v8::Local<v8::V
m_serializeInvoked = true;
#endif
DCHECK(m_serializedScriptValue);
+ AutoReset<ExceptionState*> reset(&m_exceptionState, &exceptionState);
ScriptState::Scope scope(m_scriptState.get());
// Prepare to transfer the provided transferables.
@@ -85,4 +87,13 @@ void V8ScriptValueSerializer::transfer(Transferables* transferables, ExceptionSt
}
}
+void V8ScriptValueSerializer::ThrowDataCloneError(v8::Local<v8::String> v8Message)
+{
+ DCHECK(m_exceptionState);
+ String message = v8StringToWebCoreString<String>(v8Message, DoNotExternalize);
+ m_exceptionState->throwDOMException(DataCloneError, message);
+ V8ThrowException::throwException(m_scriptState->isolate(), m_exceptionState->getException());
+ m_exceptionState->clearException();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698