script: Re-implement evaluate_key_path_on_value in IndexedDB (#38847)

The current implementation of evaluate_key_path_on_value was translated
from gecko, and it is incomplete. The unimplemented part occurs many
crashes in WPT tests.

This PR re-implements it according to the spec. It should eliminate many
crashed WPT tests, and increase the code readability.

Testing: Update WPT test expectation
Fixes: #38817 partially, and #25325

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This commit is contained in:
Kingsley Yung 2025-09-05 16:00:07 +08:00 committed by GitHub
parent ebc1282c7a
commit b29eab0ffe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 694 additions and 178 deletions

View file

@ -29,8 +29,9 @@ use crate::dom::domstringlist::DOMStringList;
use crate::dom::globalscope::GlobalScope;
use crate::dom::idbrequest::IDBRequest;
use crate::dom::idbtransaction::IDBTransaction;
use crate::indexed_db;
use crate::indexed_db::{convert_value_to_key, convert_value_to_key_range, extract_key};
use crate::indexed_db::{
self, ExtractionResult, convert_value_to_key, convert_value_to_key_range, extract_key,
};
use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
#[derive(JSTraceable, MallocSizeOf)]
@ -242,7 +243,7 @@ impl IDBObjectStore {
serialized_key = Some(convert_value_to_key(cx, key, None)?);
} else {
// Step 11: We should use in-line keys instead
if let Some(Ok(kpk)) = self
if let Some(Ok(ExtractionResult::Key(kpk))) = self
.key_path
.as_ref()
.map(|p| extract_key(cx, value, p, None))