browser_timeline-waterfall-rerender.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /* eslint-disable */
  4. /**
  5. * Tests if the waterfall remembers the selection when rerendering.
  6. */
  7. function* spawnTest() {
  8. let { target, panel } = yield initPerformance(SIMPLE_URL);
  9. let { $, $$, EVENTS, PerformanceController, OverviewView, WaterfallView } = panel.panelWin;
  10. const MIN_MARKERS_COUNT = 50;
  11. const MAX_MARKERS_SELECT = 20;
  12. yield startRecording(panel);
  13. ok(true, "Recording has started.");
  14. let updated = 0;
  15. OverviewView.on(EVENTS.UI_OVERVIEW_RENDERED, () => updated++);
  16. ok((yield waitUntil(() => updated > 0)),
  17. "The overview graphs were updated a bunch of times.");
  18. ok((yield waitUntil(() => PerformanceController.getCurrentRecording().getMarkers().length > MIN_MARKERS_COUNT)),
  19. "There are some markers available.");
  20. yield stopRecording(panel);
  21. ok(true, "Recording has ended.");
  22. let currentMarkers = PerformanceController.getCurrentRecording().getMarkers();
  23. info("Gathered markers: " + JSON.stringify(currentMarkers, null, 2));
  24. let initialBarsCount = $$(".waterfall-marker-bar").length;
  25. info("Initial bars count: " + initialBarsCount);
  26. // Select a portion of the overview.
  27. let rerendered = WaterfallView.once(EVENTS.UI_WATERFALL_RENDERED);
  28. OverviewView.setTimeInterval({ startTime: 0, endTime: currentMarkers[MAX_MARKERS_SELECT].end });
  29. yield rerendered;
  30. ok(!$(".waterfall-tree-item:focus"),
  31. "There is no item focused in the waterfall yet.");
  32. ok($("#waterfall-details").hidden,
  33. "The waterfall sidebar is initially hidden.");
  34. // Focus the second item in the tree.
  35. WaterfallView._markersRoot.getChild(1).focus();
  36. let beforeResizeBarsCount = $$(".waterfall-marker-bar").length;
  37. info("Before resize bars count: " + beforeResizeBarsCount);
  38. ok(beforeResizeBarsCount < initialBarsCount,
  39. "A subset of the total markers was selected.");
  40. is(Array.indexOf($$(".waterfall-tree-item"), $(".waterfall-tree-item:focus")), 2,
  41. "The correct item was focused in the tree.");
  42. ok(!$("#waterfall-details").hidden,
  43. "The waterfall sidebar is now visible.");
  44. // Simulate a resize on the marker details.
  45. rerendered = WaterfallView.once(EVENTS.UI_WATERFALL_RENDERED);
  46. EventUtils.sendMouseEvent({ type: "mouseup" }, WaterfallView.detailsSplitter);
  47. yield rerendered;
  48. let afterResizeBarsCount = $$(".waterfall-marker-bar").length;
  49. info("After resize bars count: " + afterResizeBarsCount);
  50. is(afterResizeBarsCount, beforeResizeBarsCount,
  51. "The same subset of the total markers remained visible.");
  52. is(Array.indexOf($$(".waterfall-tree-item"), $(".waterfall-tree-item:focus")), 2,
  53. "The correct item is still focused in the tree.");
  54. ok(!$("#waterfall-details").hidden,
  55. "The waterfall sidebar is still visible.");
  56. yield teardown(panel);
  57. finish();
  58. }
  59. /* eslint-enable */