summaryrefslogtreecommitdiffstats
path: root/devtools/client/performance/test/unit/test_profiler-categories.js
blob: 7ba2881676cb67293bd0b4388a062974488455a7 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

/**
 * Tests if the profiler categories are mapped correctly.
 */

function run_test() {
  run_next_test();
}

add_task(function () {
  let { CATEGORIES, CATEGORY_MAPPINGS } = require("devtools/client/performance/modules/categories");
  let { L10N } = require("devtools/client/performance/modules/global");
  let count = CATEGORIES.length;

  ok(count,
    "Should have a non-empty list of categories available.");

  ok(CATEGORIES.some(e => e.color),
    "All categories have an associated color.");

  ok(CATEGORIES.every(e => e.label),
    "All categories have an associated label.");

  ok(CATEGORIES.every(e => e.label === L10N.getStr("category." + e.abbrev)),
    "All categories have a correctly localized label.");

  ok(Object.keys(CATEGORY_MAPPINGS).every(e => (Number(e) >= 9000 && Number(e) <= 9999) ||
                                                Number.isInteger(Math.log2(e))),
    "All bitmask mappings keys are powers of 2, or between 9000-9999 for special " +
    "categories.");

  ok(Object.keys(CATEGORY_MAPPINGS).every(e => CATEGORIES.indexOf(CATEGORY_MAPPINGS[e])
                                               !== -1),
    "All bitmask mappings point to a category.");
});