browser_perf-tree-view-01.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://foo/bar/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 column structure.
  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.autoExpandDepth = 0;
  19. treeRoot.attachTo(container);
  20. is(container.childNodes.length, 1,
  21. "The container node should have one child available.");
  22. is(container.childNodes[0].className, "call-tree-item",
  23. "The root node in the tree has the correct class name.");
  24. is(container.childNodes[0].childNodes.length, 6,
  25. "The root node in the tree has the correct number of children.");
  26. is(container.childNodes[0].querySelectorAll(".call-tree-cell").length, 6,
  27. "The root node in the tree has only 6 'call-tree-cell' children.");
  28. is(container.childNodes[0].childNodes[0].getAttribute("type"), "duration",
  29. "The root node in the tree has a duration cell.");
  30. is(container.childNodes[0].childNodes[0].textContent.trim(), "20 ms",
  31. "The root node in the tree has the correct duration cell value.");
  32. is(container.childNodes[0].childNodes[1].getAttribute("type"), "percentage",
  33. "The root node in the tree has a percentage cell.");
  34. is(container.childNodes[0].childNodes[1].textContent.trim(), "100%",
  35. "The root node in the tree has the correct percentage cell value.");
  36. is(container.childNodes[0].childNodes[2].getAttribute("type"), "self-duration",
  37. "The root node in the tree has a self-duration cell.");
  38. is(container.childNodes[0].childNodes[2].textContent.trim(), "0 ms",
  39. "The root node in the tree has the correct self-duration cell value.");
  40. is(container.childNodes[0].childNodes[3].getAttribute("type"), "self-percentage",
  41. "The root node in the tree has a self-percentage cell.");
  42. is(container.childNodes[0].childNodes[3].textContent.trim(), "0%",
  43. "The root node in the tree has the correct self-percentage cell value.");
  44. is(container.childNodes[0].childNodes[4].getAttribute("type"), "samples",
  45. "The root node in the tree has an samples cell.");
  46. is(container.childNodes[0].childNodes[4].textContent.trim(), "0",
  47. "The root node in the tree has the correct samples cell value.");
  48. is(container.childNodes[0].childNodes[5].getAttribute("type"), "function",
  49. "The root node in the tree has a function cell.");
  50. is(container.childNodes[0].childNodes[5].style.marginInlineStart, "0px",
  51. "The root node in the tree has the correct indentation.");
  52. });