browser_perf-tree-view-09.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. /**
  5. * Tests that the profiler's tree view sorts inverted call trees by
  6. * "self cost" and not "total cost".
  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 RecordingUtils = require("devtools/shared/performance/recording-utils");
  11. add_task(function () {
  12. let threadNode = new ThreadNode(gProfile.threads[0], { startTime: 0, endTime: 20,
  13. invertTree: true });
  14. let treeRoot = new CallView({ frame: threadNode, inverted: true });
  15. let container = document.createElement("vbox");
  16. treeRoot.attachTo(container);
  17. is(treeRoot.getChild(0).frame.location, "B",
  18. "The tree root's first child is the `B` function.");
  19. is(treeRoot.getChild(1).frame.location, "A",
  20. "The tree root's second child is the `A` function.");
  21. });
  22. const gProfile = RecordingUtils.deflateProfile({
  23. meta: { version: 2 },
  24. threads: [{
  25. samples: [{
  26. time: 1,
  27. frames: [
  28. { location: "(root)" },
  29. { location: "A" },
  30. { location: "B" },
  31. ]
  32. }, {
  33. time: 2,
  34. frames: [
  35. { location: "(root)" },
  36. { location: "A" },
  37. { location: "B" }
  38. ]
  39. }, {
  40. time: 3,
  41. frames: [
  42. { location: "(root)" },
  43. { location: "A" },
  44. { location: "B" },
  45. ]
  46. }, {
  47. time: 4,
  48. frames: [
  49. { location: "(root)" },
  50. { location: "A" }
  51. ]
  52. }]
  53. }]
  54. });