Closed Bug 1808734 Opened 2 years ago Closed 2 years ago

_getVisibleTabs() may return tab instead of array

Categories

(Firefox :: Tabbed Browser, defect)

Firefox 111
defect

Tracking

()

RESOLVED FIXED
Tracking Status
firefox-esr102 --- wontfix
firefox108 --- wontfix
firefox109 --- wontfix
firefox110 --- wontfix
firefox111 --- fixed

People

(Reporter: Oriol, Assigned: Oriol)

References

(Regression)

Details

(Keywords: regression)

Consumers of _getVisibleTabs() expect it to return an array, e.g. they use .length and such.

However, it may return a tab instead of an array: https://searchfox.org/mozilla-central/rev/d6a131ceb435c03ccab2592578f6e2ebf12c1644/browser/base/content/tabbrowser-tabs.js#1201-1208

    _getVisibleTabs() {
      // Cannot access gBrowser before it's initialized.
      if (!gBrowser) {
        return this.allTabs[0];
      }

      return gBrowser.visibleTabs;
    }

Unless I'm missing something, gBrowser.tabContainer.allTabs[0] is a tab, not an array.

Seems a regression from https://phabricator.services.mozilla.com/D32855, since previously it was https://searchfox.org/mozilla-central/rev/f1d137eff50a5dfa45fc93def1e91cb4e3c34214/browser/base/content/tabbrowser.xml#269-278

      <method name="_getVisibleTabs">
        <body><![CDATA[
          // Cannot access gBrowser before it's initialized.
          if (!gBrowser) {
            return [ this.firstElementChild ];
          }

          return gBrowser.visibleTabs;
        ]]></body>
      </method>

I don't know if it causes problems in practice, though.

Also, I'm not sure it makes sense to only return the 1st tab, nor why gBrowser is needed at all. Why not let gBrowser.visibleTabs redirect to gBrowser.tabContainer._getVisibleTabs() instead of the other way around, and cache _visibleTabs in gBrowser.tabContainer?

Set release status flags based on info from the regressing bug 1555060

:aswan, since you are the author of the regressor, bug 1555060, could you take a look? Also, could you set the severity field?

For more information, please visit auto_nag documentation.

Flags: needinfo?(andrew.swan)

Redirecting the NI to the triage owner since aswan is no longer at Mozilla.

It's worth noting that tabContainer.allTabs uses tabContainer.arrowScrollbox, which is initialized in MozTabbrowserTabs#init.
So trying to use _getVisibleTabs before that will throw anyways.
And just one tick later, gBrowser will have been initialized.
So I think it's likely that there is nothing hitting that code-path.

This was fixed in bug 1808784 right?

Flags: needinfo?(oriol-bugzilla)

Yes, I forgot to close this.

Status: NEW → RESOLVED
Closed: 2 years ago
Depends on: 1808784
Flags: needinfo?(oriol-bugzilla)
Resolution: --- → FIXED
Assignee: nobody → oriol-bugzilla
Flags: needinfo?(dao+bmo)
Version: unspecified → Firefox 111
You need to log in before you can comment on or make changes to this bug.