1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 18:05:07 +00:00

LibWeb: Throw more specific serialization errors for some object types

This commit is contained in:
Idan Horowitz 2023-11-11 01:23:09 +02:00 committed by Andreas Kling
parent 1d24e08934
commit 4e89ec7fd5

View file

@ -264,7 +264,21 @@ public:
TRY(serialize_string(m_serialized, *message));
}
// 15, 16, 18 - 24: FIXME: Serialize other data types
// 20. Otherwise, if value is a platform object, then throw a "DataCloneError" DOMException.
else if (value.is_object() && is<Bindings::PlatformObject>(value.as_object())) {
return throw_completion(WebIDL::DataCloneError::create(*m_vm.current_realm(), "Cannot serialize platform objects"_fly_string));
}
// 21. Otherwise, if IsCallable(value) is true, then throw a "DataCloneError" DOMException.
else if (value.is_function()) {
return throw_completion(WebIDL::DataCloneError::create(*m_vm.current_realm(), "Cannot serialize functions"_fly_string));
}
// FIXME: 22. Otherwise, if value has any internal slot other than [[Prototype]] or [[Extensible]], then throw a "DataCloneError" DOMException.
// FIXME: 23. Otherwise, if value is an exotic object and value is not the %Object.prototype% intrinsic object associated with any realm, then throw a "DataCloneError" DOMException.
// 15, 16, 18, 19, 24: FIXME: Serialize other data types
else {
return throw_completion(WebIDL::DataCloneError::create(*m_vm.current_realm(), "Unsupported type"_fly_string));
}