Bug 457296 - allow content manager to removing mail address permissions. r=josh

This commit is contained in:
Magnus Melin 2014-01-25 21:00:10 +02:00
parent 1b0eea1b45
commit ae2409391b
2 changed files with 13 additions and 4 deletions

View File

@ -94,8 +94,14 @@ GetPrincipal(const nsACString& aHost, uint32_t aAppId, bool aIsInBrowserElement,
if (NS_FAILED(rv)) {
// NOTE: most callers will end up here because we don't append "http://" for
// hosts. It's fine to arbitrary use "http://" because, for those entries,
// we will actually just use the host.
rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("http://") + aHost);
// we will actually just use the host. If we end up here, but the host looks
// like an email address, we use mailto: instead.
nsCString scheme;
if (aHost.FindChar('@') == -1)
scheme = NS_LITERAL_CSTRING("http://");
else
scheme = NS_LITERAL_CSTRING("mailto:");
rv = NS_NewURI(getter_AddRefs(uri), scheme + aHost);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -15,13 +15,16 @@ function run_test() {
Services.perms.add(uri, kType, kCapability);
do_check_true(permission_exists(kTestAddr, kType, kCapability));
Services.perms.removeAll();
// remove the permission, and make sure it was removed
Services.perms.remove(kTestAddr, kType);
do_check_false(permission_exists(kTestAddr, kType, kCapability));
uri = Services.io.newURI("mailto:" + kTestAddr, null, null);
Services.perms.add(uri, kType, kCapability);
do_check_true(permission_exists(kTestAddr, kType, kCapability));
Services.perms.removeAll();
Services.perms.remove(kTestAddr, kType);
do_check_false(permission_exists(kTestAddr, kType, kCapability));
}
function permission_exists(aHost, aType, aCapability) {