summaryrefslogtreecommitdiffstats
path: root/devtools/client/performance-new/test/browser/browser_aboutprofiling-interval.js
blob: 6dcc4e11561d4bb0c7b0ee54098f2d433fb2ad38 (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

add_task(async function test() {
  info("Test that about:profiling can modify the sampling interval.");

  await withAboutProfiling(async document => {
    const intervalInput = await getNearestInputFromText(
      document,
      "Sampling interval:"
    );
    is(
      getActiveConfiguration().interval,
      1,
      "The active configuration's interval is set to a specific number initially."
    );
    is(
      intervalInput.getAttribute("aria-valuemin"),
      "0.01",
      "aria-valuemin has the expected value"
    );
    is(
      intervalInput.getAttribute("aria-valuemax"),
      "100",
      "aria-valuemax has the expected value"
    );
    is(
      intervalInput.getAttribute("aria-valuenow"),
      "1",
      "aria-valuenow has the expected value"
    );

    info(
      "Increase the interval by an arbitrary amount. The input range will " +
        "scale that to the final value presented to the profiler."
    );
    setReactFriendlyInputValue(intervalInput, Number(intervalInput.value) + 1);

    is(
      getActiveConfiguration().interval,
      2,
      "The configuration's interval was able to be increased."
    );
    is(
      intervalInput.getAttribute("aria-valuenow"),
      "2",
      "aria-valuenow has the expected value"
    );

    intervalInput.focus();

    info("Increase the interval with the keyboard");
    EventUtils.synthesizeKey("VK_RIGHT");
    await waitUntil(() => getActiveConfiguration().interval === 3);
    is(
      intervalInput.getAttribute("aria-valuenow"),
      "3",
      "aria-valuenow has the expected value"
    );

    info("Decrease the interval with the keyboard");
    EventUtils.synthesizeKey("VK_LEFT");
    await waitUntil(() => getActiveConfiguration().interval === 2);
    is(
      intervalInput.getAttribute("aria-valuenow"),
      "2",
      "aria-valuenow has the expected value"
    );
  });
});