Bug 1705168: Enable forced-colors in UA and chrome always r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D112069
This commit is contained in:
Morgan Reschenberg 2021-04-14 21:33:11 +00:00
Родитель c44a60db43
Коммит 26ebc62e3a
2 изменённых файлов: 30 добавлений и 1 удалений

Просмотреть файл

@ -6,6 +6,25 @@
<script>
const SHEET = document.querySelector('style');
SimpleTest.waitForExplicitFinish();
async function testWithPref() {
await new Promise(r => {
SpecialPowers.pushPrefEnv(
{
set: [
["layout.css.forced-colors.enabled", false],
],
},
r
);
});
expectParseable("(forced-colors: none)");
expectParseable("(forced-colors: active)");
expectParseable("(forced-colors)");
SimpleTest.finish();
}
function expect(q, shouldBeParseable) {
const NOT_PARSEABLE_TEXT = "@media screen, not all {\n}";
@ -63,5 +82,11 @@ expectParseable("(prefers-contrast: no-preference)")
expectParseable("(prefers-contrast: less)");
expectParseable("(prefers-contrast)")
expectParseable("(forced-colors: none)");
expectParseable("(forced-colors: active)");
expectParseable("(forced-colors)");
expectNonParseable("(-moz-os-version: )");
testWithPref();
</script>

Просмотреть файл

@ -221,7 +221,11 @@ fn disabled_by_pref(feature: &Atom, context: &ParserContext) -> bool {
#[cfg(feature = "gecko")]
{
if *feature == atom!("forced-colors") {
return !static_prefs::pref!("layout.css.forced-colors.enabled");
// forced-colors is always enabled in the ua and chrome. On
// the web it is hidden behind a preference, which is defaulted
// to 'true' as of bug 1659511.
return !context.in_ua_or_chrome_sheet() &&
!static_prefs::pref!("layout.css.forced-colors.enabled");
}
// prefers-contrast is always enabled in the ua and chrome. On
// the web it is hidden behind a preference.