browser/components/customizableui/test/browser_913972_currentset_overflow.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:4edf6e53b9c2
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 let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
8
9 // Resize to a small window, resize back, shouldn't affect currentSet
10 add_task(function() {
11 let originalWindowWidth = window.outerWidth;
12 let oldCurrentSet = navbar.currentSet;
13 ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
14 ok(CustomizableUI.inDefaultState, "Should start in default state.");
15 let oldChildCount = navbar.customizationTarget.childElementCount;
16 window.resizeTo(400, window.outerHeight);
17 yield waitForCondition(() => navbar.hasAttribute("overflowing"));
18 ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
19 is(navbar.currentSet, oldCurrentSet, "Currentset should be the same when overflowing.");
20 ok(CustomizableUI.inDefaultState, "Should still be in default state when overflowing.");
21 ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
22 window.resizeTo(originalWindowWidth, window.outerHeight);
23 yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
24 ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar.");
25 is(navbar.currentSet, oldCurrentSet, "Currentset should still be the same now we're no longer overflowing.");
26 ok(CustomizableUI.inDefaultState, "Should still be in default state now we're no longer overflowing.");
27
28 // Verify actual physical placements match those of the placement array:
29 let placementCounter = 0;
30 let placements = CustomizableUI.getWidgetIdsInArea(CustomizableUI.AREA_NAVBAR);
31 for (let node of navbar.customizationTarget.childNodes) {
32 if (node.getAttribute("skipintoolbarset") == "true") {
33 continue;
34 }
35 is(placements[placementCounter++], node.id, "Nodes should match after overflow");
36 }
37 is(placements.length, placementCounter, "Should have as many nodes as expected");
38 is(navbar.customizationTarget.childElementCount, oldChildCount, "Number of nodes should match");
39 });
40
41 // Enter and exit customization mode, check that currentSet works
42 add_task(function() {
43 let oldCurrentSet = navbar.currentSet;
44 ok(CustomizableUI.inDefaultState, "Should start in default state.");
45 yield startCustomizing();
46 ok(CustomizableUI.inDefaultState, "Should be in default state in customization mode.");
47 is(navbar.currentSet, oldCurrentSet, "Currentset should be the same in customization mode.");
48 yield endCustomizing();
49 ok(CustomizableUI.inDefaultState, "Should be in default state after customization mode.");
50 is(navbar.currentSet, oldCurrentSet, "Currentset should be the same after customization mode.");
51 });
52
53 add_task(function asyncCleanup() {
54 yield resetCustomization();
55 });

mercurial