summaryrefslogtreecommitdiffstats
path: root/dom/media/test/browser/wmfme/browser_wmfme_max_crashes.js
blob: 44728141713d9f348a6720a3daaa6780fc3ac9dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"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);
});