Bug 1613801 - Don't include brand name in the window title on Mac. r=fluent-reviewers,flod,Gijs
authorZibi Braniecki <zbraniecki@mozilla.com>
Tue, 18 Feb 2020 20:07:46 +0000
changeset 514523 021e98de289dbadaad53290c71fd22b63c9f68df
parent 514522 8bd615a461b7b032b658093cd5734111b6801873
child 514524 f19f8e8d16b472f64d8baf6a89bcaf74ac834e67
push id107613
push userzbraniecki@mozilla.com
push dateTue, 18 Feb 2020 20:09:20 +0000
treeherderautoland@021e98de289d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfluent-reviewers, flod, Gijs
bugs1613801
milestone75.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 1613801 - Don't include brand name in the window title on Mac. r=fluent-reviewers,flod,Gijs Differential Revision: https://phabricator.services.mozilla.com/D62391
browser/base/content/tabbrowser.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
browser/locales/en-US/browser/browser.ftl
python/l10n/fluent_migrations/bug_1613801_window_title_mac.py
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -968,20 +968,22 @@
 
       let mode =
         docElement.getAttribute("privatebrowsingmode") == "temporary"
           ? "private"
           : "default";
 
       if (title) {
         return {
-          id: "browser-main-window-content-title",
+          id:
+            mode == "private"
+              ? "browser-main-window-content-title-private"
+              : "browser-main-window-content-title-default",
           args: {
             title,
-            mode,
           },
         };
       }
       return {
         id: "browser-main-window-title",
         args: {
           mode,
         },
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
@@ -1,32 +1,39 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This test makes sure that the window title changes correctly while switching
 // from and to private browsing mode.
 
+const { AppConstants } = ChromeUtils.import(
+  "resource://gre/modules/AppConstants.jsm"
+);
+
 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.title;
 
   // XXX: Bug 1597849 - Dehardcode titles by fetching them from Fluent
   //                    to compare with the actual values.
-  let page_with_title = test_title + " - " + app_name;
+  const isMacOS = AppConstants.platform == "macosx";
+
+  let page_with_title = isMacOS ? test_title : `${test_title} - ${app_name}`;
   let page_without_title = app_name;
   let about_pb_title = app_name;
-  let pb_page_with_title =
-    test_title + " - " + app_name + " (Private Browsing)";
+  let pb_page_with_title = isMacOS
+    ? `${test_title} - (Private Browsing)`
+    : `${test_title} - ${app_name} (Private Browsing)`;
   let pb_page_without_title = app_name + " (Private Browsing)";
   let 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);
 
--- a/browser/locales/en-US/browser/browser.ftl
+++ b/browser/locales/en-US/browser/browser.ftl
@@ -13,31 +13,42 @@
 #
 # Variables
 #   $mode (String) - "private" in case of a private browsing mode, "default" otherwise.
 browser-main-window-title = { $mode ->
         [private] { -brand-full-name } (Private Browsing)
        *[default] { -brand-full-name }
     }
 
-# This is the default window title in case there is a content
-# title to be displayed.
-#
-# Depending on the $mode, the string will look like this (in en-US):
-#
-# "default" - "Example Title - Mozilla Firefox"
-# "private" - "Example Title - Mozilla Firefox (Private Browsing)"
-#
-# Variables
-#   $mode (String) - "private" in case of a private browsing mode, "default" otherwise.
-#   $title (String) - Content title string.
-browser-main-window-content-title = { $mode ->
-        [private] { $title } - { -brand-full-name } (Private Browsing)
-       *[default] { $title } - { -brand-full-name }
-    }
+## This is the default window title in case there is content
+## title to be displayed.
+##
+## On macOS the title doesn't include the brand name, on all other
+## platforms it does.
+##
+## For example, in private mode on Windows, the title will be:
+## "Example Title - Mozilla Firefox (Private Browsing)"
+##
+## while on macOS in default mode it will be:
+## "Example Title"
+##
+## Variables
+##   $title (String) - Content title string.
+
+browser-main-window-content-title-default = { PLATFORM() ->
+    [macos] { $title }
+   *[other] { $title } - { -brand-full-name }
+}
+
+browser-main-window-content-title-private = { PLATFORM() ->
+    [macos] { $title } - (Private Browsing)
+   *[other] { $title } - { -brand-full-name } (Private Browsing)
+}
+
+##
 
 urlbar-identity-button =
     .aria-label = View site information
 
 ## Tooltips for images appearing in the address bar
 
 urlbar-services-notification-anchor =
     .tooltiptext = Open install message panel
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1613801_window_title_mac.py
@@ -0,0 +1,31 @@
+# coding=utf8
+
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+from __future__ import absolute_import
+import fluent.syntax.ast as FTL
+from fluent.migrate.helpers import transforms_from
+
+
+def migrate(ctx):
+    """Bug 1613801 - Don't include brand name in the window title on Mac., part {index}."""
+
+    ctx.add_transforms(
+        'browser/browser/browser.ftl',
+        'browser/browser/browser.ftl',
+        transforms_from(
+"""
+browser-main-window-content-title-default = { PLATFORM() ->
+    [macos] { $title }
+   *[other] { $title } - { -brand-full-name }
+}
+
+browser-main-window-content-title-private = { PLATFORM() ->
+    [macos] { $title } - {COPY(from_path, "mainWindow.titlePrivateBrowsingSuffix", trim:"True")}
+   *[other] { $title } - { -brand-full-name } {COPY(from_path, "mainWindow.titlePrivateBrowsingSuffix", trim:"True")}
+}
+""", from_path="browser/chrome/browser/browser.dtd")
+    )
+
+