Bug 1805806 - Nullify the onchange listeners before the end of the test to avoid intermittent failures. r=rpl,bholley

Differential Revision: https://phabricator.services.mozilla.com/D167272
This commit is contained in:
William Durand 2023-01-19 17:18:26 +00:00
parent d42dc60869
commit f911a1db2e

View File

@ -54,6 +54,7 @@
// We expect the same states with and without sysex support.
const expectedChangedStates = ["denied", "granted", "prompt"];
const results = [];
for (let sysex of [false, true]) {
let result = await navigator.permissions.query({ name: "midi", sysex });
is(result?.state, "prompt", "expected 'prompt' permission status");
@ -68,6 +69,7 @@
"expected change event with sysex support"
);
};
results.push(result);
} else {
result.onchange = () => {
is(
@ -76,6 +78,7 @@
"expected change event"
);
};
results.push(result);
}
}
@ -169,6 +172,8 @@
await SpecialPowers.removePermission("midi-sysex", document);
await SpecialPowers.removePermission("midi", document);
results.forEach(result => result.onchange = null);
SimpleTest.finish();
}
</script>