browser_dbg_instruments-pane-collapse.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4. /**
  5. * Tests that the debugger panes collapse properly.
  6. */
  7. const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
  8. var gTab, gPanel, gDebugger;
  9. var gPrefs, gOptions;
  10. function test() {
  11. Task.spawn(function* () {
  12. let options = {
  13. source: TAB_URL,
  14. line: 1
  15. };
  16. let [aTab,, aPanel] = yield initDebugger(TAB_URL, options);
  17. gTab = aTab;
  18. gPanel = aPanel;
  19. gDebugger = gPanel.panelWin;
  20. gPrefs = gDebugger.Prefs;
  21. gOptions = gDebugger.DebuggerView.Options;
  22. testPanesState();
  23. gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
  24. yield testInstrumentsPaneCollapse();
  25. testPanesStartupPref();
  26. closeDebuggerAndFinish(gPanel);
  27. });
  28. }
  29. function testPanesState() {
  30. let instrumentsPane =
  31. gDebugger.document.getElementById("instruments-pane");
  32. let instrumentsPaneToggleButton =
  33. gDebugger.document.getElementById("instruments-pane-toggle");
  34. ok(instrumentsPane.classList.contains("pane-collapsed") &&
  35. instrumentsPaneToggleButton.classList.contains("pane-collapsed"),
  36. "The debugger view instruments pane should initially be hidden.");
  37. is(gPrefs.panesVisibleOnStartup, false,
  38. "The debugger view instruments pane should initially be preffed as hidden.");
  39. isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
  40. "The options menu item should not be checked.");
  41. }
  42. function* testInstrumentsPaneCollapse () {
  43. let instrumentsPane =
  44. gDebugger.document.getElementById("instruments-pane");
  45. let instrumentsPaneToggleButton =
  46. gDebugger.document.getElementById("instruments-pane-toggle");
  47. let width = parseInt(instrumentsPane.getAttribute("width"));
  48. is(width, gPrefs.instrumentsWidth,
  49. "The instruments pane has an incorrect width.");
  50. is(instrumentsPane.style.marginLeft, "0px",
  51. "The instruments pane has an incorrect left margin.");
  52. is(instrumentsPane.style.marginRight, "0px",
  53. "The instruments pane has an incorrect right margin.");
  54. ok(!instrumentsPane.hasAttribute("animated"),
  55. "The instruments pane has an incorrect animated attribute.");
  56. ok(!instrumentsPane.classList.contains("pane-collapsed") &&
  57. !instrumentsPaneToggleButton.classList.contains("pane-collapsed"),
  58. "The instruments pane should at this point be visible.");
  59. // Trigger reflow to make sure the UI is in required state.
  60. gDebugger.document.documentElement.getBoundingClientRect();
  61. gDebugger.DebuggerView.toggleInstrumentsPane({ visible: false, animated: true });
  62. yield once(instrumentsPane, "transitionend");
  63. is(gPrefs.panesVisibleOnStartup, false,
  64. "The debugger view panes should still initially be preffed as hidden.");
  65. isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
  66. "The options menu item should still not be checked.");
  67. let margin = -(width + 1) + "px";
  68. is(width, gPrefs.instrumentsWidth,
  69. "The instruments pane has an incorrect width after collapsing.");
  70. is(instrumentsPane.style.marginLeft, margin,
  71. "The instruments pane has an incorrect left margin after collapsing.");
  72. is(instrumentsPane.style.marginRight, margin,
  73. "The instruments pane has an incorrect right margin after collapsing.");
  74. ok(!instrumentsPane.hasAttribute("animated"),
  75. "The instruments pane has an incorrect attribute after an animated collapsing.");
  76. ok(instrumentsPane.classList.contains("pane-collapsed") &&
  77. instrumentsPaneToggleButton.classList.contains("pane-collapsed"),
  78. "The instruments pane should not be visible after collapsing.");
  79. gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
  80. is(gPrefs.panesVisibleOnStartup, false,
  81. "The debugger view panes should still initially be preffed as hidden.");
  82. isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
  83. "The options menu item should still not be checked.");
  84. is(width, gPrefs.instrumentsWidth,
  85. "The instruments pane has an incorrect width after uncollapsing.");
  86. is(instrumentsPane.style.marginLeft, "0px",
  87. "The instruments pane has an incorrect left margin after uncollapsing.");
  88. is(instrumentsPane.style.marginRight, "0px",
  89. "The instruments pane has an incorrect right margin after uncollapsing.");
  90. ok(!instrumentsPane.hasAttribute("animated"),
  91. "The instruments pane has an incorrect attribute after an unanimated uncollapsing.");
  92. ok(!instrumentsPane.classList.contains("pane-collapsed") &&
  93. !instrumentsPaneToggleButton.classList.contains("pane-collapsed"),
  94. "The instruments pane should be visible again after uncollapsing.");
  95. }
  96. function testPanesStartupPref() {
  97. let instrumentsPane =
  98. gDebugger.document.getElementById("instruments-pane");
  99. let instrumentsPaneToggleButton =
  100. gDebugger.document.getElementById("instruments-pane-toggle");
  101. is(gPrefs.panesVisibleOnStartup, false,
  102. "The debugger view panes should still initially be preffed as hidden.");
  103. ok(!instrumentsPane.classList.contains("pane-collapsed") &&
  104. !instrumentsPaneToggleButton.classList.contains("pane-collapsed"),
  105. "The debugger instruments pane should at this point be visible.");
  106. is(gPrefs.panesVisibleOnStartup, false,
  107. "The debugger view panes should initially be preffed as hidden.");
  108. isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
  109. "The options menu item should still not be checked.");
  110. gOptions._showPanesOnStartupItem.setAttribute("checked", "true");
  111. gOptions._toggleShowPanesOnStartup();
  112. ok(!instrumentsPane.classList.contains("pane-collapsed") &&
  113. !instrumentsPaneToggleButton.classList.contains("pane-collapsed"),
  114. "The debugger instruments pane should at this point be visible.");
  115. is(gPrefs.panesVisibleOnStartup, true,
  116. "The debugger view panes should now be preffed as visible.");
  117. is(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
  118. "The options menu item should now be checked.");
  119. gOptions._showPanesOnStartupItem.setAttribute("checked", "false");
  120. gOptions._toggleShowPanesOnStartup();
  121. ok(!instrumentsPane.classList.contains("pane-collapsed") &&
  122. !instrumentsPaneToggleButton.classList.contains("pane-collapsed"),
  123. "The debugger instruments pane should at this point be visible.");
  124. is(gPrefs.panesVisibleOnStartup, false,
  125. "The debugger view panes should now be preffed as hidden.");
  126. isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
  127. "The options menu item should now be unchecked.");
  128. }
  129. registerCleanupFunction(function () {
  130. gTab = null;
  131. gPanel = null;
  132. gDebugger = null;
  133. gPrefs = null;
  134. gOptions = null;
  135. });