summaryrefslogtreecommitdiffstats
path: root/devtools/client/performance/test/browser_perf-tree-view-08.js
blob: 7b65ea45cf44d3b9723de26811f9869bd9b0941e (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

/**
 * Tests that the profiler's tree view renders generalized platform data
 * when `contentOnly` is on correctly.
 */

const { ThreadNode } = require("devtools/client/performance/modules/logic/tree-model");
const { CallView } = require("devtools/client/performance/modules/widgets/tree-view");
const { CATEGORY_MASK } = require("devtools/client/performance/modules/categories");
const RecordingUtils = require("devtools/shared/performance/recording-utils");

add_task(function () {
  let threadNode = new ThreadNode(gProfile.threads[0], { startTime: 0, endTime: 20,
                                                         contentOnly: true });

  // Don't display the synthesized (root) and the real (root) node twice.
  threadNode.calls = threadNode.calls[0].calls;

  let treeRoot = new CallView({ frame: threadNode, autoExpandDepth: 10 });
  let container = document.createElement("vbox");
  treeRoot.attachTo(container);

  /*
   * (root)
   *   - A
   *     - B
   *       - C
   *       - D
   *     - (GC)
   *     - E
   *       - F
   *         - (JS)
   *   - (JS)
   */

  let A = treeRoot.getChild(0);
  let JS = treeRoot.getChild(1);
  let GC = A.getChild(1);
  let JS2 = A.getChild(2).getChild().getChild();

  is(JS.target.getAttribute("category"), "js",
    "Generalized JS node has correct category");
  is(JS.target.getAttribute("tooltiptext"), "JIT",
    "Generalized JS node has correct category");
  is(JS.target.querySelector(".call-tree-name").textContent.trim(), "JIT",
    "Generalized JS node has correct display value as just the category name.");

  is(JS2.target.getAttribute("category"), "js",
    "Generalized second JS node has correct category");
  is(JS2.target.getAttribute("tooltiptext"), "JIT",
    "Generalized second JS node has correct category");
  is(JS2.target.querySelector(".call-tree-name").textContent.trim(), "JIT",
    "Generalized second JS node has correct display value as just the category name.");

  is(GC.target.getAttribute("category"), "gc",
    "Generalized GC node has correct category");
  is(GC.target.getAttribute("tooltiptext"), "GC",
    "Generalized GC node has correct category");
  is(GC.target.querySelector(".call-tree-name").textContent.trim(), "GC",
    "Generalized GC node has correct display value as just the category name.");
});

const gProfile = RecordingUtils.deflateProfile({
  meta: { version: 2 },
  threads: [{
    samples: [{
      time: 1,
      frames: [
        { location: "(root)" },
        { location: "http://content/A" },
        { location: "http://content/B" },
        { location: "http://content/C" }
      ]
    }, {
      time: 1 + 1,
      frames: [
        { location: "(root)" },
        { location: "http://content/A" },
        { location: "http://content/B" },
        { location: "http://content/D" }
      ]
    }, {
      time: 1 + 1 + 2,
      frames: [
        { location: "(root)" },
        { location: "http://content/A" },
        { location: "http://content/E" },
        { location: "http://content/F" },
        { location: "platform_JS", category: CATEGORY_MASK("js") },
      ]
    }, {
      time: 1 + 1 + 2 + 3,
      frames: [
        { location: "(root)" },
        { location: "platform_JS2", category: CATEGORY_MASK("js") },
      ]
    }, {
      time: 1 + 1 + 2 + 3 + 5,
      frames: [
        { location: "(root)" },
        { location: "http://content/A" },
        { location: "platform_GC", category: CATEGORY_MASK("gc", 1) },
      ]
    }]
  }]
});