Bug 1721899 - Update waitForShutdownDecoder helper function to use mozRequestDebugInfo. r=bryce

The waitForShutdownDecoder test helper function was introduced in bug 1521964,
but the interface for the function that it was calling (mozDebugReaderData)
changed in bug 1542674. Due to the way the promiseWaitForCondition used to
work before bug 1721898, the sudden breakage of that interface was silently
ignored and this helper function stopped working without us knowing.

After bug 1721898 landed, this breakage suddenly became visible. This patch
updates waitForShutdownDecoder to use the machine-readable debug data
structure that was introduced in bug 1542674. It's still a hacky way of
determining when a video decoder has shut down, but I'm not aware of
any other way of doing that, and this is just for a test.

Differential Revision: https://phabricator.services.mozilla.com/D121766
This commit is contained in:
Mike Conley 2022-03-30 20:05:53 +00:00
Родитель 0e0fd88032
Коммит 7a52e8a584
1 изменённых файлов: 4 добавлений и 8 удалений

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

@ -196,14 +196,10 @@ function waitForEventOnce(target, event) {
* @resolves
* When the decoder has shut down.
*/
async function waitForShutdownDecoder(video) {
await SimpleTest.promiseWaitForCondition(async () => {
// FIXME(bug 1721899): previously `promiseWaitForCondition` wouldn't await
// on async functions, so the condition would always immediately resolve as
// `true`.
return true;
// let readerData = SpecialPowers.wrap(video).mozDebugReaderData;
// return readerData.includes(": shutdown");
function waitForShutdownDecoder(video) {
return SimpleTest.promiseWaitForCondition(async () => {
let readerData = await SpecialPowers.wrap(video).mozRequestDebugInfo();
return readerData.decoder.reader.audioDecoderName == "shutdown";
}, "Video decoder should eventually shut down.");
}