mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Use TemporaryExecutionContext in structured deserialization
No need to manually prepare / clean up a context. We also previously would not have done the clean up steps if structured deserialization threw an exception.
This commit is contained in:
Notes:
github-actions[bot]
2025-07-18 14:10:56 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/20c60053411 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5492 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/shannonbooth
@@ -64,6 +64,7 @@
|
||||
#include <LibWeb/HTML/ImageBitmap.h>
|
||||
#include <LibWeb/HTML/ImageData.h>
|
||||
#include <LibWeb/HTML/MessagePort.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/StructuredSerialize.h>
|
||||
#include <LibWeb/Streams/ReadableStream.h>
|
||||
#include <LibWeb/Streams/TransformStream.h>
|
||||
@@ -1507,15 +1508,12 @@ WebIDL::ExceptionOr<SerializationRecord> structured_serialize_internal(JS::VM& v
|
||||
// https://html.spec.whatwg.org/multipage/structured-data.html#structureddeserialize
|
||||
WebIDL::ExceptionOr<JS::Value> structured_deserialize(JS::VM& vm, SerializationRecord const& serialized, JS::Realm& target_realm, Optional<DeserializationMemory> memory)
|
||||
{
|
||||
TemporaryExecutionContext execution_context { target_realm };
|
||||
|
||||
if (!memory.has_value())
|
||||
memory = DeserializationMemory { vm.heap() };
|
||||
|
||||
// IMPLEMENTATION DEFINED: We need to make sure there's an execution context for target_realm on the stack before constructing these JS objects
|
||||
prepare_to_run_script(target_realm);
|
||||
|
||||
auto result = TRY(structured_deserialize_internal(vm, serialized.span(), target_realm, *memory));
|
||||
|
||||
clean_up_after_running_script(target_realm);
|
||||
VERIFY(result.value.has_value());
|
||||
return *result.value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user