Bug 1427186 - treat empty tab title as non-content tab title (use default title) and update test, r?dao draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Sun, 11 Mar 2018 21:23:54 +0000
changeset 766398 5fe1129f445a11db1fa6f003215ecd0c282213da
parent 766397 b0b9588300b0219924a1958b4957b4a4839d6d7a
push id102318
push usergijskruitbosch@gmail.com
push dateMon, 12 Mar 2018 20:45:36 +0000
reviewersdao
bugs1427186
milestone61.0a1
Bug 1427186 - treat empty tab title as non-content tab title (use default title) and update test, r?dao MozReview-Commit-ID: FUR7edzMy1u
browser/base/content/tabbrowser.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
--- 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) ]);
   }