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

@ -1,13 +1,11 @@
[create-index.any.html]
expected: CRASH
[Assure no crash when populating index]
expected: TIMEOUT
expected: FAIL
[create-index.any.worker.html]
expected: TIMEOUT
[Assure no crash when populating index]
expected: TIMEOUT
expected: FAIL
[create-index.any.serviceworker.html]

View file

@ -1,8 +1,18 @@
[idbdatabase_deleteObjectStore.any.worker.html]
expected: CRASH
[Deleted object store's name should be removed from database's list. Attempting to use a deleted IDBObjectStore should throw an InvalidStateError]
expected: FAIL
[Attempting to access an index that was deleted as part of object store deletion and then recreated using the same object store name should throw a NotFoundError]
expected: FAIL
[idbdatabase_deleteObjectStore.any.html]
expected: CRASH
[Deleted object store's name should be removed from database's list. Attempting to use a deleted IDBObjectStore should throw an InvalidStateError]
expected: FAIL
[Attempting to access an index that was deleted as part of object store deletion and then recreated using the same object store name should throw a NotFoundError]
expected: FAIL
[idbdatabase_deleteObjectStore.any.serviceworker.html]
expected: ERROR

View file

@ -2,10 +2,37 @@
expected: ERROR
[idbobjectstore_add.any.worker.html]
expected: CRASH
[add() where an index has unique:true specified]
expected: FAIL
[add() autoIncrement and inline keys]
expected: FAIL
[add() autoIncrement and out-of-line keys]
expected: FAIL
[Object store has autoIncrement:true and the key path is an object attribute]
expected: FAIL
[add() a record where a value being indexed does not meet the constraints of a valid key]
expected: FAIL
[idbobjectstore_add.any.serviceworker.html]
expected: ERROR
[idbobjectstore_add.any.html]
expected: CRASH
[add() where an index has unique:true specified]
expected: FAIL
[add() autoIncrement and inline keys]
expected: FAIL
[add() autoIncrement and out-of-line keys]
expected: FAIL
[Object store has autoIncrement:true and the key path is an object attribute]
expected: FAIL
[add() a record where a value being indexed does not meet the constraints of a valid key]
expected: FAIL

View file

@ -1,5 +1,4 @@
[idbobjectstore_getAll-options.tentative.any.worker.html]
expected: CRASH
[Single item get]
expected: FAIL
@ -80,7 +79,6 @@
expected: ERROR
[idbobjectstore_getAll-options.tentative.any.html]
expected: CRASH
[Single item get]
expected: FAIL

View file

@ -1,5 +1,4 @@
[idbobjectstore_getAll.any.html]
expected: CRASH
[Single item get]
expected: FAIL
@ -59,7 +58,6 @@
expected: ERROR
[idbobjectstore_getAll.any.worker.html]
expected: CRASH
[Single item get]
expected: FAIL

View file

@ -1,5 +1,4 @@
[idbobjectstore_getAllKeys-options.tentative.any.worker.html]
expected: CRASH
[Single item get]
expected: FAIL
@ -74,7 +73,6 @@
expected: ERROR
[idbobjectstore_getAllKeys-options.tentative.any.html]
expected: CRASH
[Single item get]
expected: FAIL

View file

@ -5,7 +5,6 @@
expected: ERROR
[idbobjectstore_getAllKeys.any.worker.html]
expected: CRASH
[Single item get]
expected: FAIL
@ -56,7 +55,6 @@
[idbobjectstore_getAllKeys.any.html]
expected: CRASH
[Single item get]
expected: FAIL

View file

@ -1,5 +1,4 @@
[idbobjectstore_getAllRecords.tentative.any.worker.html]
expected: CRASH
[Single item]
expected: FAIL
@ -77,7 +76,6 @@
[idbobjectstore_getAllRecords.tentative.any.html]
expected: CRASH
[Single item]
expected: FAIL

View file

@ -2,10 +2,43 @@
expected: ERROR
[idbobjectstore_put.any.worker.html]
expected: CRASH
[put() record with key already exists]
expected: FAIL
[put() where an index has unique:true specified]
expected: FAIL
[autoIncrement and inline keys]
expected: FAIL
[autoIncrement and out-of-line keys]
expected: FAIL
[Object store has autoIncrement:true and the key path is an object attribute]
expected: FAIL
[put() a record where a value being indexed does not meet the constraints of a valid key]
expected: FAIL
[idbobjectstore_put.any.serviceworker.html]
expected: ERROR
[idbobjectstore_put.any.html]
expected: CRASH
[put() record with key already exists]
expected: FAIL
[put() where an index has unique:true specified]
expected: FAIL
[autoIncrement and inline keys]
expected: FAIL
[autoIncrement and out-of-line keys]
expected: FAIL
[Object store has autoIncrement:true and the key path is an object attribute]
expected: FAIL
[put() a record where a value being indexed does not meet the constraints of a valid key]
expected: FAIL

