browser_perf-loading-02.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 details view is locked after recording has stopped and before
  6. * the recording has finished loading.
  7. * Also test that the details view isn't locked if the recording that is being
  8. * stopped isn't the active one.
  9. */
  10. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  11. const { initPerformanceInNewTab, teardownToolboxAndRemoveTab } = require("devtools/client/performance/test/helpers/panel-utils");
  12. const { startRecording, stopRecording } = require("devtools/client/performance/test/helpers/actions");
  13. const { once } = require("devtools/client/performance/test/helpers/event-utils");
  14. const { getSelectedRecordingIndex, setSelectedRecording } = require("devtools/client/performance/test/helpers/recording-utils");
  15. add_task(function* () {
  16. let { panel } = yield initPerformanceInNewTab({
  17. url: SIMPLE_URL,
  18. win: window
  19. });
  20. let { EVENTS, $, PerformanceController } = panel.panelWin;
  21. let detailsContainer = $("#details-pane-container");
  22. let recordingNotice = $("#recording-notice");
  23. let loadingNotice = $("#loading-notice");
  24. let detailsPane = $("#details-pane");
  25. yield startRecording(panel);
  26. is(detailsContainer.selectedPanel, recordingNotice,
  27. "The recording-notice is shown while recording.");
  28. let recordingStopping = once(PerformanceController, EVENTS.RECORDING_STATE_CHANGE, {
  29. expectedArgs: { "1": "recording-stopping" }
  30. });
  31. let recordingStopped = once(PerformanceController, EVENTS.RECORDING_STATE_CHANGE, {
  32. expectedArgs: { "1": "recording-stopped" }
  33. });
  34. let everythingStopped = stopRecording(panel);
  35. yield recordingStopping;
  36. is(detailsContainer.selectedPanel, loadingNotice,
  37. "The loading-notice is shown while the record is stopping.");
  38. yield recordingStopped;
  39. is(detailsContainer.selectedPanel, detailsPane,
  40. "The details panel is shown after the record has stopped.");
  41. yield everythingStopped;
  42. yield startRecording(panel);
  43. info("While the 2nd record is still going, switch to the first one.");
  44. let recordingSelected = once(PerformanceController, EVENTS.RECORDING_SELECTED);
  45. setSelectedRecording(panel, 0);
  46. yield recordingSelected;
  47. recordingStopping = once(PerformanceController, EVENTS.RECORDING_STATE_CHANGE, {
  48. expectedArgs: { "1": "recording-stopping" }
  49. });
  50. recordingStopped = once(PerformanceController, EVENTS.RECORDING_STATE_CHANGE, {
  51. expectedArgs: { "1": "recording-stopped" }
  52. });
  53. everythingStopped = stopRecording(panel);
  54. yield recordingStopping;
  55. is(detailsContainer.selectedPanel, detailsPane,
  56. "The details panel is still shown while the 2nd record is being stopped.");
  57. is(getSelectedRecordingIndex(panel), 0,
  58. "The first record is still selected.");
  59. yield recordingStopped;
  60. is(detailsContainer.selectedPanel, detailsPane,
  61. "The details panel is still shown after the 2nd record has stopped.");
  62. is(getSelectedRecordingIndex(panel), 1,
  63. "The second record is now selected.");
  64. yield everythingStopped;
  65. yield teardownToolboxAndRemoveTab(panel);
  66. });