|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Test that the sources and instruments panels widths are properly |
|
6 * remembered when the debugger closes. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; |
|
10 |
|
11 function test() { |
|
12 let gTab, gDebuggee, gPanel, gDebugger; |
|
13 let gPrefs, gSources, gInstruments; |
|
14 |
|
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"); |
|
23 |
|
24 waitForSourceShown(gPanel, ".html").then(performTest); |
|
25 }); |
|
26 |
|
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; |
|
31 |
|
32 do { |
|
33 someWidth1 = parseInt(Math.random() * 200) + 100; |
|
34 someWidth2 = parseInt(Math.random() * 300) + 100; |
|
35 } while ((someWidth1 == preferredSw) || (someWidth2 == preferredIw)); |
|
36 |
|
37 info("Preferred sources width: " + preferredSw); |
|
38 info("Preferred instruments width: " + preferredIw); |
|
39 info("Generated sources width: " + someWidth1); |
|
40 info("Generated instruments width: " + someWidth2); |
|
41 |
|
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."); |
|
46 |
|
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."); |
|
51 |
|
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."); |
|
56 |
|
57 gSources.setAttribute("width", someWidth1); |
|
58 gInstruments.setAttribute("width", someWidth2); |
|
59 |
|
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."); |
|
64 |
|
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."); |
|
69 |
|
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."); |
|
75 |
|
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); |
|
79 |
|
80 finish(); |
|
81 }); |
|
82 } |
|
83 } |