1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_888817_currentset_updating.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Adding, moving and removing items should update the relevant currentset attributes 1.11 +add_task(function() { 1.12 + ok(CustomizableUI.inDefaultState, "Should be in the default state when we start"); 1.13 + let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS); 1.14 + setToolbarVisibility(personalbar, true); 1.15 + ok(!CustomizableUI.inDefaultState, "Making the bookmarks toolbar visible takes it out of the default state"); 1.16 + 1.17 + let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); 1.18 + let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS); 1.19 + let navbarCurrentset = navbar.getAttribute("currentset") || navbar.currentSet; 1.20 + let personalbarCurrentset = personalbar.getAttribute("currentset") || personalbar.currentSet; 1.21 + 1.22 + let otherWin = yield openAndLoadWindow(); 1.23 + let otherNavbar = otherWin.document.getElementById(CustomizableUI.AREA_NAVBAR); 1.24 + let otherPersonalbar = otherWin.document.getElementById(CustomizableUI.AREA_BOOKMARKS); 1.25 + 1.26 + CustomizableUI.moveWidgetWithinArea("home-button", 0); 1.27 + navbarCurrentset = "home-button," + navbarCurrentset.replace(",home-button", ""); 1.28 + is(navbar.getAttribute("currentset"), navbarCurrentset, 1.29 + "Should have updated currentSet after move."); 1.30 + is(otherNavbar.getAttribute("currentset"), navbarCurrentset, 1.31 + "Should have updated other window's currentSet after move."); 1.32 + 1.33 + CustomizableUI.addWidgetToArea("home-button", CustomizableUI.AREA_BOOKMARKS); 1.34 + navbarCurrentset = navbarCurrentset.replace("home-button,", ""); 1.35 + personalbarCurrentset = personalbarCurrentset + ",home-button"; 1.36 + is(navbar.getAttribute("currentset"), navbarCurrentset, 1.37 + "Should have updated navbar currentSet after implied remove."); 1.38 + is(otherNavbar.getAttribute("currentset"), navbarCurrentset, 1.39 + "Should have updated other window's navbar currentSet after implied remove."); 1.40 + is(personalbar.getAttribute("currentset"), personalbarCurrentset, 1.41 + "Should have updated personalbar currentSet after add."); 1.42 + is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset, 1.43 + "Should have updated other window's personalbar currentSet after add."); 1.44 + 1.45 + CustomizableUI.removeWidgetFromArea("home-button"); 1.46 + personalbarCurrentset = personalbarCurrentset.replace(",home-button", ""); 1.47 + is(personalbar.getAttribute("currentset"), personalbarCurrentset, 1.48 + "Should have updated currentSet after remove."); 1.49 + is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset, 1.50 + "Should have updated other window's currentSet after remove."); 1.51 + 1.52 + yield promiseWindowClosed(otherWin); 1.53 + // Reset in asyncCleanup will put our button back for us. 1.54 +}); 1.55 + 1.56 +add_task(function asyncCleanup() { 1.57 + let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS); 1.58 + setToolbarVisibility(personalbar, false); 1.59 + yield resetCustomization(); 1.60 +});