browser/components/customizableui/test/browser_913972_currentset_overflow.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/customizableui/test/browser_913972_currentset_overflow.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     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 +let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
    1.11 +
    1.12 +// Resize to a small window, resize back, shouldn't affect currentSet
    1.13 +add_task(function() {
    1.14 +  let originalWindowWidth = window.outerWidth;
    1.15 +  let oldCurrentSet = navbar.currentSet;
    1.16 +  ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
    1.17 +  ok(CustomizableUI.inDefaultState, "Should start in default state.");
    1.18 +  let oldChildCount = navbar.customizationTarget.childElementCount;
    1.19 +  window.resizeTo(400, window.outerHeight);
    1.20 +  yield waitForCondition(() => navbar.hasAttribute("overflowing"));
    1.21 +  ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
    1.22 +  is(navbar.currentSet, oldCurrentSet, "Currentset should be the same when overflowing.");
    1.23 +  ok(CustomizableUI.inDefaultState, "Should still be in default state when overflowing.");
    1.24 +  ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
    1.25 +  window.resizeTo(originalWindowWidth, window.outerHeight);
    1.26 +  yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
    1.27 +  ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar.");
    1.28 +  is(navbar.currentSet, oldCurrentSet, "Currentset should still be the same now we're no longer overflowing.");
    1.29 +  ok(CustomizableUI.inDefaultState, "Should still be in default state now we're no longer overflowing.");
    1.30 +
    1.31 +  // Verify actual physical placements match those of the placement array:
    1.32 +  let placementCounter = 0;
    1.33 +  let placements = CustomizableUI.getWidgetIdsInArea(CustomizableUI.AREA_NAVBAR);
    1.34 +  for (let node of navbar.customizationTarget.childNodes) {
    1.35 +    if (node.getAttribute("skipintoolbarset") == "true") {
    1.36 +      continue;
    1.37 +    }
    1.38 +    is(placements[placementCounter++], node.id, "Nodes should match after overflow");
    1.39 +  }
    1.40 +  is(placements.length, placementCounter, "Should have as many nodes as expected");
    1.41 +  is(navbar.customizationTarget.childElementCount, oldChildCount, "Number of nodes should match");
    1.42 +});
    1.43 +
    1.44 +// Enter and exit customization mode, check that currentSet works
    1.45 +add_task(function() {
    1.46 +  let oldCurrentSet = navbar.currentSet;
    1.47 +  ok(CustomizableUI.inDefaultState, "Should start in default state.");
    1.48 +  yield startCustomizing();
    1.49 +  ok(CustomizableUI.inDefaultState, "Should be in default state in customization mode.");
    1.50 +  is(navbar.currentSet, oldCurrentSet, "Currentset should be the same in customization mode.");
    1.51 +  yield endCustomizing();
    1.52 +  ok(CustomizableUI.inDefaultState, "Should be in default state after customization mode.");
    1.53 +  is(navbar.currentSet, oldCurrentSet, "Currentset should be the same after customization mode.");
    1.54 +});
    1.55 +
    1.56 +add_task(function asyncCleanup() {
    1.57 +  yield resetCustomization();
    1.58 +});

mercurial