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: * Test that the sources and instruments panels widths are properly michael@0: * remembered when the debugger closes. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; michael@0: michael@0: function test() { michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gPrefs, gSources, gInstruments; michael@0: 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: gSources = gDebugger.document.getElementById("sources-pane"); michael@0: gInstruments = gDebugger.document.getElementById("instruments-pane"); michael@0: michael@0: waitForSourceShown(gPanel, ".html").then(performTest); michael@0: }); michael@0: michael@0: function performTest() { michael@0: let preferredSw = Services.prefs.getIntPref("devtools.debugger.ui.panes-sources-width"); michael@0: let preferredIw = Services.prefs.getIntPref("devtools.debugger.ui.panes-instruments-width"); michael@0: let someWidth1, someWidth2; michael@0: michael@0: do { michael@0: someWidth1 = parseInt(Math.random() * 200) + 100; michael@0: someWidth2 = parseInt(Math.random() * 300) + 100; michael@0: } while ((someWidth1 == preferredSw) || (someWidth2 == preferredIw)); michael@0: michael@0: info("Preferred sources width: " + preferredSw); michael@0: info("Preferred instruments width: " + preferredIw); michael@0: info("Generated sources width: " + someWidth1); michael@0: info("Generated instruments width: " + someWidth2); michael@0: michael@0: ok(gPrefs.sourcesWidth, michael@0: "The debugger preferences should have a saved sourcesWidth value."); michael@0: ok(gPrefs.instrumentsWidth, michael@0: "The debugger preferences should have a saved instrumentsWidth value."); michael@0: michael@0: is(gPrefs.sourcesWidth, preferredSw, michael@0: "The debugger preferences should have a correct sourcesWidth value."); michael@0: is(gPrefs.instrumentsWidth, preferredIw, michael@0: "The debugger preferences should have a correct instrumentsWidth value."); michael@0: michael@0: is(gSources.getAttribute("width"), gPrefs.sourcesWidth, michael@0: "The sources pane width should be the same as the preferred value."); michael@0: is(gInstruments.getAttribute("width"), gPrefs.instrumentsWidth, michael@0: "The instruments pane width should be the same as the preferred value."); michael@0: michael@0: gSources.setAttribute("width", someWidth1); michael@0: gInstruments.setAttribute("width", someWidth2); michael@0: michael@0: is(gPrefs.sourcesWidth, preferredSw, michael@0: "The sources pane width pref should still be the same as the preferred value."); michael@0: is(gPrefs.instrumentsWidth, preferredIw, michael@0: "The instruments pane width pref should still be the same as the preferred value."); michael@0: michael@0: isnot(gSources.getAttribute("width"), gPrefs.sourcesWidth, michael@0: "The sources pane width should not be the preferred value anymore."); michael@0: isnot(gInstruments.getAttribute("width"), gPrefs.instrumentsWidth, michael@0: "The instruments pane width should not be the preferred value anymore."); michael@0: michael@0: teardown(gPanel).then(() => { michael@0: is(gPrefs.sourcesWidth, someWidth1, michael@0: "The sources pane width should have been saved by now."); michael@0: is(gPrefs.instrumentsWidth, someWidth2, michael@0: "The instruments pane width should have been saved by now."); michael@0: michael@0: // Cleanup after ourselves! michael@0: Services.prefs.setIntPref("devtools.debugger.ui.panes-sources-width", preferredSw); michael@0: Services.prefs.setIntPref("devtools.debugger.ui.panes-instruments-width", preferredIw); michael@0: michael@0: finish(); michael@0: }); michael@0: } michael@0: }