Backed out changeset 5da81833a114 (bug 1754772) for causing bc failures on browser_Troubleshoot.js. CLOSED TREE

This commit is contained in:
Marian-Vasile Laza
2022-10-24 18:59:03 +03:00
parent 9a792da492
commit 593a27e0c4
7 changed files with 21 additions and 138 deletions

View File

@@ -144,47 +144,3 @@ add_task(async function test_remote_configuration() {
await doCleanup();
});
add_task(async function test_places_db_stats_table() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:support" },
async function(browser) {
const [
initialToggleText,
toggleTextAfterShow,
toggleTextAfterHide,
] = await SpecialPowers.spawn(browser, [], async function() {
const toggleButton = content.document.getElementById(
"place-database-stats-toggle"
);
const getToggleText = () =>
content.document.l10n.getAttributes(toggleButton).id;
const toggleTexts = [];
const table = content.document.getElementById(
"place-database-stats-tbody"
);
await ContentTaskUtils.waitForCondition(
() => table.style.display === "none",
"Stats table is hidden initially"
);
toggleTexts.push(getToggleText());
toggleButton.click();
await ContentTaskUtils.waitForCondition(
() => table.style.display === "",
"Stats table is shown after first toggle"
);
toggleTexts.push(getToggleText());
toggleButton.click();
await ContentTaskUtils.waitForCondition(
() => table.style.display === "none",
"Stats table is hidden after second toggle"
);
toggleTexts.push(getToggleText());
return toggleTexts;
});
Assert.equal(initialToggleText, "place-database-stats-show");
Assert.equal(toggleTextAfterShow, "place-database-stats-hide");
Assert.equal(toggleTextAfterHide, "place-database-stats-show");
}
);
});

View File

@@ -430,7 +430,26 @@ const placesStatsHandler = new (class extends TableViewer {
* Loads the current metadata from the database and updates the display.
*/
async updateDisplay() {
let data = await PlacesDBUtils.getEntitiesStatsAndCounts();
let stats = await PlacesDBUtils.getEntitiesStats();
let data = [];
let db = await PlacesUtils.promiseDBConnection();
for (let [entity, value] of stats) {
let count = "-";
try {
if (
entity.startsWith("moz_") &&
!entity.endsWith("index") &&
entity != "moz_places_visitcount" /* bug in index name */
) {
count = (
await db.execute(`SELECT count(*) FROM ${entity}`)
)[0].getResultByIndex(0);
}
} catch (ex) {
console.error(ex);
}
data.push(Object.assign(value, { entity, count }));
}
this.displayData(data);
}
})();

View File

@@ -1371,38 +1371,6 @@ export var PlacesDBUtils = {
return entitiesByName;
},
/**
* Gets detailed statistics about database entities and their respective row
* counts.
* @returns {Array} An array that augments each object returned by
* {@link getEntitiesStats} with the following extra properties:
* - entity: name of the entity
* - count: row count of the entity
*/
async getEntitiesStatsAndCounts() {
let stats = await PlacesDBUtils.getEntitiesStats();
let data = [];
let db = await lazy.PlacesUtils.promiseDBConnection();
for (let [entity, value] of stats) {
let count = "-";
try {
if (
entity.startsWith("moz_") &&
!entity.endsWith("index") &&
entity != "moz_places_visitcount" /* bug in index name */
) {
count = (
await db.execute(`SELECT count(*) FROM ${entity}`)
)[0].getResultByIndex(0);
}
} catch (ex) {
console.error(ex);
}
data.push(Object.assign(value, { entity, count }));
}
return data;
},
/**
* Runs a list of tasks, returning a Map when done.
*

View File

@@ -432,33 +432,6 @@ var snapshotFormatters = {
$.append($("locked-prefs-tbody"), prefsTable(data));
},
places(data) {
const statsBody = $("place-database-stats-tbody");
$.append(
statsBody,
data.map(function(entry) {
return $.new("tr", [
$.new("td", entry.entity),
$.new("td", entry.count),
$.new("td", entry.sizeBytes / 1024),
$.new("td", entry.sizePerc),
$.new("td", entry.efficiencyPerc),
$.new("td", entry.sequentialityPerc),
]);
})
);
statsBody.style.display = "none";
$("place-database-stats-toggle").addEventListener("click", function(event) {
if (statsBody.style.display === "none") {
document.l10n.setAttributes(event.target, "place-database-stats-hide");
statsBody.style.display = "";
} else {
document.l10n.setAttributes(event.target, "place-database-stats-show");
statsBody.style.display = "none";
}
});
},
printingPreferences(data) {
if (AppConstants.platform == "android") {
return;

View File

@@ -647,28 +647,11 @@
<tr class="no-copy">
<th class="column" data-l10n-id="place-database-integrity"/>
<td colspan="5">
<td>
<button id="verify-place-integrity-button" data-l10n-id="place-database-verify-integrity"/>
<pre id="verify-place-result" class="hidden no-copy"></pre>
</td>
</tr>
<tr class="no-copy">
<th class="column" data-l10n-id="place-database-stats"/>
<td colspan="5">
<button id="place-database-stats-toggle" data-l10n-id="place-database-stats-show"/>
</td>
</tr>
</tbody>
<tbody id="place-database-stats-tbody">
<tr>
<th data-l10n-id="place-database-stats-entity"/>
<th data-l10n-id="place-database-stats-count"/>
<th data-l10n-id="place-database-stats-size-kib"/>
<th data-l10n-id="place-database-stats-size-perc"/>
<th data-l10n-id="place-database-stats-efficiency-perc"/>
<th data-l10n-id="place-database-stats-sequentiality-perc"/>
</tr>
</tbody>
</table>
#endif

View File

@@ -118,15 +118,6 @@ graphics-window-protocol = Window Protocol
# Desktop environment in use on Linux (e.g. GNOME, KDE, XFCE, etc).
graphics-desktop-environment = Desktop Environment
place-database-title = Places Database
place-database-stats = Statistics
place-database-stats-show = Show Statistics
place-database-stats-hide = Hide Statistics
place-database-stats-entity = Entity
place-database-stats-count = Count
place-database-stats-size-kib = Size (KiB)
place-database-stats-size-perc = Size (%)
place-database-stats-efficiency-perc = Efficiency (%)
place-database-stats-sequentiality-perc = Sequentiality (%)
place-database-integrity = Integrity
place-database-verify-integrity = Verify Integrity
a11y-title = Accessibility

View File

@@ -11,9 +11,6 @@ import { E10SUtils } from "resource://gre/modules/E10SUtils.sys.mjs";
const { FeatureGate } = ChromeUtils.import(
"resource://featuregates/FeatureGate.jsm"
);
const { PlacesDBUtils } = ChromeUtils.importESModule(
"resource://gre/modules/PlacesDBUtils.sys.mjs"
);
// We use a list of prefs for display to make sure we only show prefs that
// are useful for support and won't compromise the user's privacy. Note that
@@ -488,10 +485,6 @@ var dataProviders = {
);
},
places: async function places(done) {
done(await PlacesDBUtils.getEntitiesStatsAndCounts());
},
printingPreferences: function printingPreferences(done) {
let filter = name => Services.prefs.prefHasUserValue(name);
let prefs = getPrefList(filter, ["print."]);