1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_980155_add_overflow_toolbar.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +const kToolbarName = "test-new-overflowable-toolbar"; 1.11 +const kTestWidgetPrefix = "test-widget-for-overflowable-toolbar-"; 1.12 + 1.13 +add_task(function addOverflowingToolbar() { 1.14 + let originalWindowWidth = window.outerWidth; 1.15 + 1.16 + let widgetIds = []; 1.17 + for (let i = 0; i < 10; i++) { 1.18 + let id = kTestWidgetPrefix + i; 1.19 + widgetIds.push(id); 1.20 + let spec = {id: id, type: "button", removable: true, label: "test", tooltiptext: "" + i}; 1.21 + CustomizableUI.createWidget(spec); 1.22 + } 1.23 + 1.24 + let toolbarNode = createOverflowableToolbarWithPlacements(kToolbarName, widgetIds); 1.25 + assertAreaPlacements(kToolbarName, widgetIds); 1.26 + 1.27 + for (let id of widgetIds) { 1.28 + document.getElementById(id).style.minWidth = "200px"; 1.29 + } 1.30 + 1.31 + isnot(toolbarNode.overflowable, null, "Toolbar should have overflowable controller"); 1.32 + isnot(toolbarNode.customizationTarget, null, "Toolbar should have customization target"); 1.33 + isnot(toolbarNode.customizationTarget, toolbarNode, "Customization target should not be toolbar node"); 1.34 + 1.35 + let oldChildCount = toolbarNode.customizationTarget.childElementCount; 1.36 + let overflowableList = document.getElementById(kToolbarName + "-overflow-list"); 1.37 + let oldOverflowCount = overflowableList.childElementCount; 1.38 + 1.39 + isnot(oldChildCount, 0, "Toolbar should have non-overflowing widgets"); 1.40 + 1.41 + window.resizeTo(400, window.outerHeight); 1.42 + yield waitForCondition(() => toolbarNode.hasAttribute("overflowing")); 1.43 + ok(toolbarNode.hasAttribute("overflowing"), "Should have an overflowing toolbar."); 1.44 + ok(toolbarNode.customizationTarget.childElementCount < oldChildCount, "Should have fewer children."); 1.45 + ok(overflowableList.childElementCount > oldOverflowCount, "Should have more overflowed widgets."); 1.46 + 1.47 + window.resizeTo(originalWindowWidth, window.outerHeight); 1.48 +}); 1.49 + 1.50 + 1.51 +add_task(function asyncCleanup() { 1.52 + removeCustomToolbars(); 1.53 + yield resetCustomization(); 1.54 +});