Skip to content
Snippets Groups Projects
Commit 8ae573ea authored by alwu's avatar alwu
Browse files

Bug 1814749 - part3 : add a test. r=jolin

parent b0968805
No related branches found
No related tags found
No related merge requests found
......@@ -8,3 +8,4 @@ support-files =
../../gizmo.mp4
[browser_wmfme_crash.js]
[browser_wmfme_max_crashes.js]
"use strict";
/**
* This test aims to ensure that the MFCDM process won't be recovered once the
* amount of crashes has exceeded the amount of value which we tolerate.
*/
add_task(async function setupTestingPref() {
await SpecialPowers.pushPrefEnv({
set: [
["media.wmf.media-engine.enabled", true],
["media.wmf.media-engine.channel-decoder.enabled", true],
],
});
});
const VIDEO_PAGE = GetTestWebBasedURL("file_video.html");
add_task(async function testPlaybackRecoveryFromCrash() {
const maxCrashes = Services.prefs.getIntPref(
"media.wmf.media-engine.max-crashes"
);
info(`The amount of tolerable crashes=${maxCrashes}`);
info(`Create a tab and load test page`);
let tab = await BrowserTestUtils.openNewForegroundTab(
window.gBrowser,
"about:blank"
);
BrowserTestUtils.loadURIString(tab.linkedBrowser, VIDEO_PAGE);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await playVideo(tab);
info("Ensure video is running via the media engine framework");
await assertRunningProcessAndDecoderName(tab, {
expectedProcess: "Utility MF Media Engine CDM",
expectedDecoder: "media engine video stream",
});
let pidBeforeCrash, pidAfterCrash;
for (let idx = 0; idx < maxCrashes; idx++) {
pidBeforeCrash = await getMFCDMProcessId();
await crashUtilityProcess(pidBeforeCrash);
info("The CDM process should be recreated which makes media keep playing");
await assertRunningProcessAndDecoderName(tab, {
expectedProcess: "Utility MF Media Engine CDM",
expectedDecoder: "media engine video stream",
});
pidAfterCrash = await getMFCDMProcessId();
isnot(
pidBeforeCrash,
pidAfterCrash,
`new process ${pidAfterCrash} is not previous crashed one ${pidBeforeCrash}`
);
}
info("This crash should result in not spawning MFCDM process again");
pidBeforeCrash = await getMFCDMProcessId();
await crashUtilityProcess(pidBeforeCrash);
await assertNotEqualRunningProcessAndDecoderName(tab, {
givenProcess: "Utility MF Media Engine CDM",
givenDecoder: "media engine video stream",
});
BrowserTestUtils.removeTab(tab);
});
......@@ -161,3 +161,40 @@ async function assertRunningProcessAndDecoderName(
}
);
}
/**
* Check whether the video playback is not performed in the given process and given decoder.
* @param {object} tab
* the tab which has a playing video
* @param {string} givenProcess
* the process name on which the video playback should not be running
* @param {string} givenDecoder
* the decoder name with which the video playback should not be running
*/
async function assertNotEqualRunningProcessAndDecoderName(
tab,
{ givenProcess, givenDecoder } = {}
) {
return SpecialPowers.spawn(
tab.linkedBrowser,
[givenProcess, givenDecoder],
// eslint-disable-next-line no-shadow
async (givenProcess, givenDecoder) => {
const video = content.document.querySelector("video");
ok(!video.paused, "checking a playing video");
const debugInfo = await SpecialPowers.wrap(video).mozRequestDebugInfo();
const videoDecoderName = debugInfo.decoder.reader.videoDecoderName;
const pattern = /(.+?)\s+\((\S+)\s+remote\)/;
const match = videoDecoderName.match(pattern);
if (match) {
const decoder = match[1];
const process = match[2];
isnot(decoder, givenDecoder, `Decoder name is not equal`);
isnot(process, givenProcess, `Process name is not equal`);
} else {
ok(false, "failed to match decoder/process name?");
}
}
);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment