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

This commit is contained in:
Magnus Melin 2014-02-05 21:49:00 +02:00
parent abebb55b8a
commit 8441b7e773
2 changed files with 11 additions and 4 deletions

View File

@ -94,8 +94,12 @@ 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 = NS_LITERAL_CSTRING(
(aHost.FindChar('@') == -1) ? "http://" : "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) {