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