Bug 1750164 - Hand over the proper unit of time from ClearDataService to PermissionManager. r=pbz

Differential Revision: https://phabricator.services.mozilla.com/D136391
This commit is contained in:
Hannah Peuckmann 2022-01-31 16:33:33 +00:00
Родитель 3866a4ff0f
Коммит 9e561c3134
4 изменённых файлов: 12 добавлений и 4 удалений

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

@ -41,7 +41,10 @@ add_task(async function sanitizeStorageAccessPermissions() {
Services.perms.ALLOW_ACTION
);
await Sanitizer.sanitize(["history"], { range: [timestamp, Date.now()] });
await Sanitizer.sanitize(["history"], {
// Sanitizer and ClearDataService work with time range in PRTime (microseconds)
range: [timestamp * 1000, Date.now() * 1000],
});
Assert.equal(
PermissionTestUtils.testExactPermission(

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

@ -2440,6 +2440,10 @@ NS_IMETHODIMP PermissionManager::GetAll(
NS_IMETHODIMP PermissionManager::GetAllByTypeSince(
const nsACString& aPrefix, int64_t aSince,
nsTArray<RefPtr<nsIPermission>>& aResult) {
// Check that aSince is a reasonable point in time, not in the future
if (aSince > (PR_Now() / PR_USEC_PER_MSEC)) {
return NS_ERROR_INVALID_ARG;
}
return GetPermissionEntries(
[&](const PermissionEntry& aPermEntry) {
return mTypeArray[aPermEntry.mType].Equals(aPrefix) &&

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

@ -838,10 +838,10 @@ const StorageAccessCleaner = {
for (let principal of aPrincipalsWithStorage) {
baseDomainsWithStorage.add(principal.baseDomain);
}
for (let perm of Services.perms.getAllByTypeSince(
"storageAccessAPI",
aFrom
// The permission manager uses milliseconds instead of microseconds
aFrom / 1000
)) {
if (!baseDomainsWithStorage.has(perm.principal.baseDomain)) {
Services.perms.removePermission(perm);

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

@ -364,7 +364,8 @@ add_task(async function test_deleteUserInteractionForClearingHistory() {
await new Promise(resolve => {
return Services.clearData.deleteUserInteractionForClearingHistory(
[principalWithStorage],
timestamp,
// ClearDataService takes PRTime (microseconds)
timestamp * 1000,
resolve
);
});