File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
browser/components/tabbrowser Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 72
72
this . addEventListener ( "mouseleave" , this ) ;
73
73
this . addEventListener ( "focusin" , this ) ;
74
74
this . addEventListener ( "focusout" , this ) ;
75
+ this . addEventListener ( "contextmenu" , this ) ;
75
76
}
76
77
77
78
init ( ) {
1486
1487
?. removeAttribute ( "rolluponmousewheel" ) ;
1487
1488
}
1488
1489
1490
+ on_contextmenu ( event ) {
1491
+ // When pressing the context menu key (as opposed to right-clicking)
1492
+ // while a tab group label has aria focus (as opposed to DOM focus),
1493
+ // open the tab group context menu as if the label had DOM focus.
1494
+ // The button property is used to differentiate between key and mouse.
1495
+ if (
1496
+ event . button == 0 &&
1497
+ this . ariaFocusedItem &&
1498
+ isTabGroupLabel ( this . ariaFocusedItem )
1499
+ ) {
1500
+ gBrowser . tabGroupMenu . openEditModal (
1501
+ this . ariaFocusedItem . closest ( "tab-group" )
1502
+ ) ;
1503
+ event . preventDefault ( ) ;
1504
+ }
1505
+ }
1506
+
1489
1507
get emptyTabTitle ( ) {
1490
1508
// Normal tab title is used also in the permanent private browsing mode.
1491
1509
const l10nId =
Original file line number Diff line number Diff line change @@ -133,6 +133,32 @@ add_task(async function test_TabGroupKeyboardFocus() {
133
133
await EventUtils . synthesizeKey ( "KEY_Enter" ) ;
134
134
Assert . ok ( tabGroup . collapsed , "Tab group should be collapsed once again" ) ;
135
135
136
+ let editor = document . getElementById ( "tab-group-editor" ) ;
137
+ let panelShown = BrowserTestUtils . waitForPopupEvent ( editor . panel , "shown" ) ;
138
+ //XXX Should simulate a context menu event, but this doesn't seem to work:
139
+ //await EventUtils.synthesizeKey("VK_CONTEXT_MENU");
140
+ gBrowser . tabContainer . on_contextmenu ( { button : 0 , preventDefault : ( ) => { } } ) ;
141
+ info ( "Waiting for the context menu key to open the group context menu" ) ;
142
+ await panelShown ;
143
+ is (
144
+ editor . panel . state ,
145
+ "open" ,
146
+ "Tab group context menu should be open after hitting context menu key"
147
+ ) ;
148
+ is (
149
+ gBrowser . tabContainer . ariaFocusedItem ,
150
+ tabGroup . labelElement ,
151
+ "Keyboard focus should remain on tab group label while group context menu is open"
152
+ ) ;
153
+ let panelHidden = BrowserTestUtils . waitForPopupEvent ( editor . panel , "hidden" ) ;
154
+ EventUtils . synthesizeKey ( "VK_ESCAPE" ) ;
155
+ await panelHidden ;
156
+ is (
157
+ gBrowser . tabContainer . ariaFocusedItem ,
158
+ tabGroup . labelElement ,
159
+ "Keyboard focus should remain on tab group label after closing the group menu context menu"
160
+ ) ;
161
+
136
162
info ( "Validate that keyboard focus skips over tabs in collapsed tab groups" ) ;
137
163
await synthesizeKeyToChangeKeyboardFocus ( tab4 , "KEY_ArrowRight" ) ;
138
164
is (
You can’t perform that action at this time.
0 commit comments