browser_perf-calltree-memory-columns.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 memory call tree view renders the correct columns.
  6. */
  7. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  8. const { UI_ENABLE_ALLOCATIONS_PREF } = require("devtools/client/performance/test/helpers/prefs");
  9. const { initPerformanceInNewTab, teardownToolboxAndRemoveTab } = require("devtools/client/performance/test/helpers/panel-utils");
  10. const { startRecording, stopRecording } = require("devtools/client/performance/test/helpers/actions");
  11. const { once } = require("devtools/client/performance/test/helpers/event-utils");
  12. add_task(function* () {
  13. let { panel } = yield initPerformanceInNewTab({
  14. url: SIMPLE_URL,
  15. win: window
  16. });
  17. let { EVENTS, $, $$, DetailsView, MemoryCallTreeView } = panel.panelWin;
  18. // Enable allocations to test.
  19. Services.prefs.setBoolPref(UI_ENABLE_ALLOCATIONS_PREF, true);
  20. yield startRecording(panel);
  21. yield stopRecording(panel);
  22. let rendered = once(MemoryCallTreeView, EVENTS.UI_MEMORY_CALL_TREE_RENDERED);
  23. yield DetailsView.selectView("memory-calltree");
  24. yield rendered;
  25. ok(DetailsView.isViewSelected(MemoryCallTreeView), "The call tree is now selected.");
  26. testCells($, $$, {
  27. "duration": false,
  28. "percentage": false,
  29. "count": true,
  30. "count-percentage": true,
  31. "size": true,
  32. "size-percentage": true,
  33. "self-duration": false,
  34. "self-percentage": false,
  35. "self-count": true,
  36. "self-count-percentage": true,
  37. "self-size": true,
  38. "self-size-percentage": true,
  39. "samples": false,
  40. "function": true
  41. });
  42. yield teardownToolboxAndRemoveTab(panel);
  43. });
  44. function testCells($, $$, visibleCells) {
  45. for (let cell in visibleCells) {
  46. if (visibleCells[cell]) {
  47. ok($(`.call-tree-cell[type=${cell}]`),
  48. `At least one ${cell} column was visible in the tree.`);
  49. } else {
  50. ok(!$(`.call-tree-cell[type=${cell}]`),
  51. `No ${cell} columns were visible in the tree.`);
  52. }
  53. }
  54. is($$(".call-tree-cell", $(".call-tree-item")).length,
  55. Object.keys(visibleCells).filter(e => visibleCells[e]).length,
  56. "The correct number of cells were found in the tree.");
  57. }