Skip to content

Commit 642f020

Browse files
committed
Bug 1866503 - closing menupopups/panels inside panelviews in temporary PanelUI panels should not close those panels, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D194632
1 parent 3caf9e8 commit 642f020

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

browser/components/customizableui/content/panelUI.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,11 @@ const PanelUI = {
457457
viewNode.classList.add("cui-widget-panelview", "PanelUI-subView");
458458

459459
let viewShown = false;
460-
let panelRemover = () => {
460+
let panelRemover = event => {
461+
// Avoid bubbled events triggering the panel closing.
462+
if (event.target != tempPanel) {
463+
return;
464+
}
461465
viewNode.classList.remove("cui-widget-panelview");
462466
if (viewShown) {
463467
CustomizableUI.removePanelCloseListeners(tempPanel);

browser/components/customizableui/test/browser.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ tags = "fullscreen"
320320

321321
["browser_panel_locationSpecific.js"]
322322

323+
["browser_panel_menulist.js"]
324+
323325
["browser_panel_toggle.js"]
324326

325327
["browser_proton_moreTools_panel.js"]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* Any copyright is dedicated to the Public Domain.
2+
http://creativecommons.org/publicdomain/zero/1.0/ */
3+
4+
"use strict";
5+
6+
const kViewID = "panelview-with-menulist";
7+
8+
/**
9+
* When there's a menulist inside a panelview, closing it shouldn't close the panel.
10+
*/
11+
add_task(async function test_closing_menulist_should_not_close_panel() {
12+
let viewCache = document.getElementById("appMenu-viewCache");
13+
let panelview = document.createXULElement("panelview");
14+
panelview.id = kViewID;
15+
let menulist = document.createXULElement("menulist");
16+
let popup = document.createXULElement("menupopup");
17+
for (let item of ["one", "two"]) {
18+
let menuitem = document.createXULElement("menuitem");
19+
menuitem.id = `menuitem-${item}`;
20+
menuitem.setAttribute("label", item);
21+
popup.append(menuitem);
22+
}
23+
menulist.append(popup);
24+
panelview.append(menulist);
25+
viewCache.append(panelview);
26+
await PanelUI.showSubView(kViewID, PanelUI.menuButton);
27+
let panel = panelview.closest("panel");
28+
29+
registerCleanupFunction(async () => {
30+
if (panel && panel.state != "closed") {
31+
let panelGone = BrowserTestUtils.waitForPopupEvent(panel, "hidden");
32+
panel.hidePopup();
33+
await panelGone;
34+
}
35+
panelview.remove();
36+
});
37+
38+
let shown = BrowserTestUtils.waitForPopupEvent(popup, "shown");
39+
menulist.openMenu(true);
40+
await shown;
41+
let hidden = BrowserTestUtils.waitForPopupEvent(popup, "hidden");
42+
popup.activateItem(popup.firstElementChild);
43+
await hidden;
44+
45+
Assert.equal(panel?.state, "open", "Panel should still be open.");
46+
});

toolkit/content/aboutNetError.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import {
1010
pemToDER,
1111
} from "chrome://global/content/certviewer/certDecoder.mjs";
1212

13+
window.addEventListener("load", console.log);
14+
window.addEventListener("load", console.log, true);
15+
document.addEventListener("load", console.log);
16+
document.addEventListener("load", console.log, true);
17+
1318
const formatter = new Intl.DateTimeFormat();
1419

1520
const HOST_NAME = getHostName();

toolkit/content/globalOverlay.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ function closeWindow(aClose, aPromptFunction, aSource) {
77
"resource://gre/modules/AppConstants.sys.mjs"
88
);
99

10+
console.error("Hello from closeWindow");
11+
1012
// Closing the last window doesn't quit the application on OS X.
1113
if (AppConstants.platform != "macosx") {
1214
var windowCount = 0;

0 commit comments

Comments
 (0)