browser/components/customizableui/test/browser_888817_currentset_updating.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 // Adding, moving and removing items should update the relevant currentset attributes
michael@0 8 add_task(function() {
michael@0 9 ok(CustomizableUI.inDefaultState, "Should be in the default state when we start");
michael@0 10 let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS);
michael@0 11 setToolbarVisibility(personalbar, true);
michael@0 12 ok(!CustomizableUI.inDefaultState, "Making the bookmarks toolbar visible takes it out of the default state");
michael@0 13
michael@0 14 let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
michael@0 15 let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS);
michael@0 16 let navbarCurrentset = navbar.getAttribute("currentset") || navbar.currentSet;
michael@0 17 let personalbarCurrentset = personalbar.getAttribute("currentset") || personalbar.currentSet;
michael@0 18
michael@0 19 let otherWin = yield openAndLoadWindow();
michael@0 20 let otherNavbar = otherWin.document.getElementById(CustomizableUI.AREA_NAVBAR);
michael@0 21 let otherPersonalbar = otherWin.document.getElementById(CustomizableUI.AREA_BOOKMARKS);
michael@0 22
michael@0 23 CustomizableUI.moveWidgetWithinArea("home-button", 0);
michael@0 24 navbarCurrentset = "home-button," + navbarCurrentset.replace(",home-button", "");
michael@0 25 is(navbar.getAttribute("currentset"), navbarCurrentset,
michael@0 26 "Should have updated currentSet after move.");
michael@0 27 is(otherNavbar.getAttribute("currentset"), navbarCurrentset,
michael@0 28 "Should have updated other window's currentSet after move.");
michael@0 29
michael@0 30 CustomizableUI.addWidgetToArea("home-button", CustomizableUI.AREA_BOOKMARKS);
michael@0 31 navbarCurrentset = navbarCurrentset.replace("home-button,", "");
michael@0 32 personalbarCurrentset = personalbarCurrentset + ",home-button";
michael@0 33 is(navbar.getAttribute("currentset"), navbarCurrentset,
michael@0 34 "Should have updated navbar currentSet after implied remove.");
michael@0 35 is(otherNavbar.getAttribute("currentset"), navbarCurrentset,
michael@0 36 "Should have updated other window's navbar currentSet after implied remove.");
michael@0 37 is(personalbar.getAttribute("currentset"), personalbarCurrentset,
michael@0 38 "Should have updated personalbar currentSet after add.");
michael@0 39 is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset,
michael@0 40 "Should have updated other window's personalbar currentSet after add.");
michael@0 41
michael@0 42 CustomizableUI.removeWidgetFromArea("home-button");
michael@0 43 personalbarCurrentset = personalbarCurrentset.replace(",home-button", "");
michael@0 44 is(personalbar.getAttribute("currentset"), personalbarCurrentset,
michael@0 45 "Should have updated currentSet after remove.");
michael@0 46 is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset,
michael@0 47 "Should have updated other window's currentSet after remove.");
michael@0 48
michael@0 49 yield promiseWindowClosed(otherWin);
michael@0 50 // Reset in asyncCleanup will put our button back for us.
michael@0 51 });
michael@0 52
michael@0 53 add_task(function asyncCleanup() {
michael@0 54 let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS);
michael@0 55 setToolbarVisibility(personalbar, false);
michael@0 56 yield resetCustomization();
michael@0 57 });

mercurial