browser_perf-telemetry-02.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 performance telemetry module records events at appropriate times.
  6. * Specifically export/import.
  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. add_task(function* () {
  13. let { panel } = yield initPerformanceInNewTab({
  14. url: SIMPLE_URL,
  15. win: window
  16. });
  17. let { EVENTS, PerformanceController } = panel.panelWin;
  18. let telemetry = PerformanceController._telemetry;
  19. let logs = telemetry.getLogs();
  20. let EXPORTED = "DEVTOOLS_PERFTOOLS_RECORDING_EXPORT_FLAG";
  21. let IMPORTED = "DEVTOOLS_PERFTOOLS_RECORDING_IMPORT_FLAG";
  22. yield startRecording(panel);
  23. yield stopRecording(panel);
  24. let file = FileUtils.getFile("TmpD", ["tmpprofile.json"]);
  25. file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("666", 8));
  26. let exported = once(PerformanceController, EVENTS.RECORDING_EXPORTED);
  27. yield PerformanceController.exportRecording("",
  28. PerformanceController.getCurrentRecording(), file);
  29. yield exported;
  30. ok(logs[EXPORTED], `A telemetry entry for ${EXPORTED} exists after exporting.`);
  31. let imported = once(PerformanceController, EVENTS.RECORDING_IMPORTED);
  32. yield PerformanceController.importRecording(null, file);
  33. yield imported;
  34. ok(logs[IMPORTED], `A telemetry entry for ${IMPORTED} exists after importing.`);
  35. yield teardownToolboxAndRemoveTab(panel);
  36. });