blob: 393fe5e5258dccf12d83620a8f63b7e0bb55482e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
Fixes CVE-2024-11692 (Select list elements could be shown over another site)
Based on <https://hg.mozilla.org/releases/mozilla-esr128/rev/a6cf1a7cd289db4f46cb34f4dd16cce133b25e8d>
Adapted to ESR 115 by Mark H Weaver <mhw@netris.org>
# HG changeset patch
# User Edgar Chen <echen@mozilla.com>
# Date 1730556179 0
# Node ID a6cf1a7cd289db4f46cb34f4dd16cce133b25e8d
# Parent e983e8a66e515a2e32497cec1b3ccf439396dadc
Bug 1909535 - Don't show select dropdown in background tabs; a=dmeehan
Original Revision: https://phabricator.services.mozilla.com/D225706
Differential Revision: https://phabricator.services.mozilla.com/D227607
diff --git a/toolkit/actors/SelectParent.sys.mjs b/toolkit/actors/SelectParent.sys.mjs
--- a/toolkit/actors/SelectParent.sys.mjs
+++ b/toolkit/actors/SelectParent.sys.mjs
@@ -273,16 +273,41 @@ export var SelectParentHelper = {
}
this._currentZoom = zoom;
this._currentMenulist = menulist;
this.populateChildren(menulist, items, uniqueItemStyles, selectedIndex);
},
open(browser, menulist, rect, isOpenedViaTouch, selectParentActor) {
+ const canOpen = (() => {
+ if (!menulist.ownerDocument.hasFocus()) {
+ // Don't open in inactive browser windows.
+ return false;
+ }
+ if (browser) {
+ if (!browser.browsingContext.isActive) {
+ // Don't open in inactive tabs.
+ return false;
+ }
+ let tabbrowser = browser.getTabBrowser();
+ if (tabbrowser && tabbrowser.selectedBrowser != browser) {
+ // AsyncTabSwitcher might delay activating our browser, check
+ // explicitly for tabbrowser.
+ return false;
+ }
+ }
+ return true;
+ })();
+
+ if (!canOpen) {
+ selectParentActor.sendAsyncMessage("Forms:DismissedDropDown", {});
+ return;
+ }
+
this._actor = selectParentActor;
menulist.hidden = false;
this._currentBrowser = browser;
this._closedWithEnter = false;
this._selectRect = rect;
this._registerListeners(menulist.menupopup);
// Set the maximum height to show exactly MAX_ROWS items.
|