View file

@ -1,11 +1,117 @@
[key_valid.any.worker.html]
expected: CRASH
[Valid key - new Date()]
expected: FAIL
[Valid key - new Date(0)]
expected: FAIL
[Valid key - [\]]
expected: FAIL
[Valid key - new Array()]
expected: FAIL
[Valid key - ["undefined"\]]
expected: FAIL
[Valid key - Infinity]
expected: FAIL
[Valid key - -Infinity]
expected: FAIL
[Valid key - 0]
expected: FAIL
[Valid key - 1.5]
expected: FAIL
[Valid key - 3e38]
expected: FAIL
[Valid key - 3e-38]
expected: FAIL
[Valid key - "foo"]
expected: FAIL
[Valid key - "\\n"]
expected: FAIL
[Valid key - ""]
expected: FAIL
[Valid key - "\\""]
expected: FAIL
[Valid key - "\\u1234"]
expected: FAIL
[Valid key - "\\u0000"]
expected: FAIL
[Valid key - "NaN"]
expected: FAIL
[key_valid.any.serviceworker.html]
expected: ERROR
[key_valid.any.html]
expected: CRASH
[Valid key - new Date()]
expected: FAIL
[Valid key - new Date(0)]
expected: FAIL
[Valid key - [\]]
expected: FAIL
[Valid key - new Array()]
expected: FAIL
[Valid key - ["undefined"\]]
expected: FAIL
[Valid key - Infinity]
expected: FAIL
[Valid key - -Infinity]
expected: FAIL
[Valid key - 0]
expected: FAIL
[Valid key - 1.5]
expected: FAIL
[Valid key - 3e38]
expected: FAIL
[Valid key - 3e-38]
expected: FAIL
[Valid key - "foo"]
expected: FAIL
[Valid key - "\\n"]
expected: FAIL
[Valid key - ""]
expected: FAIL
[Valid key - "\\""]
expected: FAIL
[Valid key - "\\u1234"]
expected: FAIL
[Valid key - "\\u0000"]
expected: FAIL
[Valid key - "NaN"]
expected: FAIL
[key_valid.any.sharedworker.html]
expected: ERROR

View file

@ -1,5 +1,67 @@
[keygenerator.any.html]
expected: CRASH
[Keygenerator - starts at one, and increments by one]
expected: FAIL
[Keygenerator - increments by one from last set key]
expected: FAIL
[Keygenerator - don't increment when new key is not bigger than current]
expected: FAIL
[Keygenerator ConstraintError when using same id as already generated]
expected: FAIL
[Key generator vs. explicit key 53 bits]
expected: FAIL
[Key generator vs. explicit key greater than 53 bits, less than 64 bits]
expected: FAIL
[Key generator vs. explicit key greater than 53 bits, less than 64 bits (negative)]
expected: FAIL
[Key generator vs. explicit key 63 bits]
expected: FAIL
[Key generator vs. explicit key 63 bits (negative)]
expected: FAIL
[Key generator vs. explicit key 64 bits]
expected: FAIL
[Key generator vs. explicit key 64 bits (negative)]
expected: FAIL
[Key generator vs. explicit key greater than 64 bits, but still finite]
expected: FAIL
[Key generator vs. explicit key greater than 64 bits, but still finite (negative)]
expected: FAIL
[Key generator vs. explicit key equal to Infinity]
expected: FAIL
[Key generator vs. explicit key equal to -Infinity]
expected: FAIL
[Key is injected into value - single segment path]
expected: FAIL
[Key is injected into value - multi-segment path]
expected: FAIL
[Key is injected into value - multi-segment path, partially populated]
expected: FAIL
[Keygenerator overflow]
expected: FAIL
[put() throws if key cannot be injected - single segment path]
expected: FAIL
[put() throws if key cannot be injected - multi-segment path]
expected: FAIL
[keygenerator.any.serviceworker.html]
expected: ERROR
@ -8,4 +70,65 @@
expected: ERROR
[keygenerator.any.worker.html]
expected: CRASH
[Keygenerator - starts at one, and increments by one]
expected: FAIL
[Keygenerator - increments by one from last set key]
expected: FAIL
[Keygenerator - don't increment when new key is not bigger than current]
expected: FAIL
[Keygenerator ConstraintError when using same id as already generated]
expected: FAIL
[Key generator vs. explicit key 53 bits]
expected: FAIL
[Key generator vs. explicit key greater than 53 bits, less than 64 bits]
expected: FAIL
[Key generator vs. explicit key greater than 53 bits, less than 64 bits (negative)]
expected: FAIL
[Key generator vs. explicit key 63 bits]
expected: FAIL
[Key generator vs. explicit key 63 bits (negative)]
expected: FAIL
[Key generator vs. explicit key 64 bits]
expected: FAIL
[Key generator vs. explicit key 64 bits (negative)]
expected: FAIL
[Key generator vs. explicit key greater than 64 bits, but still finite]
expected: FAIL
[Key generator vs. explicit key greater than 64 bits, but still finite (negative)]
expected: FAIL
[Key generator vs. explicit key equal to Infinity]
expected: FAIL
[Key generator vs. explicit key equal to -Infinity]
expected: FAIL
[Key is injected into value - single segment path]
expected: FAIL
[Key is injected into value - multi-segment path]
expected: FAIL
[Key is injected into value - multi-segment path, partially populated]
expected: FAIL
[Keygenerator overflow]
expected: FAIL
[put() throws if key cannot be injected - single segment path]
expected: FAIL
[put() throws if key cannot be injected - multi-segment path]
expected: FAIL

View file

@ -1,11 +1,129 @@
[keypath.any.worker.html]
expected: CRASH
[undefined - my.key]
expected: FAIL
[undefined - my.køi]
expected: FAIL
[undefined - my.key_ya]
expected: FAIL
[undefined - public.key$ya]
expected: FAIL
[undefined - true.$]
expected: FAIL
[undefined - my._]
expected: FAIL
[undefined - delete.a7]
expected: FAIL
[undefined - p.p.p.p.p.p.p.p.p.p.p.p.p.p]
expected: FAIL
[undefined - str.length]
expected: FAIL
[undefined - arr.length]
expected: FAIL
[undefined - length]
expected: FAIL
[undefined - '' uses value as key]
expected: FAIL
[undefined - [''\] uses value as [key\]]
expected: FAIL
[undefined - ['x', 'y'\]]
expected: FAIL
[undefined - [['x'\], 'y'\] (stringifies)]
expected: FAIL
[undefined - ['x', {toString->'y'}\] (stringifies)]
expected: FAIL
[undefined - name,type]
expected: FAIL
[undefined - name,type.name]
expected: FAIL
[undefined - list with 1 field]
expected: FAIL
[undefined - array loop -> stringify becomes [''\]]
expected: FAIL
[keypath.any.serviceworker.html]
expected: ERROR
[keypath.any.html]
expected: CRASH
[undefined - my.key]
expected: FAIL
[undefined - my.køi]
expected: FAIL
[undefined - my.key_ya]
expected: FAIL
[undefined - public.key$ya]
expected: FAIL
[undefined - true.$]
expected: FAIL
[undefined - my._]
expected: FAIL
[undefined - delete.a7]
expected: FAIL
[undefined - p.p.p.p.p.p.p.p.p.p.p.p.p.p]
expected: FAIL
[undefined - str.length]
expected: FAIL
[undefined - arr.length]
expected: FAIL
[undefined - length]
expected: FAIL
[undefined - '' uses value as key]
expected: FAIL
[undefined - [''\] uses value as [key\]]
expected: FAIL
[undefined - ['x', 'y'\]]
expected: FAIL
[undefined - [['x'\], 'y'\] (stringifies)]
expected: FAIL
[undefined - ['x', {toString->'y'}\] (stringifies)]
expected: FAIL
[undefined - name,type]
expected: FAIL
[undefined - name,type.name]
expected: FAIL
[undefined - list with 1 field]
expected: FAIL
[undefined - array loop -> stringify becomes [''\]]
expected: FAIL
[keypath.any.sharedworker.html]
expected: ERROR

View file

@ -5,7 +5,6 @@
expected: ERROR
[nested-cloning-large-multiple.any.html]
expected: CRASH
[multiple requests of objects with blobs and large typed arrays]
expected: FAIL
@ -14,7 +13,6 @@
[nested-cloning-large-multiple.any.worker.html]
expected: CRASH
[multiple requests of objects with blobs and large typed arrays]
expected: FAIL

View file

@ -1,5 +1,4 @@
[nested-cloning-large.any.html]
expected: CRASH
[large typed array]
expected: FAIL
@ -26,7 +25,6 @@
expected: ERROR
[nested-cloning-large.any.worker.html]
expected: CRASH
[large typed array]
expected: FAIL

View file

@ -1,5 +1,4 @@
[nested-cloning-small.any.html]
expected: CRASH
[blob with small typed array]
expected: FAIL
@ -26,7 +25,6 @@
expected: ERROR
[nested-cloning-small.any.worker.html]
expected: CRASH
[blob with small typed array]
expected: FAIL

View file

@ -16,9 +16,6 @@
[Deactivation of new transactions happens at end of invocation]
expected: FAIL
[New transactions from microtask are deactivated before next task]
expected: FAIL
[transaction-deactivation-timing.any.sharedworker.html]
expected: ERROR

View file

@ -2,10 +2,14 @@
expected: ERROR
[transaction-requestqueue.any.worker.html]
expected: CRASH
[Transactions have a request queue]
expected: FAIL
[transaction-requestqueue.any.html]
expected: CRASH
[Transactions have a request queue]
expected: FAIL
[transaction-requestqueue.any.sharedworker.html]
expected: ERROR