fune/browser/components/customizableui/test/browser_888817_currentset_updating.js
Jared Wein 3f6801477a Bug 1242137 - Fix eslint errors in /browser/components/customizableui. r=gijs
--HG--
extra : commitid : CTMv8KOMjRK
extra : rebase_source : 768fb80e4652c1f0e14eea9e32da8eff795f1659
extra : amend_source : bd695a57c00c8004b048ccd4673465d66bea22c6
extra : histedit_source : ca0c6fcb719d0e7f0895de1bd429fa9804833f65
2016-01-23 14:55:27 -05:00

57 lines
3 KiB
JavaScript

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