Bug 1596843 - Part 3: Remove the unused nsIPermissionManager.updateExpireTime() method; r=baku

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-11-17 20:06:08 +00:00
parent c05273a531
commit 5478509264
3 changed files with 0 additions and 125 deletions

View File

@ -2997,55 +2997,6 @@ void nsPermissionManager::UpdateDB(
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
NS_IMETHODIMP
nsPermissionManager::UpdateExpireTime(nsIPrincipal* aPrincipal,
const nsACString& aType,
bool aExactHostMatch,
uint64_t aSessionExpireTime,
uint64_t aPersistentExpireTime) {
NS_ENSURE_ARG_POINTER(aPrincipal);
uint64_t nowms = PR_Now() / 1000;
if (aSessionExpireTime < nowms || aPersistentExpireTime < nowms) {
return NS_ERROR_INVALID_ARG;
}
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
return NS_OK;
}
// Setting the expire time of an nsEP is non-sensical.
if (IsExpandedPrincipal(aPrincipal)) {
return NS_ERROR_INVALID_ARG;
}
MOZ_ASSERT(PermissionAvailable(aPrincipal, aType));
int32_t typeIndex = GetTypeIndex(aType, false);
// If type == -1, the type isn't known,
// so just return NS_OK
if (typeIndex == -1) return NS_OK;
PermissionHashKey* entry =
GetPermissionHashKey(aPrincipal, typeIndex, aExactHostMatch);
if (!entry) {
return NS_OK;
}
int32_t idx = entry->GetPermissionIndex(typeIndex);
if (-1 == idx) {
return NS_OK;
}
PermissionEntry& perm = entry->GetPermissions()[idx];
if (perm.mExpireType == EXPIRE_TIME) {
perm.mExpireTime = aPersistentExpireTime;
} else if (perm.mExpireType == EXPIRE_SESSION && perm.mExpireTime != 0) {
perm.mExpireTime = aSessionExpireTime;
}
return NS_OK;
}
NS_IMETHODIMP
nsPermissionManager::GetPermissionsWithKey(const nsACString& aPermissionKey,
nsTArray<IPC::Permission>& aPerms) {

View File

@ -84,38 +84,6 @@ function* do_run_test() {
0
);
// add a permission for renewal
pm.addFromPrincipal(
principal,
"test/expiration-perm-renewable",
1,
pm.EXPIRE_TIME,
now + 100
);
pm.addFromPrincipal(
principal,
"test/expiration-session-renewable",
1,
pm.EXPIRE_SESSION,
now + 100
);
// And immediately renew them with longer timeouts
pm.updateExpireTime(
principal,
"test/expiration-perm-renewable",
true,
now + 100,
now + 1e6
);
pm.updateExpireTime(
principal,
"test/expiration-session-renewable",
true,
now + 1e6,
now + 100
);
// check that the second two haven't expired yet
Assert.equal(
1,
@ -129,17 +97,6 @@ function* do_run_test() {
1,
pm.testPermissionFromPrincipal(principal, "test/expiration-perm-nexp")
);
Assert.equal(
1,
pm.testPermissionFromPrincipal(principal, "test/expiration-perm-renewable")
);
Assert.equal(
1,
pm.testPermissionFromPrincipal(
principal,
"test/expiration-session-renewable"
)
);
// ... and the first one has
do_timeout(10, continue_test);
@ -183,18 +140,5 @@ function* do_run_test() {
pm.getPermissionObject(principal, "test/expiration-session-exp2", false)
);
// Check that the renewable permissions actually got renewed
Assert.equal(
1,
pm.testPermissionFromPrincipal(principal, "test/expiration-perm-renewable")
);
Assert.equal(
1,
pm.testPermissionFromPrincipal(
principal,
"test/expiration-session-renewable"
)
);
do_finish_generator_test(test_generator);
}

View File

@ -198,26 +198,6 @@ interface nsIPermissionManager : nsISupports
*/
readonly attribute Array<nsIPermission> all;
/**
* If the current permission is set to expire, reset the expiration time. If
* there is no permission or the current permission does not expire, this
* method will silently return.
*
* @param sessionExpiretime an integer representation of when this permission
* should be forgotten (milliseconds since
* Jan 1 1970 0:00:00), if it is currently
* EXPIRE_SESSION.
* @param sessionExpiretime an integer representation of when this permission
* should be forgotten (milliseconds since
* Jan 1 1970 0:00:00), if it is currently
* EXPIRE_TIME.
*/
void updateExpireTime(in nsIPrincipal principal,
in ACString type,
in boolean exactHost,
in uint64_t sessionExpireTime,
in uint64_t persistentExpireTime);
/**
* The content process doesn't have access to every permission. Instead, when
* LOAD_DOCUMENT_URI channels for http://, https://, and ftp:// URIs are