|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 const kToolbarName = "test-new-overflowable-toolbar"; |
|
8 const kTestWidgetPrefix = "test-widget-for-overflowable-toolbar-"; |
|
9 |
|
10 add_task(function addOverflowingToolbar() { |
|
11 let originalWindowWidth = window.outerWidth; |
|
12 |
|
13 let widgetIds = []; |
|
14 for (let i = 0; i < 10; i++) { |
|
15 let id = kTestWidgetPrefix + i; |
|
16 widgetIds.push(id); |
|
17 let spec = {id: id, type: "button", removable: true, label: "test", tooltiptext: "" + i}; |
|
18 CustomizableUI.createWidget(spec); |
|
19 } |
|
20 |
|
21 let toolbarNode = createOverflowableToolbarWithPlacements(kToolbarName, widgetIds); |
|
22 assertAreaPlacements(kToolbarName, widgetIds); |
|
23 |
|
24 for (let id of widgetIds) { |
|
25 document.getElementById(id).style.minWidth = "200px"; |
|
26 } |
|
27 |
|
28 isnot(toolbarNode.overflowable, null, "Toolbar should have overflowable controller"); |
|
29 isnot(toolbarNode.customizationTarget, null, "Toolbar should have customization target"); |
|
30 isnot(toolbarNode.customizationTarget, toolbarNode, "Customization target should not be toolbar node"); |
|
31 |
|
32 let oldChildCount = toolbarNode.customizationTarget.childElementCount; |
|
33 let overflowableList = document.getElementById(kToolbarName + "-overflow-list"); |
|
34 let oldOverflowCount = overflowableList.childElementCount; |
|
35 |
|
36 isnot(oldChildCount, 0, "Toolbar should have non-overflowing widgets"); |
|
37 |
|
38 window.resizeTo(400, window.outerHeight); |
|
39 yield waitForCondition(() => toolbarNode.hasAttribute("overflowing")); |
|
40 ok(toolbarNode.hasAttribute("overflowing"), "Should have an overflowing toolbar."); |
|
41 ok(toolbarNode.customizationTarget.childElementCount < oldChildCount, "Should have fewer children."); |
|
42 ok(overflowableList.childElementCount > oldOverflowCount, "Should have more overflowed widgets."); |
|
43 |
|
44 window.resizeTo(originalWindowWidth, window.outerHeight); |
|
45 }); |
|
46 |
|
47 |
|
48 add_task(function asyncCleanup() { |
|
49 removeCustomToolbars(); |
|
50 yield resetCustomization(); |
|
51 }); |