Bug 1492582 - Use document.title instead of writing the title attribute on the document element r=dao
☠☠ backed out by 1f8651278127 ☠ ☠
authorBrendan Dahl <bdahl@mozilla.com>
Thu, 07 Nov 2019 16:21:02 +0000
changeset 501116 f05dfbeff17b6fcad6815daa15e35c6f6d7b0792
parent 501115 e0e56a195659d800f8583bc5b8ea4f18c21e9ae5
child 501117 d4be1aa8cdb6189649fb09e812fc3ca0aa2bf83e
push id100004
push userbdahl@mozilla.com
push dateThu, 07 Nov 2019 16:33:00 +0000
treeherderautoland@1484255e5f4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1492582
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1492582 - Use document.title instead of writing the title attribute on the document element r=dao Differential Revision: https://phabricator.services.mozilla.com/D33561
browser/base/content/browser.js
browser/base/content/browser.xhtml
browser/base/content/tabbrowser.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -8615,20 +8615,17 @@ var gPrivateBrowsingUI = {
 
     if (window.location.href != AppConstants.BROWSER_CHROME_URL) {
       return;
     }
 
     // Adjust the window's title
     let docElement = document.documentElement;
     if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
-      docElement.setAttribute(
-        "title",
-        docElement.getAttribute("title_privatebrowsing")
-      );
+      docElement.title = docElement.getAttribute("title_privatebrowsing");
       docElement.setAttribute(
         "titlemodifier",
         docElement.getAttribute("titlemodifier_privatebrowsing")
       );
     }
     docElement.setAttribute(
       "privatebrowsingmode",
       PrivateBrowsingUtils.permanentPrivateBrowsing ? "permanent" : "temporary"
--- a/browser/base/content/browser.xhtml
+++ b/browser/base/content/browser.xhtml
@@ -37,17 +37,16 @@
 ]>
 
 <html id="main-window"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:svg="http://www.w3.org/2000/svg"
         xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns="http://www.w3.org/1999/xhtml"
-        title="&mainWindow.title;"
         title_normal="&mainWindow.title;"
 #ifdef XP_MACOSX
         title_privatebrowsing="&mainWindow.title;&mainWindow.titlemodifiermenuseparator;&mainWindow.titlePrivateBrowsingSuffix;"
         titledefault="&mainWindow.title;"
         titlemodifier=""
         titlemodifier_normal=""
         titlemodifier_privatebrowsing="&mainWindow.titlePrivateBrowsingSuffix;"
 #else
@@ -75,16 +74,18 @@
   <link rel="localization" href="branding/brand.ftl"/>
   <link rel="localization" href="browser/branding/sync-brand.ftl"/>
   <link rel="localization" href="browser/browser.ftl"/>
   <link rel="localization" href="browser/menubar.ftl"/>
   <link rel="localization" href="browser/protectionsPanel.ftl"/>
   <link rel="localization" href="browser/appmenu.ftl"/>
   <link rel="localization" href="browser/readerView.ftl"/>
 
+  <title>&mainWindow.title;</title>
+
 # All JS files which are needed by browser.xhtml and other top level windows to
 # support MacOS specific features *must* go into the global-scripts.inc file so
 # that they can be shared with macWindow.inc.xul.
 #include global-scripts.inc
 
 <script>
   /* eslint-env mozilla/browser-window */
   Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", this);
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -967,17 +967,17 @@
       }
 
       if (!docTitle) {
         docTitle = docElement.getAttribute("titledefault");
       }
 
       var modifier = docElement.getAttribute("titlemodifier");
       if (docTitle) {
-        newTitle += docElement.getAttribute("titlepreface");
+        newTitle += docElement.getAttribute("titlepreface") || "";
         newTitle += docTitle;
         if (modifier) {
           newTitle += sep;
         }
       }
       newTitle += modifier;
 
       // If location bar is hidden and the URL type supports a host,
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
@@ -8,17 +8,17 @@
 add_task(async function test() {
   const testPageURL =
     "http://mochi.test:8888/browser/" +
     "browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle_page.html";
   requestLongerTimeout(2);
 
   // initialization of expected titles
   let test_title = "Test title";
-  let app_name = document.documentElement.getAttribute("title");
+  let app_name = document.title;
   const isOSX = "nsILocalFileMac" in Ci;
   let page_with_title;
   let page_without_title;
   let about_pb_title;
   let pb_page_with_title;
   let pb_page_without_title;
   let pb_about_pb_title;
   if (isOSX) {