browser/components/customizableui/test/browser_913972_currentset_overflow.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 let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
michael@0 8
michael@0 9 // Resize to a small window, resize back, shouldn't affect currentSet
michael@0 10 add_task(function() {
michael@0 11 let originalWindowWidth = window.outerWidth;
michael@0 12 let oldCurrentSet = navbar.currentSet;
michael@0 13 ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
michael@0 14 ok(CustomizableUI.inDefaultState, "Should start in default state.");
michael@0 15 let oldChildCount = navbar.customizationTarget.childElementCount;
michael@0 16 window.resizeTo(400, window.outerHeight);
michael@0 17 yield waitForCondition(() => navbar.hasAttribute("overflowing"));
michael@0 18 ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
michael@0 19 is(navbar.currentSet, oldCurrentSet, "Currentset should be the same when overflowing.");
michael@0 20 ok(CustomizableUI.inDefaultState, "Should still be in default state when overflowing.");
michael@0 21 ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
michael@0 22 window.resizeTo(originalWindowWidth, window.outerHeight);
michael@0 23 yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
michael@0 24 ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar.");
michael@0 25 is(navbar.currentSet, oldCurrentSet, "Currentset should still be the same now we're no longer overflowing.");
michael@0 26 ok(CustomizableUI.inDefaultState, "Should still be in default state now we're no longer overflowing.");
michael@0 27
michael@0 28 // Verify actual physical placements match those of the placement array:
michael@0 29 let placementCounter = 0;
michael@0 30 let placements = CustomizableUI.getWidgetIdsInArea(CustomizableUI.AREA_NAVBAR);
michael@0 31 for (let node of navbar.customizationTarget.childNodes) {
michael@0 32 if (node.getAttribute("skipintoolbarset") == "true") {
michael@0 33 continue;
michael@0 34 }
michael@0 35 is(placements[placementCounter++], node.id, "Nodes should match after overflow");
michael@0 36 }
michael@0 37 is(placements.length, placementCounter, "Should have as many nodes as expected");
michael@0 38 is(navbar.customizationTarget.childElementCount, oldChildCount, "Number of nodes should match");
michael@0 39 });
michael@0 40
michael@0 41 // Enter and exit customization mode, check that currentSet works
michael@0 42 add_task(function() {
michael@0 43 let oldCurrentSet = navbar.currentSet;
michael@0 44 ok(CustomizableUI.inDefaultState, "Should start in default state.");
michael@0 45 yield startCustomizing();
michael@0 46 ok(CustomizableUI.inDefaultState, "Should be in default state in customization mode.");
michael@0 47 is(navbar.currentSet, oldCurrentSet, "Currentset should be the same in customization mode.");
michael@0 48 yield endCustomizing();
michael@0 49 ok(CustomizableUI.inDefaultState, "Should be in default state after customization mode.");
michael@0 50 is(navbar.currentSet, oldCurrentSet, "Currentset should be the same after customization mode.");
michael@0 51 });
michael@0 52
michael@0 53 add_task(function asyncCleanup() {
michael@0 54 yield resetCustomization();
michael@0 55 });

mercurial