browser/devtools/debugger/test/browser_dbg_panel-size.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_panel-size.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Test that the sources and instruments panels widths are properly
     1.9 + * remembered when the debugger closes.
    1.10 + */
    1.11 +
    1.12 +const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
    1.13 +
    1.14 +function test() {
    1.15 +  let gTab, gDebuggee, gPanel, gDebugger;
    1.16 +  let gPrefs, gSources, gInstruments;
    1.17 +
    1.18 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.19 +    gTab = aTab;
    1.20 +    gDebuggee = aDebuggee;
    1.21 +    gPanel = aPanel;
    1.22 +    gDebugger = gPanel.panelWin;
    1.23 +    gPrefs = gDebugger.Prefs;
    1.24 +    gSources = gDebugger.document.getElementById("sources-pane");
    1.25 +    gInstruments = gDebugger.document.getElementById("instruments-pane");
    1.26 +
    1.27 +    waitForSourceShown(gPanel, ".html").then(performTest);
    1.28 +  });
    1.29 +
    1.30 +  function performTest() {
    1.31 +    let preferredSw = Services.prefs.getIntPref("devtools.debugger.ui.panes-sources-width");
    1.32 +    let preferredIw = Services.prefs.getIntPref("devtools.debugger.ui.panes-instruments-width");
    1.33 +    let someWidth1, someWidth2;
    1.34 +
    1.35 +    do {
    1.36 +      someWidth1 = parseInt(Math.random() * 200) + 100;
    1.37 +      someWidth2 = parseInt(Math.random() * 300) + 100;
    1.38 +    } while ((someWidth1 == preferredSw) || (someWidth2 == preferredIw));
    1.39 +
    1.40 +    info("Preferred sources width: " + preferredSw);
    1.41 +    info("Preferred instruments width: " + preferredIw);
    1.42 +    info("Generated sources width: " + someWidth1);
    1.43 +    info("Generated instruments width: " + someWidth2);
    1.44 +
    1.45 +    ok(gPrefs.sourcesWidth,
    1.46 +      "The debugger preferences should have a saved sourcesWidth value.");
    1.47 +    ok(gPrefs.instrumentsWidth,
    1.48 +      "The debugger preferences should have a saved instrumentsWidth value.");
    1.49 +
    1.50 +    is(gPrefs.sourcesWidth, preferredSw,
    1.51 +      "The debugger preferences should have a correct sourcesWidth value.");
    1.52 +    is(gPrefs.instrumentsWidth, preferredIw,
    1.53 +      "The debugger preferences should have a correct instrumentsWidth value.");
    1.54 +
    1.55 +    is(gSources.getAttribute("width"), gPrefs.sourcesWidth,
    1.56 +      "The sources pane width should be the same as the preferred value.");
    1.57 +    is(gInstruments.getAttribute("width"), gPrefs.instrumentsWidth,
    1.58 +      "The instruments pane width should be the same as the preferred value.");
    1.59 +
    1.60 +    gSources.setAttribute("width", someWidth1);
    1.61 +    gInstruments.setAttribute("width", someWidth2);
    1.62 +
    1.63 +    is(gPrefs.sourcesWidth, preferredSw,
    1.64 +      "The sources pane width pref should still be the same as the preferred value.");
    1.65 +    is(gPrefs.instrumentsWidth, preferredIw,
    1.66 +      "The instruments pane width pref should still be the same as the preferred value.");
    1.67 +
    1.68 +    isnot(gSources.getAttribute("width"), gPrefs.sourcesWidth,
    1.69 +      "The sources pane width should not be the preferred value anymore.");
    1.70 +    isnot(gInstruments.getAttribute("width"), gPrefs.instrumentsWidth,
    1.71 +      "The instruments pane width should not be the preferred value anymore.");
    1.72 +
    1.73 +    teardown(gPanel).then(() => {
    1.74 +      is(gPrefs.sourcesWidth, someWidth1,
    1.75 +        "The sources pane width should have been saved by now.");
    1.76 +      is(gPrefs.instrumentsWidth, someWidth2,
    1.77 +        "The instruments pane width should have been saved by now.");
    1.78 +
    1.79 +      // Cleanup after ourselves!
    1.80 +      Services.prefs.setIntPref("devtools.debugger.ui.panes-sources-width", preferredSw);
    1.81 +      Services.prefs.setIntPref("devtools.debugger.ui.panes-instruments-width", preferredIw);
    1.82 +
    1.83 +      finish();
    1.84 +    });
    1.85 +  }
    1.86 +}

mercurial