Bug 1554167 - Remove pending shutdown sanitization immediately after shutdown sanitization finishes. r=mak,baku

In https://hg.mozilla.org/mozilla-central/rev/25397a6f8c4f#l1.35 we added an early return to
the SanitizeOnShutdown function to avoid cleaning principals by permission if the user had
set their preferences to clear all storage on shutdown anyway. This unfortunately ended
the function execution before it would call `removePendingSanitization("shutdown");` later on
and thus remove the pending shutdown sanitization (which, in fact, had completed successfully earlier).

The result is that the shutdown sanitization would be left dangling and run again on next startup,
where, for reasons I don't fully understand, it would race and conflict with loading the home page,
if that home page was from web content.

The solution is to remove the pending shutdown sanitization immediately after the sanitization is done.

As far as I can see there was never really a point in having it happen after session principal
cleanup finished, since in case of a crash it would not run the principal cleanup again next startup,
just the shutdown cleanup.

For good measure I also moved the new tab container sanitization to happen earlier in this function,
to prevent it from dangling as well.

Differential Revision: https://phabricator.services.mozilla.com/D33087

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Johann Hofmann 2019-05-30 15:39:39 +00:00
Родитель 98809ae136
Коммит de6eaee5b4
1 изменённых файлов: 17 добавлений и 13 удалений

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

@ -745,11 +745,28 @@ class PrincipalsCollector {
async function sanitizeOnShutdown(progress) {
log("Sanitizing on shutdown");
let needsSyncSavePrefs = false;
if (Sanitizer.shouldSanitizeOnShutdown) {
// Need to sanitize upon shutdown
progress.advancement = "shutdown-cleaner";
let itemsToClear = getItemsToClearFromPrefBranch(Sanitizer.PREF_SHUTDOWN_BRANCH);
await Sanitizer.sanitize(itemsToClear, { progress });
// We didn't crash during shutdown sanitization, so annotate it to avoid
// sanitizing again on startup.
removePendingSanitization("shutdown");
needsSyncSavePrefs = true;
}
if (Sanitizer.shouldSanitizeNewTabContainer) {
progress.advancement = "newtab-segregation";
sanitizeNewTabSegregation();
removePendingSanitization("newtab-container");
needsSyncSavePrefs = true;
}
if (needsSyncSavePrefs) {
Services.prefs.savePrefFile(null);
}
let principalsCollector = new PrincipalsCollector();
@ -810,19 +827,6 @@ async function sanitizeOnShutdown(progress) {
await maybeSanitizeSessionPrincipals(progress, selectedPrincipals);
}
if (Sanitizer.shouldSanitizeNewTabContainer) {
progress.advancement = "newtab-segregation";
sanitizeNewTabSegregation();
removePendingSanitization("newtab-container");
}
if (Sanitizer.shouldSanitizeOnShutdown) {
// We didn't crash during shutdown sanitization, so annotate it to avoid
// sanitizing again on startup.
removePendingSanitization("shutdown");
Services.prefs.savePrefFile(null);
}
progress.advancement = "done";
}