browser_perf-tree-view-03.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 column structure and can auto-expand all nodes.
  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. let $$fun = i => container.querySelectorAll(".call-tree-cell[type=function]")[i];
  20. let $$nam = i => container.querySelectorAll(
  21. ".call-tree-cell[type=function] > .call-tree-name")[i];
  22. let $$dur = i => container.querySelectorAll(".call-tree-cell[type=duration]")[i];
  23. is(container.childNodes.length, 7,
  24. "The container node should have all children available.");
  25. is(Array.filter(container.childNodes, e => e.className != "call-tree-item").length, 0,
  26. "All item nodes in the tree have the correct class name.");
  27. is($$fun(0).style.marginInlineStart, "0px",
  28. "The root node's function cell has the correct indentation.");
  29. is($$fun(1).style.marginInlineStart, "16px",
  30. "The .A node's function cell has the correct indentation.");
  31. is($$fun(2).style.marginInlineStart, "32px",
  32. "The .A.B node's function cell has the correct indentation.");
  33. is($$fun(3).style.marginInlineStart, "48px",
  34. "The .A.B.D node's function cell has the correct indentation.");
  35. is($$fun(4).style.marginInlineStart, "48px",
  36. "The .A.B.C node's function cell has the correct indentation.");
  37. is($$fun(5).style.marginInlineStart, "32px",
  38. "The .A.E node's function cell has the correct indentation.");
  39. is($$fun(6).style.marginInlineStart, "48px",
  40. "The .A.E.F node's function cell has the correct indentation.");
  41. is($$nam(0).textContent.trim(), "(root)",
  42. "The root node's function cell displays the correct name.");
  43. is($$nam(1).textContent.trim(), "A",
  44. "The .A node's function cell displays the correct name.");
  45. is($$nam(2).textContent.trim(), "B",
  46. "The .A.B node's function cell displays the correct name.");
  47. is($$nam(3).textContent.trim(), "D",
  48. "The .A.B.D node's function cell displays the correct name.");
  49. is($$nam(4).textContent.trim(), "C",
  50. "The .A.B.C node's function cell displays the correct name.");
  51. is($$nam(5).textContent.trim(), "E",
  52. "The .A.E node's function cell displays the correct name.");
  53. is($$nam(6).textContent.trim(), "F",
  54. "The .A.E.F node's function cell displays the correct name.");
  55. is($$dur(0).textContent.trim(), "20 ms",
  56. "The root node's function cell displays the correct duration.");
  57. is($$dur(1).textContent.trim(), "20 ms",
  58. "The .A node's function cell displays the correct duration.");
  59. is($$dur(2).textContent.trim(), "15 ms",
  60. "The .A.B node's function cell displays the correct duration.");
  61. is($$dur(3).textContent.trim(), "10 ms",
  62. "The .A.B.D node's function cell displays the correct duration.");
  63. is($$dur(4).textContent.trim(), "5 ms",
  64. "The .A.B.C node's function cell displays the correct duration.");
  65. is($$dur(5).textContent.trim(), "5 ms",
  66. "The .A.E node's function cell displays the correct duration.");
  67. is($$dur(6).textContent.trim(), "5 ms",
  68. "The .A.E.F node's function cell displays the correct duration.");
  69. });