I looked into chromium’s implementation, and it’s a bit more complex than what I described in the description. Details are in TabStripModelOrderController::DetermineNewSelectedIndex(…)¹.
I think it would be worth identifying what in chromium’s implementation we want to replicate.
One thing that wasn’t reported as part of this bug is that when opening background tabs from a given page, they should be placed to the right of the opener, in sequence (i.e. if I open B, C and D as background tabs from A, the order of the tabs should be A-B-C-D, not A-D-C-B as it is currently). This should probably be implemented as part of this bug.
I looked into chromium’s implementation, and it’s a bit more complex than what I described in the description. Details are in TabStripModelOr derController: :DetermineNewSe lectedIndex( …)¹.
I think it would be worth identifying what in chromium’s implementation we want to replicate.
One thing that wasn’t reported as part of this bug is that when opening background tabs from a given page, they should be placed to the right of the opener, in sequence (i.e. if I open B, C and D as background tabs from A, the order of the tabs should be A-B-C-D, not A-D-C-B as it is currently). This should probably be implemented as part of this bug.
¹ https:/ /cs.chromium. org/chromium/ src/chrome/ browser/ ui/tabs/ tab_strip_ model_order_ controller. cc?l=52