mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-09 02:21:53 +00:00
LibWeb/IDB: Update convert_a_value_to_a_key to latest changes
This commit is contained in:
parent
ad4ade3f07
commit
a0b252c0dd
Notes:
github-actions[bot]
2025-03-13 10:24:16 +00:00
Author: https://github.com/stelar7
Commit: a0b252c0dd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3746
Reviewed-by: https://github.com/gmta ✅
3 changed files with 35 additions and 2 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <LibWeb/IndexedDB/Internal/Database.h>
|
||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
|
||||
|
@ -213,10 +214,14 @@ ErrorOr<GC::Ref<Key>> convert_a_value_to_a_key(JS::Realm& realm, JS::Value input
|
|||
// - If input is a buffer source type
|
||||
if (input.is_object() && (is<JS::TypedArrayBase>(input.as_object()) || is<JS::ArrayBuffer>(input.as_object()) || is<JS::DataView>(input.as_object()))) {
|
||||
|
||||
// 1. Let bytes be the result of getting a copy of the bytes held by the buffer source input. Rethrow any exceptions.
|
||||
// 1. If input is [detached] then return invalid.
|
||||
if (WebIDL::is_buffer_source_detached(input))
|
||||
return Error::from_string_literal("Detached buffer is not supported as key");
|
||||
|
||||
// 2. Let bytes be the result of getting a copy of the bytes held by the buffer source input.
|
||||
auto data_buffer = TRY(WebIDL::get_buffer_source_copy(input.as_object()));
|
||||
|
||||
// 2. Return a new key with type binary and value bytes.
|
||||
// 3. Return a new key with type binary and value bytes.
|
||||
return Key::create_binary(realm, data_buffer);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue