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: const kToolbarName = "test-new-overflowable-toolbar"; michael@0: const kTestWidgetPrefix = "test-widget-for-overflowable-toolbar-"; michael@0: michael@0: add_task(function addOverflowingToolbar() { michael@0: let originalWindowWidth = window.outerWidth; michael@0: michael@0: let widgetIds = []; michael@0: for (let i = 0; i < 10; i++) { michael@0: let id = kTestWidgetPrefix + i; michael@0: widgetIds.push(id); michael@0: let spec = {id: id, type: "button", removable: true, label: "test", tooltiptext: "" + i}; michael@0: CustomizableUI.createWidget(spec); michael@0: } michael@0: michael@0: let toolbarNode = createOverflowableToolbarWithPlacements(kToolbarName, widgetIds); michael@0: assertAreaPlacements(kToolbarName, widgetIds); michael@0: michael@0: for (let id of widgetIds) { michael@0: document.getElementById(id).style.minWidth = "200px"; michael@0: } michael@0: michael@0: isnot(toolbarNode.overflowable, null, "Toolbar should have overflowable controller"); michael@0: isnot(toolbarNode.customizationTarget, null, "Toolbar should have customization target"); michael@0: isnot(toolbarNode.customizationTarget, toolbarNode, "Customization target should not be toolbar node"); michael@0: michael@0: let oldChildCount = toolbarNode.customizationTarget.childElementCount; michael@0: let overflowableList = document.getElementById(kToolbarName + "-overflow-list"); michael@0: let oldOverflowCount = overflowableList.childElementCount; michael@0: michael@0: isnot(oldChildCount, 0, "Toolbar should have non-overflowing widgets"); michael@0: michael@0: window.resizeTo(400, window.outerHeight); michael@0: yield waitForCondition(() => toolbarNode.hasAttribute("overflowing")); michael@0: ok(toolbarNode.hasAttribute("overflowing"), "Should have an overflowing toolbar."); michael@0: ok(toolbarNode.customizationTarget.childElementCount < oldChildCount, "Should have fewer children."); michael@0: ok(overflowableList.childElementCount > oldOverflowCount, "Should have more overflowed widgets."); michael@0: michael@0: window.resizeTo(originalWindowWidth, window.outerHeight); michael@0: }); michael@0: michael@0: michael@0: add_task(function asyncCleanup() { michael@0: removeCustomToolbars(); michael@0: yield resetCustomization(); michael@0: });