Files
sousa-gecko/browser/components/preferences/tests/browser_fluent.js
T
Tim Giles 355b2cce60 Bug 2037667 - Part 2: Update shared preferences tests for SRD pref flip r=mkennedy
Update shared preferences tests so they pass under both the legacy XUL
preferences and the new settings redesign preferences. Each file follows
one or more of these patterns:

- Calls `openPrefsTab` helper from head.js for pane navigation.
- Replace hard-coded pane/subcategory selectors with unscoped versions.
  SRD pane containers don't have a DOM id while the legacy containers
  do.
- Add SRD-conditional branches for elements that change when the
  redesign is enabled. This includes pane location, DOM shape, or
  telemetry bucket changes.
- Guard null-element accesses, fix sync-pane-loaded observer leaks, and
  use assertions with a tolerance value where exact equality checks were
  too strict.
- Drop redundant inline `browser.settings-redesign.enabled=true`
  pushPrefEnv calls.

Note: This commit pairs with the previous commit in the stack (Part 1).
browser-srd.toml entries added there reference these files, so these two
commits must land or back out together.

Differential Revision: https://phabricator.services.mozilla.com/D302556
2026-05-29 05:47:05 +00:00

42 lines
1.3 KiB
JavaScript

function whenMainPaneLoadedFinished() {
return new Promise(function (resolve) {
const topic = "main-pane-loaded";
Services.obs.addObserver(function observer() {
Services.obs.removeObserver(observer, topic);
resolve();
}, topic);
});
}
// Temporary test for an experimental new localization API.
// See bug 1402069 for details.
add_task(async function () {
// The string is used only when `browserTabsRemoteAutostart` is true
if (!Services.appinfo.browserTabsRemoteAutostart) {
ok(true, "fake test to avoid harness complaining");
return;
}
let doc;
if (SRD_PREF_VALUE) {
// paneGeneral is never registered under SRD, so main-pane-loaded never
// fires. Open the default pane via openPrefsTab instead.
let tab = await openPrefsTab("");
doc = tab.linkedBrowser.contentDocument;
} else {
await Promise.all([
openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true }),
whenMainPaneLoadedFinished(),
]);
doc = gBrowser.contentDocument;
}
await doc.l10n.ready;
let [msg] = await doc.l10n.formatMessages([{ id: "pane-general-title" }]);
ok(msg.value, "pane-general-title message has a value");
Assert.equal(msg.attributes, null, "pane-general-title has no attributes");
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});