Backed out changeset 4f223f11a08f (bug 1334411) for failing xpcshell's browser/modules/test/unit/test_SitePermissions.js. r=backout on a CLOSED TREE

--HG--
extra : amend_source : 312a520b843a8b640ffc5060651c64b36a6ddd97
This commit is contained in:
Sebastian Hengst 2017-10-25 00:11:02 +02:00
parent 24b7b2eb7c
commit d3632a713b
10 changed files with 96 additions and 0 deletions

View File

@ -796,6 +796,8 @@
tooltiptext="&urlbar.webNotificationsBlocked.tooltip;"/>
<image data-permission-id="camera" class="blocked-permission-icon camera-icon" role="button"
tooltiptext="&urlbar.cameraBlocked.tooltip;"/>
<image data-permission-id="indexedDB" class="blocked-permission-icon indexedDB-icon" role="button"
tooltiptext="&urlbar.indexedDBBlocked.tooltip;"/>
<image data-permission-id="microphone" class="blocked-permission-icon microphone-icon" role="button"
tooltiptext="&urlbar.microphoneBlocked.tooltip;"/>
<image data-permission-id="screen" class="blocked-permission-icon screen-icon" role="button"

View File

@ -280,6 +280,14 @@
</hbox>
<vbox id="permList" flex="1">
<hbox id="perm-indexedDB-extras">
<spacer flex="1"/>
<vbox id="permIndexedDBStatusBox" pack="center">
<label id="indexedDBStatus" control="indexedDBClear" hidden="true"/>
</vbox>
<button id="indexedDBClear" label="&permClearStorage;" hidden="true"
accesskey="&permClearStorage.accesskey;" onclick="onIndexedDBClear();"/>
</hbox>
<vbox class="permission" id="perm-plugins-row">
<label class="permissionLabel" id="permPluginsLabel"
value="&permPlugins;" control="pluginsRadioGroup"/>

View File

