Skip to content

Commit 11a55a5

Browse files
authored
Fix test browser.test_preload_file to pass in old browsers (#25406)
Fix test browser.test_preload_file to pass in old browsers that do not support IndexedDB 3.0 API.
1 parent 4999e29 commit 11a55a5

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

test/test_browser.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,24 @@ def clear_indexed_db(self):
501501
<script src="browser_reporting.js"></script>
502502
<script>
503503
// Clear the cache, so that the next test starts from a clean slate.
504-
indexedDB.databases().then(dbs => {
505-
Promise.all(dbs.map(db => {
506-
return indexedDB.deleteDatabase(db.name);
507-
})).then(() => {
508-
reportResultToServer("clear");
504+
if (indexedDB.databases) {
505+
// If the tested browser supports IndexedDB 3.0 API, then enumerate all
506+
// available databases and delete them.
507+
indexedDB.databases().then(dbs => {
508+
Promise.all(dbs.map(db => {
509+
return indexedDB.deleteDatabase(db.name);
510+
})).then(() => {
511+
reportResultToServer("clear");
512+
});
509513
});
510-
});
514+
} else {
515+
// Testing an old browser that does not support indexedDB.databases():
516+
// Delete the fixed database EM_PRELOAD_CACHE (this is hardcoded in
517+
// file packager)
518+
indexedDB.deleteDatabase('EM_PRELOAD_CACHE').onsuccess = () => {
519+
reportResultToServer("clear");
520+
};
521+
}
511522
</script>
512523
''')
513524
self.run_browser('clear_indexed_db.html', '/report_result?clear')

0 commit comments

Comments
 (0)