Bug 1427186 - treat empty tab title as non-content tab title (use default title) and update test, r?dao
MozReview-Commit-ID: FUR7edzMy1u
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -865,17 +865,17 @@ window._gBrowser = {
if (tab._labelIsContentTitle) {
// Strip out any null bytes in the content title, since the
// underlying widget implementations of nsWindow::SetTitle pass
// null-terminated strings to system APIs.
docTitle = tab.getAttribute("label").replace(/\0/g, "");
}
- if (!docTitle)
+ if (!docTitle || docTitle == this.tabContainer.emptyTabTitle)
docTitle = docElement.getAttribute("titledefault");
var modifier = docElement.getAttribute("titlemodifier");
if (docTitle) {
newTitle += docElement.getAttribute("titlepreface");
newTitle += docTitle;
if (modifier)
newTitle += sep;
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
@@ -21,24 +21,24 @@ add_task(async function test() {
let pb_page_without_title;
let pb_about_pb_title;
if (isOSX) {
page_with_title = test_title;
page_without_title = app_name;
about_pb_title = "Open a private window?";
pb_page_with_title = test_title + " - (Private Browsing)";
pb_page_without_title = app_name + " - (Private Browsing)";
- pb_about_pb_title = "Private Browsing - (Private Browsing)";
+ pb_about_pb_title = app_name + " - (Private Browsing)";
} else {
page_with_title = test_title + " - " + app_name;
page_without_title = app_name;
about_pb_title = "Open a private window? - " + app_name;
pb_page_with_title = test_title + " - " + app_name + " (Private Browsing)";
pb_page_without_title = app_name + " (Private Browsing)";
- pb_about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)";
+ pb_about_pb_title = app_name + " (Private Browsing)";
}
async function testTabTitle(aWindow, url, insidePB, expected_title) {
let tab = (await BrowserTestUtils.openNewForegroundTab(aWindow.gBrowser));
await BrowserTestUtils.loadURI(tab.linkedBrowser, url);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await BrowserTestUtils.waitForCondition(() => {
@@ -49,17 +49,17 @@ add_task(async function test() {
" is correct (" + (insidePB ? "inside" : "outside") +
" private browsing mode)");
let win = aWindow.gBrowser.replaceTabWithWindow(tab);
await BrowserTestUtils.waitForEvent(win, "load", false);
await BrowserTestUtils.waitForCondition(() => {
return win.document.title === expected_title;
- }, `Window title should be ${expected_title}, got ${aWindow.document.title}`);
+ }, `Window title should be ${expected_title}, got ${win.document.title}`);
is(win.document.title, expected_title, "The window title for " + url +
" detached tab is correct (" + (insidePB ? "inside" : "outside") +
" private browsing mode)");
await Promise.all([ BrowserTestUtils.closeWindow(win),
BrowserTestUtils.closeWindow(aWindow) ]);
}