Commit Graph

29 Commits

Author SHA1 Message Date
Taym Haddadi
cfc4920815 indexeddb: implement "inject a key into a value using a key path with value" (#42727)
implement "inject a key into a value using a key path with value"
following he spec:

https://w3c.github.io/IndexedDB/#inject-a-key-into-a-value-using-a-key-path
 

Testing: More indexeddb tests should pass.
part of https://github.com/servo/servo/issues/40983

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2026-03-02 23:16:29 +00:00
Jonathan Schwender
37dfa42731 Unify servo package naming (#42916)
This is a preparation for publishing to crates.io. Changes include:
- Add `servo-` prefixes to avoid name collisions on crates.io
- Use `-` instead of `_` in package names.
- Rename the crates to their original names in Cargo.toml,
  to keep the diff minimal
- Rename `media` to `servo-media-thread` to avoid name collision with
  `servo-media` (originally from the media repository).

This is an outcome of the previous discussion at [#general > Switch
remaining git dependencies to
crates.io](https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Switch.20remaining.20git.20dependencies.20to.20crates.2Eio/with/576336288)

Testing: This should be mostly covered by our CI, but some amount of
breakage is to be expected, since some package names could still be
referenced from scripts which are not tested or run in CI. [mach try
run](https://github.com/jschwe/servo/actions/runs/22502945949)

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2026-03-01 14:15:27 +00:00
Taym Haddadi
a7b675399c indexeddb: Add processed flag, rename close to close_pending and update spec links to version 3 of the spec (#42859)
This changes does three things:
- Updates all specification links to reflect version 3 of the
specification
- Renames the `IDBDatabase::close` member to
`IDBDatabase::close_pending` to better match the specification
- Adds a `OpenRequest::processed` member, again to better match the
specification

Testing: This should not change behavior, so is covered by existing
IndexedDB WPT tests.
Fixes: Part of #40983

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-02-26 08:41:41 +00:00
Taym Haddadi
0bc3b61a74 indexeddb: propagate legacy didThrow from version-change event dispatch (#42669)
indexeddb: propagate legacy didThrow from version-change event dispatch

Testing: fire-upgradeneeded-event-exception.any.js,
upgrade-transaction-deactivation-timing.any.js are passing.

depends on https://github.com/servo/servo/pull/41508

part of https://github.com/servo/servo/issues/40983

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2026-02-20 15:50:46 +00:00
Ashwin Naren
c056f9b08e indexeddb: Report memory usage (#42486)
Reports memory usage, including partial sqlite3 memory usage stats for
the sqlite3 engine.

Testing: Manual
2026-02-19 21:00:51 +00:00
Taym Haddadi
590ae85779 Indexeddb: transaction lifecycle (#41508)
Indexeddb: transaction lifecycle

Testing: more Indexeddb test should pass
part of #40983

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2026-02-19 11:05:33 +00:00
Josh Matthews
36c436ac12 storage: Do not panic if sqlite fails to open a DB. (#42444)
#42442 triggered a bunch of intermittent panics due to DBs being cleaned
up while tests were still trying to use them. This is very difficult to
test reliably, but replacing calls to unwrap with sending error values
to the script thread is clearly an improvement.

Testing: Some intermittent crashes now turn into intermittent timeouts.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-02-12 17:31:11 +00:00
Ashwin Naren
086863398d webstorage: Improve storage memory size reporting (#42484)
`local_storage_origins` is ~2-3kb of memory, which is probably large
enough to be included in the report, given that it likely can grow much
more. A much bigger memory user is sqlite3, but I'm still working on
finding a way to extract memory usage for it.

Testing: Manual

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2026-02-10 17:42:53 +00:00
Ashwin Naren
3442a91766 indexeddb: Implement index retrieval (#42440)
Retrieve already stored indexes from the backend when querying for other
object store data.

Also removes the extraneous blocking IPC call when creating an
`IDBObjectStore` object by batching all the info into a single struct.

Testing: WPT
Fixes: #42438

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2026-02-08 09:22:50 +00:00
Ashwin Naren
879f3e1451 indexeddb: IDBIndex creation and deletion (#38840)
Implements `createIndex` and `deleteIndex`, they have already been
implemented in the backend.

Testing: WPT
Fixes: Partially #38100

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2026-02-07 21:41:25 +00:00
Gregory Terzian
91ee834195 Indexeddb: connection lifecycle (#42082)
Implement the full connection lifecycle, from opening and potentially
upgrading a database, waiting on existing connections to close, firing
the versionchange and blocked events, and updating pending open requests
when connections close.

Testing: WPT
Fixes: Part of https://github.com/servo/servo/issues/40983

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2026-02-02 06:14:27 +00:00
Ashwin Naren
c14053f728 Don't persist session storage changes (#41326)
Bug that would result in local storage changes being overwritten by
session storage ones.

Testing: Added a unit test
Fixes: #41324

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2026-01-24 13:55:51 +00:00
Gregory Terzian
19b26b7e6e indexeddb: track open requests by id (#41933)
Track open requests by their ID, so that specific requests can be
aborted instead of aborting all request for a given db name. This is
important because worker and windows at the same origin could be opening
databases and aborting their opening, but this should not affect other
scopes at the origin.

Testing: Existing WPT test suites. 
Fixes: None, but part of https://github.com/servo/servo/issues/40983

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2026-01-20 14:04:16 +00:00
Gregory Terzian
5c68a717ab indexeddb: implement connection queue (#41500)
Implement the connection queue concept from
https://w3c.github.io/IndexedDB/#connection-queue, as well as the
related logic to abort open requests.

Testing: WPT tests.
Fixes: Part of https://github.com/servo/servo/issues/40983

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2026-01-08 15:40:23 +00:00
Jan Varga
a2195e5924 libservo: Extend SiteDataManager::clear_site_data to clear sessionStorage (#41709)
sessionStorage entries are identified via their associated origins and
removed
across all browsing contexts. This brings sessionStorage in line with
cookies,
which were already handled by the API.

Both public and private browsing contexts are included in the clearing
operation.

The necessary support has been added to the storage crate to clear
WebStorage
data.

Testing: A new integration test has been added.

Signed-off-by: Jan Varga <jvarga@igalia.com>
2026-01-06 17:40:42 +00:00
Gregory Terzian
9cd480f7ee indexeddb: implement databases concept(detete and databases method) (#41322)
Moves the concept of databases closer to the 3.0 spec, by implementing
the delete functionality, and the method returning current databases to
script.

Testing: WPT tests with new passes
Fixes: The "Implement databases deletion and `databases`" item of
https://github.com/servo/servo/issues/40983

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-12-23 14:09:48 +00:00
Jan Varga
1a6b18937a libservo: Add initial SiteDataManager::site_data API (#41378)
This PR adds an initial `site_data` API to `SiteDataManager`, allowing
embedders to obtain a unified list of sites that have associated site
data.

The implementation introduces supporting infrastructure across storage
and
`SiteDataManager` layers, including a small helper for obtaining
WebStorage
origins and initial support for filtering by storage type. At this
stage,
sites correspond directly to origins, future work will extend this to
higher
level grouping (e.g. domain or eTLD+1).

Testing: Added a new integration test covering site data behavior across
localStorage and sessionStorage.

---------

Signed-off-by: Jan Varga <jvarga@igalia.com>
2025-12-21 12:45:43 +00:00
Taym Haddadi
f794a2480d IndexedDB: Handle error of creating new db Step 6 of (#41014)
I added error handling for handle_open_db but I also added it to
SqliteEngine::new and handle_sync_operation because we also open db
there, so I am not sure about these two.

part of #40983

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-12-17 19:11:46 +00:00
Jan Varga
84eb1b084e storage: Add support for listing WebStorage origins (#41293)
This PR adds support for listing origins that have associated WebStorage
data.

Both localStorage and sessionStorage are supported. For sessionStorage,
origins are reported if data exists in any browsing context, while only
localStorage origins persist across restarts.

The implementation introduces an internal origin descriptor abstraction
to support future extensions, such as reporting perorigin usage.

This functionality is primarily intended to be used by
`SiteDataManager`.

Testing: Added a unit test covering origin listing before and after
restart.

---------

Signed-off-by: Jan Varga <jvarga@igalia.com>
2025-12-16 18:55:27 +00:00
Gregory Terzian
5c777abc63 indexeddb: move database open and upgrade transaction to in parallel. (#40939)
The spec concept of [opening a
database](https://www.w3.org/TR/IndexedDB-2/#open-a-database), and the
conditional [upgrade of a
database](https://w3c.github.io/IndexedDB/#upgrade-a-database), should
be run in-parallel, meaning on the backend indexeddb thread, and not on
the script-thread.

This implements the move, but retains a blocking wait on the upgrade
transaction finish. It is the first step towards a larger
refactoring(see https://github.com/servo/servo/issues/40983), which will
see concepts like transaction lifecyle and connection queues be
implemented on the indexeddb thread, and which will make any waiting
non-blocking as well.

Other smaller changes to support the above are: 
- returning whether a physical db was created when instantiating the db
engine.
- using a global counter to produce transaction ids.

Testing: New failures on WPT tests: to be fixed as part of several
follow-ups.
Fixes: The parts of
https://github.com/servo/servo/issues/38942#issuecomment-3270223903 that
were not addressed when the issue was closed.

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
Signed-off-by: Gregory Terzian <2792687+gterzian@users.noreply.github.com>
Co-authored-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-12-11 12:22:49 +00:00
Narfinger
a841eb49d5 IndexedDB: Use GenericSender, GenericReceiver and GenericCallback for IndexedDB (#41031)
Moving IndexedDB to use the generic channel methods.

Of note is the change in 'IDBRequest::execute_async'. This method
previously added a channel that was constructed from the callsite in put
into the AsyncOperation. Now we do not take a function but take a
'FnOnce(GenericCallback<BackendResult<T>>) -> AsyncOperation'. With this
the callsite can construct the AsyncOperation to give in the
'IndexedDBThreadMsg::Async'.

The rest are mostly just type changes.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: WPT tests on the IndexedDB subset still pass.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-12-04 05:25:17 +00:00
Jan Varga
1d0540810e storage: Introduce storage coordination thread and infrastructure for parallel next-generation IndexedDB implementation (#40661)
This PR introduces a new storage coordination thread, intended to serve
as the central point for managing all current and future storage
endpoints in Servo.

In addition to the new coordination thread, this PR also lays the
infrastructure required to develop a parallel, next-generation IndexedDB
implementation under the indexeddb_next feature flag living on a
separate branch.

Testing: Unit and WPT tests continue to pass

---------

Signed-off-by: Jan Varga <jvarga@igalia.com>
2025-11-28 10:40:02 +00:00
Ashwin Naren
950ff27065 indexeddb: Support deletion of key ranges (#39582)
Allows for key ranges to be deleted, as per spec.

Testing: WPT

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-11-23 06:44:13 +00:00
WaterWhisperer
241bff962d Change some #[allow]s to #[expect]s (#40458)
Removes some unneeded lints.

Testing: Refactor
Part of: #40383

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-06 12:31:48 +00:00
Yerkebulan Tulibergenov
cce77287db move unit tests to a separate mod test (#40332)
move unit tests to a separate mod test

Testing: existing unit test still runs with mach test-unit.

This change will reduce the amount of code that the compiler has to
compile when we are not running tests.

Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-11-01 05:57:41 +00:00
Ashwin Naren
c03babc885 storage: Rename remaining references storage to webstorage (#40090)
Clarifies the remaining references to `storage` that actually refer to
`webstorage`.

Testing: Refactor

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-10-23 01:42:26 +00:00
Ashwin Naren
3f12394dea storage: More documentation for indexeddb_thread.rs (#39662)
Cleaned up some of the documentation.

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-10-08 19:42:54 +00:00
Ashwin Naren
fef56fcc47 Consistently rename storage to webstorage to prevent confusion (#39550)
Add the prefix of "WebStorage" instead of "Storage" for all webstorage
spec related things. For example, a `struct` called `StorageManager`:
this could refer to either webstorage's thread manager or to the backend
for [the storage manager
interface](https://storage.spec.whatwg.org/#storagemanager). webstorage
is the full name of the spec, so I chose to keep that in the names of
files/structs to prevent confusion when storage manager is implemented.

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-29 17:13:34 +00:00
Ashwin Naren
d12dc23083 storage: Move storage related backend threads to their own crate (#39418)
This PR moves storage related APIs (currently just webstorage and
indexeddb) into their own crate. This reduces the congestion in the net
thread.

Related Zulip thread:
https://servo.zulipchat.com/#narrow/channel/263398-general/topic/indexedDB.20location/with/535911631

Sub PRs:
- [x] Move shared storage/net stuff to base (`IpcSend` and
`CoreResourcePool`) #39419

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-28 08:00:20 +00:00