Bug 1860705: Use pushPrefEnv instead of setBoolPref in mochitest test_statechange.html. r=eeejay

setBoolPref has a persistent effect for the rest of the test run (potentially
affecting the behavior of other prefs), so we don't want to use
that. This test is currently failing when run in test-verify mode as a result
of this.  With pushPrefEnv, the test will properly undo its pref-modification
when it completes.

Note: I'm moving the pref-toggle statement inside of a function so that I can
use the ergonomic `await` syntax. This is still essentially right at the start
of the test, since `doTests` is the main function here.

Differential Revision: https://phabricator.services.mozilla.com/D197830
This commit is contained in:
Daniel Holbert 2024-01-09 20:22:57 +00:00
Родитель 5e6ef0e003
Коммит eec12e877e
1 изменённых файлов: 5 добавлений и 6 удалений

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

@ -18,12 +18,6 @@
src="../states.js"></script>
<script type="application/javascript">
// Disable mixed-content upgrading as this test is expecting an HTTP load
Services.prefs.setBoolPref(
"security.mixed_content.upgrade_display_content",
false
);
async function openNode(aIDDetails, aIDSummary, aIsOpen) {
let p = waitForStateChange(aIDSummary, STATE_EXPANDED, aIsOpen, false);
if (aIsOpen) {
@ -369,6 +363,11 @@
}
async function doTests() {
// Disable mixed-content upgrading as this test is expecting an HTTP load
await SpecialPowers.pushPrefEnv({
set: [["security.mixed_content.upgrade_display_content", false]]
});
// Test opening details objects
await openNode("detailsOpen", "summaryOpen", true);
await openNode("detailsOpen", "summaryOpen", false);