forked from mirrors/gecko-dev
		
	 fe96089fe4
			
		
	
	
		fe96089fe4
		
	
	
	
	
		
			
			MozReview-Commit-ID: Tq8YrZWG6P --HG-- extra : rebase_source : 2e02e0a809d08ff26291a027b73a54668d6d5f9d
		
			
				
	
	
		
			51 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /* This Source Code Form is subject to the terms of the Mozilla Public
 | |
|  * License, v. 2.0. If a copy of the MPL was not distributed with this
 | |
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 | |
| 
 | |
| "use strict";
 | |
| 
 | |
| const kToolbarName = "test-new-overflowable-toolbar";
 | |
| const kTestWidgetPrefix = "test-widget-for-overflowable-toolbar-";
 | |
| 
 | |
| add_task(async function addOverflowingToolbar() {
 | |
|   let originalWindowWidth = window.outerWidth;
 | |
| 
 | |
|   let widgetIds = [];
 | |
|   for (let i = 0; i < 10; i++) {
 | |
|     let id = kTestWidgetPrefix + i;
 | |
|     widgetIds.push(id);
 | |
|     let spec = {id, type: "button", removable: true, label: "test", tooltiptext: "" + i};
 | |
|     CustomizableUI.createWidget(spec);
 | |
|   }
 | |
| 
 | |
|   let toolbarNode = createOverflowableToolbarWithPlacements(kToolbarName, widgetIds);
 | |
|   assertAreaPlacements(kToolbarName, widgetIds);
 | |
| 
 | |
|   for (let id of widgetIds) {
 | |
|     document.getElementById(id).style.minWidth = "200px";
 | |
|   }
 | |
| 
 | |
|   isnot(toolbarNode.overflowable, null, "Toolbar should have overflowable controller");
 | |
|   isnot(toolbarNode.customizationTarget, null, "Toolbar should have customization target");
 | |
|   isnot(toolbarNode.customizationTarget, toolbarNode, "Customization target should not be toolbar node");
 | |
| 
 | |
|   let oldChildCount = toolbarNode.customizationTarget.childElementCount;
 | |
|   let overflowableList = document.getElementById(kToolbarName + "-overflow-list");
 | |
|   let oldOverflowCount = overflowableList.childElementCount;
 | |
| 
 | |
|   isnot(oldChildCount, 0, "Toolbar should have non-overflowing widgets");
 | |
| 
 | |
|   window.resizeTo(kForceOverflowWidthPx, window.outerHeight);
 | |
|   await waitForCondition(() => toolbarNode.hasAttribute("overflowing"));
 | |
|   ok(toolbarNode.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
 | |
|   ok(toolbarNode.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
 | |
|   ok(overflowableList.childElementCount > oldOverflowCount, "Should have more overflowed widgets.");
 | |
| 
 | |
|   window.resizeTo(originalWindowWidth, window.outerHeight);
 | |
| });
 | |
| 
 | |
| 
 | |
| add_task(async function asyncCleanup() {
 | |
|   removeCustomToolbars();
 | |
|   await resetCustomization();
 | |
| });
 |