зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset f8fc57f3ab64 (bug 1509047) for build bustages on a CLOSED TREE
This commit is contained in:
Родитель
11a785122a
Коммит
eb6a42f46f
|
@ -2575,31 +2575,16 @@ nsPermissionManager::GetPermissionHashKey(nsIURI* aURI,
|
|||
|
||||
NS_IMETHODIMP nsPermissionManager::GetEnumerator(nsISimpleEnumerator **aEnum)
|
||||
{
|
||||
nsTArray<RefPtr<nsIPermission>> array;
|
||||
nsresult rv = GetAllWithTypePrefix(NS_LITERAL_CSTRING(""), array);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMArray<nsIPermission> comArray;
|
||||
comArray.SetCapacity(array.Length());
|
||||
for (size_t i = 0; i < array.Length(); i++) {
|
||||
comArray.AppendElement(array[i].forget());
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aEnum, comArray, NS_GET_IID(nsIPermission));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPermissionManager::GetAllWithTypePrefix(const nsACString& aPrefix,
|
||||
nsTArray<RefPtr<nsIPermission>>& aResult)
|
||||
{
|
||||
aResult.Clear();
|
||||
if (XRE_IsContentProcess()) {
|
||||
NS_WARNING("nsPermissionManager's getAllWithTypePrefix is not available in the "
|
||||
NS_WARNING("nsPermissionManager's enumerator is not available in the "
|
||||
"content process, as not all permissions may be available.");
|
||||
*aEnum = nullptr;
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// roll an nsCOMArray of all our permissions, then hand out an enumerator
|
||||
nsCOMArray<nsIPermission> array;
|
||||
|
||||
for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
|
||||
PermissionHashKey* entry = iter.Get();
|
||||
for (const auto& permEntry : entry->GetPermissions()) {
|
||||
|
@ -2610,11 +2595,6 @@ NS_IMETHODIMP nsPermissionManager::GetAllWithTypePrefix(const nsACString& aPrefi
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!aPrefix.IsEmpty() &&
|
||||
!StringBeginsWith(mTypeArray.ElementAt(permEntry.mType), aPrefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsresult rv = GetPrincipalFromOrigin(entry->GetKey()->mOrigin,
|
||||
getter_AddRefs(principal));
|
||||
|
@ -2622,7 +2602,7 @@ NS_IMETHODIMP nsPermissionManager::GetAllWithTypePrefix(const nsACString& aPrefi
|
|||
continue;
|
||||
}
|
||||
|
||||
RefPtr<nsIPermission> permission =
|
||||
nsCOMPtr<nsIPermission> permission =
|
||||
nsPermission::Create(principal,
|
||||
mTypeArray.ElementAt(permEntry.mType),
|
||||
permEntry.mPermission,
|
||||
|
@ -2631,11 +2611,11 @@ NS_IMETHODIMP nsPermissionManager::GetAllWithTypePrefix(const nsACString& aPrefi
|
|||
if (NS_WARN_IF(!permission)) {
|
||||
continue;
|
||||
}
|
||||
aResult.AppendElement(std::move(permission));
|
||||
array.AppendObject(permission);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_NewArrayEnumerator(aEnum, array, NS_GET_IID(nsIPermission));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPermissionManager::GetAllForURI(nsIURI* aURI, nsISimpleEnumerator **aEnum)
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function check_enumerator(prefix, permissions) {
|
||||
let pm = Cc["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Ci.nsIPermissionManager);
|
||||
|
||||
let array = pm.getAllWithTypePrefix(prefix);
|
||||
for (let [uri, type, capability] of permissions) {
|
||||
let perm = array.shift();
|
||||
Assert.ok(perm != null);
|
||||
Assert.ok(perm.principal.URI.equals(uri));
|
||||
Assert.equal(perm.type, type);
|
||||
Assert.equal(perm.capability, capability);
|
||||
Assert.equal(perm.expireType, pm.EXPIRE_NEVER);
|
||||
}
|
||||
Assert.equal(array.length, 0);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
let pm = Cc["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Ci.nsIPermissionManager);
|
||||
|
||||
let uri = NetUtil.newURI("http://example.com");
|
||||
let sub = NetUtil.newURI("http://sub.example.com");
|
||||
|
||||
check_enumerator("test/", [ ]);
|
||||
|
||||
pm.add(uri, "test/getallwithtypeprefix", pm.ALLOW_ACTION);
|
||||
pm.add(sub, "other-test/getallwithtypeprefix", pm.PROMPT_ACTION);
|
||||
check_enumerator("test/", [
|
||||
[ uri, "test/getallwithtypeprefix", pm.ALLOW_ACTION ],
|
||||
]);
|
||||
|
||||
pm.add(sub, "test/getallwithtypeprefix", pm.PROMPT_ACTION);
|
||||
check_enumerator("test/", [
|
||||
[ sub, "test/getallwithtypeprefix", pm.PROMPT_ACTION ],
|
||||
[ uri, "test/getallwithtypeprefix", pm.ALLOW_ACTION ],
|
||||
]);
|
||||
|
||||
check_enumerator("test/getallwithtypeprefix", [
|
||||
[ sub, "test/getallwithtypeprefix", pm.PROMPT_ACTION ],
|
||||
[ uri, "test/getallwithtypeprefix", pm.ALLOW_ACTION ],
|
||||
]);
|
||||
|
||||
// check that UNKNOWN_ACTION permissions are ignored
|
||||
pm.add(uri, "test/getallwithtypeprefix2", pm.UNKNOWN_ACTION);
|
||||
check_enumerator("test/", [
|
||||
[ sub, "test/getallwithtypeprefix", pm.PROMPT_ACTION ],
|
||||
[ uri, "test/getallwithtypeprefix", pm.ALLOW_ACTION ],
|
||||
]);
|
||||
|
||||
// check that permission updates are reflected
|
||||
pm.add(uri, "test/getallwithtypeprefix", pm.PROMPT_ACTION);
|
||||
check_enumerator("test/", [
|
||||
[ sub, "test/getallwithtypeprefix", pm.PROMPT_ACTION ],
|
||||
[ uri, "test/getallwithtypeprefix", pm.PROMPT_ACTION ],
|
||||
]);
|
||||
|
||||
// check that permission removals are reflected
|
||||
pm.remove(uri, "test/getallwithtypeprefix");
|
||||
check_enumerator("test/", [
|
||||
[ sub, "test/getallwithtypeprefix", pm.PROMPT_ACTION ],
|
||||
]);
|
||||
|
||||
pm.removeAll();
|
||||
check_enumerator("test/", [ ]);
|
||||
}
|
||||
|
|
@ -21,7 +21,6 @@ skip-if = true # Bug 863738
|
|||
[test_permmanager_defaults.js]
|
||||
[test_permmanager_expiration.js]
|
||||
[test_permmanager_getAllForURI.js]
|
||||
[test_permmanager_getAllWithTypePrefix.js]
|
||||
[test_permmanager_getPermissionObject.js]
|
||||
[test_permmanager_notifications.js]
|
||||
[test_permmanager_removeall.js]
|
||||
|
|
|
@ -125,16 +125,6 @@ interface nsIPermissionManager : nsISupports
|
|||
*/
|
||||
nsISimpleEnumerator getAllForPrincipal(in nsIPrincipal principal);
|
||||
|
||||
/**
|
||||
* Get all custom permissions of a specific type, specified with a prefix
|
||||
* string. This will return an array of all permissions which are not set to
|
||||
* default. Also the passed type argument is either equal to or a prefix of
|
||||
* the type of the returned permissions.
|
||||
*
|
||||
* @param prefix the type prefix string
|
||||
*/
|
||||
Array<nsIPermission> getAllWithTypePrefix(in ACString prefix);
|
||||
|
||||
/**
|
||||
* Add permission information for a given principal.
|
||||
* It is internally calling the other add() method using the nsIURI from the
|
||||
|
|
Загрузка…
Ссылка в новой задаче