зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1695084 - Update persistent storage permission prompt. r=mconley,flod
Differential Revision: https://phabricator.services.mozilla.com/D107058
This commit is contained in:
Родитель
54ab3624a4
Коммит
451f185db7
|
@ -633,11 +633,10 @@ xr.remember=Remember this decision
|
|||
# Persistent storage UI
|
||||
persistentStorage.allow=Allow
|
||||
persistentStorage.allow.accesskey=A
|
||||
persistentStorage.neverAllow.label=Never Allow
|
||||
persistentStorage.neverAllow.accesskey=N
|
||||
persistentStorage.notNow.label=Not Now
|
||||
persistentStorage.notNow.accesskey=w
|
||||
persistentStorage.allowWithSite=Will you allow %S to store data in persistent storage?
|
||||
persistentStorage.block.label=Block
|
||||
persistentStorage.block.accesskey=B
|
||||
persistentStorage.allowWithSite2=Allow %S to store data in persistent storage?
|
||||
persistentStorage.remember=Remember this decision
|
||||
|
||||
webNotifications.allow=Allow Notifications
|
||||
webNotifications.allow.accesskey=A
|
||||
|
|
|
@ -1083,11 +1083,24 @@ PersistentStoragePermissionPrompt.prototype = {
|
|||
let learnMoreURL =
|
||||
Services.urlFormatter.formatURLPref("app.support.baseURL") +
|
||||
"storage-permissions";
|
||||
return {
|
||||
let options = {
|
||||
learnMoreURL,
|
||||
displayURI: false,
|
||||
name: this.getPrincipalName(),
|
||||
checkbox: {
|
||||
show:
|
||||
!this.principal.schemeIs("file") &&
|
||||
!PrivateBrowsingUtils.isWindowPrivate(this.browser.ownerGlobal),
|
||||
},
|
||||
};
|
||||
|
||||
if (options.checkbox.show) {
|
||||
options.checkbox.label = gBrowserBundle.GetStringFromName(
|
||||
"persistentStorage.remember"
|
||||
);
|
||||
}
|
||||
|
||||
return options;
|
||||
},
|
||||
|
||||
get notificationID() {
|
||||
|
@ -1100,7 +1113,7 @@ PersistentStoragePermissionPrompt.prototype = {
|
|||
|
||||
get message() {
|
||||
return gBrowserBundle.formatStringFromName(
|
||||
"persistentStorage.allowWithSite",
|
||||
"persistentStorage.allowWithSite2",
|
||||
["<>"]
|
||||
);
|
||||
},
|
||||
|
@ -1117,22 +1130,12 @@ PersistentStoragePermissionPrompt.prototype = {
|
|||
},
|
||||
{
|
||||
label: gBrowserBundle.GetStringFromName(
|
||||
"persistentStorage.notNow.label"
|
||||
"persistentStorage.block.label"
|
||||
),
|
||||
accessKey: gBrowserBundle.GetStringFromName(
|
||||
"persistentStorage.notNow.accesskey"
|
||||
),
|
||||
action: Ci.nsIPermissionManager.DENY_ACTION,
|
||||
},
|
||||
{
|
||||
label: gBrowserBundle.GetStringFromName(
|
||||
"persistentStorage.neverAllow.label"
|
||||
),
|
||||
accessKey: gBrowserBundle.GetStringFromName(
|
||||
"persistentStorage.neverAllow.accesskey"
|
||||
"persistentStorage.block.accesskey"
|
||||
),
|
||||
action: SitePermissions.BLOCK,
|
||||
scope: SitePermissions.SCOPE_PERSISTENT,
|
||||
},
|
||||
];
|
||||
},
|
||||
|
|
|
@ -114,11 +114,8 @@ async function testPrompt(Prompt) {
|
|||
|
||||
let isNotificationPrompt =
|
||||
Prompt == PermissionUI.DesktopNotificationPermissionPrompt;
|
||||
let isPersistentStoragePrompt =
|
||||
Prompt == PermissionUI.PersistentStoragePermissionPrompt;
|
||||
|
||||
let expectedSecondaryActionsCount =
|
||||
isNotificationPrompt || isPersistentStoragePrompt ? 2 : 1;
|
||||
let expectedSecondaryActionsCount = isNotificationPrompt ? 2 : 1;
|
||||
Assert.equal(
|
||||
notification.secondaryActions.length,
|
||||
expectedSecondaryActionsCount,
|
||||
|
@ -171,7 +168,7 @@ async function testPrompt(Prompt) {
|
|||
// or by clicking the "never" option from the dropdown (for notifications and persistent-storage).
|
||||
popupNotification = getPopupNotificationNode();
|
||||
let secondaryActionToClickIndex = 0;
|
||||
if (isNotificationPrompt || isPersistentStoragePrompt) {
|
||||
if (isNotificationPrompt) {
|
||||
secondaryActionToClickIndex = 1;
|
||||
} else {
|
||||
popupNotification.checkbox.checked = true;
|
||||
|
|
|
@ -54,7 +54,7 @@ addTest(async function testPermissionDenied() {
|
|||
});
|
||||
registerPopupEventHandler("popupshown", function() {
|
||||
ok(true, "prompt shown");
|
||||
triggerSecondaryCommand(this, 1);
|
||||
triggerSecondaryCommand(this, /* remember = */ true);
|
||||
});
|
||||
registerPopupEventHandler("popuphidden", function() {
|
||||
ok(true, "prompt hidden");
|
||||
|
|
|
@ -66,42 +66,24 @@ function triggerMainCommand(popup, win) {
|
|||
EventUtils.synthesizeMouseAtCenter(notification.button, {}, win);
|
||||
}
|
||||
|
||||
async function triggerSecondaryCommand(popup, actionIndex, win) {
|
||||
if (!win) {
|
||||
win = window;
|
||||
}
|
||||
|
||||
async function triggerSecondaryCommand(popup, remember = false, win = window) {
|
||||
info("triggering secondary command");
|
||||
let notifications = popup.childNodes;
|
||||
ok(notifications.length > 0, "at least one notification displayed");
|
||||
let notification = notifications[0];
|
||||
|
||||
if (!actionIndex) {
|
||||
await EventUtils.synthesizeMouseAtCenter(
|
||||
notification.secondaryButton,
|
||||
{},
|
||||
win
|
||||
);
|
||||
} else {
|
||||
// Click the dropmarker arrow and wait for the menu to show up.
|
||||
let dropdownPromise = BrowserTestUtils.waitForEvent(
|
||||
notification.menupopup,
|
||||
"popupshown"
|
||||
);
|
||||
await EventUtils.synthesizeMouseAtCenter(notification.menubutton, {});
|
||||
await dropdownPromise;
|
||||
|
||||
let actionMenuItem = notification.querySelectorAll("menuitem")[
|
||||
actionIndex - 1
|
||||
];
|
||||
await EventUtils.synthesizeMouseAtCenter(actionMenuItem, {});
|
||||
if (remember) {
|
||||
notification.checkbox.checked = true;
|
||||
}
|
||||
|
||||
await EventUtils.synthesizeMouseAtCenter(
|
||||
notification.secondaryButton,
|
||||
{},
|
||||
win
|
||||
);
|
||||
}
|
||||
|
||||
function dismissNotification(popup, win) {
|
||||
if (!win) {
|
||||
win = window;
|
||||
}
|
||||
function dismissNotification(popup, win = window) {
|
||||
info("dismissing notification");
|
||||
executeSoon(function() {
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, win);
|
||||
|
|
Загрузка…
Ссылка в новой задаче