Skip to content
Permalink
Browse files
SerializedScriptValue::deserialize() should take ports as a const Vec…
…tor&

https://bugs.webkit.org/show_bug.cgi?id=178727

Reviewed by Alex Christensen.

SerializedScriptValue::deserialize() should take ports as a const Vector&, not a Vector&.
It does not modify the input vector.

* bindings/js/JSMessageEventCustom.cpp:
(WebCore::JSMessageEvent::data const):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneDeserializer::deserialize):
(WebCore::CloneDeserializer::CloneDeserializer):
(WebCore::SerializedScriptValue::deserialize):
* bindings/js/SerializedScriptValue.h:


Canonical link: https://commits.webkit.org/194901@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223905 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Oct 24, 2017
1 parent 7432b6d commit 4d08e2acf0ad819ef265eeb910aecfd57e27ebe7
Showing 4 changed files with 28 additions and 12 deletions.
@@ -1,3 +1,21 @@
2017-10-24 Chris Dumez <cdumez@apple.com>

SerializedScriptValue::deserialize() should take ports as a const Vector&
https://bugs.webkit.org/show_bug.cgi?id=178727

Reviewed by Alex Christensen.

SerializedScriptValue::deserialize() should take ports as a const Vector&, not a Vector&.
It does not modify the input vector.

* bindings/js/JSMessageEventCustom.cpp:
(WebCore::JSMessageEvent::data const):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneDeserializer::deserialize):
(WebCore::CloneDeserializer::CloneDeserializer):
(WebCore::SerializedScriptValue::deserialize):
* bindings/js/SerializedScriptValue.h:

2017-10-24 Konstantin Tokarev <annulen@yandex.ru>

[MediaFoundation] Videos are always autoplaying for local files
@@ -79,9 +79,8 @@ JSValue JSMessageEvent::data(ExecState& state) const

case MessageEvent::DataTypeSerializedScriptValue:
if (RefPtr<SerializedScriptValue> serializedValue = event.dataAsSerializedScriptValue()) {
Vector<RefPtr<MessagePort>> ports = wrapped().ports();
// FIXME: Why does this suppress exceptions?
result = serializedValue->deserialize(state, globalObject(), ports, SerializationErrorMode::NonThrowing);
result = serializedValue->deserialize(state, globalObject(), wrapped().ports(), SerializationErrorMode::NonThrowing);
} else
result = jsNull();
break;
@@ -1716,7 +1716,7 @@ class CloneDeserializer : CloneBase {
return str;
}

static DeserializationResult deserialize(ExecState* exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContentsArray, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths, ArrayBufferContentsArray* sharedBuffers
static DeserializationResult deserialize(ExecState* exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContentsArray, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths, ArrayBufferContentsArray* sharedBuffers
#if ENABLE(WEBASSEMBLY)
, WasmModuleArray* wasmModules
#endif
@@ -1773,7 +1773,7 @@ class CloneDeserializer : CloneBase {
size_t m_index;
};

CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents,
CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents,
#if ENABLE(WEBASSEMBLY)
WasmModuleArray* wasmModules,
#endif
@@ -1795,7 +1795,7 @@ class CloneDeserializer : CloneBase {
m_version = 0xFFFFFFFF;
}

CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths, ArrayBufferContentsArray* sharedBuffers
CloneDeserializer(ExecState* exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, ArrayBufferContentsArray* arrayBufferContents, const Vector<uint8_t>& buffer, const Vector<String>& blobURLs, const Vector<String> blobFilePaths, ArrayBufferContentsArray* sharedBuffers
#if ENABLE(WEBASSEMBLY)
, WasmModuleArray* wasmModules
#endif
@@ -2935,7 +2935,7 @@ class CloneDeserializer : CloneBase {
const uint8_t* m_end;
unsigned m_version;
Vector<CachedString> m_constantPool;
Vector<RefPtr<MessagePort>>& m_messagePorts;
const Vector<RefPtr<MessagePort>>& m_messagePorts;
ArrayBufferContentsArray* m_arrayBufferContents;
Vector<RefPtr<JSC::ArrayBuffer>> m_arrayBuffers;
Vector<String> m_blobURLs;
@@ -3358,18 +3358,17 @@ String SerializedScriptValue::toString()

JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, SerializationErrorMode throwExceptions)
{
Vector<RefPtr<MessagePort>> dummyMessagePorts;
return deserialize(exec, globalObject, dummyMessagePorts, throwExceptions);
return deserialize(exec, globalObject, { }, throwExceptions);
}

JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, SerializationErrorMode throwExceptions)
JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, SerializationErrorMode throwExceptions)
{
Vector<String> dummyBlobs;
Vector<String> dummyPaths;
return deserialize(exec, globalObject, messagePorts, dummyBlobs, dummyPaths, throwExceptions);
}

JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, Vector<RefPtr<MessagePort>>& messagePorts, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode throwExceptions)
JSValue SerializedScriptValue::deserialize(ExecState& exec, JSGlobalObject* globalObject, const Vector<RefPtr<MessagePort>>& messagePorts, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode throwExceptions)
{
DeserializationResult result = CloneDeserializer::deserialize(&exec, globalObject, messagePorts, m_arrayBufferContentsArray.get(), m_data, blobURLs, blobFilePaths, m_sharedBufferContentsArray.get()
#if ENABLE(WEBASSEMBLY)
@@ -73,8 +73,8 @@ class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue>
static Ref<SerializedScriptValue> nullValue();

WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, SerializationErrorMode = SerializationErrorMode::Throwing);
WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, Vector<RefPtr<MessagePort>>&, SerializationErrorMode = SerializationErrorMode::Throwing);
JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, Vector<RefPtr<MessagePort>>&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode = SerializationErrorMode::Throwing);
WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, const Vector<RefPtr<MessagePort>>&, SerializationErrorMode = SerializationErrorMode::Throwing);
JSC::JSValue deserialize(JSC::ExecState&, JSC::JSGlobalObject*, const Vector<RefPtr<MessagePort>>&, const Vector<String>& blobURLs, const Vector<String>& blobFilePaths, SerializationErrorMode = SerializationErrorMode::Throwing);

static uint32_t wireFormatVersion();

0 comments on commit 4d08e2a

Please sign in to comment.