Lazy / discarded tab's "title" does not match the tab's label, URLs have the scheme prefix
Categories
(Firefox :: Session Restore, 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:
- 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 });
- 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:
- Move the URI / URL -> label text conversion logic from its current place in
setTabTitle
/_setTabLabel
, to a new method (in tabbrowser.js). - 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 whenlazyTabTitle
is void (here).
Reporter | ||
Comment 1•5 years ago
|
||
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.
Description
•