summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/xpcshell/test_ext_geckoProfiler_schema.js
blob: d0bbf7e60f99fdc5bbf7e77422cae0ccc23f96e0 (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
"use strict";

add_task(async function() {
  const acceptedExtensionIdsPref =
    "extensions.geckoProfiler.acceptedExtensionIds";
  Services.prefs.setCharPref(
    acceptedExtensionIdsPref,
    "profilertest@mozilla.com"
  );

  let extension = ExtensionTestUtils.loadExtension({
    background: () => {
      browser.test.sendMessage(
        "features",
        Object.values(browser.geckoProfiler.ProfilerFeature)
      );
    },
    manifest: {
      permissions: ["geckoProfiler"],
      applications: {
        gecko: {
          id: "profilertest@mozilla.com",
        },
      },
    },
  });

  await extension.startup();
  let acceptedFeatures = await extension.awaitMessage("features");
  await extension.unload();

  Services.prefs.clearUserPref(acceptedExtensionIdsPref);

  const allFeaturesAcceptedByProfiler = Services.profiler.GetAllFeatures();
  ok(
    allFeaturesAcceptedByProfiler.length >= 2,
    "Either we've massively reduced the profiler's feature set, or something is wrong."
  );

  // Check that the list of available values in the ProfilerFeature enum
  // matches the list of features supported by the profiler.
  for (const feature of allFeaturesAcceptedByProfiler) {
    ok(
      acceptedFeatures.includes(feature),
      `The schema of the geckoProfiler.start() method should accept the "${feature}" feature.`
    );
  }
  for (const feature of acceptedFeatures) {
    ok(
      // Bug 1594566 - ignore Responsiveness until the extension is updated
      allFeaturesAcceptedByProfiler.includes(feature) ||
        feature == "responsiveness",
      `The schema of the geckoProfiler.start() method mentions a "${feature}" feature which is not supported by the profiler.`
    );
  }
});