diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /layout/style/test/test_computed_style_prefs.html | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/style/test/test_computed_style_prefs.html')
-rw-r--r-- | layout/style/test/test_computed_style_prefs.html | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/layout/style/test/test_computed_style_prefs.html b/layout/style/test/test_computed_style_prefs.html new file mode 100644 index 0000000000..c624488e66 --- /dev/null +++ b/layout/style/test/test_computed_style_prefs.html @@ -0,0 +1,94 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test that preffed off properties do not appear in computed style</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=919594">Mozilla Bug 919594</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script type="application/javascript"> + +/** 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.touch_action.enabled": ["touch-action"] +}; + +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) })) +]; + +SimpleTest.waitForExplicitFinish(); +step(); +</script> +</pre> +</body> +</html> |