browser_perf-tree-view-04.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. /**
  5. * Tests if the profiler's tree view implementation works properly and
  6. * creates the correct DOM nodes in the correct order.
  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 { synthesizeProfile } = require("devtools/client/performance/test/helpers/synth-utils");
  11. add_task(function () {
  12. let profile = synthesizeProfile();
  13. let threadNode = new ThreadNode(profile.threads[0], { startTime: 0, endTime: 20 });
  14. // Don't display the synthesized (root) and the real (root) node twice.
  15. threadNode.calls = threadNode.calls[0].calls;
  16. let treeRoot = new CallView({ frame: threadNode });
  17. let container = document.createElement("vbox");
  18. treeRoot.attachTo(container);
  19. is(treeRoot.target.getAttribute("origin"), "chrome",
  20. "The root node's 'origin' attribute is correct.");
  21. is(treeRoot.target.getAttribute("category"), "",
  22. "The root node's 'category' attribute is correct.");
  23. is(treeRoot.target.getAttribute("tooltiptext"), "",
  24. "The root node's 'tooltiptext' attribute is correct.");
  25. is(treeRoot.target.querySelector(".call-tree-category"), null,
  26. "The root node's category label cell should be hidden.");
  27. let A = treeRoot.getChild();
  28. let B = A.getChild();
  29. let D = B.getChild();
  30. is(D.target.getAttribute("origin"), "chrome",
  31. "The .A.B.D node's 'origin' attribute is correct.");
  32. is(D.target.getAttribute("category"), "gc",
  33. "The .A.B.D node's 'category' attribute is correct.");
  34. is(D.target.getAttribute("tooltiptext"), "D (http://foo/bar/baz:78:9)",
  35. "The .A.B.D node's 'tooltiptext' attribute is correct.");
  36. is(D.target.childNodes.length, 6,
  37. "The number of columns displayed for tree items is correct.");
  38. is(D.target.childNodes[0].getAttribute("type"), "duration",
  39. "The first column displayed for tree items is correct.");
  40. is(D.target.childNodes[1].getAttribute("type"), "percentage",
  41. "The third column displayed for tree items is correct.");
  42. is(D.target.childNodes[2].getAttribute("type"), "self-duration",
  43. "The second column displayed for tree items is correct.");
  44. is(D.target.childNodes[3].getAttribute("type"), "self-percentage",
  45. "The fourth column displayed for tree items is correct.");
  46. is(D.target.childNodes[4].getAttribute("type"), "samples",
  47. "The fifth column displayed for tree items is correct.");
  48. is(D.target.childNodes[5].getAttribute("type"), "function",
  49. "The sixth column displayed for tree items is correct.");
  50. let functionCell = D.target.childNodes[5];
  51. is(functionCell.childNodes.length, 7,
  52. "The number of columns displayed for function cells is correct.");
  53. is(functionCell.childNodes[0].className, "arrow theme-twisty",
  54. "The first node displayed for function cells is correct.");
  55. is(functionCell.childNodes[1].className, "plain call-tree-name",
  56. "The second node displayed for function cells is correct.");
  57. is(functionCell.childNodes[2].className, "plain call-tree-url",
  58. "The third node displayed for function cells is correct.");
  59. is(functionCell.childNodes[3].className, "plain call-tree-line",
  60. "The fourth node displayed for function cells is correct.");
  61. is(functionCell.childNodes[4].className, "plain call-tree-column",
  62. "The fifth node displayed for function cells is correct.");
  63. is(functionCell.childNodes[5].className, "plain call-tree-host",
  64. "The sixth node displayed for function cells is correct.");
  65. is(functionCell.childNodes[6].className, "plain call-tree-category",
  66. "The seventh node displayed for function cells is correct.");
  67. });