Bug 1715499 - Display special dialogue for single base domain r=pbz,fluent-reviewers,preferences-reviewers,flod,Gijs,jaws

Differential Revision: https://phabricator.services.mozilla.com/D118729
This commit is contained in:
Stefan Zabka 2021-07-20 18:52:03 +00:00
Родитель 699174544b
Коммит 9468e1cce4
5 изменённых файлов: 111 добавлений и 8 удалений

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

@ -25,7 +25,19 @@ let gSiteDataRemoveSelected = {
if (!hosts) {
throw new Error("Must specify hosts option in arguments.");
}
let dialog = document.getElementById("SiteDataRemoveSelectedDialog");
if (hosts.length == 1) {
dialog.classList.add("single-entry");
document.l10n.setAttributes(
document.getElementById("removing-description"),
"site-data-removing-single-desc",
{
baseDomain: hosts[0],
}
);
return;
}
dialog.classList.add("multi-entry");
hosts.sort();
let fragment = document.createDocumentFragment();
for (let host of hosts) {

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

@ -38,13 +38,11 @@
<description id="removing-description" data-l10n-id="site-data-removing-desc"/>
</vbox>
</hbox>
<separator class="multi-site"/>
<separator/>
<label data-l10n-id="site-data-removing-table"/>
<separator class="thin"/>
<richlistbox id="removalList" class="theme-listbox" flex="1"/>
<label data-l10n-id="site-data-removing-table" class="multi-site"/>
<separator class="thin multi-site"/>
<richlistbox id="removalList" class="theme-listbox multi-site" flex="1"/>
<!-- Load the script after the elements for layout issues (bug 1501755). -->
<script src="chrome://browser/content/preferences/dialogs/siteDataRemoveSelected.js"/>
</dialog>

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

@ -247,3 +247,81 @@ add_task(async function test_sorting() {
await SiteDataTestUtils.clear();
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
// Test single entry removal
add_task(async function test_single_entry_removal() {
let testData = await addTestData([
{
usage: 1024,
origin: "https://xyz.com",
cookies: 6,
persisted: true,
},
{
usage: 1024 * 3,
origin: "http://bar.com",
cookies: 2,
persisted: false,
},
]);
let updatePromise = promiseSiteDataManagerSitesUpdated();
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
await updatePromise;
await openSiteDataSettingsDialog();
let dialog = content.gSubDialog._topDialog;
let dialogFrame = dialog._frame;
let frameDoc = dialogFrame.contentDocument;
let sitesList = frameDoc.getElementById("sitesList");
let host = testData[0];
let site = sitesList.querySelector(`richlistitem[host="${host}"]`);
sitesList.addItemToSelection(site);
frameDoc.getElementById("removeSelected").doCommand();
let saveChangesButton = frameDoc.querySelector("dialog").getButton("accept");
let dialogOpened = BrowserTestUtils.promiseAlertDialogOpen(
null,
REMOVE_DIALOG_URL
);
setTimeout(() => saveChangesButton.doCommand(), 0);
let dialogWin = await dialogOpened;
let rootElement = dialogWin.document.getElementById(
"SiteDataRemoveSelectedDialog"
);
is(rootElement.classList.length, 1, "There should only be one class set");
is(
rootElement.classList[0],
"single-entry",
"The only class set should be single-entry (to hide the list)"
);
let description = dialogWin.document.getElementById("removing-description");
is(
description.getAttribute("data-l10n-id"),
"site-data-removing-single-desc",
"The description for single site should be selected"
);
let removalList = dialogWin.document.getElementById("removalList");
is(
BrowserTestUtils.is_visible(removalList),
false,
"The removal list should be invisible"
);
let removeButton = dialogWin.document
.querySelector("dialog")
.getButton("accept");
let dialogClosed = BrowserTestUtils.waitForEvent(dialogWin, "unload");
updatePromise = promiseSiteDataManagerSitesUpdated();
removeButton.doCommand();
await dialogClosed;
await updatePromise;
await openSiteDataSettingsDialog();
dialog = content.gSubDialog._topDialog;
dialogFrame = dialog._frame;
frameDoc = dialogFrame.contentDocument;
assertSitesListed(frameDoc, testData.slice(1));
await SiteDataTestUtils.clear();
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

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

@ -58,5 +58,8 @@ site-data-removing-dialog =
site-data-removing-header = Removing Cookies and Site Data
site-data-removing-desc = Removing cookies and site data may log you out of websites. Are you sure you want to make the changes?
# Variables:
# $baseDomain (String) - The single domain for which data is being removed
site-data-removing-single-desc = Removing cookies and site data may log you out of websites. Are you sure you want to remove cookies and site data for <strong>{ $baseDomain }</strong>?
site-data-removing-table = Cookies and site data for the following websites will be removed

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

@ -29,8 +29,20 @@
* Confirmation dialog of removing sites selected
*/
#SiteDataRemoveSelectedDialog {
min-height: 36em;
padding: 16px;
width: 50px;
}
#SiteDataRemoveSelectedDialog.single-entry {
min-height: 8em;
}
#SiteDataRemoveSelectedDialog.single-entry .multi-site {
display: none;
}
#SiteDataRemoveSelectedDialog.multi-entry {
min-height: 36em;
}
#SiteDataRemoveSelectedDialog > dialog {