Commit 6e2c9bb2 authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[serialize] copy bytes for non detachable array_buffer

in WriteJSArrayBuffer when array_buffer is not in
array_buffer_transfer_map_

According to https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal
steps 13.3.2-4, should normally serialize array buffer which
is not detachable

Bug: v8:12703
Change-Id: I4554c5d07ae85e1a96a728ebba04c6a071575f6f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3518910Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79466}
parent e35a3a77
......@@ -5003,7 +5003,8 @@ class Serializer : public ValueSerializer::Delegate {
Local<ArrayBuffer> array_buffer =
Local<ArrayBuffer>::New(isolate_, global_array_buffer);
if (!array_buffer->IsDetachable()) {
isolate_->ThrowError("ArrayBuffer could not be transferred");
isolate_->ThrowError(
"ArrayBuffer is not detachable and could not be transferred");
return Nothing<bool>();
}
......
......@@ -907,10 +907,6 @@ Maybe<bool> ValueSerializer::WriteJSArrayBuffer(
WriteVarint(index.FromJust());
return ThrowIfOutOfMemory();
}
if (!array_buffer->is_detachable()) {
return ThrowDataCloneError(
MessageTemplate::kDataCloneErrorNonDetachableArrayBuffer);
}
uint32_t* transfer_entry = array_buffer_transfer_map_.Find(array_buffer);
if (transfer_entry) {
......
......@@ -15,7 +15,13 @@
let worker = new Worker('', {type: 'string'});
let memory = new WebAssembly.Memory({initial: 1, maximum: 2});
assertThrows(() => worker.postMessage(memory.buffer), Error);
worker.postMessage(memory.buffer);
assertThrows(() => {
worker.postMessage(memory.buffer, [memory.buffer])
}, Error)
assertThrows(() => {
worker.postMessage(undefined, [memory.buffer])
}, Error)
})();
// Can't use assert in a worker.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment