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