mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-03-09 21:47:00 -04:00
Throw DataCloneError if SAB cannot be cloned (#781)
Best case, it produces serialized output that cannot be deserialized. Worst case, it hits this assert in V8: # Fatal error in v8::FromJust # Maybe value is Nothing.
This commit is contained in:
parent
0bdeb0c5c4
commit
09347d32c8
2 changed files with 11 additions and 4 deletions
|
@ -2551,8 +2551,11 @@ struct v8__ValueSerializer__Delegate : public v8::ValueSerializer::Delegate {
|
||||||
v8::Local<v8::SharedArrayBuffer> shared_array_buffer) override {
|
v8::Local<v8::SharedArrayBuffer> shared_array_buffer) override {
|
||||||
uint32_t result = 0;
|
uint32_t result = 0;
|
||||||
if (!v8__ValueSerializer__Delegate__GetSharedArrayBufferId(
|
if (!v8__ValueSerializer__Delegate__GetSharedArrayBufferId(
|
||||||
this, isolate, shared_array_buffer, &result))
|
this, isolate, shared_array_buffer, &result)) {
|
||||||
return v8::Nothing<uint32_t>();
|
// Forward to the original method. It'll throw DataCloneError.
|
||||||
|
return v8::ValueSerializer::Delegate::GetSharedArrayBufferId(
|
||||||
|
isolate, shared_array_buffer);
|
||||||
|
}
|
||||||
return v8::Just(result);
|
return v8::Just(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4723,8 +4723,12 @@ fn value_serializer_not_implemented() {
|
||||||
assert!(scope.stack_trace().is_some());
|
assert!(scope.stack_trace().is_some());
|
||||||
assert!(scope.message().is_some());
|
assert!(scope.message().is_some());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scope.message().unwrap().get(scope).to_rust_string_lossy(scope),
|
scope
|
||||||
"Uncaught Error: Deno serializer: get_shared_array_buffer_id not implemented"
|
.message()
|
||||||
|
.unwrap()
|
||||||
|
.get(scope)
|
||||||
|
.to_rust_string_lossy(scope),
|
||||||
|
"Uncaught Error: #<SharedArrayBuffer> could not be cloned."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue