Bug 1844619 - Update assert to account for OPFS temporary files. r=dom-storage-reviewers,janv

Differential Revision: https://phabricator.services.mozilla.com/D188461
This commit is contained in:
Jari Jalkanen 2023-10-04 08:22:04 +00:00
Родитель c161434a26
Коммит 6955346ac7
4 изменённых файлов: 36 добавлений и 3 удалений

Просмотреть файл

@ -806,10 +806,9 @@ Result<bool, QMResult> FileSystemDatabaseManagerVersion001::RemoveDirectory(
QM_TRY_UNWRAP(DebugOnly<Usage> removedUsage, QM_TRY_UNWRAP(DebugOnly<Usage> removedUsage,
mFileManager->RemoveFiles(descendants, failedRemovals)); mFileManager->RemoveFiles(descendants, failedRemovals));
// We only check the most common case. This can fail spuriously if an external // Usage is for the current main file but we remove temporary files too.
// application writes to the file, or OS reports zero size due to corruption.
MOZ_ASSERT_IF(failedRemovals.IsEmpty() && (0 == mFilesOfUnknownUsage), MOZ_ASSERT_IF(failedRemovals.IsEmpty() && (0 == mFilesOfUnknownUsage),
usage == removedUsage); usage <= removedUsage);
TryRemoveDuringIdleMaintenance(failedRemovals); TryRemoveDuringIdleMaintenance(failedRemovals);

Просмотреть файл

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<script>
window.addEventListener('load', async () => {
await navigator.serviceWorker.register('sw1844619.js?1619678955', {})
await navigator.serviceWorker.register('sw1844619.js?4246054133', {})
})
</script>
</head>
</html>

Просмотреть файл

@ -6,3 +6,5 @@ load 1800470.html
load 1809759.html load 1809759.html
load 1816710.html load 1816710.html
load 1841702.html load 1841702.html
HTTP load 1844619.html

Просмотреть файл

@ -0,0 +1,21 @@
async function timeout (cmd) {
const timer = new Promise((resolve, reject) => {
const id = setTimeout(() => {
clearTimeout(id)
reject(new Error('Promise timed out!'))
}, 750)
})
return Promise.race([cmd, timer])
}
(async () => {
const root = await navigator.storage.getDirectory()
const blob = new Blob(['A'])
const sub = await root.getDirectoryHandle('a', { 'create': true })
const file = await root.getFileHandle('b', { 'create': true })
await file.move(sub)
const stream = await file.createWritable({})
await stream.write(blob)
const sub2 = await root.getDirectoryHandle('a', {})
await sub2.move(root, 'X')
})()