Commit Graph

16 Commits

Author SHA1 Message Date
Tim Ledbetter
504a8e6d1d Tests: Resync imported WPT tests 2026-04-04 23:36:58 +02:00
Zaggy1024
ef845fe22a LibWeb: Don't count unversioned databases in IDBFactory::databases()
This code was treating the parameter to the JS::Array as if it was a
capacity, but that causes JS to see more databases than are actually
accessible if a database was being created in an aborted transaction.
2026-03-20 23:59:35 -05:00
Zaggy1024
547d4eb1f5 LibWeb: Implement IndexedDB request/transaction reverts
To allow these to be reverted, we store mutation logs per object store
in the scope of a readwrite transaction to track the modifications that
were made by it. If a revert is needed, the log is played in reverse to
bring us back to the original state.
2026-03-20 23:59:35 -05:00
Zaggy1024
5eeac1b9dd LibWeb: Fire the "blocked" event at the IDB open request
...rather than at each of the open connections. These disagreed with the
spec steps written right above them.

The transaction-lifetime.any.html and idbdatabase_close.any.html tests
pass instead of timing out with these changes, so they've been imported.
2026-03-05 17:12:55 -06:00
Zaggy1024
e8c1c2246e LibWeb: Autocommit IDB transactions with no requests during cleanup
If the current JS task has not made any requests, then nothing else
will trigger a commit like the spec desires, so we need to do it in the
microtask checkpoint.

Two WPT tests no longer time out with this change and have been
imported.
2026-03-05 17:12:55 -06:00
Zaggy1024
3c24a394c6 LibWeb: Refactor IndexedDB to handle requests serially
Previously, after one request was marked as processed, we would
synchronously queue another task to process the next request. This
would mean that two open requests on the same database could
interleave. This was especially problematic when one of the requests
would cause the database to upgrade, since the second open request
would begin processing before the upgradeneeded event fired, causing an
exception to be thrown in the second open().

The solution is to explicitly check for continuation conditions after
events have been fired in order to ensure that every step for the
request is completed before starting any further request processing.

For connection requests, the spec states:

> Open requests are processed in a connection queue. The queue contains
> all open requests associated with an storage key and a name. Requests
> added to the connection queue processed in order and each request
> must run to completion before the next request is processed. An open
> request may be blocked on other connections, requiring those
> connections to close before the request can complete and allow
> further requests to be processed.

For requests against a transaction, the spec states:

> Once the transaction has been started the implementation can begin
> executing the requests placed against the transaction. Requests must
> be executed in the order in which they were made against the
> transaction. Likewise, their results must be returned in the order
> the requests were placed against a specific transaction. There is no
> guarantee about the order that results from requests in different
> transactions are returned.

In the process of reworking it to use this approach, I've added a bunch
of new tests that cover things that our imported WPTs weren't checking.

With the fix for serializing connection requests, we can now fully
download the assets for the emscripten-compiled asm.js games in the
Humble Mozilla Bundle, particularly FTL: Faster Than Light.

There were no regressions in our test suite. One web platform test,
'idbindex_reverse_cursor.any.html', has one newly-failing subtest, but
the subtest was apparently only passing by chance due synchronous
execution of requests. A few web platform tests that were added in a
prior commit improved. The delete-request-queue.any.html test has
stopped crashing, and the close-in-upgrade-needed.any.html test has
stopped flaking, so they are both imported here as well.

Incidentally fixes #7512, for which a crash test has been added.
2026-03-05 17:12:55 -06:00
Zaggy1024
6a9ee92ec1 Tests: Add some more IndexedDB tests from WPT 2026-03-05 17:12:55 -06:00
Tim Ledbetter
84043cd82d LibWeb: Track deleted state on IndexedDb Index and ObjectStore
An `InvalidStateError` is now thrown when an attempt is made to
interact with an index or object store that has been deleted.
2026-02-24 17:37:04 +01:00
stelar7
684c543ddb LibWeb/IDB: Handle cursor iteration more correctly 2025-11-13 08:52:16 -05:00
stelar7
964c0ddde9 LibWeb/IDB: Import getAllRecords test 2025-10-28 19:25:26 -04:00
Luke Wilde
85e8d2ba38 LibWeb/IndexedDB: Prevent copying and moving of RequestList
RequestList cannot be copied or moved, because m_pending_request_queue
contains lambdas that store pointers to the original RequestList and
completion steps that we don't have a reference to.

Fixes a bunch of WPT regressions and imports the ones that work.
2025-10-23 14:42:45 +02:00
stelar7
9e66f49b44 LibWeb/Tests: Update IDB keyorder test file 2025-08-14 09:31:56 +01:00
Tim Ledbetter
689dff3ee8 Tests: Synchronize imported tests with the WPT repository 2025-06-22 23:51:34 +02:00
stelar7
439245b14a LibWeb: Import WPT tests for IDBKeyRange 2025-01-14 23:46:09 +01:00
stelar7
74828bbd10 LibWeb: Import WPT for idbfactory.open 2024-11-26 14:50:27 +01:00
stelar7
331f26a88b LibWeb: Implement IDBFactory::cmp 2024-11-25 11:53:50 +01:00