зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1535995 - Check that group information is up to date; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D23822
This commit is contained in:
Родитель
718ffb7d51
Коммит
9db88adebf
Двоичный файл не отображается.
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
/**
|
||||
* This test is mainly to verify that metadata files with old group information
|
||||
* get updated, so writing to local storage won't cause a crash because of null
|
||||
* quota object. See bug 1516333.
|
||||
*/
|
||||
|
||||
async function testSteps()
|
||||
{
|
||||
const principal = getPrincipal("https://foo.bar.mozilla-iot.org");
|
||||
|
||||
info("Clearing");
|
||||
|
||||
let request = clear();
|
||||
await requestFinished(request);
|
||||
|
||||
info("Installing package");
|
||||
|
||||
// The profile contains one initialized origin directory, a script for origin
|
||||
// initialization and the storage database:
|
||||
// - storage/default/https+++foo.bar.mozilla-iot.org
|
||||
// - 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/localstorage/test/unit/create_db.js
|
||||
// Note: to make it become the profile in the test, additional manual steps
|
||||
// are needed.
|
||||
// 1. Manually change the group in .metadata and .metadata-v2 from
|
||||
// "bar.mozilla-iot.org" to "mozilla-iot.org".
|
||||
// 2. Remove the folder "storage/temporary".
|
||||
// 3. Remove the file "storage/ls-archive.sqlite".
|
||||
installPackage("groupMismatch_profile");
|
||||
|
||||
info("Getting storage");
|
||||
|
||||
let storage = getLocalStorage(principal);
|
||||
|
||||
info("Adding item");
|
||||
|
||||
storage.setItem("foo", "bar");
|
||||
}
|
|
@ -7,6 +7,7 @@ head = head.js
|
|||
support-files =
|
||||
archive_profile.zip
|
||||
corruptedDatabase_profile.zip
|
||||
groupMismatch_profile.zip
|
||||
migration_profile.zip
|
||||
stringLength_profile.zip
|
||||
|
||||
|
@ -30,6 +31,7 @@ run-sequentially = test_databaseShadowing_clearOriginsByPrefix2.js depends on a
|
|||
run-sequentially = this test depends on a file produced by test_databaseShadowing_clearOriginsByPrefix1.js
|
||||
[test_eviction.js]
|
||||
[test_groupLimit.js]
|
||||
[test_groupMismatch.js]
|
||||
[test_migration.js]
|
||||
[test_originInit.js]
|
||||
[test_snapshotting.js]
|
||||
|
|
|
@ -3572,6 +3572,66 @@ nsresult QuotaManager::GetDirectoryMetadata2(
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = binaryStream->Close();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!origin.EqualsLiteral(kChromeOrigin)) {
|
||||
OriginAttributes originAttributes;
|
||||
nsCString originNoSuffix;
|
||||
if (NS_WARN_IF(!originAttributes.PopulateFromOrigin(origin,
|
||||
originNoSuffix))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
RefPtr<MozURL> url;
|
||||
rv = MozURL::Init(getter_AddRefs(url), originNoSuffix);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCString baseDomain;
|
||||
rv = url->BaseDomain(baseDomain);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCString upToDateGroup = baseDomain + suffix;
|
||||
|
||||
if (group != upToDateGroup) {
|
||||
group = upToDateGroup;
|
||||
|
||||
rv = CreateDirectoryMetadata(
|
||||
aDirectory, timestamp, suffix, group, origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CreateDirectoryMetadata2(
|
||||
aDirectory, timestamp, persisted, suffix, group, origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
ContentPrincipalInfo contentPrincipalInfo;
|
||||
contentPrincipalInfo.attrs() = originAttributes;
|
||||
contentPrincipalInfo.originNoSuffix() = originNoSuffix;
|
||||
contentPrincipalInfo.spec() = originNoSuffix;
|
||||
contentPrincipalInfo.baseDomain() = baseDomain;
|
||||
|
||||
PrincipalInfo principalInfo(contentPrincipalInfo);
|
||||
|
||||
nsTArray<PrincipalInfo> principalInfos;
|
||||
principalInfos.AppendElement(principalInfo);
|
||||
|
||||
RefPtr<PrincipalVerifier> principalVerifier =
|
||||
PrincipalVerifier::CreateAndDispatch(std::move(principalInfos));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
*aTimestamp = timestamp;
|
||||
*aPersisted = persisted;
|
||||
aSuffix = suffix;
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
/**
|
||||
* This test is mainly to verify that metadata files with old group information
|
||||
* get updated. See bug 1535995.
|
||||
*/
|
||||
|
||||
async function testSteps()
|
||||
{
|
||||
const principal = getPrincipal("https://foo.bar.mozilla-iot.org");
|
||||
const metadataFile = getRelativeFile(
|
||||
"storage/default/https+++foo.bar.mozilla-iot.org/.metadata-v2");
|
||||
|
||||
async function readMetadataFile() {
|
||||
let file = await File.createFromNsIFile(metadataFile);
|
||||
|
||||
let buffer = await new Promise(resolve => {
|
||||
let reader = new FileReader();
|
||||
reader.onloadend = () => resolve(reader.result);
|
||||
reader.readAsArrayBuffer(file);
|
||||
});
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
info("Clearing");
|
||||
|
||||
let request = clear();
|
||||
await requestFinished(request);
|
||||
|
||||
info("Installing package");
|
||||
|
||||
// The profile contains one initialized origin directory, a script for origin
|
||||
// initialization and the storage database:
|
||||
// - storage/default/https+++foo.bar.mozilla-iot.org
|
||||
// - 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/localstorage/test/unit/create_db.js
|
||||
// Note: to make it become the profile in the test, additional manual steps
|
||||
// are needed.
|
||||
// 1. Manually change the group in .metadata and .metadata-v2 from
|
||||
// "bar.mozilla-iot.org" to "mozilla-iot.org".
|
||||
// 2. Remove the folder "storage/temporary".
|
||||
// 3. Remove the file "storage/ls-archive.sqlite".
|
||||
installPackage("groupMismatch_profile");
|
||||
|
||||
info("Reading out contents of metadata file");
|
||||
|
||||
let metadataBuffer = await readMetadataFile();
|
||||
|
||||
info("Initializing origin");
|
||||
|
||||
request = initOrigin(principal, "default");
|
||||
await requestFinished(request);
|
||||
|
||||
info("Reading out contents of metadata file");
|
||||
|
||||
let metadataBuffer2 = await readMetadataFile();
|
||||
|
||||
info("Verifying blobs differ");
|
||||
|
||||
ok(!compareBuffers(metadataBuffer, metadataBuffer2), "Metadata differ");
|
||||
}
|
|
@ -9,6 +9,7 @@ support-files =
|
|||
createLocalStorage_profile.zip
|
||||
defaultStorageUpgrade_profile.zip
|
||||
getUsage_profile.zip
|
||||
groupMismatch_profile.zip
|
||||
idbSubdirUpgrade1_profile.zip
|
||||
idbSubdirUpgrade2_profile.zip
|
||||
morgueCleanup_profile.zip
|
||||
|
@ -26,6 +27,7 @@ support-files =
|
|||
[test_createLocalStorage.js]
|
||||
[test_defaultStorageUpgrade.js]
|
||||
[test_getUsage.js]
|
||||
[test_groupMismatch.js]
|
||||
[test_idbSubdirUpgrade.js]
|
||||
[test_initTemporaryStorage.js]
|
||||
[test_morgueCleanup.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче