browser/devtools/debugger/test/browser_dbg_panel-size.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.

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 * Test that the sources and instruments panels widths are properly
michael@0 6 * remembered when the debugger closes.
michael@0 7 */
michael@0 8
michael@0 9 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
michael@0 10
michael@0 11 function test() {
michael@0 12 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 13 let gPrefs, gSources, gInstruments;
michael@0 14
michael@0 15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 16 gTab = aTab;
michael@0 17 gDebuggee = aDebuggee;
michael@0 18 gPanel = aPanel;
michael@0 19 gDebugger = gPanel.panelWin;
michael@0 20 gPrefs = gDebugger.Prefs;
michael@0 21 gSources = gDebugger.document.getElementById("sources-pane");
michael@0 22 gInstruments = gDebugger.document.getElementById("instruments-pane");
michael@0 23
michael@0 24 waitForSourceShown(gPanel, ".html").then(performTest);
michael@0 25 });
michael@0 26
michael@0 27 function performTest() {
michael@0 28 let preferredSw = Services.prefs.getIntPref("devtools.debugger.ui.panes-sources-width");
michael@0 29 let preferredIw = Services.prefs.getIntPref("devtools.debugger.ui.panes-instruments-width");
michael@0 30 let someWidth1, someWidth2;
michael@0 31
michael@0 32 do {
michael@0 33 someWidth1 = parseInt(Math.random() * 200) + 100;
michael@0 34 someWidth2 = parseInt(Math.random() * 300) + 100;
michael@0 35 } while ((someWidth1 == preferredSw) || (someWidth2 == preferredIw));
michael@0 36
michael@0 37 info("Preferred sources width: " + preferredSw);
michael@0 38 info("Preferred instruments width: " + preferredIw);
michael@0 39 info("Generated sources width: " + someWidth1);
michael@0 40 info("Generated instruments width: " + someWidth2);
michael@0 41
michael@0 42 ok(gPrefs.sourcesWidth,
michael@0 43 "The debugger preferences should have a saved sourcesWidth value.");
michael@0 44 ok(gPrefs.instrumentsWidth,
michael@0 45 "The debugger preferences should have a saved instrumentsWidth value.");
michael@0 46
michael@0 47 is(gPrefs.sourcesWidth, preferredSw,
michael@0 48 "The debugger preferences should have a correct sourcesWidth value.");
michael@0 49 is(gPrefs.instrumentsWidth, preferredIw,
michael@0 50 "The debugger preferences should have a correct instrumentsWidth value.");
michael@0 51
michael@0 52 is(gSources.getAttribute("width"), gPrefs.sourcesWidth,
michael@0 53 "The sources pane width should be the same as the preferred value.");
michael@0 54 is(gInstruments.getAttribute("width"), gPrefs.instrumentsWidth,
michael@0 55 "The instruments pane width should be the same as the preferred value.");
michael@0 56
michael@0 57 gSources.setAttribute("width", someWidth1);
michael@0 58 gInstruments.setAttribute("width", someWidth2);
michael@0 59
michael@0 60 is(gPrefs.sourcesWidth, preferredSw,
michael@0 61 "The sources pane width pref should still be the same as the preferred value.");
michael@0 62 is(gPrefs.instrumentsWidth, preferredIw,
michael@0 63 "The instruments pane width pref should still be the same as the preferred value.");
michael@0 64
michael@0 65 isnot(gSources.getAttribute("width"), gPrefs.sourcesWidth,
michael@0 66 "The sources pane width should not be the preferred value anymore.");
michael@0 67 isnot(gInstruments.getAttribute("width"), gPrefs.instrumentsWidth,
michael@0 68 "The instruments pane width should not be the preferred value anymore.");
michael@0 69
michael@0 70 teardown(gPanel).then(() => {
michael@0 71 is(gPrefs.sourcesWidth, someWidth1,
michael@0 72 "The sources pane width should have been saved by now.");
michael@0 73 is(gPrefs.instrumentsWidth, someWidth2,
michael@0 74 "The instruments pane width should have been saved by now.");
michael@0 75
michael@0 76 // Cleanup after ourselves!
michael@0 77 Services.prefs.setIntPref("devtools.debugger.ui.panes-sources-width", preferredSw);
michael@0 78 Services.prefs.setIntPref("devtools.debugger.ui.panes-instruments-width", preferredIw);
michael@0 79
michael@0 80 finish();
michael@0 81 });
michael@0 82 }
michael@0 83 }

mercurial