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) {
this.categoriesInitialized = true;
// Each element of gCategoryInits is a name
for (let category of gCategoryInits.values()) {
category.init();
}
if (document.hasPendingL10nMutations) {
await new Promise(r =>
document.addEventListener("L10nMutationsFinished", r, { once: true })
);
for (let [, /* name */ category] of gCategoryInits) {
if (!category.inited) {
await category.init();
}
}
}
},

View File

@ -155,24 +155,43 @@ var gLastCategory = { category: undefined, subcategory: undefined };
const gXULDOMParser = new DOMParser();
var gCategoryModules = 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) {
gCategoryModules.set(categoryName, categoryObject);
gCategoryInits.set(categoryName, {
_initted: false,
init() {
inited: false,
async init() {
let startTime = performance.now();
if (this._initted) {
return;
}
this._initted = true;
let template = document.getElementById("template-" + categoryName);
if (template) {
// 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();
this.inited = true;
ChromeUtils.addProfilerMarker(
"Preferences",
{ startTime },
@ -367,28 +386,24 @@ async function gotoPref(
}
window.history.replaceState(category, document.title);
let categoryInfo = gCategoryInits.get(category);
if (!categoryInfo) {
let err = new Error(
"Unknown in-content prefs category! Can't init " + category
try {
await init_category_if_required(category);
} catch (ex) {
console.error(
new Error(
"Error initializing preference category " + category + ": " + ex
)
);
console.error(err);
throw err;
throw ex;
}
categoryInfo.init();
if (document.hasPendingL10nMutations) {
await new Promise(r =>
document.addEventListener("L10nMutationsFinished", r, { once: true })
);
// Bail out of this goToPref if the category
// or subcategory changed during async operation.
if (
gLastCategory.category !== category ||
gLastCategory.subcategory !== subcategory
) {
return;
}
// Bail out of this goToPref if the category
// or subcategory changed during async operation.
if (
gLastCategory.category !== category ||
gLastCategory.subcategory !== subcategory
) {
return;
}
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(
doc.getElementById(category),
{},
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) {
checkVisibility(
doc.getElementById(definition.id),
shouldShow,
`${definition.id} should be ${
shouldShow ? "visible" : "hidden"
} after category change to ${category}`
true,
`${definition.id} should be visible after category change to ${category}`
);
}
}

View File

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