# HG changeset patch # User Johann Hofmann # Date 1519207589 -3600 # Node ID 57a398ca3a4db155ffbe90b5293e731936cf2b22 # Parent 278d965eb75f50ca057fef4c11ee1f28df1fa85e Bug 1432745 - Merge the "persistent" column in the site data manager into the "usage" column. r=nhnt11 MozReview-Commit-ID: 6a2ZOhC7p3a diff --git a/browser/components/preferences/in-content-new/tests/browser_siteData.js b/browser/components/preferences/in-content-new/tests/browser_siteData.js --- a/browser/components/preferences/in-content-new/tests/browser_siteData.js +++ b/browser/components/preferences/in-content-new/tests/browser_siteData.js @@ -208,25 +208,25 @@ add_task(async function() { let siteItems = frameDoc.getElementsByTagName("richlistitem"); is(siteItems.length, 2, "Should list two sites with cookies"); let sitesList = frameDoc.getElementById("sitesList"); let site1 = sitesList.querySelector(`richlistitem[host="example.com"]`); let site2 = sitesList.querySelector(`richlistitem[host="example.org"]`); let columns = site1.querySelectorAll(".item-box > label"); is(columns[0].value, "example.com", "Should show the correct host."); - is(columns[2].value, "2", "Should show the correct number of cookies."); - is(columns[3].value, "", "Should show no site data."); - is(columns[4].value, args.creationDate1, "Should show the correct date."); + is(columns[1].value, "2", "Should show the correct number of cookies."); + is(columns[2].value, "", "Should show no site data."); + is(columns[3].value, args.creationDate1, "Should show the correct date."); columns = site2.querySelectorAll(".item-box > label"); is(columns[0].value, "example.org", "Should show the correct host."); - is(columns[2].value, "1", "Should show the correct number of cookies."); - is(columns[3].value, "", "Should show no site data."); - is(columns[4].value, args.creationDate2, "Should show the correct date."); + is(columns[1].value, "1", "Should show the correct number of cookies."); + is(columns[2].value, "", "Should show no site data."); + is(columns[3].value, args.creationDate2, "Should show the correct date."); let removeBtn = frameDoc.getElementById("removeSelected"); let saveBtn = frameDoc.getElementById("save"); site2.click(); removeBtn.doCommand(); saveBtn.doCommand(); }); await removeDialogOpenPromise; @@ -242,19 +242,19 @@ add_task(async function() { let siteItems = frameDoc.getElementsByTagName("richlistitem"); is(siteItems.length, 1, "Should list one site with cookies"); let sitesList = frameDoc.getElementById("sitesList"); let site1 = sitesList.querySelector(`richlistitem[host="example.com"]`); let columns = site1.querySelectorAll(".item-box > label"); is(columns[0].value, "example.com", "Should show the correct host."); - is(columns[2].value, "2", "Should show the correct number of cookies."); - is(columns[3].value, "", "Should show no site data."); - is(columns[4].value, args.creationDate1, "Should show the correct date."); + is(columns[1].value, "2", "Should show the correct number of cookies."); + is(columns[2].value, "", "Should show no site data."); + is(columns[3].value, args.creationDate1, "Should show the correct date."); let removeBtn = frameDoc.getElementById("removeSelected"); let saveBtn = frameDoc.getElementById("save"); site1.click(); removeBtn.doCommand(); saveBtn.doCommand(); }); await acceptRemovePromise; diff --git a/browser/components/preferences/in-content-new/tests/browser_siteData3.js b/browser/components/preferences/in-content-new/tests/browser_siteData3.js --- a/browser/components/preferences/in-content-new/tests/browser_siteData3.js +++ b/browser/components/preferences/in-content-new/tests/browser_siteData3.js @@ -88,25 +88,22 @@ add_task(async function() { let siteItems = frameDoc.getElementsByTagName("richlistitem"); is(siteItems.length, 1, "Should group sites across scheme, port and origin attributes"); let columns = siteItems[0].querySelectorAll(".item-box > label"); let expected = "account.xyz.com"; is(columns[0].value, expected, "Should group and list sites by host"); - let prefStrBundle = frameDoc.getElementById("bundlePreferences"); - expected = prefStrBundle.getString("persistent"); - is(columns[1].value, expected, "Should mark persisted status across scheme, port and origin attributes"); + is(columns[1].value, "5", "Should group cookies across scheme, port and origin attributes"); - is(columns[2].value, "5", "Should group cookies across scheme, port and origin attributes"); - - expected = prefStrBundle.getFormattedString("siteUsage", + let prefStrBundle = frameDoc.getElementById("bundlePreferences"); + expected = prefStrBundle.getFormattedString("siteUsagePersistent", DownloadUtils.convertByteUnits(quotaUsage * mockSiteDataManager.fakeSites.length)); - is(columns[3].value, expected, "Should sum up usages across scheme, port and origin attributes"); + is(columns[2].value, expected, "Should sum up usages across scheme, port, origin attributes and persistent status"); await mockSiteDataManager.unregister(); await BrowserTestUtils.removeTab(gBrowser.selectedTab); }); // Test sorting add_task(async function() { await SpecialPowers.pushPrefEnv({set: [["browser.storageManager.enabled", true]]}); @@ -136,17 +133,16 @@ add_task(async function() { await updatePromise; await openSiteDataSettingsDialog(); let dialog = content.gSubDialog._topDialog; let dialogFrame = dialog._frame; let frameDoc = dialogFrame.contentDocument; let hostCol = frameDoc.getElementById("hostCol"); let usageCol = frameDoc.getElementById("usageCol"); - let statusCol = frameDoc.getElementById("statusCol"); let cookiesCol = frameDoc.getElementById("cookiesCol"); let sitesList = frameDoc.getElementById("sitesList"); // Test default sorting assertSortByUsage("descending"); // Test sorting on the usage column usageCol.click(); @@ -155,28 +151,22 @@ add_task(async function() { assertSortByUsage("descending"); // Test sorting on the host column hostCol.click(); assertSortByBaseDomain("ascending"); hostCol.click(); assertSortByBaseDomain("descending") - // Test sorting on the permission status column + // Test sorting on the cookies column cookiesCol.click(); assertSortByCookies("ascending"); cookiesCol.click(); assertSortByCookies("descending"); - // Test sorting on the cookies column - statusCol.click(); - assertSortByStatus("ascending"); - statusCol.click(); - assertSortByStatus("descending"); - await mockSiteDataManager.unregister(); await BrowserTestUtils.removeTab(gBrowser.selectedTab); function assertSortByBaseDomain(order) { let siteItems = sitesList.getElementsByTagName("richlistitem"); for (let i = 0; i < siteItems.length - 1; ++i) { let aHost = siteItems[i].getAttribute("host"); let bHost = siteItems[i + 1].getAttribute("host"); @@ -186,37 +176,16 @@ add_task(async function() { if (order == "ascending") { Assert.lessOrEqual(result, 0, "Should sort sites in the ascending order by host"); } else { Assert.greaterOrEqual(result, 0, "Should sort sites in the descending order by host"); } } } - function assertSortByStatus(order) { - let siteItems = sitesList.getElementsByTagName("richlistitem"); - for (let i = 0; i < siteItems.length - 1; ++i) { - let aHost = siteItems[i].getAttribute("host"); - let bHost = siteItems[i + 1].getAttribute("host"); - let a = findSiteByHost(aHost); - let b = findSiteByHost(bHost); - let result = 0; - if (a.persisted && !b.persisted) { - result = 1; - } else if (!a.persisted && b.persisted) { - result = -1; - } - if (order == "ascending") { - Assert.lessOrEqual(result, 0, "Should sort sites in the ascending order by permission status"); - } else { - Assert.greaterOrEqual(result, 0, "Should sort sites in the descending order by permission status"); - } - } - } - function assertSortByUsage(order) { let siteItems = sitesList.getElementsByTagName("richlistitem"); for (let i = 0; i < siteItems.length - 1; ++i) { let aHost = siteItems[i].getAttribute("host"); let bHost = siteItems[i + 1].getAttribute("host"); let a = findSiteByHost(aHost); let b = findSiteByHost(bHost); let result = a.usage - b.usage; diff --git a/browser/components/preferences/in-content/tests/browser_siteData.js b/browser/components/preferences/in-content/tests/browser_siteData.js --- a/browser/components/preferences/in-content/tests/browser_siteData.js +++ b/browser/components/preferences/in-content/tests/browser_siteData.js @@ -206,25 +206,25 @@ add_task(async function() { let siteItems = frameDoc.getElementsByTagName("richlistitem"); is(siteItems.length, 2, "Should list two sites with cookies"); let sitesList = frameDoc.getElementById("sitesList"); let site1 = sitesList.querySelector(`richlistitem[host="example.com"]`); let site2 = sitesList.querySelector(`richlistitem[host="example.org"]`); let columns = site1.querySelectorAll(".item-box > label"); is(columns[0].value, "example.com", "Should show the correct host."); - is(columns[2].value, "2", "Should show the correct number of cookies."); - is(columns[3].value, "", "Should show no site data."); - is(columns[4].value, args.creationDate1, "Should show the correct date."); + is(columns[1].value, "2", "Should show the correct number of cookies."); + is(columns[2].value, "", "Should show no site data."); + is(columns[3].value, args.creationDate1, "Should show the correct date."); columns = site2.querySelectorAll(".item-box > label"); is(columns[0].value, "example.org", "Should show the correct host."); - is(columns[2].value, "1", "Should show the correct number of cookies."); - is(columns[3].value, "", "Should show no site data."); - is(columns[4].value, args.creationDate2, "Should show the correct date."); + is(columns[1].value, "1", "Should show the correct number of cookies."); + is(columns[2].value, "", "Should show no site data."); + is(columns[3].value, args.creationDate2, "Should show the correct date."); let removeBtn = frameDoc.getElementById("removeSelected"); let saveBtn = frameDoc.getElementById("save"); site2.click(); removeBtn.doCommand(); saveBtn.doCommand(); }); await removeDialogOpenPromise; @@ -240,19 +240,19 @@ add_task(async function() { let siteItems = frameDoc.getElementsByTagName("richlistitem"); is(siteItems.length, 1, "Should list one site with cookies"); let sitesList = frameDoc.getElementById("sitesList"); let site1 = sitesList.querySelector(`richlistitem[host="example.com"]`); let columns = site1.querySelectorAll(".item-box > label"); is(columns[0].value, "example.com", "Should show the correct host."); - is(columns[2].value, "2", "Should show the correct number of cookies."); - is(columns[3].value, "", "Should show no site data."); - is(columns[4].value, args.creationDate1, "Should show the correct date."); + is(columns[1].value, "2", "Should show the correct number of cookies."); + is(columns[2].value, "", "Should show no site data."); + is(columns[3].value, args.creationDate1, "Should show the correct date."); let removeBtn = frameDoc.getElementById("removeSelected"); let saveBtn = frameDoc.getElementById("save"); site1.click(); removeBtn.doCommand(); saveBtn.doCommand(); }); await acceptRemovePromise; diff --git a/browser/components/preferences/in-content/tests/browser_siteData3.js b/browser/components/preferences/in-content/tests/browser_siteData3.js --- a/browser/components/preferences/in-content/tests/browser_siteData3.js +++ b/browser/components/preferences/in-content/tests/browser_siteData3.js @@ -126,17 +126,16 @@ add_task(async function() { await updatePromise; await openSiteDataSettingsDialog(); let dialog = content.gSubDialog._topDialog; let dialogFrame = dialog._frame; let frameDoc = dialogFrame.contentDocument; let hostCol = frameDoc.getElementById("hostCol"); let usageCol = frameDoc.getElementById("usageCol"); - let statusCol = frameDoc.getElementById("statusCol"); let cookiesCol = frameDoc.getElementById("cookiesCol"); let sitesList = frameDoc.getElementById("sitesList"); // Test default sorting assertSortByUsage("descending"); // Test sorting on the usage column usageCol.click(); @@ -145,28 +144,22 @@ add_task(async function() { assertSortByUsage("descending"); // Test sorting on the host column hostCol.click(); assertSortByBaseDomain("ascending"); hostCol.click(); assertSortByBaseDomain("descending"); - // Test sorting on the permission status column + // Test sorting on the cookies column cookiesCol.click(); assertSortByCookies("ascending"); cookiesCol.click(); assertSortByCookies("descending"); - // Test sorting on the cookies column - statusCol.click(); - assertSortByStatus("ascending"); - statusCol.click(); - assertSortByStatus("descending"); - await mockSiteDataManager.unregister(); await BrowserTestUtils.removeTab(gBrowser.selectedTab); function assertSortByBaseDomain(order) { let siteItems = sitesList.getElementsByTagName("richlistitem"); for (let i = 0; i < siteItems.length - 1; ++i) { let aHost = siteItems[i].getAttribute("host"); let bHost = siteItems[i + 1].getAttribute("host"); @@ -176,37 +169,16 @@ add_task(async function() { if (order == "ascending") { Assert.lessOrEqual(result, 0, "Should sort sites in the ascending order by host"); } else { Assert.greaterOrEqual(result, 0, "Should sort sites in the descending order by host"); } } } - function assertSortByStatus(order) { - let siteItems = sitesList.getElementsByTagName("richlistitem"); - for (let i = 0; i < siteItems.length - 1; ++i) { - let aHost = siteItems[i].getAttribute("host"); - let bHost = siteItems[i + 1].getAttribute("host"); - let a = findSiteByHost(aHost); - let b = findSiteByHost(bHost); - let result = 0; - if (a.persisted && !b.persisted) { - result = 1; - } else if (!a.persisted && b.persisted) { - result = -1; - } - if (order == "ascending") { - Assert.lessOrEqual(result, 0, "Should sort sites in the ascending order by permission status"); - } else { - Assert.greaterOrEqual(result, 0, "Should sort sites in the descending order by permission status"); - } - } - } - function assertSortByUsage(order) { let siteItems = sitesList.getElementsByTagName("richlistitem"); for (let i = 0; i < siteItems.length - 1; ++i) { let aHost = siteItems[i].getAttribute("host"); let bHost = siteItems[i + 1].getAttribute("host"); let a = findSiteByHost(aHost); let b = findSiteByHost(bHost); let result = a.usage - b.usage; diff --git a/browser/components/preferences/siteDataSettings.js b/browser/components/preferences/siteDataSettings.js --- a/browser/components/preferences/siteDataSettings.js +++ b/browser/components/preferences/siteDataSettings.js @@ -13,17 +13,16 @@ ChromeUtils.defineModuleGetter(this, "Do "use strict"; let gSiteDataSettings = { // Array of metadata of sites. Each array element is object holding: // - uri: uri of site; instance of nsIURI // - baseDomain: base domain of the site // - cookies: array of cookies of that site - // - status: persistent-storage permission status // - usage: disk usage which site uses // - userAction: "remove" or "update-permission"; the action user wants to take. _sites: null, _list: null, _searchBox: null, _prefStrBundle: null, @@ -45,31 +44,27 @@ let gSiteDataSettings = { } box.appendChild(label); container.appendChild(box); } // Add "Host" column. addColumnItem(site.host, "4"); - // Add "Status" column - addColumnItem(site.persisted ? - this._prefStrBundle.getString("persistent") : null, "2"); - // Add "Cookies" column. addColumnItem(site.cookies.length, "1"); // Add "Storage" column - if (site.usage > 0) { + if (site.usage > 0 || site.persisted) { let size = DownloadUtils.convertByteUnits(site.usage); - let str = this._prefStrBundle.getFormattedString("siteUsage", size); - addColumnItem(str, "1"); + let strName = site.persisted ? "siteUsagePersistent" : "siteUsage"; + addColumnItem(this._prefStrBundle.getFormattedString(strName, size), "2"); } else { // Pass null to avoid showing "0KB" when there is no site data stored. - addColumnItem(null, "1"); + addColumnItem(null, "2"); } // Add "Last Used" column. addColumnItem(site.lastAccessed > 0 ? this._formatter.format(site.lastAccessed) : null, "2"); item.appendChild(container); return item; @@ -100,17 +95,16 @@ let gSiteDataSettings = { let settingsDescription = document.getElementById("settingsDescription"); settingsDescription.textContent = this._prefStrBundle.getFormattedString("siteDataSettings2.description", [brandShortName]); setEventListener("sitesList", "select", this.onSelect); setEventListener("hostCol", "click", this.onClickTreeCol); setEventListener("usageCol", "click", this.onClickTreeCol); setEventListener("lastAccessedCol", "click", this.onClickTreeCol); setEventListener("cookiesCol", "click", this.onClickTreeCol); - setEventListener("statusCol", "click", this.onClickTreeCol); setEventListener("cancel", "command", this.close); setEventListener("save", "command", this.saveChanges); setEventListener("searchBox", "command", this.onCommandSearch); setEventListener("removeAll", "command", this.onClickRemoveAll); setEventListener("removeSelected", "command", this.onClickRemoveSelected); }, _updateButtonsState() { @@ -147,27 +141,16 @@ let gSiteDataSettings = { case "hostCol": sortFunc = (a, b) => { let aHost = a.baseDomain.toLowerCase(); let bHost = b.baseDomain.toLowerCase(); return aHost.localeCompare(bHost); }; break; - case "statusCol": - sortFunc = (a, b) => { - if (a.persisted && !b.persisted) { - return 1; - } else if (!a.persisted && b.persisted) { - return -1; - } - return 0; - }; - break; - case "cookiesCol": sortFunc = (a, b) => a.cookies.length - b.cookies.length; break; case "usageCol": sortFunc = (a, b) => a.usage - b.usage; break; diff --git a/browser/components/preferences/siteDataSettings.xul b/browser/components/preferences/siteDataSettings.xul --- a/browser/components/preferences/siteDataSettings.xul +++ b/browser/components/preferences/siteDataSettings.xul @@ -33,20 +33,19 @@ - - +