4 <title>Test that preffed off properties do not appear in computed style
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
9 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=919594">Mozilla Bug
919594</a>
11 <div id=
"content" style=
"display: none">
15 <script type=
"application/javascript">
17 /** Test that preffed off properties do not appear in computed style **/
19 function testWithAllPrefsDisabled() {
20 let exposedProperties = Object.keys(gCS).map(i =
> gCS[i]);
22 // Store the number of properties for later tests to use.
23 gLengthWithAllPrefsDisabled = gCS.length;
25 // Check that all of the properties behind the prefs are not exposed.
26 for (let pref in gProps) {
27 for (let prop of gProps[pref]) {
28 ok(!exposedProperties.includes(prop), prop +
" not exposed when prefs are false");
33 function testWithOnePrefEnabled(aPref) {
34 let exposedProperties = Object.keys(gCS).map(i =
> gCS[i]);
36 // Check that the number of properties on the object is as expected.
37 is(gCS.length, gLengthWithAllPrefsDisabled + gProps[aPref].length,
"length when " + aPref +
" is true");
39 // Check that the properties corresponding to aPref are exposed.
40 for (let prop of gProps[aPref]) {
41 ok(exposedProperties.includes(prop), prop +
" exposed when " + aPref +
" is true");
46 if (gTestIndex == gTests.length) {
47 // Reached the end of the tests.
53 // We've just finished running one tests. Pop the prefs and go on to
57 SpecialPowers.popPrefEnv(step);
61 // About to run one test. Push the prefs and run it.
62 let fn = gTests[gTestIndex].fn;
64 SpecialPowers.pushPrefEnv(gTests[gTestIndex].settings,
65 function() { fn(); SimpleTest.executeSoon(step); });
71 "layout.css.backdrop-filter.enabled": [
"backdrop-filter"],
74 var gCS = getComputedStyle(document.body,
"");
75 var gLengthWithAllPrefsDisabled;
78 var gPrefsPushed = false;
80 // First, test when all of the prefs are disabled.
81 { settings: { set: Object.keys(gProps).map(x =
> [x, false]) },
82 fn: testWithAllPrefsDisabled },
83 // Then, test each pref enabled individually.
84 ...Object.keys(gProps).map(p =
>
85 ({ settings: { set: Object.keys(gProps).map(x =
> [x, x == p]) },
86 fn: testWithOnePrefEnabled.bind(null, p) }))
89 SimpleTest.waitForExplicitFinish();