browser/components/customizableui/test/browser_980155_add_overflow_toolbar.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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

mercurial