browser_overflow_use_subviews.js (3023B)
1 "use strict"; 2 3 const kOverflowPanel = document.getElementById("widget-overflow"); 4 5 var gOriginalWidth; 6 async function stopOverflowing() { 7 kOverflowPanel.removeAttribute("animate"); 8 unensureToolbarOverflow(window, gOriginalWidth); 9 await TestUtils.waitForCondition( 10 () => !document.getElementById("nav-bar").hasAttribute("overflowing") 11 ); 12 CustomizableUI.reset(); 13 } 14 15 registerCleanupFunction(stopOverflowing); 16 17 /** 18 * This checks that subview-compatible items show up as subviews rather than 19 * re-anchored panels. If we ever remove the library widget, please 20 * replace this test with another subview - don't remove it. 21 */ 22 add_task(async function check_library_subview_in_overflow() { 23 kOverflowPanel.setAttribute("animate", "false"); 24 gOriginalWidth = window.outerWidth; 25 26 CustomizableUI.addWidgetToArea("library-button", CustomizableUI.AREA_NAVBAR); 27 28 let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); 29 ok( 30 !navbar.hasAttribute("overflowing"), 31 "Should start with a non-overflowing toolbar." 32 ); 33 ensureToolbarOverflow(window, false); 34 await TestUtils.waitForCondition(() => navbar.hasAttribute("overflowing")); 35 36 let chevron = document.getElementById("nav-bar-overflow-button"); 37 let shownPanelPromise = BrowserTestUtils.waitForEvent( 38 kOverflowPanel, 39 "ViewShown" 40 ); 41 chevron.click(); 42 await shownPanelPromise; 43 44 let button = document.getElementById("library-button"); 45 button.click(); 46 47 let libraryView = document.getElementById("appMenu-libraryView"); 48 await BrowserTestUtils.waitForEvent(libraryView, "ViewShown"); 49 let hasSubviews = !!kOverflowPanel.querySelector("panelmultiview"); 50 let expectedPanel = hasSubviews 51 ? kOverflowPanel 52 : document.getElementById("customizationui-widget-panel"); 53 is(libraryView.closest("panel"), expectedPanel, "Should be inside the panel"); 54 expectedPanel.hidePopup(); 55 await Promise.resolve(); // wait for popup to hide fully. 56 await stopOverflowing(); 57 }); 58 59 /** 60 * This checks that non-subview-compatible items still work correctly. 61 * Ideally we should make the downloads panel and bookmarks/library item 62 * proper subview items, then this test can go away, and potentially we can 63 * simplify some of the subview anchoring code. 64 */ 65 add_task(async function check_downloads_panel_in_overflow() { 66 let button = document.getElementById("downloads-button"); 67 await gCustomizeMode.addToPanel(button); 68 await waitForOverflowButtonShown(); 69 70 let chevron = document.getElementById("nav-bar-overflow-button"); 71 let shownPanelPromise = promisePanelElementShown(window, kOverflowPanel); 72 chevron.click(); 73 await shownPanelPromise; 74 75 button.click(); 76 await TestUtils.waitForCondition(() => { 77 let panel = document.getElementById("downloadsPanel"); 78 return panel && panel.state != "closed"; 79 }); 80 let downloadsPanel = document.getElementById("downloadsPanel"); 81 isnot( 82 downloadsPanel.state, 83 "closed", 84 "Should be attempting to show the downloads panel." 85 ); 86 downloadsPanel.hidePopup(); 87 });