|
2 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
|
3 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
4 | 4 |
|
5 |
| -const { TabStateFlusher } = ChromeUtils.importESModule( |
6 |
| - "resource:///modules/sessionstore/TabStateFlusher.sys.mjs" |
7 |
| -); |
8 |
| - |
9 | 5 | let resetTelemetry = async () => {
|
10 | 6 | await Services.fog.testFlushAllChildren();
|
11 | 7 | Services.fog.testResetFOG();
|
12 | 8 | };
|
13 | 9 |
|
14 |
| -window.gTabsPanel.init(); |
15 |
| - |
16 | 10 | add_task(async function test_tabGroupTelemetry() {
|
17 | 11 | await resetTelemetry();
|
18 | 12 |
|
@@ -202,188 +196,3 @@ add_task(async function test_tabGroupTelemetry() {
|
202 | 196 | await removeTabGroup(group1);
|
203 | 197 | await removeTabGroup(group2);
|
204 | 198 | });
|
205 |
| - |
206 |
| -/** |
207 |
| - * @param {MozTabbrowserTabGroup} tabGroup |
208 |
| - * @returns {Promise<MozPanel>} |
209 |
| - * Panel holding the tab group context menu for the requested tab group. |
210 |
| - */ |
211 |
| -async function openTabGroupContextMenu(tabGroup) { |
212 |
| - let tabgroupEditor = document.getElementById("tab-group-editor"); |
213 |
| - let tabgroupPanel = tabgroupEditor.panel; |
214 |
| - |
215 |
| - let panelShown = BrowserTestUtils.waitForPopupEvent(tabgroupPanel, "shown"); |
216 |
| - EventUtils.synthesizeMouseAtCenter( |
217 |
| - tabGroup.querySelector(".tab-group-label"), |
218 |
| - { type: "contextmenu", button: 2 }, |
219 |
| - window |
220 |
| - ); |
221 |
| - await panelShown; |
222 |
| - |
223 |
| - return tabgroupPanel; |
224 |
| -} |
225 |
| - |
226 |
| -add_task(async function test_tabGroupContextMenu_deleteTabGroup() { |
227 |
| - await resetTelemetry(); |
228 |
| - |
229 |
| - let tab = BrowserTestUtils.addTab(gBrowser, "https://example.com"); |
230 |
| - await BrowserTestUtils.browserLoaded(tab.linkedBrowser); |
231 |
| - |
232 |
| - let group = gBrowser.addTabGroup([tab]); |
233 |
| - // Close the automatically-opened "create tab group" menu. |
234 |
| - gBrowser.tabGroupMenu.close(); |
235 |
| - let groupId = group.id; |
236 |
| - |
237 |
| - let menu = await openTabGroupContextMenu(group); |
238 |
| - let deleteTabGroupButton = menu.querySelector("#tabGroupEditor_deleteGroup"); |
239 |
| - deleteTabGroupButton.click(); |
240 |
| - |
241 |
| - await TestUtils.waitForCondition( |
242 |
| - () => !gBrowser.tabGroups.includes(group), |
243 |
| - "wait for group to be deleted" |
244 |
| - ); |
245 |
| - |
246 |
| - let tabGroupDeleteEvents = Glean.tabgroup.delete.testGetValue(); |
247 |
| - Assert.equal( |
248 |
| - tabGroupDeleteEvents.length, |
249 |
| - 1, |
250 |
| - "should have recorded a tabgroup.delete event" |
251 |
| - ); |
252 |
| - |
253 |
| - let [tabGroupDeleteEvent] = tabGroupDeleteEvents; |
254 |
| - Assert.deepEqual( |
255 |
| - tabGroupDeleteEvent.extra, |
256 |
| - { |
257 |
| - source: "tab_group", |
258 |
| - id: groupId, |
259 |
| - }, |
260 |
| - "should have recorded the correct source and ID" |
261 |
| - ); |
262 |
| - |
263 |
| - await resetTelemetry(); |
264 |
| -}); |
265 |
| - |
266 |
| -/** |
267 |
| - * @returns {Promise<PanelView>} |
268 |
| - */ |
269 |
| -async function openTabsMenu() { |
270 |
| - let viewShown = BrowserTestUtils.waitForEvent( |
271 |
| - window.document.getElementById("allTabsMenu-allTabsView"), |
272 |
| - "ViewShown" |
273 |
| - ); |
274 |
| - window.document.getElementById("alltabs-button").click(); |
275 |
| - return (await viewShown).target; |
276 |
| -} |
277 |
| - |
278 |
| -/** |
279 |
| - * @returns {Promise<void>} |
280 |
| - */ |
281 |
| -async function closeTabsMenu() { |
282 |
| - let panel = window.document |
283 |
| - .getElementById("allTabsMenu-allTabsView") |
284 |
| - .closest("panel"); |
285 |
| - if (!panel) { |
286 |
| - return; |
287 |
| - } |
288 |
| - let hidden = BrowserTestUtils.waitForPopupEvent(panel, "hidden"); |
289 |
| - panel.hidePopup(); |
290 |
| - await hidden; |
291 |
| -} |
292 |
| - |
293 |
| -/** |
294 |
| - * @param {XULToolbarButton} triggerNode |
295 |
| - * @param {string} contextMenuId |
296 |
| - * @returns {Promise<XULMenuElement|XULPopupElement>} |
297 |
| - */ |
298 |
| -async function getContextMenu(triggerNode, contextMenuId) { |
299 |
| - let win = triggerNode.ownerGlobal; |
300 |
| - triggerNode.scrollIntoView(); |
301 |
| - const contextMenu = win.document.getElementById(contextMenuId); |
302 |
| - const contextMenuShown = BrowserTestUtils.waitForPopupEvent( |
303 |
| - contextMenu, |
304 |
| - "shown" |
305 |
| - ); |
306 |
| - |
307 |
| - EventUtils.synthesizeMouseAtCenter( |
308 |
| - triggerNode, |
309 |
| - { type: "contextmenu", button: 2 }, |
310 |
| - win |
311 |
| - ); |
312 |
| - await contextMenuShown; |
313 |
| - return contextMenu; |
314 |
| -} |
315 |
| - |
316 |
| -/** |
317 |
| - * @param {XULMenuElement|XULPopupElement} contextMenu |
318 |
| - * @returns {Promise<void>} |
319 |
| - */ |
320 |
| -async function closeContextMenu(contextMenu) { |
321 |
| - let menuHidden = BrowserTestUtils.waitForPopupEvent(contextMenu, "hidden"); |
322 |
| - contextMenu.hidePopup(); |
323 |
| - await menuHidden; |
324 |
| -} |
325 |
| - |
326 |
| -/** |
327 |
| - * Returns a new basic, unnamed tab group that is fully loaded in the browser |
328 |
| - * and in session state. |
329 |
| - * |
330 |
| - * @returns {Promise<MozTabbrowserTabGroup>} |
331 |
| - */ |
332 |
| -async function makeTabGroup() { |
333 |
| - let tab = BrowserTestUtils.addTab(gBrowser, "https://example.com"); |
334 |
| - await BrowserTestUtils.browserLoaded(tab.linkedBrowser); |
335 |
| - await TabStateFlusher.flush(tab.linkedBrowser); |
336 |
| - |
337 |
| - let group = gBrowser.addTabGroup([tab]); |
338 |
| - // Close the automatically-opened "create tab group" menu. |
339 |
| - gBrowser.tabGroupMenu.close(); |
340 |
| - return group; |
341 |
| -} |
342 |
| - |
343 |
| -add_task(async function test_tabOverflowContextMenu_deleteOpenTabGroup() { |
344 |
| - await resetTelemetry(); |
345 |
| - |
346 |
| - info("set up an open tab group to be deleted"); |
347 |
| - let openGroup = await makeTabGroup(); |
348 |
| - let openGroupId = openGroup.id; |
349 |
| - |
350 |
| - info("delete the open tab group"); |
351 |
| - let allTabsMenu = await openTabsMenu(); |
352 |
| - let tabGroupButton = allTabsMenu.querySelector( |
353 |
| - `#allTabsMenu-groupsView [data-tab-group-id="${openGroupId}"]` |
354 |
| - ); |
355 |
| - |
356 |
| - let menu = await getContextMenu( |
357 |
| - tabGroupButton, |
358 |
| - "open-tab-group-context-menu" |
359 |
| - ); |
360 |
| - |
361 |
| - menu.querySelector("#open-tab-group-context-menu_delete").click(); |
362 |
| - await closeContextMenu(menu); |
363 |
| - await closeTabsMenu(); |
364 |
| - |
365 |
| - await TestUtils.waitForCondition( |
366 |
| - () => !gBrowser.tabGroups.includes(openGroup), |
367 |
| - "wait for group to be deleted" |
368 |
| - ); |
369 |
| - |
370 |
| - let tabGroupDeleteEvents = Glean.tabgroup.delete.testGetValue(); |
371 |
| - Assert.equal( |
372 |
| - tabGroupDeleteEvents.length, |
373 |
| - 1, |
374 |
| - "should have recorded one tabgroup.delete event" |
375 |
| - ); |
376 |
| - |
377 |
| - let [openTabGroupDeleteEvent] = tabGroupDeleteEvents; |
378 |
| - |
379 |
| - Assert.deepEqual( |
380 |
| - openTabGroupDeleteEvent.extra, |
381 |
| - { |
382 |
| - source: "tab_overflow", |
383 |
| - id: openGroupId, |
384 |
| - }, |
385 |
| - "should have recorded the correct source and ID for the open tab group" |
386 |
| - ); |
387 |
| - |
388 |
| - await resetTelemetry(); |
389 |
| -}); |
0 commit comments