tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 811cc5be15e93c2b65bbb64e68bf34915f8b5d19
parent 9a9da20b36d291ba5eb3cf67302d03b89b09cb88
Author: Stephen Thompson <sthompson@mozilla.com>
Date:   Wed, 22 Oct 2025 14:02:42 +0000

Bug 1968371 - improve passage rate for browser_tab_groups_tab_interactions_telemetry r=jswinarton,tabbrowser-reviewers

Generally ensuring that tabs' browsers load, waiting for a tab to be fully duplicated before removing it, and more tightly targeting the close tab button in the list all tabs menu.

The frequent failure is a timeout in test_tabInteractionsCloseTabOverflowMenu waiting for close_tabmenu to be counted after clicking the close button in the list all tabs menu. Treeherder history has it happening only in Linux opt with socket networking (spi-nw). I can't reproduce that locally with the same config as spi-nw test harness runs, but I gave it a shot.

I did find some other issues locally that don't seem to show up in Treeherder. This patch tries to fix those.

I get `test_tabInteractionsRemoveFromGroup - at chrome://mochikit/content/tests/SimpleTest/EventUtils.js:3901 - Error: drag hasn't been started by the operation` when running headless locally, which I suspect we may start to see if this patch does manage to fix the current timeout problem in test_tabInteractionsCloseTabOverflowMenu.

Differential Revision: https://phabricator.services.mozilla.com/D269533

Diffstat:
Mbrowser/components/tabbrowser/test/browser/tabs/browser_tab_groups_tab_interactions_telemetry.js | 62++++++++++++++------------------------------------------------
1 file changed, 14 insertions(+), 48 deletions(-)

