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.

     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/. */
     5 "use strict";
     7 const kToolbarName = "test-new-overflowable-toolbar";
     8 const kTestWidgetPrefix = "test-widget-for-overflowable-toolbar-";
    10 add_task(function addOverflowingToolbar() {
    11   let originalWindowWidth = window.outerWidth;
    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   }
    21   let toolbarNode = createOverflowableToolbarWithPlacements(kToolbarName, widgetIds);
    22   assertAreaPlacements(kToolbarName, widgetIds);
    24   for (let id of widgetIds) {
    25     document.getElementById(id).style.minWidth = "200px";
    26   }
    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");
    32   let oldChildCount = toolbarNode.customizationTarget.childElementCount;
    33   let overflowableList = document.getElementById(kToolbarName + "-overflow-list");
    34   let oldOverflowCount = overflowableList.childElementCount;
    36   isnot(oldChildCount, 0, "Toolbar should have non-overflowing widgets");
    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.");
    44   window.resizeTo(originalWindowWidth, window.outerHeight);
    45 });
    48 add_task(function asyncCleanup() {
    49   removeCustomToolbars();
    50   yield resetCustomization();
    51 });

mercurial