browser_perf-tree-view-08.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. /**
  5. * Tests that the profiler's tree view renders generalized platform data
  6. * when `contentOnly` is on correctly.
  7. */
  8. const { ThreadNode } = require("devtools/client/performance/modules/logic/tree-model");
  9. const { CallView } = require("devtools/client/performance/modules/widgets/tree-view");
  10. const { CATEGORY_MASK } = require("devtools/client/performance/modules/categories");
  11. const RecordingUtils = require("devtools/shared/performance/recording-utils");
  12. add_task(function () {
  13. let threadNode = new ThreadNode(gProfile.threads[0], { startTime: 0, endTime: 20,
  14. contentOnly: true });
  15. // Don't display the synthesized (root) and the real (root) node twice.
  16. threadNode.calls = threadNode.calls[0].calls;
  17. let treeRoot = new CallView({ frame: threadNode, autoExpandDepth: 10 });
  18. let container = document.createElement("vbox");
  19. treeRoot.attachTo(container);
  20. /*
  21. * (root)
  22. * - A
  23. * - B
  24. * - C
  25. * - D
  26. * - (GC)
  27. * - E
  28. * - F
  29. * - (JS)
  30. * - (JS)
  31. */
  32. let A = treeRoot.getChild(0);
  33. let JS = treeRoot.getChild(1);
  34. let GC = A.getChild(1);
  35. let JS2 = A.getChild(2).getChild().getChild();
  36. is(JS.target.getAttribute("category"), "js",
  37. "Generalized JS node has correct category");
  38. is(JS.target.getAttribute("tooltiptext"), "JIT",
  39. "Generalized JS node has correct category");
  40. is(JS.target.querySelector(".call-tree-name").textContent.trim(), "JIT",
  41. "Generalized JS node has correct display value as just the category name.");
  42. is(JS2.target.getAttribute("category"), "js",
  43. "Generalized second JS node has correct category");
  44. is(JS2.target.getAttribute("tooltiptext"), "JIT",
  45. "Generalized second JS node has correct category");
  46. is(JS2.target.querySelector(".call-tree-name").textContent.trim(), "JIT",
  47. "Generalized second JS node has correct display value as just the category name.");
  48. is(GC.target.getAttribute("category"), "gc",
  49. "Generalized GC node has correct category");
  50. is(GC.target.getAttribute("tooltiptext"), "GC",
  51. "Generalized GC node has correct category");
  52. is(GC.target.querySelector(".call-tree-name").textContent.trim(), "GC",
  53. "Generalized GC node has correct display value as just the category name.");
  54. });
  55. const gProfile = RecordingUtils.deflateProfile({
  56. meta: { version: 2 },
  57. threads: [{
  58. samples: [{
  59. time: 1,
  60. frames: [
  61. { location: "(root)" },
  62. { location: "http://content/A" },
  63. { location: "http://content/B" },
  64. { location: "http://content/C" }
  65. ]
  66. }, {
  67. time: 1 + 1,
  68. frames: [
  69. { location: "(root)" },
  70. { location: "http://content/A" },
  71. { location: "http://content/B" },
  72. { location: "http://content/D" }
  73. ]
  74. }, {
  75. time: 1 + 1 + 2,
  76. frames: [
  77. { location: "(root)" },
  78. { location: "http://content/A" },
  79. { location: "http://content/E" },
  80. { location: "http://content/F" },
  81. { location: "platform_JS", category: CATEGORY_MASK("js") },
  82. ]
  83. }, {
  84. time: 1 + 1 + 2 + 3,
  85. frames: [
  86. { location: "(root)" },
  87. { location: "platform_JS2", category: CATEGORY_MASK("js") },
  88. ]
  89. }, {
  90. time: 1 + 1 + 2 + 3 + 5,
  91. frames: [
  92. { location: "(root)" },
  93. { location: "http://content/A" },
  94. { location: "platform_GC", category: CATEGORY_MASK("gc", 1) },
  95. ]
  96. }]
  97. }]
  98. });