browser_perf-loading-01.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 recordings view shows the right label while recording, after
  6. * recording, and once the record has loaded.
  7. */
  8. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  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. const { getSelectedRecording, getDurationLabelText } = require("devtools/client/performance/test/helpers/recording-utils");
  13. add_task(function* () {
  14. let { panel } = yield initPerformanceInNewTab({
  15. url: SIMPLE_URL,
  16. win: window
  17. });
  18. let { EVENTS, L10N, PerformanceController } = panel.panelWin;
  19. yield startRecording(panel);
  20. is(getDurationLabelText(panel, 0),
  21. L10N.getStr("recordingsList.recordingLabel"),
  22. "The duration node should show the 'recording' message while recording");
  23. let recordingStopping = once(PerformanceController, EVENTS.RECORDING_STATE_CHANGE, {
  24. expectedArgs: { "1": "recording-stopping" }
  25. });
  26. let recordingStopped = once(PerformanceController, EVENTS.RECORDING_STATE_CHANGE, {
  27. expectedArgs: { "1": "recording-stopped" }
  28. });
  29. let everythingStopped = stopRecording(panel);
  30. yield recordingStopping;
  31. is(getDurationLabelText(panel, 0),
  32. L10N.getStr("recordingsList.loadingLabel"),
  33. "The duration node should show the 'loading' message while stopping");
  34. yield recordingStopped;
  35. const selected = getSelectedRecording(panel);
  36. is(getDurationLabelText(panel, 0),
  37. L10N.getFormatStr("recordingsList.durationLabel",
  38. selected.getDuration().toFixed(0)),
  39. "The duration node should show the duration after the record has stopped");
  40. yield everythingStopped;
  41. yield teardownToolboxAndRemoveTab(panel);
  42. });