browser_perf-docload.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. /**
  5. * Tests if the sidebar is updated with "DOMContentLoaded" and "load" markers.
  6. */
  7. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  8. const { initPerformanceInNewTab, teardownToolboxAndRemoveTab } = require("devtools/client/performance/test/helpers/panel-utils");
  9. const { startRecording, stopRecording, reload } = require("devtools/client/performance/test/helpers/actions");
  10. const { waitUntil } = require("devtools/client/performance/test/helpers/wait-utils");
  11. add_task(function* () {
  12. let { panel, target } = yield initPerformanceInNewTab({
  13. url: SIMPLE_URL,
  14. win: window
  15. });
  16. let { PerformanceController } = panel.panelWin;
  17. yield startRecording(panel);
  18. yield reload(target);
  19. yield waitUntil(() => {
  20. // Wait until we get the necessary markers.
  21. let markers = PerformanceController.getCurrentRecording().getMarkers();
  22. if (!markers.some(m => m.name == "document::DOMContentLoaded") ||
  23. !markers.some(m => m.name == "document::Load")) {
  24. return false;
  25. }
  26. ok(markers.filter(m => m.name == "document::DOMContentLoaded").length == 1,
  27. "There should only be one `DOMContentLoaded` marker.");
  28. ok(markers.filter(m => m.name == "document::Load").length == 1,
  29. "There should only be one `load` marker.");
  30. return true;
  31. });
  32. yield stopRecording(panel);
  33. yield teardownToolboxAndRemoveTab(panel);
  34. });