Bug 1366870 - Part 2: Set initial tab title to URL's hostname until we know the actual page title. r?dao draft
authorChris Peterson <cpeterson@mozilla.com>
Sat, 10 Jun 2017 12:39:18 -0700
changeset 592162 048c093aa259ec76a9a7d5b2e36c5b7cc0fdc62f
parent 592161 8b8f8990a8e0dbe22e290bbb15788b1e89e07fff
child 632744 50d34259897c0bbfeac9f854da25d3ce5252a32b
push id63304
push usercpeterson@mozilla.com
push dateSat, 10 Jun 2017 23:20:00 +0000
reviewersdao
bugs1366870
milestone55.0a1
Bug 1366870 - Part 2: Set initial tab title to URL's hostname until we know the actual page title. r?dao We currently show a full URL as the initial tab title (e.g. "https://www.mozilla.org/en-US/") until the page loads and we know the actual page title. When loading multiple tabs, such as during session restore, many tabs will have the same undifferentiated tab title prefix like "https://www....". Since the URL scheme and "www." subdomain are not meaningful to users, just show the URL's hostname without any "www." prefix (e.g. "mozilla.org"). Other browsers' initial tab titles for comparison: * Firefox 54 uses "Connecting...". * IE11 uses the same "hostname without www" placeholder as this changeset. * Edge uses "Blank page". * Chrome uses "Loading..." on Windows and "Untitled" on Mac. * Safari uses "Untitled". MozReview-Commit-ID: JxLxvBjpIBh
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1467,16 +1467,19 @@
             // Some tests pass in values that are not valid URLs, such as
             // "example.com" with no scheme. Just show whatever was passed in
             // until we know the page's actual title.
             let hostname;
             try {
               const fixedURI = URIFixup.createFixupURI(uri, URIFixup.FIXUP_FLAG_NONE);
               hostname = fixedURI.host;
             } catch (e) {
+            }
+
+            if (!hostname) {
               return uri;
             }
 
             return hostname.startsWith("www.") ? hostname.slice(4) : hostname;
           }
         ]]></body>
       </method>