Bug 1972971 - Add missing invalidation for use_document_fonts pref. r=layout-reviewers,jfkthame a=dmeehan

It was getting it for free before D243340 because of the:

  if (PreferenceSheet::AffectedByPref(prefName)) {
    restyleHint |= RestyleHint::RestyleSubtree();
    PreferenceSheet::Refresh();
    UpdateForcedColors();
  }

Tweak test_dont_use_document_fonts to cover this.

Differential Revision: https://phabricator.services.mozilla.com/D254664
This commit is contained in:
Emilio Cobos Álvarez
2025-06-23 12:51:39 +00:00
committed by dmeehan@mozilla.com
parent 3986b0ddfa
commit 3678041f7b
2 changed files with 13 additions and 5 deletions

View File

@@ -94,21 +94,28 @@ test(function() {
}, "Sanity"); }, "Sanity");
function runTest({ specified, computed, description, expected }) { function runTest({ specified, computed, description, expected }) {
test(function() { promise_test(async function() {
content.style.fontFamily = ""; content.style.fontFamily = "";
content.style.fontFamily = specified; content.style.fontFamily = specified;
assert_equals(getComputedStyle(content).fontFamily, expected); const before = getComputedStyle(content).fontFamily;
await SpecialPowers.pushPrefEnv({'set': [['browser.display.use_document_fonts', 0]]});
const after = getComputedStyle(content).fontFamily;
if (specified != computed) {
assert_not_equals(before, after);
}
assert_equals(after, expected);
await SpecialPowers.popPrefEnv();
}, description); }, description);
} }
(async function() { (async function() {
await SpecialPowers.pushPrefEnv({'set': [['browser.display.use_document_fonts', 0]]});
for (const test of kTests) for (const test of kTests)
runTest(test); runTest(test);
promise_test(async function() {
test(function() { await SpecialPowers.pushPrefEnv({'set': [['browser.display.use_document_fonts', 0]]});
content.style.font = "menu"; content.style.font = "menu";
assert_equals(getComputedStyle(content).fontFamily, systemFont); assert_equals(getComputedStyle(content).fontFamily, systemFont);
await SpecialPowers.popPrefEnv();
}, "System font should be honored"); }, "System font should be honored");
done(); done();

View File

@@ -542,6 +542,7 @@ static constexpr struct {
{"browser.display.foreground_color.dark"_ns, {"browser.display.foreground_color.dark"_ns,
widget::ThemeChangeKind::Style}, widget::ThemeChangeKind::Style},
{"browser.display.document_color_use"_ns, widget::ThemeChangeKind::Style}, {"browser.display.document_color_use"_ns, widget::ThemeChangeKind::Style},
{"browser.display.use_document_fonts"_ns, widget::ThemeChangeKind::Style},
{"browser.display.permit_backplate"_ns, widget::ThemeChangeKind::Style}, {"browser.display.permit_backplate"_ns, widget::ThemeChangeKind::Style},
{"ui.use_standins_for_native_colors"_ns, widget::ThemeChangeKind::Style}, {"ui.use_standins_for_native_colors"_ns, widget::ThemeChangeKind::Style},
{"privacy.resistFingerprinting"_ns, widget::ThemeChangeKind::Style}, {"privacy.resistFingerprinting"_ns, widget::ThemeChangeKind::Style},