browser_perf-calltree-js-columns.js 2.2 KB

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