зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1591803) for causing build bustages on XULAlerts.cpp CLOSED TREE
Backed out changeset 7eff50262110 (bug 1591803) Backed out changeset c0b6f37d24d2 (bug 1591803)
This commit is contained in:
Родитель
214c8d96df
Коммит
9c93bb3a7a
|
@ -793,7 +793,7 @@ var ThirdPartyCookies = {
|
|||
|
||||
// Cookie exceptions get "inherited" from parent- to sub-domain, so we need to
|
||||
// clear any cookie permissions from parent domains as well.
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (
|
||||
perm.type == "cookie" &&
|
||||
Services.eTLD.hasRootDomain(host, perm.principal.URI.host)
|
||||
|
|
|
@ -201,7 +201,9 @@ function promiseReloadPlugin(aId, aBrowser) {
|
|||
// after a test is done using the plugin doorhanger, we should just clear
|
||||
// any permissions that may have crept in
|
||||
function clearAllPluginPermissions() {
|
||||
for (let perm of Services.perms.all) {
|
||||
let perms = Services.perms.enumerator;
|
||||
while (perms.hasMoreElements()) {
|
||||
let perm = perms.getNext();
|
||||
if (perm.type.startsWith("plugin")) {
|
||||
info(
|
||||
"removing permission:" + perm.principal.origin + " " + perm.type + "\n"
|
||||
|
|
|
@ -8,7 +8,9 @@ const baseURL = getRootDirectory(gTestPath).replace(
|
|||
);
|
||||
|
||||
function clearAllPermissionsByPrefix(aPrefix) {
|
||||
for (let perm of Services.perms.all) {
|
||||
let perms = Services.perms.enumerator;
|
||||
while (perms.hasMoreElements()) {
|
||||
let perm = perms.getNext();
|
||||
if (perm.type.startsWith(aPrefix)) {
|
||||
Services.perms.removePermission(perm);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
// Bug 380852 - Delete permission manager entries in Clear Recent History
|
||||
|
||||
function countPermissions() {
|
||||
return Services.perms.all.length;
|
||||
let result = 0;
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
result++;
|
||||
enumerator.getNext();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
add_task(async function test() {
|
||||
|
@ -21,7 +27,7 @@ add_task(async function test() {
|
|||
|
||||
// Sanity check
|
||||
ok(
|
||||
!!Services.perms.all.length,
|
||||
Services.perms.enumerator.hasMoreElements(),
|
||||
"Permission manager should have elements, since we just added one"
|
||||
);
|
||||
|
||||
|
|
|
@ -1746,7 +1746,7 @@ BrowserGlue.prototype = {
|
|||
Services.telemetry.getHistogramById("COOKIE_BEHAVIOR").add(cookieBehavior);
|
||||
|
||||
let exceptions = 0;
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
if (permission.type == "trackingprotection") {
|
||||
exceptions++;
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ var gPermissionManager = {
|
|||
|
||||
_loadPermissions() {
|
||||
// load permissions into a table.
|
||||
for (let nextPermission of Services.perms.all) {
|
||||
for (let nextPermission of Services.perms.enumerator) {
|
||||
this._addPermissionToList(nextPermission);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -330,7 +330,7 @@ var gSitePermissionsManager = {
|
|||
|
||||
_loadPermissions() {
|
||||
// load permissions into a table.
|
||||
for (let nextPermission of Services.perms.all) {
|
||||
for (let nextPermission of Services.perms.enumerator) {
|
||||
this._addPermissionToList(nextPermission);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -94,7 +94,7 @@ var gTranslationExceptions = {
|
|||
|
||||
// Load site permissions into an array.
|
||||
this._sites = [];
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (
|
||||
perm.type == kPermissionType &&
|
||||
perm.capability == Services.perms.DENY_ACTION
|
||||
|
|
|
@ -46,7 +46,7 @@ function getLanguageExceptions() {
|
|||
|
||||
function getDomainExceptions() {
|
||||
let results = [];
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (
|
||||
perm.type == "translate" &&
|
||||
perm.capability == Services.perms.DENY_ACTION
|
||||
|
|
|
@ -94,7 +94,7 @@ var PermissionUITelemetry = {
|
|||
"microphone",
|
||||
"screen",
|
||||
];
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (!commonPermissions.includes(perm.type)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -907,7 +907,7 @@ async function sanitizeOnShutdown(progress) {
|
|||
progress.advancement = "session-permission";
|
||||
|
||||
// Let's see if we have to forget some particular site.
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
if (
|
||||
permission.type != "cookie" ||
|
||||
permission.capability != Ci.nsICookiePermission.ACCESS_SESSION
|
||||
|
@ -991,7 +991,7 @@ function cookiesAllowedForDomainOrSubDomain(principal) {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (perm.type != "cookie") {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -437,8 +437,10 @@ var SiteDataManager = {
|
|||
// we consider part of "site data and cookies".
|
||||
_getDeletablePermissions() {
|
||||
let perms = [];
|
||||
let enumerator = Services.perms.enumerator;
|
||||
|
||||
for (let permission of Services.perms.all) {
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let permission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
if (
|
||||
permission.type == "persistent-storage" ||
|
||||
permission.type == "storage-access"
|
||||
|
|
|
@ -593,6 +593,125 @@ nsresult NotificationPermissionRequest::ResolvePromise() {
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsIObserver)
|
||||
|
||||
NotificationTelemetryService::NotificationTelemetryService()
|
||||
: mDNDRecorded(false) {}
|
||||
|
||||
NotificationTelemetryService::~NotificationTelemetryService() {}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<NotificationTelemetryService>
|
||||
NotificationTelemetryService::GetInstance() {
|
||||
nsCOMPtr<nsISupports> telemetrySupports =
|
||||
do_GetService(NOTIFICATIONTELEMETRYSERVICE_CONTRACTID);
|
||||
if (!telemetrySupports) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<NotificationTelemetryService> telemetry =
|
||||
static_cast<NotificationTelemetryService*>(telemetrySupports.get());
|
||||
return telemetry.forget();
|
||||
}
|
||||
|
||||
nsresult NotificationTelemetryService::Init() {
|
||||
// Only perform permissions telemetry collection in the parent process.
|
||||
if (!XRE_IsParentProcess()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RecordPermissions();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void NotificationTelemetryService::RecordPermissions() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess(),
|
||||
"RecordPermissions may only be called in the parent process");
|
||||
|
||||
if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> permissionManager =
|
||||
services::GetPermissionManager();
|
||||
if (!permissionManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
nsresult rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
bool hasMoreElements;
|
||||
nsresult rv = enumerator->HasMoreElements(&hasMoreElements);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
if (!hasMoreElements) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsISupports> supportsPermission;
|
||||
rv = enumerator->GetNext(getter_AddRefs(supportsPermission));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
uint32_t capability;
|
||||
if (!GetNotificationPermission(supportsPermission, &capability)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NotificationTelemetryService::GetNotificationPermission(
|
||||
nsISupports* aSupports, uint32_t* aCapability) {
|
||||
nsCOMPtr<nsIPermission> permission = do_QueryInterface(aSupports);
|
||||
if (!permission) {
|
||||
return false;
|
||||
}
|
||||
nsAutoCString type;
|
||||
permission->GetType(type);
|
||||
if (!type.EqualsLiteral("desktop-notification")) {
|
||||
return false;
|
||||
}
|
||||
permission->GetCapability(aCapability);
|
||||
return true;
|
||||
}
|
||||
|
||||
void NotificationTelemetryService::RecordDNDSupported() {
|
||||
if (mDNDRecorded) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAlertsService> alertService = components::Alerts::Service();
|
||||
if (!alertService) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAlertsDoNotDisturb> alertServiceDND =
|
||||
do_QueryInterface(alertService);
|
||||
if (!alertServiceDND) {
|
||||
return;
|
||||
}
|
||||
|
||||
mDNDRecorded = true;
|
||||
bool isEnabled;
|
||||
nsresult rv = alertServiceDND->GetManualDoNotDisturb(&isEnabled);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Telemetry::Accumulate(Telemetry::ALERTS_SERVICE_DND_SUPPORTED_FLAG, true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NotificationTelemetryService::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Observer that the alert service calls to do common tasks and/or dispatch to
|
||||
// the specific observer for the context e.g. main thread, worker, or service
|
||||
// worker.
|
||||
|
@ -1065,6 +1184,13 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
IPC::Principal(mPrincipal));
|
||||
return NS_OK;
|
||||
} else if (!strcmp("alertshow", aTopic) || !strcmp("alertfinished", aTopic)) {
|
||||
RefPtr<NotificationTelemetryService> telemetry =
|
||||
NotificationTelemetryService::GetInstance();
|
||||
if (telemetry) {
|
||||
// Record whether "do not disturb" is supported after the first
|
||||
// notification, to account for falling back to XUL alerts.
|
||||
telemetry->RecordDNDSupported();
|
||||
}
|
||||
Unused << NS_WARN_IF(NS_FAILED(AdjustPushQuota(aTopic)));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#include "nsTHashtable.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
#define NOTIFICATIONTELEMETRYSERVICE_CONTRACTID \
|
||||
"@mozilla.org/notificationTelemetryService;1"
|
||||
|
||||
class nsIPrincipal;
|
||||
class nsIVariant;
|
||||
|
||||
|
@ -31,6 +34,29 @@ class Promise;
|
|||
class StrongWorkerRef;
|
||||
class WorkerPrivate;
|
||||
|
||||
// Records telemetry probes at application startup, when a notification is
|
||||
// shown, and when the notification permission is revoked for a site.
|
||||
class NotificationTelemetryService final : public nsIObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
NotificationTelemetryService();
|
||||
|
||||
static already_AddRefed<NotificationTelemetryService> GetInstance();
|
||||
|
||||
nsresult Init();
|
||||
void RecordDNDSupported();
|
||||
void RecordPermissions();
|
||||
|
||||
private:
|
||||
virtual ~NotificationTelemetryService();
|
||||
|
||||
bool GetNotificationPermission(nsISupports* aSupports, uint32_t* aCapability);
|
||||
|
||||
bool mDNDRecorded;
|
||||
};
|
||||
|
||||
/*
|
||||
* Notifications on workers introduce some lifetime issues. The property we
|
||||
* are trying to satisfy is:
|
||||
|
@ -94,6 +120,7 @@ class Notification : public DOMEventTargetHelper,
|
|||
friend class ServiceWorkerNotificationObserver;
|
||||
friend class WorkerGetRunnable;
|
||||
friend class WorkerNotificationObserver;
|
||||
friend class NotificationTelemetryService;
|
||||
|
||||
public:
|
||||
IMPL_EVENT_HANDLER(click)
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "nsPermission.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsILineInputStream.h"
|
||||
|
@ -2533,9 +2535,20 @@ nsPermissionManager::GetPermissionHashKey(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPermissionManager::GetAll(
|
||||
nsTArray<RefPtr<nsIPermission>>& aResult) {
|
||||
return GetAllWithTypePrefix(NS_LITERAL_CSTRING(""), aResult);
|
||||
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(
|
||||
|
|
|
@ -22,6 +22,11 @@ function do_finish_generator_test(generator) {
|
|||
});
|
||||
}
|
||||
|
||||
function do_count_array(all) {
|
||||
return all.length;
|
||||
function do_count_enumerator(enumerator) {
|
||||
let i = 0;
|
||||
for (let item of enumerator) {
|
||||
void item;
|
||||
++i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ add_task(async function do_test() {
|
|||
// be found.
|
||||
function findCapabilityViaEnum(origin = TEST_ORIGIN, type = TEST_PERMISSION) {
|
||||
let result = undefined;
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (perm.matchesURI(origin, true) && perm.type == type) {
|
||||
if (result !== undefined) {
|
||||
// we've already found one previously - that's bad!
|
||||
|
|
|
@ -195,7 +195,7 @@ add_task(async function test() {
|
|||
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
|
||||
|
||||
// Force initialization of the nsPermissionManager
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
let isExpected = false;
|
||||
|
||||
expected.forEach((it, i) => {
|
||||
|
|
|
@ -212,7 +212,7 @@ add_task(function test() {
|
|||
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
|
||||
|
||||
// Force initialization of the nsPermissionManager
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
let isExpected = false;
|
||||
|
||||
expected.forEach((it, i) => {
|
||||
|
|
|
@ -263,7 +263,7 @@ add_task(async function test() {
|
|||
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
|
||||
|
||||
// Force initialization of the nsPermissionManager
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
let isExpected = false;
|
||||
|
||||
expected.forEach((it, i) => {
|
||||
|
|
|
@ -117,7 +117,7 @@ add_task(function test() {
|
|||
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
|
||||
|
||||
// Force initialization of the nsPermissionManager
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
let isExpected = false;
|
||||
|
||||
expected.forEach((it, i) => {
|
||||
|
|
|
@ -263,7 +263,7 @@ add_task(async function test() {
|
|||
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
|
||||
|
||||
// Force initialization of the nsPermissionManager
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
let isExpected = false;
|
||||
|
||||
expected.forEach((it, i) => {
|
||||
|
|
|
@ -111,7 +111,7 @@ add_task(function test() {
|
|||
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
|
||||
|
||||
// Force initialization of the nsPermissionManager
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
let isExpected = false;
|
||||
|
||||
expected.forEach((it, i) => {
|
||||
|
|
|
@ -250,7 +250,7 @@ add_task(async function test() {
|
|||
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
|
||||
|
||||
// Force initialization of the nsPermissionManager
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
let isExpected = false;
|
||||
|
||||
expected.forEach((it, i) => {
|
||||
|
|
|
@ -187,7 +187,7 @@ add_task(async function test() {
|
|||
Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
|
||||
|
||||
// Force initialization of the nsPermissionManager
|
||||
for (let permission of Services.perms.all) {
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
let isExpected = false;
|
||||
|
||||
expected.forEach((it, i) => {
|
||||
|
|
|
@ -136,7 +136,7 @@ permission_observer.prototype = {
|
|||
} else if (data == "cleared") {
|
||||
// only clear once: at the end
|
||||
Assert.ok(!this.cleared);
|
||||
Assert.equal(do_count_array(Services.perms.all), 0);
|
||||
Assert.equal(do_count_enumerator(Services.perms.enumerator), 0);
|
||||
this.cleared = true;
|
||||
} else {
|
||||
do_throw("unexpected data '" + data + "'!");
|
||||
|
|
|
@ -9,7 +9,7 @@ function run_test() {
|
|||
Ci.nsIPermissionManager
|
||||
);
|
||||
|
||||
Assert.equal(pm.all.length, 0);
|
||||
Assert.equal(perm_count(), 0);
|
||||
|
||||
// add some permissions
|
||||
let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
|
||||
|
@ -32,10 +32,10 @@ function run_test() {
|
|||
pm.addFromPrincipal(principal3, "cucumber", 3);
|
||||
pm.addFromPrincipal(principal3, "apple", 1);
|
||||
|
||||
Assert.equal(pm.all.length, 7);
|
||||
Assert.equal(perm_count(), 7);
|
||||
|
||||
pm.removeByType("apple");
|
||||
Assert.equal(pm.all.length, 4);
|
||||
Assert.equal(perm_count(), 4);
|
||||
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal, "pear"), 1);
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal2, "pear"), 2);
|
||||
|
@ -48,7 +48,7 @@ function run_test() {
|
|||
Assert.equal(pm.testPermissionFromPrincipal(principal3, "cucumber"), 3);
|
||||
|
||||
pm.removeByType("cucumber");
|
||||
Assert.equal(pm.all.length, 2);
|
||||
Assert.equal(perm_count(), 2);
|
||||
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal, "pear"), 1);
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal2, "pear"), 2);
|
||||
|
@ -61,7 +61,7 @@ function run_test() {
|
|||
Assert.equal(pm.testPermissionFromPrincipal(principal3, "cucumber"), 0);
|
||||
|
||||
pm.removeByType("pear");
|
||||
Assert.equal(pm.all.length, 0);
|
||||
Assert.equal(perm_count(), 0);
|
||||
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal, "pear"), 0);
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal2, "pear"), 0);
|
||||
|
@ -72,4 +72,15 @@ function run_test() {
|
|||
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal, "cucumber"), 0);
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal3, "cucumber"), 0);
|
||||
|
||||
function perm_count() {
|
||||
let enumerator = pm.enumerator;
|
||||
let count = 0;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
count++;
|
||||
enumerator.getNext();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ add_task(async function test() {
|
|||
Ci.nsIPermissionManager
|
||||
);
|
||||
|
||||
Assert.equal(pm.all.length, 0);
|
||||
Assert.equal(perm_count(), 0);
|
||||
|
||||
// add some permissions
|
||||
let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
|
||||
|
@ -44,11 +44,11 @@ add_task(async function test() {
|
|||
pm.addFromPrincipal(principal3, "cucumber", 3);
|
||||
pm.addFromPrincipal(principal3, "apple", 1);
|
||||
|
||||
Assert.equal(pm.all.length, 7);
|
||||
Assert.equal(perm_count(), 7);
|
||||
|
||||
pm.removeByTypeSince("apple", since);
|
||||
|
||||
Assert.equal(pm.all.length, 5);
|
||||
Assert.equal(perm_count(), 5);
|
||||
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal, "pear"), 1);
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal2, "pear"), 2);
|
||||
|
@ -61,7 +61,7 @@ add_task(async function test() {
|
|||
Assert.equal(pm.testPermissionFromPrincipal(principal3, "cucumber"), 3);
|
||||
|
||||
pm.removeByTypeSince("cucumber", since);
|
||||
Assert.equal(pm.all.length, 4);
|
||||
Assert.equal(perm_count(), 4);
|
||||
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal, "pear"), 1);
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal2, "pear"), 2);
|
||||
|
@ -74,7 +74,7 @@ add_task(async function test() {
|
|||
Assert.equal(pm.testPermissionFromPrincipal(principal3, "cucumber"), 0);
|
||||
|
||||
pm.removeByTypeSince("pear", since);
|
||||
Assert.equal(pm.all.length, 3);
|
||||
Assert.equal(perm_count(), 3);
|
||||
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal, "pear"), 1);
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal2, "pear"), 0);
|
||||
|
@ -85,4 +85,15 @@ add_task(async function test() {
|
|||
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal, "cucumber"), 1);
|
||||
Assert.equal(pm.testPermissionFromPrincipal(principal3, "cucumber"), 0);
|
||||
|
||||
function perm_count() {
|
||||
let enumerator = pm.enumerator;
|
||||
let count = 0;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
count++;
|
||||
enumerator.getNext();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ function run_test() {
|
|||
Ci.nsIPermissionManager
|
||||
);
|
||||
|
||||
Assert.equal(pm.all.length, 0);
|
||||
Assert.equal(perm_count(), 0);
|
||||
|
||||
// add some permissions
|
||||
let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
|
||||
|
@ -30,27 +30,40 @@ function run_test() {
|
|||
pm.addFromPrincipal(principal2, "pear", 2);
|
||||
|
||||
// Make sure that removePermission doesn't remove more than one permission each time
|
||||
Assert.equal(pm.all.length, 5);
|
||||
Assert.equal(perm_count(), 5);
|
||||
|
||||
remove_one_by_type("apple");
|
||||
Assert.equal(pm.all.length, 4);
|
||||
Assert.equal(perm_count(), 4);
|
||||
|
||||
remove_one_by_type("apple");
|
||||
Assert.equal(pm.all.length, 3);
|
||||
Assert.equal(perm_count(), 3);
|
||||
|
||||
remove_one_by_type("pear");
|
||||
Assert.equal(pm.all.length, 2);
|
||||
Assert.equal(perm_count(), 2);
|
||||
|
||||
remove_one_by_type("cucumber");
|
||||
Assert.equal(pm.all.length, 1);
|
||||
Assert.equal(perm_count(), 1);
|
||||
|
||||
remove_one_by_type("pear");
|
||||
Assert.equal(pm.all.length, 0);
|
||||
Assert.equal(perm_count(), 0);
|
||||
|
||||
function perm_count() {
|
||||
let enumerator = pm.enumerator;
|
||||
let count = 0;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
count++;
|
||||
enumerator.getNext();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
function remove_one_by_type(type) {
|
||||
for (let perm of pm.all) {
|
||||
if (perm.type == type) {
|
||||
pm.removePermission(perm);
|
||||
let enumerator = pm.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let it = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
if (it.type == type) {
|
||||
pm.removePermission(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,6 +305,13 @@ Classes = [
|
|||
'headers': ['/dom/base/nsNoDataProtocolContentPolicy.h'],
|
||||
'categories': {'content-policy': '@mozilla.org/no-data-protocol-content-policy;1'},
|
||||
},
|
||||
{
|
||||
'cid': '{5995b782-6a0e-4066-aac5-276f0a9ad8cf}',
|
||||
'contract_ids': ['@mozilla.org/notificationTelemetryService;1'],
|
||||
'type': 'mozilla::dom::NotificationTelemetryService',
|
||||
'headers': ['mozilla/dom/Notification.h'],
|
||||
'init_method': 'Init',
|
||||
},
|
||||
{
|
||||
'cid': '{bd066e5f-146f-4472-8331-7bfd05b1ed90}',
|
||||
'contract_ids': ['@mozilla.org/nullprincipal;1'],
|
||||
|
|
|
@ -34,6 +34,7 @@ interface nsIObserver;
|
|||
interface nsIPrincipal;
|
||||
interface mozIDOMWindow;
|
||||
interface nsIPermission;
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsIRunnable;
|
||||
|
||||
%{ C++
|
||||
|
@ -204,10 +205,11 @@ interface nsIPermissionManager : nsISupports
|
|||
in boolean exactHost);
|
||||
|
||||
/**
|
||||
* Returns all stored permissions.
|
||||
* @return an array of nsIPermission objects
|
||||
* Allows enumeration of all stored permissions
|
||||
* @return an nsISimpleEnumerator interface that allows access to
|
||||
* nsIPermission objects
|
||||
*/
|
||||
readonly attribute Array<nsIPermission> all;
|
||||
readonly attribute nsISimpleEnumerator enumerator;
|
||||
|
||||
/**
|
||||
* Remove all permissions that will match the origin pattern.
|
||||
|
|
|
@ -71,8 +71,8 @@ function run_test() {
|
|||
);
|
||||
}
|
||||
|
||||
// test the all property ...
|
||||
var perms = pm.all;
|
||||
// test the enumerator ...
|
||||
var perms = Array.from(pm.enumerator);
|
||||
Assert.equal(perms.length, hosts.length);
|
||||
|
||||
// ... remove all the hosts ...
|
||||
|
@ -96,7 +96,7 @@ function run_test() {
|
|||
Assert.equal(perms.length, 0);
|
||||
|
||||
// ... and check the permmgr's empty
|
||||
Assert.equal(pm.all.length, 0);
|
||||
Assert.equal(pm.enumerator.hasMoreElements(), false);
|
||||
|
||||
// test UTF8 normalization behavior: expect ASCII/ACE host encodings
|
||||
var utf8 = "b\u00FCcher.dolske.org"; // "bücher.dolske.org"
|
||||
|
@ -106,14 +106,15 @@ function run_test() {
|
|||
{}
|
||||
);
|
||||
pm.addFromPrincipal(principal, "utf8", 1);
|
||||
Assert.notEqual(Services.perms.all.length, 0);
|
||||
var ace = Services.perms.all[0];
|
||||
var enumerator = pm.enumerator;
|
||||
Assert.equal(enumerator.hasMoreElements(), true);
|
||||
var ace = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
Assert.equal(ace.principal.URI.asciiHost, aceref);
|
||||
Assert.equal(Services.perms.all.length > 1, false);
|
||||
Assert.equal(enumerator.hasMoreElements(), false);
|
||||
|
||||
// test removeAll()
|
||||
pm.removeAll();
|
||||
Assert.equal(Services.perms.all.length, 0);
|
||||
Assert.equal(pm.enumerator.hasMoreElements(), false);
|
||||
|
||||
principal = secMan.createContentPrincipalFromOrigin(
|
||||
"https://www.example.com"
|
||||
|
@ -125,5 +126,5 @@ function run_test() {
|
|||
// Try to remove already deleted entry.
|
||||
perm = pm.getPermissionObject(principal, "offline-app", true);
|
||||
pm.removePermission(perm);
|
||||
Assert.equal(Services.perms.all.length, 0);
|
||||
Assert.equal(pm.enumerator.hasMoreElements(), false);
|
||||
}
|
||||
|
|
|
@ -712,7 +712,7 @@ const PushNotificationsCleaner = {
|
|||
const StorageAccessCleaner = {
|
||||
deleteByHost(aHost, aOriginAttributes) {
|
||||
return new Promise(aResolve => {
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (perm.type == "storageAccessAPI") {
|
||||
let toBeRemoved = false;
|
||||
try {
|
||||
|
@ -832,7 +832,7 @@ const AuthCacheCleaner = {
|
|||
const PermissionsCleaner = {
|
||||
deleteByHost(aHost, aOriginAttributes) {
|
||||
return new Promise(aResolve => {
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
let toBeRemoved;
|
||||
try {
|
||||
toBeRemoved = Services.eTLD.hasRootDomain(
|
||||
|
|
|
@ -422,7 +422,7 @@ LoginManager.prototype = {
|
|||
log.debug("Getting a list of all disabled origins");
|
||||
|
||||
let disabledHosts = [];
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (
|
||||
perm.type == PERMISSION_SAVE_LOGINS &&
|
||||
perm.capability == Services.perms.DENY_ACTION
|
||||
|
|
|
@ -74,7 +74,7 @@ function checkStorageData(storage, ref_disabledHosts, ref_logins) {
|
|||
|
||||
function getAllDisabledHostsFromPermissionManager() {
|
||||
let disabledHosts = [];
|
||||
for (let perm of Services.perms.all) {
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (
|
||||
perm.type == PERMISSION_SAVE_LOGINS &&
|
||||
perm.capability == Services.perms.DENY_ACTION
|
||||
|
|
|
@ -13349,6 +13349,15 @@
|
|||
"kind": "boolean",
|
||||
"description": "XUL-only: whether the user has toggled do not disturb."
|
||||
},
|
||||
"ALERTS_SERVICE_DND_SUPPORTED_FLAG": {
|
||||
"record_in_processes": ["main", "content"],
|
||||
"products": ["firefox", "fennec", "geckoview"],
|
||||
"alert_emails": ["firefox-dev@mozilla.org"],
|
||||
"bug_numbers": [1219030],
|
||||
"expires_in_version": "50",
|
||||
"kind": "flag",
|
||||
"description": "Whether the do not disturb option is supported. True if the browser uses XUL alerts."
|
||||
},
|
||||
"PLUGIN_DRAWING_MODEL": {
|
||||
"record_in_processes": ["main", "content"],
|
||||
"products": ["firefox", "fennec", "geckoview"],
|
||||
|
|
|
@ -1261,6 +1261,7 @@
|
|||
"A11Y_ISIMPLEDOM_USAGE_FLAG",
|
||||
"ADDON_FORBIDDEN_CPOW_USAGE",
|
||||
"ADDON_MANAGER_UPGRADE_UI_SHOWN",
|
||||
"ALERTS_SERVICE_DND_SUPPORTED_FLAG",
|
||||
"AUTO_REJECTED_TRANSLATION_OFFERS",
|
||||
"BROWSER_SHIM_USAGE_BLOCKED",
|
||||
"CANVAS_WEBGL_ACCL_FAILURE_ID",
|
||||
|
|
Загрузка…
Ссылка в новой задаче