michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Adding, moving and removing items should update the relevant currentset attributes michael@0: add_task(function() { michael@0: ok(CustomizableUI.inDefaultState, "Should be in the default state when we start"); michael@0: let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS); michael@0: setToolbarVisibility(personalbar, true); michael@0: ok(!CustomizableUI.inDefaultState, "Making the bookmarks toolbar visible takes it out of the default state"); michael@0: michael@0: let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); michael@0: let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS); michael@0: let navbarCurrentset = navbar.getAttribute("currentset") || navbar.currentSet; michael@0: let personalbarCurrentset = personalbar.getAttribute("currentset") || personalbar.currentSet; michael@0: michael@0: let otherWin = yield openAndLoadWindow(); michael@0: let otherNavbar = otherWin.document.getElementById(CustomizableUI.AREA_NAVBAR); michael@0: let otherPersonalbar = otherWin.document.getElementById(CustomizableUI.AREA_BOOKMARKS); michael@0: michael@0: CustomizableUI.moveWidgetWithinArea("home-button", 0); michael@0: navbarCurrentset = "home-button," + navbarCurrentset.replace(",home-button", ""); michael@0: is(navbar.getAttribute("currentset"), navbarCurrentset, michael@0: "Should have updated currentSet after move."); michael@0: is(otherNavbar.getAttribute("currentset"), navbarCurrentset, michael@0: "Should have updated other window's currentSet after move."); michael@0: michael@0: CustomizableUI.addWidgetToArea("home-button", CustomizableUI.AREA_BOOKMARKS); michael@0: navbarCurrentset = navbarCurrentset.replace("home-button,", ""); michael@0: personalbarCurrentset = personalbarCurrentset + ",home-button"; michael@0: is(navbar.getAttribute("currentset"), navbarCurrentset, michael@0: "Should have updated navbar currentSet after implied remove."); michael@0: is(otherNavbar.getAttribute("currentset"), navbarCurrentset, michael@0: "Should have updated other window's navbar currentSet after implied remove."); michael@0: is(personalbar.getAttribute("currentset"), personalbarCurrentset, michael@0: "Should have updated personalbar currentSet after add."); michael@0: is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset, michael@0: "Should have updated other window's personalbar currentSet after add."); michael@0: michael@0: CustomizableUI.removeWidgetFromArea("home-button"); michael@0: personalbarCurrentset = personalbarCurrentset.replace(",home-button", ""); michael@0: is(personalbar.getAttribute("currentset"), personalbarCurrentset, michael@0: "Should have updated currentSet after remove."); michael@0: is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset, michael@0: "Should have updated other window's currentSet after remove."); michael@0: michael@0: yield promiseWindowClosed(otherWin); michael@0: // Reset in asyncCleanup will put our button back for us. michael@0: }); michael@0: michael@0: add_task(function asyncCleanup() { michael@0: let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS); michael@0: setToolbarVisibility(personalbar, false); michael@0: yield resetCustomization(); michael@0: });