browser_perf-tree-view-05.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. * can toggle categories hidden or visible.
  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 categories = container.querySelectorAll(".call-tree-category");
  20. is(categories.length, 6,
  21. "The call tree displays a correct number of categories.");
  22. ok(!container.hasAttribute("categories-hidden"),
  23. "All categories should be visible in the tree.");
  24. treeRoot.toggleCategories(false);
  25. is(categories.length, 6,
  26. "The call tree displays the same number of categories.");
  27. ok(container.hasAttribute("categories-hidden"),
  28. "All categories should now be hidden in the tree.");
  29. });