|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 let bookmarksToolbar = document.getElementById("PersonalToolbar"); |
|
8 let navbar = document.getElementById("nav-bar"); |
|
9 let tabsToolbar = document.getElementById("TabsToolbar"); |
|
10 |
|
11 // Customization reset should restore visibility to default-visible toolbars. |
|
12 add_task(function() { |
|
13 is(navbar.collapsed, false, "Test should start with navbar visible"); |
|
14 setToolbarVisibility(navbar, false); |
|
15 is(navbar.collapsed, true, "navbar should be hidden now"); |
|
16 |
|
17 yield resetCustomization(); |
|
18 |
|
19 is(navbar.collapsed, false, "Customization reset should restore visibility to the navbar"); |
|
20 }); |
|
21 |
|
22 // Customization reset should restore collapsed-state to default-collapsed toolbars. |
|
23 add_task(function() { |
|
24 ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); |
|
25 |
|
26 is(bookmarksToolbar.collapsed, true, "Test should start with bookmarks toolbar collapsed"); |
|
27 is(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should have height=0"); |
|
28 isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); |
|
29 is(navbar.collapsed, false, "The nav-bar should be shown by default"); |
|
30 |
|
31 setToolbarVisibility(bookmarksToolbar, true); |
|
32 setToolbarVisibility(navbar, false); |
|
33 isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should be visible now"); |
|
34 is(navbar.getBoundingClientRect().height, 1, "navbar should have a height=1 (due to border)"); |
|
35 is(CustomizableUI.inDefaultState, false, "Should no longer be in default state"); |
|
36 |
|
37 yield startCustomizing(); |
|
38 gCustomizeMode.reset(); |
|
39 yield waitForCondition(function() !gCustomizeMode.resetting); |
|
40 yield endCustomizing(); |
|
41 |
|
42 is(bookmarksToolbar.collapsed, true, "Customization reset should restore collapsed-state to the bookmarks toolbar"); |
|
43 isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); |
|
44 is(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should have height=0 after reset"); |
|
45 ok(CustomizableUI.inDefaultState, "Everything should be back to default state"); |
|
46 }); |
|
47 |
|
48 // Check that the menubar will be collapsed by resetting, if the platform supports it. |
|
49 add_task(function() { |
|
50 let menubar = document.getElementById("toolbar-menubar"); |
|
51 const canMenubarCollapse = CustomizableUI.isToolbarDefaultCollapsed(menubar.id); |
|
52 if (!canMenubarCollapse) { |
|
53 return; |
|
54 } |
|
55 ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); |
|
56 |
|
57 is(menubar.getBoundingClientRect().height, 0, "menubar should be hidden by default"); |
|
58 setToolbarVisibility(menubar, true); |
|
59 isnot(menubar.getBoundingClientRect().height, 0, "menubar should be visible now"); |
|
60 |
|
61 yield startCustomizing(); |
|
62 gCustomizeMode.reset(); |
|
63 yield waitForCondition(function() !gCustomizeMode.resetting); |
|
64 |
|
65 is(menubar.getAttribute("autohide"), "true", "The menubar should have autohide=true after reset in customization mode"); |
|
66 is(menubar.getBoundingClientRect().height, 0, "The menubar should have height=0 after reset in customization mode"); |
|
67 |
|
68 yield endCustomizing(); |
|
69 |
|
70 is(menubar.getAttribute("autohide"), "true", "The menubar should have autohide=true after reset"); |
|
71 is(menubar.getBoundingClientRect().height, 0, "The menubar should have height=0 after reset"); |
|
72 }); |
|
73 |
|
74 // Customization reset should restore collapsed-state to default-collapsed toolbars. |
|
75 add_task(function() { |
|
76 ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); |
|
77 is(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should have height=0"); |
|
78 isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); |
|
79 |
|
80 setToolbarVisibility(bookmarksToolbar, true); |
|
81 isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should be visible now"); |
|
82 is(CustomizableUI.inDefaultState, false, "Should no longer be in default state"); |
|
83 |
|
84 yield startCustomizing(); |
|
85 |
|
86 isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should be visible before reset"); |
|
87 isnot(navbar.getBoundingClientRect().height, 0, "The navbar should be visible before reset"); |
|
88 isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); |
|
89 |
|
90 gCustomizeMode.reset(); |
|
91 yield waitForCondition(function() !gCustomizeMode.resetting); |
|
92 |
|
93 is(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should have height=0 after reset"); |
|
94 isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); |
|
95 isnot(navbar.getBoundingClientRect().height, 0, "The navbar should still be visible after reset"); |
|
96 ok(CustomizableUI.inDefaultState, "Everything should be back to default state"); |
|
97 yield endCustomizing(); |
|
98 }); |
|
99 |
|
100 // Check that the menubar will be collapsed by resetting, if the platform supports it. |
|
101 add_task(function() { |
|
102 let menubar = document.getElementById("toolbar-menubar"); |
|
103 const canMenubarCollapse = CustomizableUI.isToolbarDefaultCollapsed(menubar.id); |
|
104 if (!canMenubarCollapse) { |
|
105 return; |
|
106 } |
|
107 ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); |
|
108 yield startCustomizing(); |
|
109 let resetButton = document.getElementById("customization-reset-button"); |
|
110 is(resetButton.disabled, true, "The reset button should be disabled when in default state"); |
|
111 |
|
112 setToolbarVisibility(menubar, true); |
|
113 is(resetButton.disabled, false, "The reset button should be enabled when not in default state") |
|
114 ok(!CustomizableUI.inDefaultState, "No longer in default state when the menubar is shown"); |
|
115 |
|
116 yield gCustomizeMode.reset(); |
|
117 |
|
118 is(resetButton.disabled, true, "The reset button should be disabled when in default state"); |
|
119 ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); |
|
120 |
|
121 yield endCustomizing(); |
|
122 }); |