@ -7,6 +7,8 @@
Components.utils.import("resource:///modules/SitePermissions.jsm");
Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
const nsIQuotaManagerService = Components.interfaces.nsIQuotaManagerService;
var gPermURI;
var gPermPrincipal;
var gUsageRequest;
@ -84,6 +86,10 @@ function initRow(aPartId) {
command.setAttribute("disabled", "true");
}
setRadioState(aPartId, state);
if (aPartId == "indexedDB") {
initIndexedDBRow();
}
}
function createRow(aPartId) {
@ -174,6 +180,68 @@ function setRadioState(aPartId, aValue) {
}
}
function initIndexedDBRow() {
// IndexedDB information is not shown for pages with a null principal
// such as sandboxed pages because these pages do not have access to indexedDB.
if (gPermPrincipal.isNullPrincipal)
return;
let row = document.getElementById("perm-indexedDB-row");
let extras = document.getElementById("perm-indexedDB-extras");
row.appendChild(extras);
var quotaManagerService =
Components.classes["@mozilla.org/dom/quota-manager-service;1"]
.getService(nsIQuotaManagerService);
gUsageRequest =
quotaManagerService.getUsageForPrincipal(gPermPrincipal,
onIndexedDBUsageCallback);
var status = document.getElementById("indexedDBStatus");
var button = document.getElementById("indexedDBClear");
status.value = "";
status.setAttribute("hidden", "true");
button.setAttribute("hidden", "true");
}
function onIndexedDBClear() {
Components.classes["@mozilla.org/dom/quota-manager-service;1"]
.getService(nsIQuotaManagerService)
.clearStoragesForPrincipal(gPermPrincipal);
Components.classes["@mozilla.org/serviceworkers/manager;1"]
.getService(Components.interfaces.nsIServiceWorkerManager)
.removeAndPropagate(gPermURI.host);
SitePermissions.remove(gPermURI, "indexedDB");
initIndexedDBRow();
}
function onIndexedDBUsageCallback(request) {
let uri = request.principal.URI;
if (!uri.equals(gPermURI)) {
throw new Error("Callback received for bad URI: " + uri);
}
let usage = request.result.usage;
if (usage) {
if (!("DownloadUtils" in window)) {
Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
}
var status = document.getElementById("indexedDBStatus");
var button = document.getElementById("indexedDBClear");
status.value =
gBundle.getFormattedString("indexedDBUsage",
DownloadUtils.convertByteUnits(usage));
status.removeAttribute("hidden");
button.removeAttribute("hidden");
}
}
function fillInPluginPermissionTemplate(aPluginName, aPermissionString) {
let permPluginTemplate = document.getElementById("permPluginTemplate").cloneNode(true);
permPluginTemplate.setAttribute("permString", aPermissionString);

View File

@ -226,6 +226,7 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY urlbar.microphoneBlocked.tooltip "You have blocked your microphone for this website.">
<!ENTITY urlbar.screenBlocked.tooltip "You have blocked this website from sharing your screen.">
<!ENTITY urlbar.geolocationBlocked.tooltip "You have blocked location information for this website.">
<!ENTITY urlbar.indexedDBBlocked.tooltip "You have blocked data storage for this website.">
<!ENTITY urlbar.webNotificationsBlocked.tooltip "You have blocked notifications for this website.">
<!ENTITY urlbar.persistentStorageBlocked.tooltip "You have blocked persistent storage for this website.">
<!ENTITY urlbar.popupBlocked.tooltip "You have blocked pop-ups for this website.">

View File

@ -59,6 +59,9 @@
<!ENTITY permissionsFor "Permissions for:">
<!ENTITY permPlugins "Activate Plugins">
<!ENTITY permClearStorage "Clear Storage">
<!ENTITY permClearStorage.accesskey "C">
<!ENTITY securityTab "Security">
<!ENTITY securityTab.accesskey "S">
<!ENTITY securityView.certView "View Certificate">

View File

@ -35,5 +35,6 @@ permission.screen.label = Share the Screen
permission.install.label = Install Add-ons
permission.popup.label = Open Pop-up Windows
permission.geo.label = Access Your Location
permission.indexedDB.label = Maintain Offline Storage
permission.focus-tab-by-prompt.label = Switch to this Tab
permission.persistent-storage.label = Store Data in Persistent Storage

View File

@ -620,6 +620,8 @@ var gPermissionObject = {
exactHostMatch: true
},
"indexedDB": {},
"focus-tab-by-prompt": {
exactHostMatch: true,
states: [ SitePermissions.UNKNOWN, SitePermissions.ALLOW ],

View File

@ -66,6 +66,7 @@
skin/classic/browser/notification-icons/desktop-notification-blocked.svg (../shared/notification-icons/desktop-notification-blocked.svg)
skin/classic/browser/notification-icons/desktop-notification.svg (../shared/notification-icons/desktop-notification.svg)
skin/classic/browser/notification-icons/focus-tab-by-prompt.svg (../shared/notification-icons/focus-tab-by-prompt.svg)
skin/classic/browser/notification-icons/indexedDB-blocked.svg (../shared/notification-icons/indexedDB-blocked.svg)
skin/classic/browser/notification-icons/indexedDB.svg (../shared/notification-icons/indexedDB.svg)
skin/classic/browser/notification-icons/login-detailed.svg (../shared/notification-icons/login-detailed.svg)
skin/classic/browser/notification-icons/login.svg (../shared/notification-icons/login.svg)

View File

@ -65,6 +65,10 @@
list-style-image: url(chrome://browser/skin/notification-icons/indexedDB.svg);
}
.indexedDB-icon.blocked-permission-icon {
list-style-image: url(chrome://browser/skin/notification-icons/indexedDB-blocked.svg);
}
.login-icon {
list-style-image: url(chrome://browser/skin/notification-icons/login.svg);
}

View File

@ -0,0 +1,6 @@
<!-- 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/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="context-fill" fill-opacity="context-fill-opacity">
<path d="M10.293 11.293L9 12.586V10l-2 2v.586l-.293-.293-1.414 1.414 2 2a1 1 0 0 0 1.414 0l3-3a1 1 0 0 0-1.414-1.414zM13 8h-1a1 1 0 0 0 0 2h2a1 1 0 0 0 1-1V4l-2 2zm1.707-6.707A1.016 1.016 0 0 0 14 1H2a1 1 0 0 0-1 1v7a1 1 0 0 0 1 1h2a1 1 0 0 0 0-2H3V3h8.586L1.293 13.293a1 1 0 1 0 1.414 1.414l12-12a1 1 0 0 0 0-1.414z"/>
</svg>

After

Width:  |  Height:  |  Size: 661 B