mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 01:42:17 +00: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:
parent
b1cfc96609
commit
20c6005341
Notes:
github-actions[bot]
2025-07-18 14:10:56 +00:00
Author: https://github.com/trflynn89
Commit: 20c6005341
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5492
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/shannonbooth
1 changed files with 3 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue