/** Test that preffed off properties do not appear in computed style **/
function testWithAllPrefsDisabled() {
let exposedProperties = Object.keys(gCS).map(i => gCS[i]);
// Store the number of properties for later tests to use.
gLengthWithAllPrefsDisabled = gCS.length;
// Check that all of the properties behind the prefs are not exposed.
for (let pref in gProps) {
for (let prop of gProps[pref]) {
ok(!exposedProperties.includes(prop), prop + " not exposed when prefs are false");
}
}
}
function testWithOnePrefEnabled(aPref) {
let exposedProperties = Object.keys(gCS).map(i => gCS[i]);
// Check that the number of properties on the object is as expected.
is(gCS.length, gLengthWithAllPrefsDisabled + gProps[aPref].length, "length when " + aPref + " is true");
// Check that the properties corresponding to aPref are exposed.
for (let prop of gProps[aPref]) {
ok(exposedProperties.includes(prop), prop + " exposed when " + aPref + " is true");
}
}
function step() {
if (gTestIndex == gTests.length) {
// Reached the end of the tests.
SimpleTest.finish();
return;
}
if (gPrefsPushed) {
// We've just finished running one tests. Pop the prefs and go on to
// the next test.
gTestIndex++;
gPrefsPushed = false;
SpecialPowers.popPrefEnv(step);
return;
}
// About to run one test. Push the prefs and run it.
let fn = gTests[gTestIndex].fn;
gPrefsPushed = true;
SpecialPowers.pushPrefEnv(gTests[gTestIndex].settings,
function() { fn(); SimpleTest.executeSoon(step); });
}
// ----
var gProps = { "layout.css.backdrop-filter.enabled": ["backdrop-filter"],
};
var gCS = getComputedStyle(document.body, ""); var gLengthWithAllPrefsDisabled;
var gTestIndex = 0; var gPrefsPushed = false; var gTests = [
// First, test when all of the prefs are disabled.
{ settings: { set: Object.keys(gProps).map(x => [x, false]) },
fn: testWithAllPrefsDisabled },
// Then, test each pref enabled individually.
...Object.keys(gProps).map(p =>
({ settings: { set: Object.keys(gProps).map(x => [x, x == p]) },
fn: testWithOnePrefEnabled.bind(null, p) }))
];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.