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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Tests that the debugger panes collapse properly.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gPrefs, gOptions;
    13 function test() {
    14   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    15     gTab = aTab;
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    19     gPrefs = gDebugger.Prefs;
    20     gOptions = gDebugger.DebuggerView.Options;
    22     testPanesState();
    24     gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
    26     testInstrumentsPaneCollapse();
    27     testPanesStartupPref();
    29     closeDebuggerAndFinish(gPanel);
    30   });
    31 }
    33 function testPanesState() {
    34   let instrumentsPane =
    35     gDebugger.document.getElementById("instruments-pane");
    36   let instrumentsPaneToggleButton =
    37     gDebugger.document.getElementById("instruments-pane-toggle");
    39   ok(instrumentsPane.hasAttribute("pane-collapsed") &&
    40      instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
    41     "The debugger view instruments pane should initially be hidden.");
    42   is(gPrefs.panesVisibleOnStartup, false,
    43     "The debugger view instruments pane should initially be preffed as hidden.");
    44   isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
    45     "The options menu item should not be checked.");
    46 }
    48 function testInstrumentsPaneCollapse() {
    49   let instrumentsPane =
    50     gDebugger.document.getElementById("instruments-pane");
    51   let instrumentsPaneToggleButton =
    52     gDebugger.document.getElementById("instruments-pane-toggle");
    54   let width = parseInt(instrumentsPane.getAttribute("width"));
    55   is(width, gPrefs.instrumentsWidth,
    56     "The instruments pane has an incorrect width.");
    57   is(instrumentsPane.style.marginLeft, "0px",
    58     "The instruments pane has an incorrect left margin.");
    59   is(instrumentsPane.style.marginRight, "0px",
    60     "The instruments pane has an incorrect right margin.");
    61   ok(!instrumentsPane.hasAttribute("animated"),
    62     "The instruments pane has an incorrect animated attribute.");
    63   ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
    64      !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
    65     "The instruments pane should at this point be visible.");
    67   gDebugger.DebuggerView.toggleInstrumentsPane({ visible: false, animated: true });
    69   is(gPrefs.panesVisibleOnStartup, false,
    70     "The debugger view panes should still initially be preffed as hidden.");
    71   isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
    72     "The options menu item should still not be checked.");
    74   let margin = -(width + 1) + "px";
    75   is(width, gPrefs.instrumentsWidth,
    76     "The instruments pane has an incorrect width after collapsing.");
    77   is(instrumentsPane.style.marginLeft, margin,
    78     "The instruments pane has an incorrect left margin after collapsing.");
    79   is(instrumentsPane.style.marginRight, margin,
    80     "The instruments pane has an incorrect right margin after collapsing.");
    81   ok(instrumentsPane.hasAttribute("animated"),
    82     "The instruments pane has an incorrect attribute after an animated collapsing.");
    83   ok(instrumentsPane.hasAttribute("pane-collapsed") &&
    84      instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
    85     "The instruments pane should not be visible after collapsing.");
    87   gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
    89   is(gPrefs.panesVisibleOnStartup, false,
    90     "The debugger view panes should still initially be preffed as hidden.");
    91   isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
    92     "The options menu item should still not be checked.");
    94   is(width, gPrefs.instrumentsWidth,
    95     "The instruments pane has an incorrect width after uncollapsing.");
    96   is(instrumentsPane.style.marginLeft, "0px",
    97     "The instruments pane has an incorrect left margin after uncollapsing.");
    98   is(instrumentsPane.style.marginRight, "0px",
    99     "The instruments pane has an incorrect right margin after uncollapsing.");
   100   ok(!instrumentsPane.hasAttribute("animated"),
   101     "The instruments pane has an incorrect attribute after an unanimated uncollapsing.");
   102   ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
   103      !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
   104     "The instruments pane should be visible again after uncollapsing.");
   105 }
   107 function testPanesStartupPref() {
   108   let instrumentsPane =
   109     gDebugger.document.getElementById("instruments-pane");
   110   let instrumentsPaneToggleButton =
   111     gDebugger.document.getElementById("instruments-pane-toggle");
   113   is(gPrefs.panesVisibleOnStartup, false,
   114     "The debugger view panes should still initially be preffed as hidden.");
   116   ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
   117      !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
   118     "The debugger instruments pane should at this point be visible.");
   119   is(gPrefs.panesVisibleOnStartup, false,
   120     "The debugger view panes should initially be preffed as hidden.");
   121   isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
   122     "The options menu item should still not be checked.");
   124   gOptions._showPanesOnStartupItem.setAttribute("checked", "true");
   125   gOptions._toggleShowPanesOnStartup();
   127   ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
   128      !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
   129     "The debugger instruments pane should at this point be visible.");
   130   is(gPrefs.panesVisibleOnStartup, true,
   131     "The debugger view panes should now be preffed as visible.");
   132   is(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
   133     "The options menu item should now be checked.");
   135   gOptions._showPanesOnStartupItem.setAttribute("checked", "false");
   136   gOptions._toggleShowPanesOnStartup();
   138   ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
   139      !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
   140     "The debugger instruments pane should at this point be visible.");
   141   is(gPrefs.panesVisibleOnStartup, false,
   142     "The debugger view panes should now be preffed as hidden.");
   143   isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
   144     "The options menu item should now be unchecked.");
   145 }
   147 registerCleanupFunction(function() {
   148   gTab = null;
   149   gDebuggee = null;
   150   gPanel = null;
   151   gDebugger = null;
   152   gPrefs = null;
   153   gOptions = null;
   154 });

mercurial