Backed out changeset af6ffefb5572 (bug 1831259) for causing bc failures in browser_aboutPrefs_fc_check_cantApply.js CLOSED TREE

This commit is contained in:
Cristian Tuns 2023-05-30 23:53:55 -04:00
parent e0e2ecf0c4
commit 2a18c8252e
4 changed files with 49 additions and 50 deletions

View File

@ -105,13 +105,10 @@ var gSearchResultsPane = {
if (!this.categoriesInitialized) { if (!this.categoriesInitialized) {
this.categoriesInitialized = true; this.categoriesInitialized = true;
// Each element of gCategoryInits is a name // Each element of gCategoryInits is a name
for (let category of gCategoryInits.values()) { for (let [, /* name */ category] of gCategoryInits) {
category.init(); if (!category.inited) {
} await category.init();
if (document.hasPendingL10nMutations) { }
await new Promise(r =>
document.addEventListener("L10nMutationsFinished", r, { once: true })
);
} }
} }
}, },

View File

@ -155,24 +155,43 @@ var gLastCategory = { category: undefined, subcategory: undefined };
const gXULDOMParser = new DOMParser(); const gXULDOMParser = new DOMParser();
var gCategoryModules = new Map(); var gCategoryModules = new Map();
var gCategoryInits = new Map(); var gCategoryInits = new Map();
function init_category_if_required(category) {
let categoryInfo = gCategoryInits.get(category);
if (!categoryInfo) {
throw new Error(
"Unknown in-content prefs category! Can't init " + category
);
}
if (categoryInfo.inited) {
return null;
}
return categoryInfo.init();
}
function register_module(categoryName, categoryObject) { function register_module(categoryName, categoryObject) {
gCategoryModules.set(categoryName, categoryObject); gCategoryModules.set(categoryName, categoryObject);
gCategoryInits.set(categoryName, { gCategoryInits.set(categoryName, {
_initted: false, inited: false,
init() { async init() {
let startTime = performance.now(); let startTime = performance.now();
if (this._initted) {
return;
}
this._initted = true;
let template = document.getElementById("template-" + categoryName); let template = document.getElementById("template-" + categoryName);
if (template) { if (template) {
// Replace the template element with the nodes inside of it. // Replace the template element with the nodes inside of it.
template.replaceWith(template.content); let frag = template.content;
await document.l10n.translateFragment(frag);
// Actually insert them into the DOM.
document.l10n.pauseObserving();
template.replaceWith(frag);
document.l10n.resumeObserving();
// We need to queue an update again because the previous update might
// have happened while we awaited on translateFragment.
Preferences.queueUpdateOfAllElements();
} }
categoryObject.init(); categoryObject.init();
this.inited = true;
ChromeUtils.addProfilerMarker( ChromeUtils.addProfilerMarker(
"Preferences", "Preferences",
{ startTime }, { startTime },
@ -367,28 +386,24 @@ async function gotoPref(
} }
window.history.replaceState(category, document.title); window.history.replaceState(category, document.title);
let categoryInfo = gCategoryInits.get(category); try {
if (!categoryInfo) { await init_category_if_required(category);
let err = new Error( } catch (ex) {
"Unknown in-content prefs category! Can't init " + category console.error(
new Error(
"Error initializing preference category " + category + ": " + ex
)
); );
console.error(err); throw ex;
throw err;
} }
categoryInfo.init();
if (document.hasPendingL10nMutations) { // Bail out of this goToPref if the category
await new Promise(r => // or subcategory changed during async operation.
document.addEventListener("L10nMutationsFinished", r, { once: true }) if (
); gLastCategory.category !== category ||
// Bail out of this goToPref if the category gLastCategory.subcategory !== subcategory
// or subcategory changed during async operation. ) {
if ( return;
gLastCategory.category !== category ||
gLastCategory.subcategory !== subcategory
) {
return;
}
} }
search(category, "data-category"); search(category, "data-category");

View File

@ -143,27 +143,17 @@ add_task(async function testFilterFeatures() {
); );
} }
// Check that switching to a non-find-in-page category changes item
// visibility appropriately.
EventUtils.synthesizeMouseAtCenter( EventUtils.synthesizeMouseAtCenter(
doc.getElementById(category), doc.getElementById(category),
{}, {},
gBrowser.contentWindow gBrowser.contentWindow
); );
// Ensure that async passes of localization and any code waiting for
// those passes have finished running.
await new Promise(r =>
requestAnimationFrame(() => requestAnimationFrame(r))
);
let shouldShow = category == "category-experimental";
for (let definition of definitions) { for (let definition of definitions) {
checkVisibility( checkVisibility(
doc.getElementById(definition.id), doc.getElementById(definition.id),
shouldShow, true,
`${definition.id} should be ${ `${definition.id} should be visible after category change to ${category}`
shouldShow ? "visible" : "hidden"
} after category change to ${category}`
); );
} }
} }

View File

@ -689,12 +689,9 @@ add_task(async function mainMenu() {
}); });
add_task(async function preferences() { add_task(async function preferences() {
let finalPaneEvent = Services.prefs.getBoolPref("identity.fxaccounts.enabled") let initialized = BrowserTestUtils.waitForEvent(gBrowser, "Initialized");
? "sync-pane-loaded"
: "privacy-pane-loaded";
let finalPrefPaneLoaded = TestUtils.topicObserved(finalPaneEvent, () => true);
await BrowserTestUtils.withNewTab("about:preferences", async browser => { await BrowserTestUtils.withNewTab("about:preferences", async browser => {
await finalPrefPaneLoaded; await initialized;
Services.telemetry.getSnapshotForKeyedScalars("main", true); Services.telemetry.getSnapshotForKeyedScalars("main", true);