browser_1484275_PanelMultiView_toggle_with_other_popup.js (2584B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const TEST_URL = "data:text/html,<html><body></body></html>"; 7 8 /** 9 * Test steps that may lead to the panel being stuck on Windows (bug 1484275). 10 */ 11 add_task(async function test_PanelMultiView_toggle_with_other_popup() { 12 // For proper cleanup, create a bookmark that we will remove later. 13 let bookmark = await PlacesUtils.bookmarks.insert({ 14 parentGuid: PlacesUtils.bookmarks.unfiledGuid, 15 url: TEST_URL, 16 }); 17 registerCleanupFunction(() => PlacesUtils.bookmarks.remove(bookmark)); 18 19 await BrowserTestUtils.withNewTab( 20 { 21 gBrowser, 22 url: TEST_URL, 23 }, 24 async function () { 25 // 1. Open the main menu. 26 await gCUITestUtils.openMainMenu(); 27 28 // 2. Open another popup not managed by PanelMultiView. 29 StarUI._createPanelIfNeeded(); 30 let bookmarkPanel = document.getElementById("editBookmarkPanel"); 31 let shown = BrowserTestUtils.waitForEvent(bookmarkPanel, "popupshown"); 32 let hidden = BrowserTestUtils.waitForEvent(bookmarkPanel, "popuphidden"); 33 EventUtils.synthesizeKey("D", { accelKey: true }); 34 await shown; 35 36 // 3. Click the button to which the main menu is anchored. We need a native 37 // mouse event to simulate the exact platform behavior with popups. 38 let clickFn = () => 39 EventUtils.promiseNativeMouseEventAndWaitForEvent({ 40 type: "click", 41 target: document.getElementById("PanelUI-button"), 42 atCenter: true, 43 eventTypeToWait: "mouseup", 44 }); 45 46 // On Windows and macOS, the operation will close both popups. 47 if (AppConstants.platform == "win" || AppConstants.platform == "macosx") { 48 await gCUITestUtils.hidePanelMultiView(PanelUI.panel, clickFn); 49 await new Promise(resolve => executeSoon(resolve)); 50 51 // 4. Test that the popup can be opened again after it's been closed. 52 await gCUITestUtils.openMainMenu(); 53 Assert.equal(PanelUI.panel.state, "open"); 54 } else { 55 // On other platforms, the operation will close both popups and reopen the 56 // main menu immediately, so we wait for the reopen to occur. 57 shown = BrowserTestUtils.waitForEvent(PanelUI.mainView, "ViewShown"); 58 clickFn(); 59 await shown; 60 } 61 62 await gCUITestUtils.hideMainMenu(); 63 64 // Make sure the events for the bookmarks panel have also been processed 65 // before closing the tab and removing the bookmark. 66 await hidden; 67 } 68 ); 69 });