Bug 1492582 - Use document.title instead of writing the title attribute on the document element r=dao
authorBrendan Dahl <bdahl@mozilla.com>
Fri, 08 Nov 2019 23:33:50 +0000
changeset 501403 47030db7c541ef3e8102572d88a60289828dde62
parent 501402 fa9ff3a262bc60d20ac657087579d7e2a0829e8f
child 501404 fb6625e16994c73d7373bc0a068812903d25e32c
push id36791
push usercsabou@mozilla.com
push dateSun, 10 Nov 2019 09:53:30 +0000
treeherdermozilla-central@72c52c0101cf [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
@@ -74,16 +73,18 @@
 <head>
   <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"/>
 
+  <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) {