Bug 1702422 - Report failed LoadQuotaFromCache as a warning (instead of an error); r=dom-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D113370
This commit is contained in:
Jan Varga 2021-04-27 07:12:23 +00:00
Родитель 4bd1418875
Коммит a43be2a21f
5 изменённых файлов: 82 добавлений и 2 удалений

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

@ -4179,6 +4179,10 @@ nsresult QuotaManager::LoadQuota() {
MOZ_TO_RESULT_INVOKE(stmt, GetInt32, 0));
if (valid) {
if (!StaticPrefs::dom_quotaManager_caching_checkBuildId()) {
return true;
}
QM_TRY_INSPECT(const auto& buildId,
MOZ_TO_RESULT_INVOKE_TYPED(nsAutoCString, stmt,
GetUTF8String, 1));
@ -4195,8 +4199,8 @@ nsresult QuotaManager::LoadQuota() {
if (!loadQuotaFromCache ||
!StaticPrefs::dom_quotaManager_loadQuotaFromCache() ||
![&LoadQuotaFromCache] {
QM_TRY(LoadQuotaFromCache(), false);
return true;
QM_WARNONLY_TRY_UNWRAP(auto res, ToResult(LoadQuotaFromCache()));
return static_cast<bool>(res);
}()) {
// A keeper to defer the return only in Nightly, so that the telemetry data
// for whole profile can be collected.

Двоичные данные
dom/quota/test/xpcshell/caching/removedOrigin_profile.zip Normal file

Двоичный файл не отображается.

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

@ -0,0 +1,61 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Verify that temporary storage initialization will notice a removed origin
* that the cache has data for and which indicates the origin was accessed
* during the last run. Currently, we expect LoadQuotaFromCache to fail because
* of this inconsistency and to fall back to full initialization.
*/
async function testSteps() {
const principal = getPrincipal("http://example.com");
const originUsage = 0;
info("Setting pref");
// The packaged profile will have a different build ID and we would treat the
// cache as invalid if we didn't bypass this check.
Services.prefs.setBoolPref("dom.quotaManager.caching.checkBuildId", false);
info("Clearing");
let request = clear();
await requestFinished(request);
info("Installing package");
// The profile contains empty default storage, a script for origin
// initialization and the storage database:
// - storage/default
// - 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/quota/test/xpcshell/create_db.js
// Note: to make it become the profile in the test, additional manual steps
// are needed.
// 1. Remove the folder "storage/default/http+++example.com".
// 2. Remove the folder "storage/temporary".
// 3. Remove the file "storage/ls-archive.sqlite".
installPackage("removedOrigin_profile");
info("Initializing");
request = init();
await requestFinished(request);
info("Initializing temporary storage");
request = initTemporaryStorage();
await requestFinished(request);
info("Getting origin usage");
request = getOriginUsage(principal, /* fromMemory */ true);
await requestFinished(request);
is(request.result.usage, originUsage, "Correct origin usage");
}

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

@ -6,5 +6,7 @@
head = head.js
support-files =
groupMismatch_profile.zip
removedOrigin_profile.zip
[test_groupMismatch.js]
[test_removedOrigin.js]

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

@ -2664,6 +2664,19 @@
value: true
mirror: always
# Should we check build ID as part of the cache validation?
# When enabled, the cache is invalidated on any upgrade (or downgrade),
# ensuring that changes in how quota usage is calculated can't cause
# inconsistencies at the cost of a slower initialization. Currently, this
# should only be set to false in tests using a packaged profile that inherently
# includes a build id different from the building running the tests. In the
# future this may be set to false if we are confident that we have sufficiently
# thorough schema versioning.
- name: dom.quotaManager.caching.checkBuildId
type: RelaxedAtomicBool
value: true
mirror: always
# Preference that users can set to override temporary storage smart limit
# calculation.
- name: dom.quotaManager.temporaryStorage.fixedLimit