Skip to content

Commit

Permalink
Backed out changeset db1ae5bf8516 (bug 1831259) for causing failures …
Browse files Browse the repository at this point in the history
…in browser_UsageTelemetry_interaction.js CLOSED TREE

browser/components/preferences/preferences.js HG: changed browser/components/preferences/tests/browser_experimental_features_filter.js
  • Loading branch information
nerli1 committed May 23, 2023
1 parent 28b24e1 commit de8af62
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 45 deletions.
11 changes: 4 additions & 7 deletions browser/components/preferences/findInPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
},
Expand Down
67 changes: 41 additions & 26 deletions browser/components/preferences/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
);
}
}
Expand Down

0 comments on commit de8af62

Please sign in to comment.