browser_canvas-frontend-reload-02.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests that the frontend UI is properly reconfigured after reloading.
  5. */
  6. function* ifTestingSupported() {
  7. let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
  8. let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
  9. is(SnapshotsListView.itemCount, 0,
  10. "There should be no snapshots initially displayed in the UI.");
  11. is(CallsListView.itemCount, 0,
  12. "There should be no function calls initially displayed in the UI.");
  13. is($("#screenshot-container").hidden, true,
  14. "The screenshot should not be initially displayed in the UI.");
  15. is($("#snapshot-filmstrip").hidden, true,
  16. "There should be no thumbnails initially displayed in the UI (1).");
  17. is($all(".filmstrip-thumbnail").length, 0,
  18. "There should be no thumbnails initially displayed in the UI (2).");
  19. yield reload(target);
  20. let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
  21. let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
  22. let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED);
  23. let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
  24. SnapshotsListView._onRecordButtonClick();
  25. yield promise.all([
  26. recordingFinished,
  27. callListPopulated,
  28. thumbnailsDisplayed,
  29. screenshotDisplayed
  30. ]);
  31. is(SnapshotsListView.itemCount, 1,
  32. "There should be one snapshot displayed in the UI.");
  33. is(CallsListView.itemCount, 8,
  34. "All the function calls should now be displayed in the UI.");
  35. is($("#screenshot-container").hidden, false,
  36. "The screenshot should now be displayed in the UI.");
  37. is($("#snapshot-filmstrip").hidden, false,
  38. "All the thumbnails should now be displayed in the UI (1).");
  39. is($all(".filmstrip-thumbnail").length, 4,
  40. "All the thumbnails should now be displayed in the UI (2).");
  41. let reset = once(window, EVENTS.UI_RESET);
  42. let navigated = reload(target);
  43. yield reset;
  44. ok(true, "The UI was reset after the refresh button was clicked.");
  45. is(SnapshotsListView.itemCount, 0,
  46. "There should be no snapshots displayed in the UI after navigating.");
  47. is(CallsListView.itemCount, 0,
  48. "There should be no function calls displayed in the UI after navigating.");
  49. is($("#snapshot-filmstrip").hidden, true,
  50. "There should be no thumbnails displayed in the UI after navigating.");
  51. is($("#screenshot-container").hidden, true,
  52. "The screenshot should not be displayed in the UI after navigating.");
  53. yield navigated;
  54. ok(true, "The target finished reloading.");
  55. yield teardown(panel);
  56. finish();
  57. }