diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/indexedDB/test/unit/test_orphaned_files.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/indexedDB/test/unit/test_orphaned_files.js')
-rw-r--r-- | dom/indexedDB/test/unit/test_orphaned_files.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/dom/indexedDB/test/unit/test_orphaned_files.js b/dom/indexedDB/test/unit/test_orphaned_files.js new file mode 100644 index 0000000000..fc4592c356 --- /dev/null +++ b/dom/indexedDB/test/unit/test_orphaned_files.js @@ -0,0 +1,59 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/** + * The goal of this test is to prove that orphaned files are cleaned up during + * origin initialization. A file is orphaned when there's a file with zero size + * in the $dbName.files/journals directory and the file table in the database + * contains no records for given id. A file can become orphaned when we didn't + * have a chance to remove the file from disk during shutdown or the app just + * crashed. + */ + +/* exported testSteps */ +async function testSteps() { + const name = "test_orphaned_files.js"; + + const objectStoreName = "Blobs"; + + const blobData = { key: 1 }; + + info("Installing profile"); + + let request = clearAllDatabases(); + await requestFinished(request); + + // The profile contains one initialized origin directory (with an IndexedDB + // database and an orphaned file), a script for origin initialization and the + // storage database: + // - storage/permanent/chrome + // - create_db.js + // - storage.sqlite + // The file create_db.js in the package was run locally, specifically it was + // temporarily added to xpcshell.ini and then executed: + // mach xpcshell-test --interactive dom/indexedDB/test/unit/create_db.js + // Note: to make it become the profile in the test, additional manual steps + // are needed. + // 1. Remove the file "storage/ls-archive.sqlite". + + installPackagedProfile("orphaned_files_profile"); + + info("Opening database"); + + request = indexedDB.open(name); + await expectingSuccess(request); + + info("Getting data"); + + request = request.result + .transaction([objectStoreName]) + .objectStore(objectStoreName) + .get(blobData.key); + await requestSucceeded(request); + + info("Verifying data"); + + ok(request.result === undefined, "Correct result"); +} |