|
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 // Adding, moving and removing items should update the relevant currentset attributes |
|
8 add_task(function() { |
|
9 ok(CustomizableUI.inDefaultState, "Should be in the default state when we start"); |
|
10 let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS); |
|
11 setToolbarVisibility(personalbar, true); |
|
12 ok(!CustomizableUI.inDefaultState, "Making the bookmarks toolbar visible takes it out of the default state"); |
|
13 |
|
14 let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); |
|
15 let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS); |
|
16 let navbarCurrentset = navbar.getAttribute("currentset") || navbar.currentSet; |
|
17 let personalbarCurrentset = personalbar.getAttribute("currentset") || personalbar.currentSet; |
|
18 |
|
19 let otherWin = yield openAndLoadWindow(); |
|
20 let otherNavbar = otherWin.document.getElementById(CustomizableUI.AREA_NAVBAR); |
|
21 let otherPersonalbar = otherWin.document.getElementById(CustomizableUI.AREA_BOOKMARKS); |
|
22 |
|
23 CustomizableUI.moveWidgetWithinArea("home-button", 0); |
|
24 navbarCurrentset = "home-button," + navbarCurrentset.replace(",home-button", ""); |
|
25 is(navbar.getAttribute("currentset"), navbarCurrentset, |
|
26 "Should have updated currentSet after move."); |
|
27 is(otherNavbar.getAttribute("currentset"), navbarCurrentset, |
|
28 "Should have updated other window's currentSet after move."); |
|
29 |
|
30 CustomizableUI.addWidgetToArea("home-button", CustomizableUI.AREA_BOOKMARKS); |
|
31 navbarCurrentset = navbarCurrentset.replace("home-button,", ""); |
|
32 personalbarCurrentset = personalbarCurrentset + ",home-button"; |
|
33 is(navbar.getAttribute("currentset"), navbarCurrentset, |
|
34 "Should have updated navbar currentSet after implied remove."); |
|
35 is(otherNavbar.getAttribute("currentset"), navbarCurrentset, |
|
36 "Should have updated other window's navbar currentSet after implied remove."); |
|
37 is(personalbar.getAttribute("currentset"), personalbarCurrentset, |
|
38 "Should have updated personalbar currentSet after add."); |
|
39 is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset, |
|
40 "Should have updated other window's personalbar currentSet after add."); |
|
41 |
|
42 CustomizableUI.removeWidgetFromArea("home-button"); |
|
43 personalbarCurrentset = personalbarCurrentset.replace(",home-button", ""); |
|
44 is(personalbar.getAttribute("currentset"), personalbarCurrentset, |
|
45 "Should have updated currentSet after remove."); |
|
46 is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset, |
|
47 "Should have updated other window's currentSet after remove."); |
|
48 |
|
49 yield promiseWindowClosed(otherWin); |
|
50 // Reset in asyncCleanup will put our button back for us. |
|
51 }); |
|
52 |
|
53 add_task(function asyncCleanup() { |
|
54 let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS); |
|
55 setToolbarVisibility(personalbar, false); |
|
56 yield resetCustomization(); |
|
57 }); |