michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that the debugger panes collapse properly. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gPrefs, gOptions; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gPrefs = gDebugger.Prefs; michael@0: gOptions = gDebugger.DebuggerView.Options; michael@0: michael@0: testPanesState(); michael@0: michael@0: gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false }); michael@0: michael@0: testInstrumentsPaneCollapse(); michael@0: testPanesStartupPref(); michael@0: michael@0: closeDebuggerAndFinish(gPanel); michael@0: }); michael@0: } michael@0: michael@0: function testPanesState() { michael@0: let instrumentsPane = michael@0: gDebugger.document.getElementById("instruments-pane"); michael@0: let instrumentsPaneToggleButton = michael@0: gDebugger.document.getElementById("instruments-pane-toggle"); michael@0: michael@0: ok(instrumentsPane.hasAttribute("pane-collapsed") && michael@0: instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), michael@0: "The debugger view instruments pane should initially be hidden."); michael@0: is(gPrefs.panesVisibleOnStartup, false, michael@0: "The debugger view instruments pane should initially be preffed as hidden."); michael@0: isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", michael@0: "The options menu item should not be checked."); michael@0: } michael@0: michael@0: function testInstrumentsPaneCollapse() { michael@0: let instrumentsPane = michael@0: gDebugger.document.getElementById("instruments-pane"); michael@0: let instrumentsPaneToggleButton = michael@0: gDebugger.document.getElementById("instruments-pane-toggle"); michael@0: michael@0: let width = parseInt(instrumentsPane.getAttribute("width")); michael@0: is(width, gPrefs.instrumentsWidth, michael@0: "The instruments pane has an incorrect width."); michael@0: is(instrumentsPane.style.marginLeft, "0px", michael@0: "The instruments pane has an incorrect left margin."); michael@0: is(instrumentsPane.style.marginRight, "0px", michael@0: "The instruments pane has an incorrect right margin."); michael@0: ok(!instrumentsPane.hasAttribute("animated"), michael@0: "The instruments pane has an incorrect animated attribute."); michael@0: ok(!instrumentsPane.hasAttribute("pane-collapsed") && michael@0: !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), michael@0: "The instruments pane should at this point be visible."); michael@0: michael@0: gDebugger.DebuggerView.toggleInstrumentsPane({ visible: false, animated: true }); michael@0: michael@0: is(gPrefs.panesVisibleOnStartup, false, michael@0: "The debugger view panes should still initially be preffed as hidden."); michael@0: isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", michael@0: "The options menu item should still not be checked."); michael@0: michael@0: let margin = -(width + 1) + "px"; michael@0: is(width, gPrefs.instrumentsWidth, michael@0: "The instruments pane has an incorrect width after collapsing."); michael@0: is(instrumentsPane.style.marginLeft, margin, michael@0: "The instruments pane has an incorrect left margin after collapsing."); michael@0: is(instrumentsPane.style.marginRight, margin, michael@0: "The instruments pane has an incorrect right margin after collapsing."); michael@0: ok(instrumentsPane.hasAttribute("animated"), michael@0: "The instruments pane has an incorrect attribute after an animated collapsing."); michael@0: ok(instrumentsPane.hasAttribute("pane-collapsed") && michael@0: instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), michael@0: "The instruments pane should not be visible after collapsing."); michael@0: michael@0: gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false }); michael@0: michael@0: is(gPrefs.panesVisibleOnStartup, false, michael@0: "The debugger view panes should still initially be preffed as hidden."); michael@0: isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", michael@0: "The options menu item should still not be checked."); michael@0: michael@0: is(width, gPrefs.instrumentsWidth, michael@0: "The instruments pane has an incorrect width after uncollapsing."); michael@0: is(instrumentsPane.style.marginLeft, "0px", michael@0: "The instruments pane has an incorrect left margin after uncollapsing."); michael@0: is(instrumentsPane.style.marginRight, "0px", michael@0: "The instruments pane has an incorrect right margin after uncollapsing."); michael@0: ok(!instrumentsPane.hasAttribute("animated"), michael@0: "The instruments pane has an incorrect attribute after an unanimated uncollapsing."); michael@0: ok(!instrumentsPane.hasAttribute("pane-collapsed") && michael@0: !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), michael@0: "The instruments pane should be visible again after uncollapsing."); michael@0: } michael@0: michael@0: function testPanesStartupPref() { michael@0: let instrumentsPane = michael@0: gDebugger.document.getElementById("instruments-pane"); michael@0: let instrumentsPaneToggleButton = michael@0: gDebugger.document.getElementById("instruments-pane-toggle"); michael@0: michael@0: is(gPrefs.panesVisibleOnStartup, false, michael@0: "The debugger view panes should still initially be preffed as hidden."); michael@0: michael@0: ok(!instrumentsPane.hasAttribute("pane-collapsed") && michael@0: !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), michael@0: "The debugger instruments pane should at this point be visible."); michael@0: is(gPrefs.panesVisibleOnStartup, false, michael@0: "The debugger view panes should initially be preffed as hidden."); michael@0: isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", michael@0: "The options menu item should still not be checked."); michael@0: michael@0: gOptions._showPanesOnStartupItem.setAttribute("checked", "true"); michael@0: gOptions._toggleShowPanesOnStartup(); michael@0: michael@0: ok(!instrumentsPane.hasAttribute("pane-collapsed") && michael@0: !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), michael@0: "The debugger instruments pane should at this point be visible."); michael@0: is(gPrefs.panesVisibleOnStartup, true, michael@0: "The debugger view panes should now be preffed as visible."); michael@0: is(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", michael@0: "The options menu item should now be checked."); michael@0: michael@0: gOptions._showPanesOnStartupItem.setAttribute("checked", "false"); michael@0: gOptions._toggleShowPanesOnStartup(); michael@0: michael@0: ok(!instrumentsPane.hasAttribute("pane-collapsed") && michael@0: !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"), michael@0: "The debugger instruments pane should at this point be visible."); michael@0: is(gPrefs.panesVisibleOnStartup, false, michael@0: "The debugger view panes should now be preffed as hidden."); michael@0: isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true", michael@0: "The options menu item should now be unchecked."); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gPrefs = null; michael@0: gOptions = null; michael@0: });