indexeddb: Support enabling IndexedDB after startup (#39177)

The servodriver harness requires preference-gated web platform features
to be toggleable at any point in the browsing session's lifetime, rather
than at startup. To support toggling IndexedDB, we need to ensure the
IDB manager thread is always started.

Testing: Verified when running `./mach test-wpt /IndexedDB --headless
--product servodriver`. We don't run servodriver in CI yet.
Fixes: #39175

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-09-06 02:55:20 -04:00 committed by GitHub
parent b5d6555238
commit c490033c52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 11 deletions

View file

@ -224,9 +224,6 @@ impl IndexedDBManager {
impl IndexedDBManager {
fn start(&mut self) {
if !pref!(dom_indexeddb_enabled) {
return;
}
loop {
// FIXME:(arihant2math) No message *most likely* means that
// the ipc sender has been dropped, so we break the look

View file

@ -58,7 +58,9 @@ impl IDBFactoryMethods<crate::DomTypeHolder> for IDBFactory {
let request = IDBOpenDBRequest::new(&self.global(), CanGc::note());
// Step 5: Runs in parallel
request.open_database(name, version);
if request.open_database(name, version).is_err() {
return Err(Error::Operation);
}
// Step 6
Ok(request)
@ -81,7 +83,9 @@ impl IDBFactoryMethods<crate::DomTypeHolder> for IDBFactory {
let request = IDBOpenDBRequest::new(&self.global(), CanGc::note());
// Step 4: Runs in parallel
request.delete_database(name.to_string());
if request.delete_database(name.to_string()).is_err() {
return Err(Error::Operation);
}
// Step 5: Return request
Ok(request)

View file

@ -224,7 +224,7 @@ impl IDBOpenDBRequest {
self.idbrequest.set_error(error, can_gc);
}
pub fn open_database(&self, name: DOMString, version: Option<u64>) {
pub fn open_database(&self, name: DOMString, version: Option<u64>) -> Result<(), ()> {
let global = self.global();
let (sender, receiver) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
@ -286,13 +286,17 @@ impl IDBOpenDBRequest {
}),
);
global
if global
.resource_threads()
.send(IndexedDBThreadMsg::Sync(open_operation))
.unwrap();
.is_err()
{
return Err(());
}
Ok(())
}
pub fn delete_database(&self, name: String) {
pub fn delete_database(&self, name: String) -> Result<(), ()> {
let global = self.global();
let (sender, receiver) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
@ -317,10 +321,14 @@ impl IDBOpenDBRequest {
}),
);
global
if global
.resource_threads()
.send(IndexedDBThreadMsg::Sync(delete_operation))
.unwrap();
.is_err()
{
return Err(());
}
Ok(())
}
pub fn dispatch_success(&self, result: &IDBDatabase) {