Bug 1681619 - in browser_extension_correction.js clear finished downloads to avoid intermittents, r=mak
The finished downloads were removed, which meant that the next time the download code asynchronously refreshed them, they were smaller than the last time that they checked, which meant we got another `onChange` notification for the download (which would still be finished / in error state), which confused the test which expected 1 notification per download. To avoid this, we clear finished downloads after each iteration inside the test, instead of at the end. Differential Revision: https://phabricator.services.mozilla.com/D100149
This commit is contained in:
@@ -8,23 +8,18 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
|
|||||||
"https://example.com"
|
"https://example.com"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let gPathsToRemove = [];
|
||||||
|
|
||||||
add_task(async function setup() {
|
add_task(async function setup() {
|
||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [["browser.download.useDownloadDir", true]],
|
set: [["browser.download.useDownloadDir", true]],
|
||||||
});
|
});
|
||||||
registerCleanupFunction(async () => {
|
registerCleanupFunction(async () => {
|
||||||
let publicList = await Downloads.getList(Downloads.PUBLIC);
|
for (let path of gPathsToRemove) {
|
||||||
let downloads = await publicList.getAll();
|
// IOUtils.remove ignores non-existing files out of the box.
|
||||||
for (let download of downloads) {
|
await IOUtils.remove(path);
|
||||||
if (download.target.exists) {
|
|
||||||
try {
|
|
||||||
info("removing " + download.target.path);
|
|
||||||
await IOUtils.remove(download.target.path);
|
|
||||||
} catch (ex) {
|
|
||||||
/* ignore */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
let publicList = await Downloads.getList(Downloads.PUBLIC);
|
||||||
await publicList.removeFinished();
|
await publicList.removeFinished();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -86,7 +81,11 @@ async function checkDownloadWithExtensionState(
|
|||||||
expectedName,
|
expectedName,
|
||||||
`Downloaded file should also match ${expectedName}`
|
`Downloaded file should also match ${expectedName}`
|
||||||
);
|
);
|
||||||
await IOUtils.remove(download.target.path);
|
gPathsToRemove.push(download.target.path);
|
||||||
|
let pathToRemove = download.target.path;
|
||||||
|
// Avoid one file interfering with subsequent files.
|
||||||
|
await publicList.removeFinished();
|
||||||
|
await IOUtils.remove(pathToRemove);
|
||||||
} else {
|
} else {
|
||||||
// We just cancel out for files that would end up without a path, as we'd
|
// We just cancel out for files that would end up without a path, as we'd
|
||||||
// prompt for a filename.
|
// prompt for a filename.
|
||||||
|
|||||||
Reference in New Issue
Block a user