Closed Bug 1962592 Opened 7 months ago Closed 7 months ago

Too many tabs.onMoved event fired when a tab group is moved to a new window

Categories

(WebExtensions :: General, defect)

defect

Tracking

(firefox139 fixed)

RESOLVED FIXED
139 Branch
Tracking Status
firefox139 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

(Blocks 1 open bug)

Details

(Whiteboard: [addons-jira])

Attachments

(2 files)

While working on extra test coverage for the tabGroups.move API, I discovered that the tabs.onMoved event fires too frequently when a tab group is moved to a new window. There are multiple reasons for that:

  • TabMove is fired whenever the tab group changes. adoptTabGroup adopts tabs by first moving tabs from another window, then adopting tabs in the tab group. Consequently, there is always a transition between tab groups, and tabs.onMoved is fired for each tab in the group.

  • When adoptTabGroup adopts tabs, it puts all tabs at the front of the specified destination. Consequently, tabs appear in reverse order before finally being moved to its destination. This final move may trigger additional TabMove events, and therefore also tabs.move.

  • The implementation of tabGroups.move first adopts tab groups at the end of a window, and then moves it to its destination. This all will trigger tabs.onMoved events.

This patch covers multiple cases:

  • Pre-existing issue: adoptTabGroup adopts tabs by first moving the tabs
    elsewhere, then moving it into a group. When moved into a group,
    TabMove is fired, which previously translated to tabs.onMoved. That
    would result in too much event noise.

  • When tabGroups.move is called, it first adopted the tab group in
    another window, and then moved the tab group as a whole. This
    results in unnecessary tabs.onMoved events too. The fix is to specify
    the desired position at once to adoptTabGroup.

Assignee: nobody → rob
Status: NEW → ASSIGNED
Pushed by tjovanovic@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/18acdfacc01b Avoid unnecessary tabs.onMoved when moving tab groups r=zombie https://hg.mozilla.org/integration/autoland/rev/52abc36a8c48 Reduce tab moves in adoptTabGroup r=tabbrowser-reviewers,dao
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: