Open Bug 1695512 Opened 5 years ago Updated 5 years ago

Lazy / discarded tab's "title" does not match the tab's label, URLs have the scheme prefix

Categories

(Firefox :: Session Restore, defect)

defect

Tracking

()

People

(Reporter: robwu, Unassigned)

References

(Blocks 1 open bug)

Details

The normal tabbrowser behavior for tabs without title (e.g. content not loaded yet, or tab is lazy/discarded), the title defaults to a trimmed version of the URL. The logic is at https://searchfox.org/mozilla-central/rev/52a3b19a3de21546f6ab9c10d37d6047107ed874/browser/base/content/tabbrowser.js#1500-1556

When a lazy browser is created without explicit title, e.g. via the tabs.create extension API call, then title / lazyTabTitle is void. The SessionStore.jsm code then defaults to using the URL, in unmodified form: https://searchfox.org/mozilla-central/rev/6a023272d590409c80458d373986e379b3ad86f4/browser/components/sessionstore/SessionStore.jsm#4610

Consequently, when the contentTitle of the lazy tab browser is queried via SessionStore.getLazyTabValue(aTab, "title"), then the full URL is returned, which differs from the rendered title on the tab.

STR:

  1. Inspect the background page of an extension with the "tabs" permission (e.g. uBlock Origin) at about:debugging and run the following snippet:
await browser.tabs.create({ url: "http://example.com/foo", discarded:true });
  1. Click to expand the object and view the url/title properies.

Expected:

  • url: "http://example.com/foo"
  • title: "example.com/foo" (matching the tab's title)

Actual:

  • url: "http://example.com/foo"
  • url: "http://example.com/foo"

To fix this, I guess that the following approach would work:

  1. Move the URI / URL -> label text conversion logic from its current place in setTabTitle / _setTabLabel, to a new method (in tabbrowser.js).
  2. Call that method, either from SessionStore.jsm (here instead of || url), or if it is undesirable to call a tabbrowser method from there, from tabbrowser.js when lazyTabTitle is void (here).

I put the bug in Session Restore because the wrong title is saved by SessionStore.jsm, but a case can also be made to move it to Firefox::Tabbed Browser since the title-normalization logic belongs there.

I'm linking this to the Tab_discarding bug so that extension developers can see this. The result of this bug is that the title as reported by the tabs API does not match the default title that is displayed in Firefox's tab (UI) element.

You need to log in before you can comment on or make changes to this bug.