summaryrefslogtreecommitdiffstats
path: root/ipc/glue/test/browser/head-multiple.js
blob: 0ab098448e2c4cca1c46d03412b259398bbfaa49 (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
70
71
72
73
74
75
76
77
78
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/* import-globals-from head.js */

async function runTest({
  expectUtility = false,
  expectRDD = false,
  expectContent = false,
  expectError = false,
}) {
  info(`Running tests with decoding from somewhere`);
  info(`  expectUtility: ${expectUtility}`);
  info(`  expectRDD: ${expectRDD}`);
  info(`  expectContent: ${expectContent}`);

  // Utility should now be the default, so dont toggle the pref unless we test
  // RDD
  if (!expectUtility) {
    await SpecialPowers.pushPrefEnv({
      set: [["media.utility-process.enabled", expectUtility]],
    });
  }

  const platform = Services.appinfo.OS;

  for (let { src, expectations } of audioTestData()) {
    if (!(platform in expectations)) {
      info(`Skipping ${src} for ${platform}`);
      continue;
    }

    const expectation = expectations[platform];

    info(`Add media tabs: ${src}`);
    let tabs = [await addMediaTab(src), await addMediaTab(src)];
    let playback = [];

    info("Play tabs");
    for (let tab of tabs) {
      playback.push(
        play(
          tab,
          expectUtility && !expectContent && !expectError
            ? expectation.process
            : "RDD",
          expectation.decoder,
          expectContent,
          false, // expectJava
          expectError
        )
      );
    }

    info("Wait all playback");
    await Promise.all(playback);

    let allstop = [];
    info("Stop tabs");
    for (let tab of tabs) {
      allstop.push(stop(tab));
    }

    info("Wait all stop");
    await Promise.all(allstop);

    let remove = [];
    info("Remove tabs");
    for (let tab of tabs) {
      remove.push(BrowserTestUtils.removeTab(tab));
    }

    info("Wait all tabs to be removed");
    await Promise.all(remove);
  }
}