browser_perf-tree-view-07.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. * has the correct 'root', 'parent', 'level' etc. accessors on child 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. container.id = "call-tree-container";
  19. treeRoot.attachTo(container);
  20. let A = treeRoot.getChild();
  21. let B = A.getChild();
  22. let D = B.getChild();
  23. is(D.root, treeRoot,
  24. "The .A.B.D node has the correct root.");
  25. is(D.parent, B,
  26. "The .A.B.D node has the correct parent.");
  27. is(D.level, 3,
  28. "The .A.B.D node has the correct level.");
  29. is(D.target.className, "call-tree-item",
  30. "The .A.B.D node has the correct target node.");
  31. is(D.container.id, "call-tree-container",
  32. "The .A.B.D node has the correct container node.");
  33. });