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: let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); michael@0: michael@0: // Resize to a small window, resize back, shouldn't affect currentSet michael@0: add_task(function() { michael@0: let originalWindowWidth = window.outerWidth; michael@0: let oldCurrentSet = navbar.currentSet; michael@0: ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar."); michael@0: ok(CustomizableUI.inDefaultState, "Should start in default state."); michael@0: let oldChildCount = navbar.customizationTarget.childElementCount; michael@0: window.resizeTo(400, window.outerHeight); michael@0: yield waitForCondition(() => navbar.hasAttribute("overflowing")); michael@0: ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); michael@0: is(navbar.currentSet, oldCurrentSet, "Currentset should be the same when overflowing."); michael@0: ok(CustomizableUI.inDefaultState, "Should still be in default state when overflowing."); michael@0: ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children."); michael@0: window.resizeTo(originalWindowWidth, window.outerHeight); michael@0: yield waitForCondition(() => !navbar.hasAttribute("overflowing")); michael@0: ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar."); michael@0: is(navbar.currentSet, oldCurrentSet, "Currentset should still be the same now we're no longer overflowing."); michael@0: ok(CustomizableUI.inDefaultState, "Should still be in default state now we're no longer overflowing."); michael@0: michael@0: // Verify actual physical placements match those of the placement array: michael@0: let placementCounter = 0; michael@0: let placements = CustomizableUI.getWidgetIdsInArea(CustomizableUI.AREA_NAVBAR); michael@0: for (let node of navbar.customizationTarget.childNodes) { michael@0: if (node.getAttribute("skipintoolbarset") == "true") { michael@0: continue; michael@0: } michael@0: is(placements[placementCounter++], node.id, "Nodes should match after overflow"); michael@0: } michael@0: is(placements.length, placementCounter, "Should have as many nodes as expected"); michael@0: is(navbar.customizationTarget.childElementCount, oldChildCount, "Number of nodes should match"); michael@0: }); michael@0: michael@0: // Enter and exit customization mode, check that currentSet works michael@0: add_task(function() { michael@0: let oldCurrentSet = navbar.currentSet; michael@0: ok(CustomizableUI.inDefaultState, "Should start in default state."); michael@0: yield startCustomizing(); michael@0: ok(CustomizableUI.inDefaultState, "Should be in default state in customization mode."); michael@0: is(navbar.currentSet, oldCurrentSet, "Currentset should be the same in customization mode."); michael@0: yield endCustomizing(); michael@0: ok(CustomizableUI.inDefaultState, "Should be in default state after customization mode."); michael@0: is(navbar.currentSet, oldCurrentSet, "Currentset should be the same after customization mode."); michael@0: }); michael@0: michael@0: add_task(function asyncCleanup() { michael@0: yield resetCustomization(); michael@0: });