Bug 933917 - Remove about:permissions. r=MattN

This commit is contained in:
Dão Gottwald 2015-11-13 11:18:27 +01:00
Родитель df98d344c4
Коммит 968573f431
19 изменённых файлов: 0 добавлений и 2179 удалений

Просмотреть файл

@ -32,7 +32,6 @@ function test() {
var urls = [
"about:config",
"about:addons",
"about:permissions"
];
function nextTest() {

Просмотреть файл

@ -93,8 +93,6 @@ static RedirEntry kRedirMap[] = {
{ "remote-newtab", "chrome://browser/content/remote-newtab/newTab.xhtml",
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
nsIAboutModule::ALLOW_SCRIPT },
{ "permissions", "chrome://browser/content/preferences/aboutPermissions.xul",
nsIAboutModule::ALLOW_SCRIPT },
{ "preferences", "chrome://browser/content/preferences/in-content/preferences.xul",
nsIAboutModule::ALLOW_SCRIPT },
{ "downloads", "chrome://browser/content/downloads/contentAreaDownloadsView.xul",

Просмотреть файл

@ -1,7 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
.site {
-moz-binding: url("chrome://browser/content/preferences/aboutPermissions.xml#site");
}

Просмотреть файл

@ -1,911 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var Ci = Components.interfaces;
var Cc = Components.classes;
var Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/DownloadUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/ForgetAboutSite.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
var gSecMan = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager);
var gFaviconService = Cc["@mozilla.org/browser/favicon-service;1"].
getService(Ci.nsIFaviconService);
var gPlacesDatabase = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsPIPlacesDatabase).
DBConnection.
clone(true);
var gSitesStmt = gPlacesDatabase.createAsyncStatement(
"SELECT url " +
"FROM moz_places " +
"WHERE rev_host > '.' " +
"AND visit_count > 0 " +
"GROUP BY rev_host " +
"ORDER BY MAX(frecency) DESC " +
"LIMIT :limit");
var gVisitStmt = gPlacesDatabase.createAsyncStatement(
"SELECT SUM(visit_count) AS count " +
"FROM moz_places " +
"WHERE rev_host = :rev_host");
/**
* Permission types that should be tested with testExactPermission, as opposed
* to testPermission. This is based on what consumers use to test these permissions.
*/
var TEST_EXACT_PERM_TYPES = ["geo", "camera", "microphone", "desktop-notification"];
/**
* Site object represents a single site, uniquely identified by a principal.
*/
function Site(principal) {
this.principal = principal;
this.listitem = null;
}
Site.prototype = {
/**
* Gets the favicon to use for the site. The callback only gets called if
* a favicon is found for either the http URI or the https URI.
*
* @param aCallback
* A callback function that takes a favicon image URL as a parameter.
*/
getFavicon: function Site_getFavicon(aCallback) {
function invokeCallback(aFaviconURI) {
try {
// Use getFaviconLinkForIcon to get image data from the database instead
// of using the favicon URI to fetch image data over the network.
aCallback(gFaviconService.getFaviconLinkForIcon(aFaviconURI).spec);
} catch (e) {
Cu.reportError("AboutPermissions: " + e);
}
}
// Get the favicon for the origin
gFaviconService.getFaviconURLForPage(this.principal.URI, function (aURI) {
if (aURI) {
invokeCallback(aURI);
}
}.bind(this));
},
/**
* Gets the number of history visits for the site.
*
* @param aCallback
* A function that takes the visit count (a number) as a parameter.
*/
getVisitCount: function Site_getVisitCount(aCallback) {
// XXX This won't be a very reliable system, as it will count both http: and https: visits
// Unfortunately, I don't think that there is a much better way to do it right now.
let rev_host = this.principal.URI.host.split("").reverse().join("") + ".";
gVisitStmt.params.rev_host = rev_host;
gVisitStmt.executeAsync({
handleResult: function(aResults) {
let row = aResults.getNextRow();
let count = row.getResultByName("count") || 0;
try {
aCallback(count);
} catch (e) {
Cu.reportError("AboutPermissions: " + e);
}
},
handleError: function(aError) {
Cu.reportError("AboutPermissions: " + aError);
},
handleCompletion: function(aReason) {
}
});
},
/**
* Gets the permission value stored for a specified permission type.
*
* @param aType
* The permission type string stored in permission manager.
* e.g. "cookie", "geo", "indexedDB", "popup", "image"
* @param aResultObj
* An object that stores the permission value set for aType.
*
* @return A boolean indicating whether or not a permission is set.
*/
getPermission: function Site_getPermission(aType, aResultObj) {
// Password saving isn't a nsIPermissionManager permission type, so handle
// it seperately.
if (aType == "password") {
aResultObj.value = this.loginSavingEnabled ?
Ci.nsIPermissionManager.ALLOW_ACTION :
Ci.nsIPermissionManager.DENY_ACTION;
return true;
}
let permissionValue;
if (TEST_EXACT_PERM_TYPES.indexOf(aType) == -1) {
permissionValue = Services.perms.testPermissionFromPrincipal(this.principal, aType);
} else {
permissionValue = Services.perms.testExactPermissionFromPrincipal(this.principal, aType);
}
aResultObj.value = permissionValue;
return permissionValue != Ci.nsIPermissionManager.UNKNOWN_ACTION;
},
/**
* Sets a permission for the site given a permission type and value.
*
* @param aType
* The permission type string stored in permission manager.
* e.g. "cookie", "geo", "indexedDB", "popup", "image"
* @param aPerm
* The permission value to set for the permission type. This should
* be one of the constants defined in nsIPermissionManager.
*/
setPermission: function Site_setPermission(aType, aPerm) {
// Password saving isn't a nsIPermissionManager permission type, so handle
// it seperately.
if (aType == "password") {
this.loginSavingEnabled = aPerm == Ci.nsIPermissionManager.ALLOW_ACTION;
return;
}
Services.perms.addFromPrincipal(this.principal, aType, aPerm);
},
/**
* Clears a user-set permission value for the site given a permission type.
*
* @param aType
* The permission type string stored in permission manager.
* e.g. "cookie", "geo", "indexedDB", "popup", "image"
*/
clearPermission: function Site_clearPermission(aType) {
Services.perms.removeFromPrincipal(this.principal, aType);
},
/**
* Gets cookies stored for the site. This does not return cookies stored
* for the base domain, only the exact hostname stored for the site.
*
* @return An array of the cookies set for the site.
*/
get cookies() {
let host = this.principal.URI.host;
let cookies = [];
let enumerator = Services.cookies.getCookiesFromHost(host);
while (enumerator.hasMoreElements()) {
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
// getCookiesFromHost returns cookies for base domain, but we only want
// the cookies for the exact domain.
if (cookie.rawHost == host) {
cookies.push(cookie);
}
}
return cookies;
},
/**
* Removes a set of specific cookies from the browser.
*/
clearCookies: function Site_clearCookies() {
this.cookies.forEach(function(aCookie) {
Services.cookies.remove(aCookie.host, aCookie.name, aCookie.path, false);
});
},
/**
* Gets logins stored for the site.
*
* @return An array of the logins stored for the site.
*/
get logins() {
let logins = Services.logins.findLogins({}, this.principal.originNoSuffix, "", "");
return logins;
},
get loginSavingEnabled() {
return Services.logins.getLoginSavingEnabled(this.principal.originNoSuffix);
},
set loginSavingEnabled(isEnabled) {
Services.logins.setLoginSavingEnabled(this.principal.originNoSuffix, isEnabled);
},
/**
* Removes all data from the browser corresponding to the site.
*/
forgetSite: function Site_forgetSite() {
// XXX This removes data for an entire domain, rather than just
// an origin. This may produce confusing results, as data will
// be cleared for the http:// as well as the https:// domain
// if you try to forget the https:// site.
ForgetAboutSite.removeDataFromDomain(this.principal.URI.host);
}
}
/**
* PermissionDefaults object keeps track of default permissions for sites based
* on global preferences.
*
* Inspired by pageinfo/permissions.js
*/
var PermissionDefaults = {
UNKNOWN: Ci.nsIPermissionManager.UNKNOWN_ACTION, // 0
ALLOW: Ci.nsIPermissionManager.ALLOW_ACTION, // 1
DENY: Ci.nsIPermissionManager.DENY_ACTION, // 2
SESSION: Ci.nsICookiePermission.ACCESS_SESSION, // 8
get password() {
if (Services.prefs.getBoolPref("signon.rememberSignons")) {
return this.ALLOW;
}
return this.DENY;
},
set password(aValue) {
let value = (aValue != this.DENY);
Services.prefs.setBoolPref("signon.rememberSignons", value);
},
// For use with network.cookie.* prefs.
COOKIE_ACCEPT: 0,
COOKIE_DENY: 2,
COOKIE_NORMAL: 0,
COOKIE_SESSION: 2,
get cookie() {
if (Services.prefs.getIntPref("network.cookie.cookieBehavior") == this.COOKIE_DENY) {
return this.DENY;
}
if (Services.prefs.getIntPref("network.cookie.lifetimePolicy") == this.COOKIE_SESSION) {
return this.SESSION;
}
return this.ALLOW;
},
set cookie(aValue) {
let value = (aValue == this.DENY) ? this.COOKIE_DENY : this.COOKIE_ACCEPT;
Services.prefs.setIntPref("network.cookie.cookieBehavior", value);
let lifetimeValue = aValue == this.SESSION ? this.COOKIE_SESSION :
this.COOKIE_NORMAL;
Services.prefs.setIntPref("network.cookie.lifetimePolicy", lifetimeValue);
},
get geo() {
if (!Services.prefs.getBoolPref("geo.enabled")) {
return this.DENY;
}
// We always ask for permission to share location with a specific site, so
// there is no global ALLOW.
return this.UNKNOWN;
},
set geo(aValue) {
let value = (aValue != this.DENY);
Services.prefs.setBoolPref("geo.enabled", value);
},
get indexedDB() {
if (!Services.prefs.getBoolPref("dom.indexedDB.enabled")) {
return this.DENY;
}
// We always ask for permission to enable indexedDB storage for a specific
// site, so there is no global ALLOW.
return this.UNKNOWN;
},
set indexedDB(aValue) {
let value = (aValue != this.DENY);
Services.prefs.setBoolPref("dom.indexedDB.enabled", value);
},
get popup() {
if (Services.prefs.getBoolPref("dom.disable_open_during_load")) {
return this.DENY;
}
return this.ALLOW;
},
set popup(aValue) {
let value = (aValue == this.DENY);
Services.prefs.setBoolPref("dom.disable_open_during_load", value);
},
get ["desktop-notification"]() {
return this.UNKNOWN;
},
get camera() {
return this.UNKNOWN;
},
get microphone() {
return this.UNKNOWN;
}
};
/**
* AboutPermissions manages the about:permissions page.
*/
var AboutPermissions = {
/**
* Number of sites to return from the places database.
*/
PLACES_SITES_LIMIT: 50,
/**
* When adding sites to the dom sites-list, divide workload into intervals.
*/
LIST_BUILD_CHUNK: 5, // interval size
LIST_BUILD_DELAY: 100, // delay between intervals
/**
* Stores a mapping of origin strings to Site objects.
*/
_sites: {},
/**
* Using a getter for sitesFilter to avoid races with tests.
*/
get sitesFilter () {
delete this.sitesFilter;
return this.sitesFilter = document.getElementById("sites-filter");
},
sitesList: null,
_selectedSite: null,
/**
* For testing, track initializations so we can send notifications
*/
_initPlacesDone: false,
_initServicesDone: false,
/**
* This reflects the permissions that we expose in the UI. These correspond
* to permission type strings in the permission manager, PermissionDefaults,
* and element ids in aboutPermissions.xul.
*
* Potential future additions: "sts/use", "sts/subd"
*/
_supportedPermissions: ["password", "cookie", "geo", "indexedDB", "popup",
"camera", "microphone", "desktop-notification"],
/**
* Permissions that don't have a global "Allow" option.
*/
_noGlobalAllow: ["geo", "indexedDB", "camera", "microphone",
"desktop-notification"],
/**
* Permissions that don't have a global "Deny" option.
*/
_noGlobalDeny: ["camera", "microphone", "desktop-notification"],
_stringBundle: Services.strings.
createBundle("chrome://browser/locale/preferences/aboutPermissions.properties"),
/**
* Called on page load.
*/
init: function() {
this.sitesList = document.getElementById("sites-list");
this.getSitesFromPlaces();
this.enumerateServicesGenerator = this.getEnumerateServicesGenerator();
setTimeout(this.enumerateServicesDriver.bind(this), this.LIST_BUILD_DELAY);
// Attach observers in case data changes while the page is open.
Services.prefs.addObserver("signon.rememberSignons", this, false);
Services.prefs.addObserver("network.cookie.", this, false);
Services.prefs.addObserver("geo.enabled", this, false);
Services.prefs.addObserver("dom.push.enabled", this, false);
Services.prefs.addObserver("dom.indexedDB.enabled", this, false);
Services.prefs.addObserver("dom.disable_open_during_load", this, false);
Services.prefs.addObserver("dom.push.enabled", this, false);
Services.obs.addObserver(this, "perm-changed", false);
Services.obs.addObserver(this, "passwordmgr-storage-changed", false);
Services.obs.addObserver(this, "cookie-changed", false);
Services.obs.addObserver(this, "browser:purge-domain-data", false);
this._observersInitialized = true;
Services.obs.notifyObservers(null, "browser-permissions-preinit", null);
},
/**
* Called on page unload.
*/
cleanUp: function() {
if (this._observersInitialized) {
Services.prefs.removeObserver("signon.rememberSignons", this, false);
Services.prefs.removeObserver("network.cookie.", this, false);
Services.prefs.removeObserver("geo.enabled", this, false);
Services.prefs.removeObserver("dom.push.enabled", this, false);
Services.prefs.removeObserver("dom.indexedDB.enabled", this, false);
Services.prefs.removeObserver("dom.disable_open_during_load", this, false);
Services.prefs.removeObserver("dom.push.enabled", this, false);
Services.obs.removeObserver(this, "perm-changed");
Services.obs.removeObserver(this, "passwordmgr-storage-changed");
Services.obs.removeObserver(this, "cookie-changed");
Services.obs.removeObserver(this, "browser:purge-domain-data");
}
gSitesStmt.finalize();
gVisitStmt.finalize();
gPlacesDatabase.asyncClose(null);
},
observe: function (aSubject, aTopic, aData) {
switch(aTopic) {
case "perm-changed":
// Permissions changes only affect individual sites.
if (!this._selectedSite) {
break;
}
// aSubject is null when nsIPermisionManager::removeAll() is called.
if (!aSubject) {
this._supportedPermissions.forEach(function(aType){
this.updatePermission(aType);
}, this);
break;
}
let permission = aSubject.QueryInterface(Ci.nsIPermission);
// We can't compare selectedSite.principal and permission.principal here
// because we need to handle the case where a parent domain was changed
// in a way that affects the subdomain.
if (this._supportedPermissions.indexOf(permission.type) != -1) {
this.updatePermission(permission.type);
}
break;
case "nsPref:changed":
this._supportedPermissions.forEach(function(aType){
this.updatePermission(aType);
}, this);
break;
case "passwordmgr-storage-changed":
this.updatePermission("password");
if (this._selectedSite) {
this.updatePasswordsCount();
}
break;
case "cookie-changed":
if (this._selectedSite) {
this.updateCookiesCount();
}
break;
case "browser:purge-domain-data":
this.deleteFromSitesList(aData);
break;
}
},
/**
* Creates Site objects for the top-frecency sites in the places database and stores
* them in _sites. The number of sites created is controlled by PLACES_SITES_LIMIT.
*/
getSitesFromPlaces: function() {
gSitesStmt.params.limit = this.PLACES_SITES_LIMIT;
gSitesStmt.executeAsync({
handleResult: function(aResults) {
AboutPermissions.startSitesListBatch();
let row;
while (row = aResults.getNextRow()) {
let spec = row.getResultByName("url");
let uri = NetUtil.newURI(spec);
let principal = gSecMan.createCodebasePrincipal(uri, {});
AboutPermissions.addPrincipal(principal);
}
AboutPermissions.endSitesListBatch();
},
handleError: function(aError) {
Cu.reportError("AboutPermissions: " + aError);
},
handleCompletion: function(aReason) {
// Notify oberservers for testing purposes.
AboutPermissions._initPlacesDone = true;
if (AboutPermissions._initServicesDone) {
Services.obs.notifyObservers(null, "browser-permissions-initialized", null);
}
}
});
},
/**
* Drives getEnumerateServicesGenerator to work in intervals.
*/
enumerateServicesDriver: function() {
if (this.enumerateServicesGenerator.next()) {
// Build top sitesList items faster so that the list never seems sparse
let delay = Math.min(this.sitesList.itemCount * 5, this.LIST_BUILD_DELAY);
setTimeout(this.enumerateServicesDriver.bind(this), delay);
} else {
this.enumerateServicesGenerator.close();
this._initServicesDone = true;
if (this._initPlacesDone) {
Services.obs.notifyObservers(null, "browser-permissions-initialized", null);
}
}
},
/**
* Finds sites that have non-default permissions and creates Site objects for
* them if they are not already stored in _sites.
*/
getEnumerateServicesGenerator: function() {
let itemCnt = 1;
let logins = Services.logins.getAllLogins();
logins.forEach(function(aLogin) {
if (itemCnt % this.LIST_BUILD_CHUNK == 0) {
yield true;
}
try {
// aLogin.hostname is a string in origin URL format (e.g. "http://foo.com")
let uri = NetUtil.newURI(aLogin.hostname);
let principal = gSecMan.createCodebasePrincipal(uri, {});
this.addPrincipal(principal);
} catch (e) {
// newURI will throw for add-ons logins stored in chrome:// URIs
}
itemCnt++;
}, this);
let disabledHosts = Services.logins.getAllDisabledHosts();
disabledHosts.forEach(function(aHostname) {
if (itemCnt % this.LIST_BUILD_CHUNK == 0) {
yield true;
}
try {
// aHostname is a string in origin URL format (e.g. "http://foo.com")
let uri = NetUtil.newURI(aHostname);
let principal = gSecMan.createCodebasePrincipal(uri, {});
this.addPrincipal(principal);
} catch (e) {
// newURI will throw for add-ons logins stored in chrome:// URIs
}
itemCnt++;
}, this);
let enumerator = Services.perms.enumerator;
while (enumerator.hasMoreElements()) {
if (itemCnt % this.LIST_BUILD_CHUNK == 0) {
yield true;
}
let permission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
// Only include sites with exceptions set for supported permission types.
if (this._supportedPermissions.indexOf(permission.type) != -1) {
this.addPrincipal(permission.principal);
}
itemCnt++;
}
yield false;
},
/**
* Creates a new Site and adds it to _sites if it's not already there.
*
* @param aPrincipal
* A principal.
*/
addPrincipal: function(aPrincipal) {
if (aPrincipal.origin in this._sites) {
return;
}
let site = new Site(aPrincipal);
this._sites[aPrincipal.origin] = site;
this.addToSitesList(site);
},
/**
* Populates sites-list richlistbox with data from Site object.
*
* @param aSite
* A Site object.
*/
addToSitesList: function(aSite) {
let item = document.createElement("richlistitem");
item.setAttribute("class", "site");
item.setAttribute("value", aSite.principal.origin);
aSite.getFavicon(function(aURL) {
item.setAttribute("favicon", aURL);
});
aSite.listitem = item;
// Make sure to only display relevant items when list is filtered
let filterValue = this.sitesFilter.value.toLowerCase();
item.collapsed = aSite.principal.origin.toLowerCase().indexOf(filterValue) == -1;
(this._listFragment || this.sitesList).appendChild(item);
},
startSitesListBatch: function () {
if (!this._listFragment)
this._listFragment = document.createDocumentFragment();
},
endSitesListBatch: function () {
if (this._listFragment) {
this.sitesList.appendChild(this._listFragment);
this._listFragment = null;
}
},
/**
* Hides sites in richlistbox based on search text in sites-filter textbox.
*/
filterSitesList: function() {
let siteItems = this.sitesList.children;
let filterValue = this.sitesFilter.value.toLowerCase();
if (filterValue == "") {
for (let i = 0; i < siteItems.length; i++) {
siteItems[i].collapsed = false;
}
return;
}
for (let i = 0; i < siteItems.length; i++) {
let siteValue = siteItems[i].value.toLowerCase();
siteItems[i].collapsed = siteValue.indexOf(filterValue) == -1;
}
},
/**
* Removes all evidence of the selected site. The "forget this site" observer
* will call deleteFromSitesList to update the UI.
*/
forgetSite: function() {
this._selectedSite.forgetSite();
},
/**
* Deletes sites for a host and all of its sub-domains. Removes these sites
* from _sites and removes their corresponding elements from the DOM.
*
* @param aHost
* The host string corresponding to the site to delete.
*/
deleteFromSitesList: function(aHost) {
for (let origin in this._sites) {
let site = this._sites[origin];
if (site.principal.URI.host.hasRootDomain(aHost)) {
if (site == this._selectedSite) {
// Replace site-specific interface with "All Sites" interface.
this.sitesList.selectedItem = document.getElementById("all-sites-item");
}
this.sitesList.removeChild(site.listitem);
delete this._sites[site.principal.origin];
}
}
},
/**
* Shows interface for managing site-specific permissions.
*/
onSitesListSelect: function(event) {
if (event.target.selectedItem.id == "all-sites-item") {
// Clear the header label value from the previously selected site.
document.getElementById("site-label").value = "";
this.manageDefaultPermissions();
return;
}
let origin = event.target.value;
let site = this._selectedSite = this._sites[origin];
document.getElementById("site-label").value = origin;
document.getElementById("header-deck").selectedPanel =
document.getElementById("site-header");
this.updateVisitCount();
this.updatePermissionsBox();
},
/**
* Shows interface for managing default permissions. This corresponds to
* the "All Sites" list item.
*/
manageDefaultPermissions: function() {
this._selectedSite = null;
document.getElementById("header-deck").selectedPanel =
document.getElementById("defaults-header");
this.updatePermissionsBox();
},
/**
* Updates permissions interface based on selected site.
*/
updatePermissionsBox: function() {
this._supportedPermissions.forEach(function(aType){
this.updatePermission(aType);
}, this);
this.updatePasswordsCount();
this.updateCookiesCount();
},
/**
* Sets menulist for a given permission to the correct state, based on the
* stored permission.
*
* @param aType
* The permission type string stored in permission manager.
* e.g. "cookie", "geo", "indexedDB", "popup", "image"
*/
updatePermission: function(aType) {
let allowItem = document.getElementById(aType + "-" + PermissionDefaults.ALLOW);
allowItem.hidden = !this._selectedSite &&
this._noGlobalAllow.indexOf(aType) != -1;
let denyItem = document.getElementById(aType + "-" + PermissionDefaults.DENY);
denyItem.hidden = !this._selectedSite &&
this._noGlobalDeny.indexOf(aType) != -1;
let permissionMenulist = document.getElementById(aType + "-menulist");
let permissionValue;
if (!this._selectedSite) {
// If there is no selected site, we are updating the default permissions interface.
permissionValue = PermissionDefaults[aType];
if (aType == "cookie")
// cookie-9 corresponds to ALLOW_FIRST_PARTY_ONLY, which is reserved
// for site-specific preferences only.
document.getElementById("cookie-9").hidden = true;
} else {
if (aType == "cookie")
document.getElementById("cookie-9").hidden = false;
let result = {};
permissionValue = this._selectedSite.getPermission(aType, result) ?
result.value : PermissionDefaults[aType];
}
permissionMenulist.selectedItem = document.getElementById(aType + "-" + permissionValue);
},
onPermissionCommand: function(event) {
let permissionType = event.currentTarget.getAttribute("type");
let permissionValue = event.target.value;
if (!this._selectedSite) {
// If there is no selected site, we are setting the default permission.
PermissionDefaults[permissionType] = permissionValue;
} else {
this._selectedSite.setPermission(permissionType, permissionValue);
}
},
updateVisitCount: function() {
this._selectedSite.getVisitCount(function(aCount) {
let visitForm = AboutPermissions._stringBundle.GetStringFromName("visitCount");
let visitLabel = PluralForm.get(aCount, visitForm)
.replace("#1", aCount);
document.getElementById("site-visit-count").value = visitLabel;
});
},
updatePasswordsCount: function() {
if (!this._selectedSite) {
document.getElementById("passwords-count").hidden = true;
document.getElementById("passwords-manage-all-button").hidden = false;
return;
}
let passwordsCount = this._selectedSite.logins.length;
let passwordsForm = this._stringBundle.GetStringFromName("passwordsCount");
let passwordsLabel = PluralForm.get(passwordsCount, passwordsForm)
.replace("#1", passwordsCount);
document.getElementById("passwords-label").value = passwordsLabel;
document.getElementById("passwords-manage-button").disabled = (passwordsCount < 1);
document.getElementById("passwords-manage-all-button").hidden = true;
document.getElementById("passwords-count").hidden = false;
},
/**
* Opens password manager dialog.
*/
managePasswords: function() {
let selectedOrigin = "";
if (this._selectedSite) {
selectedOrigin = this._selectedSite.principal.URI.prePath;
}
let win = Services.wm.getMostRecentWindow("Toolkit:PasswordManager");
if (win) {
win.setFilter(selectedOrigin);
win.focus();
} else {
window.openDialog("chrome://passwordmgr/content/passwordManager.xul",
"Toolkit:PasswordManager", "", {filterString : selectedOrigin});
}
},
updateCookiesCount: function() {
if (!this._selectedSite) {
document.getElementById("cookies-count").hidden = true;
document.getElementById("cookies-clear-all-button").hidden = false;
document.getElementById("cookies-manage-all-button").hidden = false;
return;
}
let cookiesCount = this._selectedSite.cookies.length;
let cookiesForm = this._stringBundle.GetStringFromName("cookiesCount");
let cookiesLabel = PluralForm.get(cookiesCount, cookiesForm)
.replace("#1", cookiesCount);
document.getElementById("cookies-label").value = cookiesLabel;
document.getElementById("cookies-clear-button").disabled = (cookiesCount < 1);
document.getElementById("cookies-manage-button").disabled = (cookiesCount < 1);
document.getElementById("cookies-clear-all-button").hidden = true;
document.getElementById("cookies-manage-all-button").hidden = true;
document.getElementById("cookies-count").hidden = false;
},
/**
* Clears cookies for the selected site.
*/
clearCookies: function() {
if (!this._selectedSite) {
return;
}
let site = this._selectedSite;
site.clearCookies(site.cookies);
this.updateCookiesCount();
},
/**
* Opens cookie manager dialog.
*/
manageCookies: function() {
// Cookies are stored by-host, and thus we filter the cookie window
// using only the host of the selected principal's origin
let selectedHost = "";
if (this._selectedSite) {
selectedHost = this._selectedSite.principal.URI.host;
}
let win = Services.wm.getMostRecentWindow("Browser:Cookies");
if (win) {
win.gCookiesWindow.setFilter(selectedHost);
win.focus();
} else {
window.openDialog("chrome://browser/content/preferences/cookies.xul",
"Browser:Cookies", "", {filterString : selectedHost});
}
},
/**
* Focusses the filter box.
*/
focusFilterBox: function() {
this.sitesFilter.focus();
}
}
// See nsPrivateBrowsingService.js
String.prototype.hasRootDomain = function hasRootDomain(aDomain) {
let index = this.indexOf(aDomain);
if (index == -1)
return false;
if (this == aDomain)
return true;
let prevChar = this[index - 1];
return (index == (this.length - aDomain.length)) &&
(prevChar == "." || prevChar == "/");
}

Просмотреть файл

@ -1,18 +0,0 @@
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE bindings>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="site" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
<content>
<xul:hbox class="site-container" align="center" flex="1">
<xul:image xbl:inherits="src=favicon" class="site-favicon"/>
<xul:label xbl:inherits="value,selected" class="site-domain" crop="end" flex="1"/>
</xul:hbox>
</content>
</binding>
</bindings>

Просмотреть файл

@ -1,266 +0,0 @@
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/preferences/aboutPermissions.css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/aboutPermissions.css"?>
<!DOCTYPE page [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD;
<!ENTITY % aboutPermissionsDTD SYSTEM "chrome://browser/locale/preferences/aboutPermissions.dtd" >
%aboutPermissionsDTD;
]>
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
id="permissions-page" title="&permissionsManager.title;"
onload="AboutPermissions.init();"
onunload="AboutPermissions.cleanUp();"
disablefastfind="true"
role="application">
<script type="application/javascript"
src="chrome://browser/content/preferences/aboutPermissions.js"/>
<keyset>
<key key="&focusSearch.key;" modifiers="accel" oncommand="AboutPermissions.focusFilterBox();"/>
</keyset>
<hbox flex="1" id="permissions-content" class="main-content">
<vbox id="sites-box">
<textbox id="sites-filter"
emptytext="&sites.search;"
oncommand="AboutPermissions.filterSitesList();"
type="search"/>
<richlistbox id="sites-list"
flex="1"
class="list"
onselect="AboutPermissions.onSitesListSelect(event);">
<richlistitem id="all-sites-item"
class="site"
value="&sites.allSites;"/>
</richlistbox>
</vbox>
<vbox id="permissions-box" flex="1">
<deck id="header-deck">
<hbox id="site-header" class="pref-item" align="center">
<description id="site-description">
&header.site.start;<label id="site-label"/>&header.site.end;
</description>
<label id="site-visit-count"/>
<spacer flex="1"/>
<button id="forget-site-button"
label="&permissions.forgetSite;"
oncommand="AboutPermissions.forgetSite();"/>
</hbox>
<hbox id="defaults-header" class="pref-item" align="center">
<description id="defaults-description">
&header.defaults;
</description>
</hbox>
</deck>
<vbox id="permissions-list" flex="1">
<!-- Passwords -->
<hbox id="password-pref-item"
class="pref-item" align="top">
<image class="pref-icon" type="password"/>
<vbox>
<label class="pref-title" value="&password.label;"/>
<hbox align="center">
<menulist id="password-menulist"
class="pref-menulist"
type="password"
oncommand="AboutPermissions.onPermissionCommand(event);">
<menupopup>
<menuitem id="password-1" value="1" label="&permission.allow;"/>
<menuitem id="password-2" value="2" label="&permission.block;"/>
</menupopup>
</menulist>
<button id="passwords-manage-all-button"
label="&password.manage;"
oncommand="AboutPermissions.managePasswords();"/>
</hbox>
<hbox id="passwords-count" align="center">
<label id="passwords-label"/>
<button id="passwords-manage-button"
label="&password.manage;"
oncommand="AboutPermissions.managePasswords();"/>
</hbox>
</vbox>
</hbox>
<!-- Geolocation -->
<hbox id="geo-pref-item"
class="pref-item" align="top">
<image class="pref-icon" type="geo"/>
<vbox>
<label class="pref-title" value="&geo.label;"/>
<hbox>
<menulist id="geo-menulist"
class="pref-menulist"
type="geo"
oncommand="AboutPermissions.onPermissionCommand(event);">
<menupopup>
<menuitem id="geo-0" value="0" label="&permission.alwaysAsk;"/>
<menuitem id="geo-1" value="1" label="&permission.allow;"/>
<menuitem id="geo-2" value="2" label="&permission.block;"/>
</menupopup>
</menulist>
</hbox>
</vbox>
</hbox>
<!-- Camera -->
<hbox id="camera-pref-item"
class="pref-item" align="top">
<image class="pref-icon" type="camera"/>
<vbox>
<label class="pref-title" value="&camera.label;"/>
<hbox align="center">
<menulist id="camera-menulist"
class="pref-menulist"
type="camera"
oncommand="AboutPermissions.onPermissionCommand(event);">
<menupopup>
<menuitem id="camera-0" value="0" label="&permission.alwaysAsk;"/>
<menuitem id="camera-1" value="1" label="&permission.allow;"/>
<menuitem id="camera-2" value="2" label="&permission.block;"/>
</menupopup>
</menulist>
</hbox>
</vbox>
</hbox>
<!-- Microphone -->
<hbox id="microphone-pref-item"
class="pref-item" align="top">
<image class="pref-icon" type="microphone"/>
<vbox>
<label class="pref-title" value="&microphone.label;"/>
<hbox align="center">
<menulist id="microphone-menulist"
class="pref-menulist"
type="microphone"
oncommand="AboutPermissions.onPermissionCommand(event);">
<menupopup>
<menuitem id="microphone-0" value="0" label="&permission.alwaysAsk;"/>
<menuitem id="microphone-1" value="1" label="&permission.allow;"/>
<menuitem id="microphone-2" value="2" label="&permission.block;"/>
</menupopup>
</menulist>
</hbox>
</vbox>
</hbox>
<!-- Cookies -->
<hbox id="cookie-pref-item"
class="pref-item" align="top">
<image class="pref-icon" type="cookie"/>
<vbox>
<label class="pref-title" value="&cookie.label;"/>
<hbox align="center">
<menulist id="cookie-menulist"
class="pref-menulist"
type="cookie"
oncommand="AboutPermissions.onPermissionCommand(event);">
<menupopup>
<menuitem id="cookie-1" value="1" label="&permission.allow;"/>
<menuitem id="cookie-8" value="8" label="&permission.allowForSession;"/>
<menuitem id="cookie-9" value="9" label="&permission.allowFirstPartyOnly;"/>
<menuitem id="cookie-2" value="2" label="&permission.block;"/>
</menupopup>
</menulist>
<button id="cookies-clear-all-button"
label="&cookie.removeAll;"
oncommand="Services.cookies.removeAll();"/>
<button id="cookies-manage-all-button"
label="&cookie.manage;"
oncommand="AboutPermissions.manageCookies();"/>
</hbox>
<hbox id="cookies-count" align="center">
<label id="cookies-label"/>
<button id="cookies-clear-button"
label="&cookie.remove;"
oncommand="AboutPermissions.clearCookies();"/>
<button id="cookies-manage-button"
label="&cookie.manage;"
oncommand="AboutPermissions.manageCookies();"/>
</hbox>
</vbox>
</hbox>
<!-- Pop-up Blocking -->
<hbox id="popup-pref-item"
class="pref-item" align="top">
<image class="pref-icon" type="popup"/>
<vbox>
<label class="pref-title" value="&popup.label;"/>
<hbox>
<menulist id="popup-menulist"
class="pref-menulist"
type="popup"
oncommand="AboutPermissions.onPermissionCommand(event);">
<menupopup>
<menuitem id="popup-1" value="1" label="&permission.allow;"/>
<menuitem id="popup-2" value="2" label="&permission.block;"/>
</menupopup>
</menulist>
</hbox>
</vbox>
</hbox>
<!-- IndexedDB Storage -->
<hbox id="indexedDB-pref-item"
class="pref-item" align="top">
<image class="pref-icon" type="indexedDB"/>
<vbox>
<label class="pref-title" value="&indexedDB.label;"/>
<hbox>
<menulist id="indexedDB-menulist"
class="pref-menulist"
type="indexedDB"
oncommand="AboutPermissions.onPermissionCommand(event);">
<menupopup>
<menuitem id="indexedDB-0" value="0" label="&permission.alwaysAsk;"/>
<menuitem id="indexedDB-1" value="1" label="&permission.allow;"/>
<menuitem id="indexedDB-2" value="2" label="&permission.block;"/>
</menupopup>
</menulist>
</hbox>
</vbox>
</hbox>
<!-- Notifications -->
<hbox id="desktop-notification-pref-item"
class="pref-item" align="top">
<image class="pref-icon" type="desktop-notification"/>
<vbox>
<label class="pref-title" value="&desktop-notification2.label;"/>
<hbox align="center">
<menulist id="desktop-notification-menulist"
class="pref-menulist"
type="desktop-notification"
oncommand="AboutPermissions.onPermissionCommand(event);">
<menupopup>
<menuitem id="desktop-notification-0" value="0" label="&permission.alwaysAsk;"/>
<menuitem id="desktop-notification-1" value="1" label="&permission.allow;"/>
<menuitem id="desktop-notification-2" value="2" label="&permission.block;"/>
</menupopup>
</menulist>
</hbox>
</vbox>
</hbox>
</vbox>
</vbox>
</hbox>
</page>

Просмотреть файл

@ -14,14 +14,12 @@ support-files =
[browser_bug1020245_openPreferences_to_paneContent.js]
[browser_change_app_handler.js]
skip-if = os != "win" # This test tests the windows-specific app selection dialog, so can't run on non-Windows
[browser_chunk_permissions.js]
[browser_connection.js]
[browser_connection_bug388287.js]
[browser_cookies_exceptions.js]
[browser_healthreport.js]
skip-if = !healthreport || (os == 'linux' && debug)
[browser_notifications_do_not_disturb.js]
[browser_permissions.js]
[browser_permissions_urlFieldHidden.js]
[browser_proxy_backup.js]
[browser_privacypane_1.js]

Просмотреть файл

@ -1,140 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Components.utils.import("resource://gre/modules/NetUtil.jsm");
Components.utils.import("resource://gre/modules/ForgetAboutSite.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
"resource://testing-common/PlacesTestUtils.jsm");
const ABOUT_PERMISSIONS_SPEC = "about:permissions";
const TEST_URI_1 = NetUtil.newURI("http://mozilla.com/");
const TEST_URI_2 = NetUtil.newURI("http://mozilla.org/");
const TEST_URI_3 = NetUtil.newURI("http://wikipedia.org/");
// values from DefaultPermissions object
const PERM_UNKNOWN = 0;
const PERM_ALLOW = 1;
const PERM_DENY = 2;
// used to set permissions on test sites
const TEST_PERMS = {
"password": PERM_ALLOW,
"cookie": PERM_ALLOW,
"geo": PERM_UNKNOWN,
"indexedDB": PERM_UNKNOWN,
"popup": PERM_DENY
};
function test() {
waitForExplicitFinish();
registerCleanupFunction(cleanUp);
setup(function() {
runNextTest();
});
}
function setup(aCallback) {
// add test history visit
PlacesTestUtils.addVisits(TEST_URI_1).then(() => {
// set permissions ourselves to avoid problems with different defaults
// from test harness configuration
for (let type in TEST_PERMS) {
if (type == "password") {
Services.logins.setLoginSavingEnabled(TEST_URI_2.prePath, true);
} else {
// set permissions on a site without history visits to test enumerateServices
Services.perms.add(TEST_URI_2, type, TEST_PERMS[type]);
}
}
Services.perms.add(TEST_URI_3, "popup", TEST_PERMS["popup"]);
aCallback();
});
}
function cleanUp() {
for (let type in TEST_PERMS) {
if (type != "password") {
Services.perms.remove(TEST_URI_1, type);
Services.perms.remove(TEST_URI_2, type);
Services.perms.remove(TEST_URI_3, type);
}
}
}
function runNextTest() {
if (gTestIndex == tests.length) {
PlacesTestUtils.clearHistory().then(finish);
return;
}
let nextTest = tests[gTestIndex++];
info(nextTest.desc);
function preinit_observer() {
Services.obs.removeObserver(preinit_observer, "browser-permissions-preinit");
nextTest.preInit();
}
Services.obs.addObserver(preinit_observer, "browser-permissions-preinit", false);
function init_observer() {
Services.obs.removeObserver(init_observer, "browser-permissions-initialized");
nextTest.run();
}
Services.obs.addObserver(init_observer, "browser-permissions-initialized", false);
// open about:permissions
let tab = gBrowser.selectedTab = gBrowser.addTab("about:permissions");
registerCleanupFunction(function() {
gBrowser.removeTab(tab);
});
}
var gSitesList;
var gTestIndex = 0;
var tests = [
// 'preInit' occurs after opening about:permissions, before sites-list is populated
// 'run' occurs after sites-list is populated
{
desc: "test filtering before sites-list is fully constructed.",
preInit: function() {
let sitesFilter = gBrowser.contentDocument.getElementById("sites-filter");
sitesFilter.value = TEST_URI_2.host;
sitesFilter.doCommand();
},
run: function() {
let testSite1 = getSiteItem(TEST_URI_1.prePath);
ok(testSite1.collapsed, "test site 1 is collapsed after early filtering");
let testSite2 = getSiteItem(TEST_URI_2.prePath);
ok(!testSite2.collapsed, "test site 2 is not collapsed after early filtering");
let testSite3 = getSiteItem(TEST_URI_3.prePath);
ok(testSite3.collapsed, "test site 3 is collapsed after early filtering");
runNextTest();
}
},
{
desc: "test removing from sites-list before it is fully constructed.",
preInit: function() {
ForgetAboutSite.removeDataFromDomain(TEST_URI_2.host);
},
run: function() {
let testSite1 = getSiteItem(TEST_URI_1.prePath);
ok(testSite1, "test site 1 was not removed from sites list");
let testSite2 = getSiteItem(TEST_URI_2.prePath);
ok(!testSite2, "test site 2 was pre-removed from sites list");
let testSite3 = getSiteItem(TEST_URI_3.prePath);
ok(testSite3, "test site 3 was not removed from sites list");
runNextTest();
}
}
];
function getSiteItem(aPrePath) {
return gBrowser.contentDocument.
querySelector(".site[value='" + aPrePath + "']");
}

Просмотреть файл

@ -1,334 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Components.utils.import("resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
"resource://testing-common/PlacesTestUtils.jsm");
const ABOUT_PERMISSIONS_SPEC = "about:permissions";
const TEST_URI_1 = NetUtil.newURI("http://mozilla.com/");
const TEST_URI_2 = NetUtil.newURI("http://mozilla.org/");
const TEST_PRINCIPAL_1 =
Services.scriptSecurityManager.createCodebasePrincipal(TEST_URI_1, {});
const TEST_PRINCIPAL_2 =
Services.scriptSecurityManager.createCodebasePrincipal(TEST_URI_2, {});
// values from DefaultPermissions object
const PERM_UNKNOWN = 0;
const PERM_ALLOW = 1;
const PERM_DENY = 2;
// cookie specific permissions
const PERM_FIRST_PARTY_ONLY = 9;
// used to set permissions on test sites
const TEST_PERMS = {
"password": PERM_ALLOW,
"cookie": PERM_ALLOW,
"geo": PERM_UNKNOWN,
"desktop-notification": PERM_UNKNOWN,
"indexedDB": PERM_UNKNOWN,
"popup": PERM_DENY,
"camera": PERM_UNKNOWN,
"microphone": PERM_UNKNOWN
};
const NO_GLOBAL_ALLOW = [
"geo",
"indexedDB",
];
// number of managed permissions in the interface
const TEST_PERMS_COUNT = 8;
function test() {
waitForExplicitFinish();
registerCleanupFunction(cleanUp);
// add test history visit
PlacesTestUtils.addVisits(TEST_URI_1).then(() => {
// set permissions ourselves to avoid problems with different defaults
// from test harness configuration
for (let type in TEST_PERMS) {
if (type == "password") {
Services.logins.setLoginSavingEnabled(TEST_URI_2.prePath, true);
} else {
// set permissions on a site without history visits to test enumerateServices
Services.perms.addFromPrincipal(TEST_PRINCIPAL_2, type, TEST_PERMS[type]);
}
}
// open about:permissions
gBrowser.selectedTab = gBrowser.addTab("about:permissions");
});
function observer() {
Services.obs.removeObserver(observer, "browser-permissions-initialized");
runNextTest();
}
Services.obs.addObserver(observer, "browser-permissions-initialized", false);
}
function cleanUp() {
for (let type in TEST_PERMS) {
if (type != "password") {
Services.perms.removeFromPrincipal(TEST_PRINCIPAL_1, type);
Services.perms.removeFromPrincipal(TEST_PRINCIPAL_2, type);
}
}
gBrowser.removeTab(gBrowser.selectedTab);
}
function runNextTest() {
if (gTestIndex == tests.length) {
PlacesTestUtils.clearHistory().then(finish);
return;
}
let nextTest = tests[gTestIndex++];
info("[" + nextTest.name + "] running test");
nextTest();
}
var gSitesList;
var gHeaderDeck;
var gSiteLabel;
var gTestIndex = 0;
var tests = [
function test_page_load() {
is(gBrowser.currentURI.spec, ABOUT_PERMISSIONS_SPEC, "about:permissions loaded");
gSitesList = gBrowser.contentDocument.getElementById("sites-list");
ok(gSitesList, "got sites list");
gHeaderDeck = gBrowser.contentDocument.getElementById("header-deck");
ok(gHeaderDeck, "got header deck");
gSiteLabel = gBrowser.contentDocument.getElementById("site-label");
ok(gSiteLabel, "got site label");
runNextTest();
},
function test_sites_list() {
is(gSitesList.firstChild.id, "all-sites-item",
"all sites is the first item in the sites list");
ok(getSiteItem(TEST_URI_1.prePath), "site item from places db exists");
ok(getSiteItem(TEST_URI_2.prePath), "site item from enumerating services exists");
runNextTest();
},
function test_filter_sites_list() {
// set filter to test host
let sitesFilter = gBrowser.contentDocument.getElementById("sites-filter");
sitesFilter.value = TEST_URI_1.host;
sitesFilter.doCommand();
// make sure correct sites are collapsed/showing
let testSite1 = getSiteItem(TEST_URI_1.prePath);
ok(!testSite1.collapsed, "test site 1 is not collapsed");
let testSite2 = getSiteItem(TEST_URI_2.prePath);
ok(testSite2.collapsed, "test site 2 is collapsed");
// clear filter
sitesFilter.value = "";
sitesFilter.doCommand();
runNextTest();
},
function test_all_sites() {
// "All Sites" item should be selected when the page is first loaded
is(gSitesList.selectedItem, gBrowser.contentDocument.getElementById("all-sites-item"),
"all sites item is selected");
let defaultsHeader = gBrowser.contentDocument.getElementById("defaults-header");
is(defaultsHeader, gHeaderDeck.selectedPanel,
"correct header shown for all sites");
ok(gBrowser.contentDocument.getElementById("passwords-count").hidden,
"passwords count is hidden");
ok(gBrowser.contentDocument.getElementById("cookies-count").hidden,
"cookies count is hidden");
// Test to make sure "Allow" items hidden for certain permission types
NO_GLOBAL_ALLOW.forEach(function(aType) {
let menuitem = gBrowser.contentDocument.getElementById(aType + "-" + PERM_ALLOW);
ok(menuitem.hidden, aType + " allow menuitem hidden for all sites");
});
runNextTest();
},
function test_all_sites_permission() {
// apply the old default of allowing all cookies
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
// there should be no user-set pref for cookie behavior
is(Services.prefs.getIntPref("network.cookie.cookieBehavior"), PERM_UNKNOWN,
"network.cookie.cookieBehavior is expected default");
// the default behavior is to allow cookies
let cookieMenulist = getPermissionMenulist("cookie");
is(cookieMenulist.value, PERM_ALLOW,
"menulist correctly shows that cookies are allowed");
// set the pref to block cookies
Services.prefs.setIntPref("network.cookie.cookieBehavior", PERM_DENY);
// check to make sure this change is reflected in the UI
is(cookieMenulist.value, PERM_DENY, "menulist correctly shows that cookies are blocked");
// clear the pref
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
runNextTest();
},
function test_manage_all_passwords() {
// make sure "Manage All Passwords..." button opens the correct dialog
addWindowListener("chrome://passwordmgr/content/passwordManager.xul", runNextTest);
gBrowser.contentDocument.getElementById("passwords-manage-all-button").doCommand();
},
function test_manage_all_cookies() {
// make sure "Manage All Cookies..." button opens the correct dialog
addWindowListener("chrome://browser/content/preferences/cookies.xul", runNextTest);
gBrowser.contentDocument.getElementById("cookies-manage-all-button").doCommand();
},
function test_select_site() {
// select the site that has the permissions we set at the beginning of the test
let testSiteItem = getSiteItem(TEST_URI_2.prePath);
gSitesList.selectedItem = testSiteItem;
let siteHeader = gBrowser.contentDocument.getElementById("site-header");
is(siteHeader, gHeaderDeck.selectedPanel,
"correct header shown for a specific site");
is(gSiteLabel.value, TEST_URI_2.prePath, "header updated for selected site");
ok(!gBrowser.contentDocument.getElementById("passwords-count").hidden,
"passwords count is not hidden");
ok(!gBrowser.contentDocument.getElementById("cookies-count").hidden,
"cookies count is not hidden");
// Test to make sure "Allow" items are *not* hidden for certain permission types
NO_GLOBAL_ALLOW.forEach(function(aType) {
let menuitem = gBrowser.contentDocument.getElementById(aType + "-" + PERM_ALLOW);
ok(!menuitem.hidden, aType + " allow menuitem not hidden for single site");
});
runNextTest();
},
function test_permissions() {
let menulists = gBrowser.contentDocument.getElementsByClassName("pref-menulist");
is(menulists.length, TEST_PERMS_COUNT, "got expected number of managed permissions");
for (let i = 0; i < menulists.length; i++) {
let permissionMenulist = menulists.item(i);
let permissionType = permissionMenulist.getAttribute("type");
// permissions should reflect what we set at the beginning of the test
is(permissionMenulist.value, TEST_PERMS[permissionType],
"got expected value for " + permissionType + " permission");
}
runNextTest();
},
function test_permission_change() {
let geoMenulist = getPermissionMenulist("geo");
is(geoMenulist.value, PERM_UNKNOWN, "menulist correctly shows that geolocation permission is unspecified");
// change a permission programatically
Services.perms.addFromPrincipal(TEST_PRINCIPAL_2, "geo", PERM_DENY);
// check to make sure this change is reflected in the UI
is(geoMenulist.value, PERM_DENY, "menulist shows that geolocation is blocked");
// change a permisssion in the UI
let geoAllowItem = gBrowser.contentDocument.getElementById("geo-" + PERM_ALLOW);
geoMenulist.selectedItem = geoAllowItem;
geoMenulist.doCommand();
// check to make sure this change is reflected in the permission manager
is(Services.perms.testPermissionFromPrincipal(TEST_PRINCIPAL_2, "geo"), PERM_ALLOW,
"permission manager shows that geolocation is allowed");
// change a site-specific cookie permission, just for fun
let cookieMenuList = getPermissionMenulist("cookie");
let cookieItem = gBrowser.contentDocument.getElementById("cookie-" + PERM_FIRST_PARTY_ONLY);
cookieMenuList.selectedItem = cookieItem;
cookieMenuList.doCommand();
is(cookieMenuList.value, PERM_FIRST_PARTY_ONLY, "menulist correctly shows that " +
"first party only cookies are allowed");
is(Services.perms.testPermissionFromPrincipal(TEST_PRINCIPAL_2, "cookie"),
PERM_FIRST_PARTY_ONLY, "permission manager shows that first party cookies " +
"are allowed");
runNextTest();
},
function test_forget_site() {
// click "Forget About This Site" button
gBrowser.contentDocument.getElementById("forget-site-button").doCommand();
PlacesTestUtils.clearHistory().then(() => {
is(gSiteLabel.value, "", "site label cleared");
let allSitesItem = gBrowser.contentDocument.getElementById("all-sites-item");
is(gSitesList.selectedItem, allSitesItem,
"all sites item selected after forgetting selected site");
// check to make sure site is gone from sites list
let testSiteItem = getSiteItem(TEST_URI_2.prePath);
ok(!testSiteItem, "site removed from sites list");
// check to make sure we forgot all permissions corresponding to site
for (let type in TEST_PERMS) {
if (type == "password") {
ok(Services.logins.getLoginSavingEnabled(TEST_URI_2.prePath),
"password saving should be enabled by default");
} else {
is(Services.perms.testPermissionFromPrincipal(TEST_PRINCIPAL_2, type), PERM_UNKNOWN,
type + " permission should not be set for test site 2");
}
}
runNextTest();
});
}
];
function getPermissionMenulist(aType) {
return gBrowser.contentDocument.getElementById(aType + "-menulist");
}
function getSiteItem(aHost) {
return gBrowser.contentDocument.
querySelector(".site[value='" + aHost + "']");
}
function addWindowListener(aURL, aCallback) {
Services.wm.addListener({
onOpenWindow: function(aXULWindow) {
info("window opened, waiting for focus");
Services.wm.removeListener(this);
var domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
waitForFocus(function() {
is(domwindow.document.location.href, aURL, "should have seen the right window open");
domwindow.close();
aCallback();
}, domwindow);
},
onCloseWindow: function(aXULWindow) { },
onWindowTitleChange: function(aXULWindow, aNewTitle) { }
});
}

Просмотреть файл

@ -3,10 +3,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
browser.jar:
content/browser/preferences/aboutPermissions.xul
content/browser/preferences/aboutPermissions.js
content/browser/preferences/aboutPermissions.css
content/browser/preferences/aboutPermissions.xml
content/browser/preferences/applicationManager.xul
content/browser/preferences/applicationManager.js
content/browser/preferences/blocklists.xul

Просмотреть файл

@ -1,48 +0,0 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!ENTITY permissionsManager.title "Permissions Manager">
<!ENTITY sites.search "Search Sites">
<!ENTITY sites.allSites "All Sites">
<!-- LOCALIZATION NOTE (permissions.header.start, permissions.header.end): These strings
surround the host name of the site to make the header for the permissions page.
example: "Permissions for mozilla.org" -->
<!ENTITY header.site.start "Permissions for">
<!ENTITY header.site.end "">
<!ENTITY header.defaults "Default Permissions for All Sites">
<!ENTITY permissions.forgetSite "Forget About This Site">
<!ENTITY permission.alwaysAsk "Always Ask">
<!ENTITY permission.allow "Allow">
<!ENTITY permission.allowForSession "Allow for Session">
<!ENTITY permission.allowFirstPartyOnly "Allow First Party Only">
<!ENTITY permission.block "Block">
<!ENTITY password.label "Store Passwords">
<!ENTITY password.manage "Manage Passwords…">
<!ENTITY cookie.label "Set Cookies">
<!ENTITY cookie.remove "Remove Cookies">
<!ENTITY cookie.manage "Manage Cookies…">
<!ENTITY cookie.removeAll "Remove All Cookies">
<!ENTITY geo.label "Share Location">
<!ENTITY plugins.label "Plugins">
<!-- LOCALIZATION NOTE (indexedDB.label): This is describing indexedDB storage
using the same language used for the permIndexedDB string in browser/pageInfo.dtd -->
<!ENTITY indexedDB.label "Maintain Offline Storage">
<!ENTITY popup.label "Open Pop-up Windows">
<!ENTITY desktop-notification2.label "Receive Notifications">
<!ENTITY camera.label "Use the Camera">
<!ENTITY microphone.label "Use the Microphone">
<!ENTITY focusSearch.key "f">

Просмотреть файл

@ -1,13 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# LOCALIZATION NOTE (visitCount): Semicolon-separated list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# #1 is the number of history visits for a site
visitCount=#1 visit;#1 visits
# LOCALIZATION NOTE (passwordsCount, cookiesCount): Semicolon-separated list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
passwordsCount=#1 password is stored for this website.;#1 passwords are stored for this website.
cookiesCount=#1 cookie is set for this website.;#1 cookies are set for this website.

Просмотреть файл

@ -65,8 +65,6 @@
locale/browser/feeds/subscribe.properties (%chrome/browser/feeds/subscribe.properties)
locale/browser/migration/migration.dtd (%chrome/browser/migration/migration.dtd)
locale/browser/migration/migration.properties (%chrome/browser/migration/migration.properties)
locale/browser/preferences/aboutPermissions.dtd (%chrome/browser/preferences/aboutPermissions.dtd)
locale/browser/preferences/aboutPermissions.properties (%chrome/browser/preferences/aboutPermissions.properties)
locale/browser/preferences/advanced.dtd (%chrome/browser/preferences/advanced.dtd)
locale/browser/preferences/applicationManager.dtd (%chrome/browser/preferences/applicationManager.dtd)
locale/browser/preferences/applicationManager.properties (%chrome/browser/preferences/applicationManager.properties)

Просмотреть файл

@ -104,7 +104,6 @@ browser.jar:
* skin/classic/browser/preferences/in-content/preferences.css (preferences/in-content/preferences.css)
* skin/classic/browser/preferences/in-content/dialog.css (preferences/in-content/dialog.css)
skin/classic/browser/preferences/applications.css (preferences/applications.css)
skin/classic/browser/preferences/aboutPermissions.css (preferences/aboutPermissions.css)
skin/classic/browser/preferences/search.css (preferences/search.css)
skin/classic/browser/social/services-16.png (social/services-16.png)
skin/classic/browser/social/services-64.png (social/services-64.png)

Просмотреть файл

@ -1,136 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@import url("chrome://global/skin/in-content/common.css");
#permissions-content {
padding-top: 48px;
-moz-padding-end: 0; /* no padding to move the scroll bar to the edge */
}
/* sites box */
#sites-box {
width: 25em;
}
#sites-filter {
margin: 0;
}
#sites-list {
margin: 5px 0 0 0;
}
.site {
padding: 4px;
border-bottom: 1px solid ThreeDLightShadow;
}
.site-favicon {
height: 16px;
width: 16px;
-moz-margin-end: 4px;
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
}
#all-sites-item > .site-container > .site-favicon {
list-style-image: none;
}
/* permissions box */
#permissions-box {
-moz-padding-start: 10px;
}
#permissions-list {
overflow-y: auto;
padding-top: 5px;
-moz-padding-end: 44px;
}
#site-description {
font-size: 125%;
}
#site-label {
font-weight: bold;
margin-top: 0;
margin-bottom: 0;
}
#defaults-description {
font-size: 125%;
font-weight: bold;
}
#header-deck {
-moz-margin-end: 44px;
}
#site-header,
#defaults-header {
margin-bottom: 1px;
}
.pref-item {
margin-bottom: 10px;
}
.pref-icon {
width: 36px;
height: 36px;
-moz-margin-end: 10px;
}
.pref-icon[type="password"] {
list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png);
}
.pref-icon[type="cookie"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="geo"] {
list-style-image: url(chrome://browser/skin/Geolocation-64.png);
}
.pref-icon[type="desktop-notification"] {
list-style-image: url(chrome://browser/skin/web-notifications-icon.svg);
}
.pref-icon[type="indexedDB"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="install"] {
list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric.svg);
}
.pref-icon[type="popup"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="image"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="plugins"] {
list-style-image: url(chrome://mozapps/skin/plugins/pluginGeneric.png);
}
.pref-icon[type="camera"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="microphone"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-title {
font-size: 125%;
-moz-margin-start: 4px;
margin-bottom: 0;
font-weight: bold;
}
.pref-menulist {
min-width: 10em;
}
#cookies-label,
#passwords-label {
-moz-margin-start: 4px; /* align with the menulists */
}

Просмотреть файл

@ -162,7 +162,6 @@ browser.jar:
* skin/classic/browser/preferences/in-content/preferences.css (preferences/in-content/preferences.css)
* skin/classic/browser/preferences/in-content/dialog.css (preferences/in-content/dialog.css)
skin/classic/browser/preferences/applications.css (preferences/applications.css)
skin/classic/browser/preferences/aboutPermissions.css (preferences/aboutPermissions.css)
skin/classic/browser/preferences/search.css (preferences/search.css)
skin/classic/browser/preferences/checkbox.png (preferences/checkbox.png)
skin/classic/browser/preferences/checkbox@2x.png (preferences/checkbox@2x.png)

Просмотреть файл

@ -1,152 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@import url("chrome://global/skin/in-content/common.css");
#permissions-content {
padding-top: 48px;
-moz-padding-end: 0; /* no padding to move the scroll bar to the edge */
}
/* sites box */
#sites-box {
width: 25em;
}
#sites-filter {
margin: 0;
}
#sites-list {
margin: 5px 0 0 0;
}
.site {
padding: 4px;
border-bottom: 1px solid ThreeDLightShadow;
}
.site-favicon {
height: 16px;
width: 16px;
-moz-margin-end: 4px;
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
}
@media (min-resolution: 2dppx) {
.site-favicon {
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon@2x.png");
}
}
#all-sites-item > .site-container > .site-favicon {
list-style-image: none;
}
/* permissions box */
#permissions-box {
-moz-padding-start: 10px;
}
#permissions-list {
overflow-y: auto;
padding-top: 5px;
-moz-padding-end: 44px;
}
#site-description {
font-size: 125%;
}
#site-label {
font-weight: bold;
margin-top: 0;
margin-bottom: 0;
}
#site-visit-count {
margin-bottom: 4px;
}
#defaults-description {
font-size: 125%;
font-weight: bold;
}
#header-deck {
-moz-margin-end: 44px;
}
#site-header,
#defaults-header {
margin-bottom: 1px;
}
.pref-item {
margin-bottom: 10px;
}
.pref-icon {
width: 36px;
height: 36px;
-moz-margin-end: 10px;
}
.pref-icon[type="password"] {
list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png);
}
.pref-icon[type="cookie"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="geo"] {
list-style-image: url(chrome://browser/skin/Geolocation-64.png);
}
.pref-icon[type="desktop-notification"] {
list-style-image: url(chrome://browser/skin/web-notifications-icon.svg);
}
.pref-icon[type="indexedDB"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="install"] {
list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric.svg);
}
.pref-icon[type="popup"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="image"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="plugins"] {
list-style-image: url(chrome://mozapps/skin/plugins/pluginGeneric.png);
}
.pref-icon[type="camera"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="microphone"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
@media (min-resolution: 2dppx) {
.pref-icon[type="geo"] {
list-style-image: url(chrome://browser/skin/Geolocation-64@2x.png);
}
}
.pref-title {
font-size: 125%;
-moz-margin-start: 2px; /* align with the menulists */
margin-bottom: 0;
font-weight: bold;
}
.pref-menulist {
min-width: 10em;
}
#cookies-label,
#passwords-label {
-moz-margin-start: 2px; /* align with the menulists */
}

Просмотреть файл

@ -188,7 +188,6 @@ browser.jar:
* skin/classic/browser/preferences/in-content/preferences.css (preferences/in-content/preferences.css)
* skin/classic/browser/preferences/in-content/dialog.css (preferences/in-content/dialog.css)
skin/classic/browser/preferences/applications.css (preferences/applications.css)
skin/classic/browser/preferences/aboutPermissions.css (preferences/aboutPermissions.css)
skin/classic/browser/preferences/search.css (preferences/search.css)
skin/classic/browser/preferences/checkbox.png (preferences/checkbox.png)
skin/classic/browser/preferences/checkbox-aero.png (preferences/checkbox-aero.png)

Просмотреть файл

@ -1,140 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@import url("chrome://global/skin/in-content/common.css");
#permissions-content {
padding-top: 48px;
-moz-padding-end: 0; /* no padding to move the scroll bar to the edge */
}
/* sites box */
#sites-box {
width: 25em;
}
#sites-filter {
margin: 0;
}
#sites-list {
margin: 5px 0 0 0;
}
.site {
padding: 4px;
border-bottom: 1px solid ThreeDLightShadow;
}
.site-favicon {
height: 16px;
width: 16px;
-moz-margin-end: 4px;
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
}
#all-sites-item > .site-container > .site-favicon {
list-style-image: none;
}
/* permissions box */
#permissions-box {
-moz-padding-start: 10px;
}
#permissions-list {
overflow-y: auto;
padding-top: 5px;
-moz-padding-end: 44px;
}
#site-description {
font-size: 125%;
}
#site-label {
font-weight: bold;
margin-top: 0;
margin-bottom: 0;
}
#site-visit-count {
margin-bottom: 0;
}
#defaults-description {
font-size: 125%;
font-weight: bold;
}
#header-deck {
-moz-margin-end: 44px;
}
#site-header,
#defaults-header {
margin-bottom: 1px;
}
.pref-item {
margin-bottom: 10px;
}
.pref-icon {
width: 36px;
height: 36px;
-moz-margin-end: 10px;
}
.pref-icon[type="password"] {
list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png);
}
.pref-icon[type="cookie"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="geo"] {
list-style-image: url(chrome://browser/skin/Geolocation-64.png);
}
.pref-icon[type="desktop-notification"] {
list-style-image: url(chrome://browser/skin/web-notifications-icon.svg);
}
.pref-icon[type="indexedDB"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="install"] {
list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric.svg);
}
.pref-icon[type="popup"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="image"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="plugins"] {
list-style-image: url(chrome://mozapps/skin/plugins/pluginGeneric.png);
}
.pref-icon[type="camera"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-icon[type="microphone"] {
list-style-image: url(chrome://global/skin/icons/question-64.png);
}
.pref-title {
font-size: 125%;
-moz-margin-start: 4px;
margin-bottom: 0;
font-weight: bold;
}
.pref-menulist {
min-width: 10em;
}
#cookies-label,
#passwords-label {
-moz-margin-start: 4px; /* align with the menulists */
}