Bug 1628325 - Stop updating TargetActor title from TabDescriptor r=daisuke

Depends on D77498

Differential Revision: https://phabricator.services.mozilla.com/D77499
This commit is contained in:
Julian Descottes 2020-06-04 00:21:27 +00:00
Родитель 60fbf0cdeb
Коммит bf13b71c17
1 изменённых файлов: 18 добавлений и 31 удалений

Просмотреть файл

@ -78,7 +78,23 @@ const TabDescriptorActor = ActorClassWithSpec(tabDescriptorSpec, {
},
_getTitle() {
return this._browser.contentTitle || this._getZombieTabTitle();
// If the content already provides a title, use it.
if (this._browser.contentTitle) {
return this._browser.contentTitle;
}
// For zombie or lazy tabs (tab created, but content has not been loaded),
// try to retrieve the title from the XUL Tab itself.
// Note: this only works on Firefox desktop.
if (this._tabbrowser) {
const tab = this._tabbrowser.getTabForBrowser(this._browser);
if (tab) {
return tab.label;
}
}
// No title available.
return null;
},
_getUrl() {
@ -146,8 +162,7 @@ const TabDescriptorActor = ActorClassWithSpec(tabDescriptorSpec, {
onDestroy
);
const form = this._createTargetForm(connectForm);
resolve(form);
resolve(connectForm);
} catch (e) {
reject({
error: "tabDestroyed",
@ -199,34 +214,6 @@ const TabDescriptorActor = ActorClassWithSpec(tabDescriptorSpec, {
return tab?.hasAttribute && tab.hasAttribute("pending");
},
/**
* If we don't have a title from the content side because it's a zombie tab, try to find
* it on the chrome side.
*/
_getZombieTabTitle() {
// If contentTitle is empty (e.g. on a not-yet-restored tab), but there is a
// tabbrowser (i.e. desktop Firefox, but not GeckoView), we can use the label
// as the title.
if (this._tabbrowser) {
const tab = this._tabbrowser.getTabForBrowser(this._browser);
if (tab) {
return tab.label;
}
}
return null;
},
_createTargetForm(connectedForm) {
const form = Object.assign({}, connectedForm);
// In case of Zombie tabs (not yet restored), look up title from other.
if (this._isZombieTab()) {
form.title = this._getZombieTabTitle() || form.title;
}
return form;
},
destroy() {
this._browser = null;