browser_962069_drag_to_overflow_chevron.js (2608B)
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 var originalWindowWidth; 8 9 // Drag to overflow chevron should open the overflow panel. 10 add_task(async function () { 11 // Load a page so the identity box can be dragged. 12 BrowserTestUtils.startLoadingURIString(gBrowser, "http://mochi.test:8888/"); 13 await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); 14 15 let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); 16 ok( 17 !navbar.hasAttribute("overflowing"), 18 "Should start with a non-overflowing toolbar." 19 ); 20 ok(CustomizableUI.inDefaultState, "Should start in default state."); 21 originalWindowWidth = ensureToolbarOverflow(window, false); 22 23 await TestUtils.waitForCondition(() => navbar.hasAttribute("overflowing")); 24 ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); 25 26 let widgetOverflowPanel = document.getElementById("widget-overflow"); 27 let panelShownPromise = promisePanelElementShown(window, widgetOverflowPanel); 28 let identityBox = document.getElementById("identity-icon-box"); 29 let overflowChevron = document.getElementById("nav-bar-overflow-button"); 30 31 // Listen for hiding immediately so we don't miss the event because of the 32 // async-ness of the 'shown' yield... 33 let panelHiddenPromise = promisePanelElementHidden( 34 window, 35 widgetOverflowPanel 36 ); 37 38 var ds = Cc["@mozilla.org/widget/dragservice;1"].getService( 39 Ci.nsIDragService 40 ); 41 42 ds.startDragSessionForTests( 43 window, 44 Ci.nsIDragService.DRAGDROP_ACTION_MOVE | 45 Ci.nsIDragService.DRAGDROP_ACTION_COPY | 46 Ci.nsIDragService.DRAGDROP_ACTION_LINK 47 ); 48 try { 49 var [result, dataTransfer] = EventUtils.synthesizeDragOver( 50 identityBox, 51 overflowChevron 52 ); 53 54 // Wait for showing panel before ending drag session. 55 await panelShownPromise; 56 57 EventUtils.synthesizeDropAfterDragOver( 58 result, 59 dataTransfer, 60 overflowChevron 61 ); 62 } finally { 63 ds.getCurrentSession().endDragSession(true); 64 } 65 66 info("Overflow panel is shown."); 67 68 widgetOverflowPanel.hidePopup(); 69 await panelHiddenPromise; 70 }); 71 72 add_task(async function () { 73 unensureToolbarOverflow(window, originalWindowWidth); 74 let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); 75 await TestUtils.waitForCondition(() => !navbar.hasAttribute("overflowing")); 76 ok( 77 !navbar.hasAttribute("overflowing"), 78 "Should not have an overflowing toolbar." 79 ); 80 });