mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1788986 - Part 2: Use a background task for QM shutdown cleanup r=janv,smaug
Differential Revision: https://phabricator.services.mozilla.com/D156331
This commit is contained in:
parent
425786bd75
commit
bfa807408a
@ -3431,6 +3431,14 @@
|
||||
value: 200
|
||||
mirror: always
|
||||
|
||||
#ifdef MOZ_BACKGROUNDTASKS
|
||||
# Use a Background Task to delete files at shutdown.
|
||||
- name: dom.quotaManager.backgroundTask.enabled
|
||||
type: bool
|
||||
value: @IS_NIGHTLY_BUILD@
|
||||
mirror: never
|
||||
#endif
|
||||
|
||||
# Determines within what distance of a tick mark, in pixels, dragging an input
|
||||
# range range will snap the range's value to that tick mark. By default, this is
|
||||
# half the default width of the range thumb.
|
||||
|
@ -739,11 +739,29 @@ const QuotaCleaner = {
|
||||
async cleanupAfterDeletionAtShutdown() {
|
||||
const storageDir = PathUtils.join(
|
||||
PathUtils.profileDir,
|
||||
Services.prefs.getStringPref("dom.quotaManager.storageName"),
|
||||
"to-be-removed"
|
||||
Services.prefs.getStringPref("dom.quotaManager.storageName")
|
||||
);
|
||||
|
||||
await IOUtils.remove(storageDir, { recursive: true });
|
||||
if (
|
||||
!AppConstants.MOZ_BACKGROUNDTASKS ||
|
||||
!Services.prefs.getBoolPref("dom.quotaManager.backgroundTask.enabled")
|
||||
) {
|
||||
await IOUtils.remove(PathUtils.join(storageDir, "to-be-removed"), {
|
||||
recursive: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const runner = Cc["@mozilla.org/backgroundtasksrunner;1"].getService(
|
||||
Ci.nsIBackgroundTasksRunner
|
||||
);
|
||||
|
||||
runner.removeDirectoryInDetachedProcess(
|
||||
storageDir,
|
||||
"to-be-removed",
|
||||
"0",
|
||||
""
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -15,6 +15,7 @@ class MovedOriginDirectoryCleanupTestCase(MarionetteTestCase):
|
||||
{
|
||||
"privacy.sanitize.sanitizeOnShutdown": True,
|
||||
"privacy.clearOnShutdown.offlineApps": True,
|
||||
"dom.quotaManager.backgroundTask.enabled": False,
|
||||
}
|
||||
)
|
||||
self.moved_origin_directory = (
|
||||
@ -58,3 +59,19 @@ class MovedOriginDirectoryCleanupTestCase(MarionetteTestCase):
|
||||
lambda _: not self.moved_origin_directory.exists(),
|
||||
message="to-be-removed subdirectory must disappear",
|
||||
)
|
||||
|
||||
def test_ensure_cleanup_by_quit_with_background_task(self):
|
||||
self.assertTrue(
|
||||
self.moved_origin_directory.exists(),
|
||||
"to-be-removed subdirectory must exist",
|
||||
)
|
||||
|
||||
self.marionette.set_pref("dom.quotaManager.backgroundTask.enabled", True)
|
||||
|
||||
# Cleanup happens via Sanitizer.sanitizeOnShutdown
|
||||
self.marionette.quit()
|
||||
|
||||
Wait(self.marionette).until(
|
||||
lambda _: not self.moved_origin_directory.exists(),
|
||||
message="to-be-removed subdirectory must disappear",
|
||||
)
|
||||
|
@ -18,6 +18,11 @@ const skipLocalStorageTests = Services.prefs.getBoolPref(
|
||||
"dom.storage.enable_unsupported_legacy_implementation"
|
||||
);
|
||||
|
||||
// XXX(krosylight): xpcshell does not support background tasks
|
||||
const skipCleanupAfterDeletionAtShutdownTests = Services.prefs.getBoolPref(
|
||||
"dom.quotaManager.backgroundTask.enabled"
|
||||
);
|
||||
|
||||
/**
|
||||
* Create an origin with partitionKey.
|
||||
* @param {String} host - Host portion of origin to create.
|
||||
@ -535,6 +540,11 @@ add_task(async function test_deleteAllAtShutdown() {
|
||||
`storage/to-be-removed has ${TEST_ORIGINS.length} subdirectories`
|
||||
);
|
||||
|
||||
if (skipCleanupAfterDeletionAtShutdownTests) {
|
||||
// XXX(krosylight): xpcshell does not support background tasks
|
||||
return;
|
||||
}
|
||||
|
||||
info("Verifying cleanupAfterDeletionAtShutdown");
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.cleanupAfterDeletionAtShutdown(
|
||||
|
Loading…
Reference in New Issue
Block a user