This repository was archived by the owner on Jul 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +61
-10
lines changed
browser/components/tabbrowser Expand file tree Collapse file tree 2 files changed +61
-10
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,6 @@ var { XPCOMUtils } = ChromeUtils.importESModule(
6
6
"resource://gre/modules/XPCOMUtils.sys.mjs"
7
7
) ;
8
8
9
- const POPUP_OPTIONS = {
10
- position : "bottomleft topleft" ,
11
- x : 0 ,
12
- y : - 2 ,
13
- } ;
14
-
15
9
const ZERO_DELAY_ACTIVATION_TIME = 300 ;
16
10
17
11
/**
@@ -64,14 +58,40 @@ export default class TabHoverPreviewPanel {
64
58
65
59
this . _panelOpener = new TabPreviewPanelTimedFunction (
66
60
( ) => {
67
- this . _panel . openPopup ( this . _tab , POPUP_OPTIONS ) ;
61
+ this . _panel . openPopup ( this . _tab , this . #popupOptions ) ;
68
62
} ,
69
63
this . _prefPreviewDelay ,
70
64
ZERO_DELAY_ACTIVATION_TIME ,
71
65
this . _win
72
66
) ;
73
67
}
74
68
69
+ get #verticalMode( ) {
70
+ return this . _win . gBrowser . tabContainer . verticalMode ;
71
+ }
72
+
73
+ get #popupOptions( ) {
74
+ if ( ! this . #verticalMode) {
75
+ return {
76
+ position : "bottomleft topleft" ,
77
+ x : 0 ,
78
+ y : - 2 ,
79
+ } ;
80
+ }
81
+ if ( ! this . _win . SidebarController . _positionStart ) {
82
+ return {
83
+ position : "topleft topright" ,
84
+ x : 0 ,
85
+ y : 4 ,
86
+ } ;
87
+ }
88
+ return {
89
+ position : "topright topleft" ,
90
+ x : 0 ,
91
+ y : 4 ,
92
+ } ;
93
+ }
94
+
75
95
getPrettyURI ( uri ) {
76
96
try {
77
97
let url = new URL ( uri ) ;
@@ -231,9 +251,9 @@ export default class TabHoverPreviewPanel {
231
251
if ( this . _tab ) {
232
252
this . _panel . moveToAnchor (
233
253
this . _tab ,
234
- POPUP_OPTIONS . position ,
235
- POPUP_OPTIONS . x ,
236
- POPUP_OPTIONS . y
254
+ this . #popupOptions . position ,
255
+ this . #popupOptions . x ,
256
+ this . #popupOptions . y
237
257
) ;
238
258
}
239
259
}
Original file line number Diff line number Diff line change @@ -759,3 +759,34 @@ add_task(async function tabContentChangeTests() {
759
759
await closePreviews ( ) ;
760
760
BrowserTestUtils . removeTab ( tab ) ;
761
761
} ) ;
762
+
763
+ /**
764
+ * In vertical tabs mode, tab preview should be displayed to the side
765
+ * and not beneath the tab.
766
+ */
767
+ add_task ( async function tabPreview_verticalTabsPositioning ( ) {
768
+ await SpecialPowers . pushPrefEnv ( {
769
+ set : [
770
+ [ "sidebar.revamp" , true ] ,
771
+ [ "sidebar.verticalTabs" , true ] ,
772
+ ] ,
773
+ } ) ;
774
+
775
+ const previewPanel = document . getElementById ( "tab-preview-panel" ) ;
776
+ const tab = await BrowserTestUtils . openNewForegroundTab (
777
+ gBrowser ,
778
+ "about:blank"
779
+ ) ;
780
+ await openPreview ( tab ) ;
781
+
782
+ let tabRect = tab . getBoundingClientRect ( ) ;
783
+ let panelRect = previewPanel . getBoundingClientRect ( ) ;
784
+
785
+ Assert . ok (
786
+ Math . abs ( tabRect . top - panelRect . top ) < 5 ,
787
+ "Preview panel not displayed beneath tab"
788
+ ) ;
789
+
790
+ await closePreviews ( ) ;
791
+ BrowserTestUtils . removeTab ( tab ) ;
792
+ } ) ;
You can’t perform that action at this time.
0 commit comments