diff --git a/browser/components/tabbrowser/test/browser/tabs/browser_tab_groups_tab_interactions_telemetry.js b/browser/components/tabbrowser/test/browser/tabs/browser_tab_groups_tab_interactions_telemetry.js @@ -115,10 +115,7 @@ add_task(async function test_tabInteractionsBasic() { let initialTab = window.gBrowser.tabs[0]; await resetTelemetry(); - let groupedTab = BrowserTestUtils.addTab( - window.gBrowser, - "https://example.com" - ); + let groupedTab = await addTab(); let group = window.gBrowser.addTabGroup([groupedTab]); group.collapsed = true; @@ -147,7 +144,7 @@ add_task(async function test_tabInteractionsBasic() { info( "Test that moving an existing tab into a tab group records tab_interactions.add" ); - let tab1 = BrowserTestUtils.addTab(window.gBrowser, "https://example.com"); + let tab1 = await addTab(); await assertMetricEmpty("add"); window.gBrowser.moveTabToGroup(tab1, group, { isUserTriggered: true }); await assertMetricFoundFor("add"); @@ -156,7 +153,7 @@ add_task(async function test_tabInteractionsBasic() { "Test that adding a new tab to a tab group records tab_interactions.new" ); await assertMetricEmpty("new"); - BrowserTestUtils.addTab(window.gBrowser, "https://example.com", { + await addTab(undefined, { tabGroup: group, }); await assertMetricFoundFor("new"); @@ -173,7 +170,9 @@ add_task(async function test_tabInteractionsBasic() { "Test that duplicating a tab within a group calls tab_interactions.duplicate" ); await assertMetricEmpty("duplicate"); + let ssTabRestored = BrowserTestUtils.waitForEvent(window, "SSTabRestored"); window.gBrowser.duplicateTab(group.tabs[0], true, { tabIndex: 2 }); + await ssTabRestored; await assertMetricFoundFor("duplicate"); window.gBrowser.removeAllTabsBut(initialTab); @@ -185,11 +184,7 @@ add_task(async function test_tabInteractionsClose() { await resetTelemetry(); FirefoxViewTestUtilsInit(this, window); - let tabs = Array.from({ length: 5 }, () => { - return BrowserTestUtils.addTab(window.gBrowser, "https://example.com", { - skipAnimation: true, - }); - }); + let tabs = await Promise.all(Array.from({ length: 5 }, () => addTab())); let group = window.gBrowser.addTabGroup(tabs); info( @@ -240,11 +235,7 @@ add_task(async function test_tabInteractionsCloseViaAnotherTabContext() { let initialTab = window.gBrowser.tabs[0]; await resetTelemetry(); - window.gBrowser.addTabGroup([ - BrowserTestUtils.addTab(window.gBrowser, "https://example.com", { - skipAnimation: true, - }), - ]); + window.gBrowser.addTabGroup([await addTab()]); await assertMetricEmpty("close_tab_other"); @@ -261,11 +252,7 @@ add_task(async function test_tabInteractionsCloseViaAnotherTabContext() { info( "Test that closing a tab via the tab context menu 'close tabs to left' command calls tab_interactions.close_tab_other" ); - window.gBrowser.addTabGroup([ - BrowserTestUtils.addTab(window.gBrowser, "https://example.com", { - skipAnimation: true, - }), - ]); + window.gBrowser.addTabGroup([await addTab()]); window.gBrowser.moveTabToEnd(initialTab); await activateTabContextMenuItem( initialTab, @@ -277,11 +264,7 @@ add_task(async function test_tabInteractionsCloseViaAnotherTabContext() { info( "Test that closing a tab via the tab context menu 'close tabs to right' command calls tab_interactions.close_tab_other" ); - window.gBrowser.addTabGroup([ - BrowserTestUtils.addTab(window.gBrowser, "https://example.com", { - skipAnimation: true, - }), - ]); + window.gBrowser.addTabGroup([await addTab()]); await activateTabContextMenuItem( initialTab, "#context_closeTabsToTheEnd", @@ -292,17 +275,7 @@ add_task(async function test_tabInteractionsCloseViaAnotherTabContext() { info( "Test that closing a tab via the tab context menu 'close duplicate tabs' command calls tab_interactions.close_tab_other" ); - let duplicateTabs = [ - BrowserTestUtils.addTab(window.gBrowser, "https://example.com", { - skipAnimation: true, - }), - BrowserTestUtils.addTab(window.gBrowser, "https://example.com", { - skipAnimation: true, - }), - ]; - await Promise.all( - duplicateTabs.map(t => BrowserTestUtils.browserLoaded(t.linkedBrowser)) - ); + let duplicateTabs = await Promise.all([addTab(), addTab()]); window.gBrowser.addTabGroup([duplicateTabs[1]]); await activateTabContextMenuItem( @@ -326,12 +299,8 @@ add_task(async function test_tabInteractionsCloseViaAnotherTabContext() { add_task(async function test_tabInteractionsCloseTabOverflowMenu() { let initialTab = window.gBrowser.tabs[0]; await resetTelemetry(); - FirefoxViewTestUtilsInit(this, window); - let tab = BrowserTestUtils.addTab(window.gBrowser, "https://example.com", { - skipAnimation: true, - }); - window.gBrowser.addTabGroup([tab]); + window.gBrowser.addTabGroup([await addTab()]); info( "Test that closing a tab from the tab overflow menu calls tab_interactions.close_tabmenu" @@ -345,7 +314,8 @@ add_task(async function test_tabInteractionsCloseTabOverflowMenu() { await assertMetricEmpty("close_tabmenu"); window.document - .querySelector(".all-tabs-item.grouped .all-tabs-close-button") + .getElementById("allTabsMenu-allTabsView-tabs") + .querySelector(":scope .all-tabs-item.grouped .all-tabs-close-button") .click(); await assertMetricFoundFor("close_tabmenu"); @@ -367,11 +337,7 @@ add_task(async function test_tabInteractionsRemoveFromGroup() { let initialTab = window.gBrowser.tabs[0]; await resetTelemetry(); - let tabs = Array.from({ length: 3 }, () => { - return BrowserTestUtils.addTab(window.gBrowser, "https://example.com", { - skipAnimation: true, - }); - }); + let tabs = await Promise.all(Array.from({ length: 3 }, () => addTab())); let group = window.gBrowser.addTabGroup(tabs); info(