browser/devtools/debugger/test/browser_dbg_instruments-pane-collapse.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_instruments-pane-collapse.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,154 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests that the debugger panes collapse properly.
     1.9 + */
    1.10 +
    1.11 +const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
    1.12 +
    1.13 +let gTab, gDebuggee, gPanel, gDebugger;
    1.14 +let gPrefs, gOptions;
    1.15 +
    1.16 +function test() {
    1.17 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.18 +    gTab = aTab;
    1.19 +    gDebuggee = aDebuggee;
    1.20 +    gPanel = aPanel;
    1.21 +    gDebugger = gPanel.panelWin;
    1.22 +    gPrefs = gDebugger.Prefs;
    1.23 +    gOptions = gDebugger.DebuggerView.Options;
    1.24 +
    1.25 +    testPanesState();
    1.26 +
    1.27 +    gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
    1.28 +
    1.29 +    testInstrumentsPaneCollapse();
    1.30 +    testPanesStartupPref();
    1.31 +
    1.32 +    closeDebuggerAndFinish(gPanel);
    1.33 +  });
    1.34 +}
    1.35 +
    1.36 +function testPanesState() {
    1.37 +  let instrumentsPane =
    1.38 +    gDebugger.document.getElementById("instruments-pane");
    1.39 +  let instrumentsPaneToggleButton =
    1.40 +    gDebugger.document.getElementById("instruments-pane-toggle");
    1.41 +
    1.42 +  ok(instrumentsPane.hasAttribute("pane-collapsed") &&
    1.43 +     instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
    1.44 +    "The debugger view instruments pane should initially be hidden.");
    1.45 +  is(gPrefs.panesVisibleOnStartup, false,
    1.46 +    "The debugger view instruments pane should initially be preffed as hidden.");
    1.47 +  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
    1.48 +    "The options menu item should not be checked.");
    1.49 +}
    1.50 +
    1.51 +function testInstrumentsPaneCollapse() {
    1.52 +  let instrumentsPane =
    1.53 +    gDebugger.document.getElementById("instruments-pane");
    1.54 +  let instrumentsPaneToggleButton =
    1.55 +    gDebugger.document.getElementById("instruments-pane-toggle");
    1.56 +
    1.57 +  let width = parseInt(instrumentsPane.getAttribute("width"));
    1.58 +  is(width, gPrefs.instrumentsWidth,
    1.59 +    "The instruments pane has an incorrect width.");
    1.60 +  is(instrumentsPane.style.marginLeft, "0px",
    1.61 +    "The instruments pane has an incorrect left margin.");
    1.62 +  is(instrumentsPane.style.marginRight, "0px",
    1.63 +    "The instruments pane has an incorrect right margin.");
    1.64 +  ok(!instrumentsPane.hasAttribute("animated"),
    1.65 +    "The instruments pane has an incorrect animated attribute.");
    1.66 +  ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
    1.67 +     !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
    1.68 +    "The instruments pane should at this point be visible.");
    1.69 +
    1.70 +  gDebugger.DebuggerView.toggleInstrumentsPane({ visible: false, animated: true });
    1.71 +
    1.72 +  is(gPrefs.panesVisibleOnStartup, false,
    1.73 +    "The debugger view panes should still initially be preffed as hidden.");
    1.74 +  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
    1.75 +    "The options menu item should still not be checked.");
    1.76 +
    1.77 +  let margin = -(width + 1) + "px";
    1.78 +  is(width, gPrefs.instrumentsWidth,
    1.79 +    "The instruments pane has an incorrect width after collapsing.");
    1.80 +  is(instrumentsPane.style.marginLeft, margin,
    1.81 +    "The instruments pane has an incorrect left margin after collapsing.");
    1.82 +  is(instrumentsPane.style.marginRight, margin,
    1.83 +    "The instruments pane has an incorrect right margin after collapsing.");
    1.84 +  ok(instrumentsPane.hasAttribute("animated"),
    1.85 +    "The instruments pane has an incorrect attribute after an animated collapsing.");
    1.86 +  ok(instrumentsPane.hasAttribute("pane-collapsed") &&
    1.87 +     instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
    1.88 +    "The instruments pane should not be visible after collapsing.");
    1.89 +
    1.90 +  gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
    1.91 +
    1.92 +  is(gPrefs.panesVisibleOnStartup, false,
    1.93 +    "The debugger view panes should still initially be preffed as hidden.");
    1.94 +  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
    1.95 +    "The options menu item should still not be checked.");
    1.96 +
    1.97 +  is(width, gPrefs.instrumentsWidth,
    1.98 +    "The instruments pane has an incorrect width after uncollapsing.");
    1.99 +  is(instrumentsPane.style.marginLeft, "0px",
   1.100 +    "The instruments pane has an incorrect left margin after uncollapsing.");
   1.101 +  is(instrumentsPane.style.marginRight, "0px",
   1.102 +    "The instruments pane has an incorrect right margin after uncollapsing.");
   1.103 +  ok(!instrumentsPane.hasAttribute("animated"),
   1.104 +    "The instruments pane has an incorrect attribute after an unanimated uncollapsing.");
   1.105 +  ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
   1.106 +     !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
   1.107 +    "The instruments pane should be visible again after uncollapsing.");
   1.108 +}
   1.109 +
   1.110 +function testPanesStartupPref() {
   1.111 +  let instrumentsPane =
   1.112 +    gDebugger.document.getElementById("instruments-pane");
   1.113 +  let instrumentsPaneToggleButton =
   1.114 +    gDebugger.document.getElementById("instruments-pane-toggle");
   1.115 +
   1.116 +  is(gPrefs.panesVisibleOnStartup, false,
   1.117 +    "The debugger view panes should still initially be preffed as hidden.");
   1.118 +
   1.119 +  ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
   1.120 +     !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
   1.121 +    "The debugger instruments pane should at this point be visible.");
   1.122 +  is(gPrefs.panesVisibleOnStartup, false,
   1.123 +    "The debugger view panes should initially be preffed as hidden.");
   1.124 +  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
   1.125 +    "The options menu item should still not be checked.");
   1.126 +
   1.127 +  gOptions._showPanesOnStartupItem.setAttribute("checked", "true");
   1.128 +  gOptions._toggleShowPanesOnStartup();
   1.129 +
   1.130 +  ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
   1.131 +     !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
   1.132 +    "The debugger instruments pane should at this point be visible.");
   1.133 +  is(gPrefs.panesVisibleOnStartup, true,
   1.134 +    "The debugger view panes should now be preffed as visible.");
   1.135 +  is(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
   1.136 +    "The options menu item should now be checked.");
   1.137 +
   1.138 +  gOptions._showPanesOnStartupItem.setAttribute("checked", "false");
   1.139 +  gOptions._toggleShowPanesOnStartup();
   1.140 +
   1.141 +  ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
   1.142 +     !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
   1.143 +    "The debugger instruments pane should at this point be visible.");
   1.144 +  is(gPrefs.panesVisibleOnStartup, false,
   1.145 +    "The debugger view panes should now be preffed as hidden.");
   1.146 +  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
   1.147 +    "The options menu item should now be unchecked.");
   1.148 +}
   1.149 +
   1.150 +registerCleanupFunction(function() {
   1.151 +  gTab = null;
   1.152 +  gDebuggee = null;
   1.153 +  gPanel = null;
   1.154 +  gDebugger = null;
   1.155 +  gPrefs = null;
   1.156 +  gOptions = null;
   1.157 +});

mercurial