browser_synced_tabs_view.js (2027B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 function promiseLayout() { 7 // Wait for layout to have happened. 8 return new Promise(resolve => 9 requestAnimationFrame(() => requestAnimationFrame(resolve)) 10 ); 11 } 12 13 add_setup(async function () { 14 registerCleanupFunction(() => CustomizableUI.reset()); 15 }); 16 17 async function withOpenSyncPanel(cb) { 18 let promise = BrowserTestUtils.waitForEvent( 19 window, 20 "ViewShown", 21 true, 22 e => e.target.id == "PanelUI-remotetabs" 23 ).then(e => e.target.closest("panel")); 24 25 let panel; 26 try { 27 gSync.openSyncedTabsPanel(); 28 panel = await promise; 29 is(panel.state, "open", "Panel should have opened."); 30 await cb(panel); 31 } finally { 32 panel?.hidePopup(); 33 } 34 } 35 36 add_task(async function test_button_in_bookmarks_toolbar() { 37 CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_BOOKMARKS); 38 CustomizableUI.setToolbarVisibility(CustomizableUI.AREA_BOOKMARKS, "never"); 39 await promiseLayout(); 40 41 await withOpenSyncPanel(async panel => { 42 is( 43 panel.anchorNode.closest("toolbarbutton"), 44 PanelUI.menuButton, 45 "Should have anchored on the menu button because the sync button isn't visible." 46 ); 47 }); 48 }); 49 50 add_task(async function test_button_in_navbar() { 51 CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_NAVBAR, 0); 52 await promiseLayout(); 53 await withOpenSyncPanel(async panel => { 54 is( 55 panel.anchorNode.closest("toolbarbutton").id, 56 "sync-button", 57 "Should have anchored on the sync button itself." 58 ); 59 }); 60 }); 61 62 add_task(async function test_button_in_overflow() { 63 CustomizableUI.addWidgetToArea( 64 "sync-button", 65 CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, 66 0 67 ); 68 await promiseLayout(); 69 await withOpenSyncPanel(async panel => { 70 is( 71 panel.anchorNode.closest("toolbarbutton").id, 72 "nav-bar-overflow-button", 73 "Should have anchored on the overflow button." 74 ); 75 }); 76 });