Bug 1588875 - Detect OS using AppConstants.platform. r=IanN a=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Wed, 30 Oct 2019 19:25:49 +0100
changeset 32345 6aa94e4ea6e19b458136a140d8c408e0e8d44911
parent 32344 77d89c12d65d48a22f94f63995bb98a26e3da901
child 32346 1fb6016c237d81d4b828b86692de1c504e728a76
push id225
push userfrgrahl@gmx.net
push dateWed, 30 Oct 2019 18:44:45 +0000
treeherdercomm-esr60@4f5c19b9a6b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, IanN
bugs1588875
Bug 1588875 - Detect OS using AppConstants.platform. r=IanN a=IanN
suite/browser/navigator.js
suite/browser/sessionHistoryUI.js
suite/browser/tabbrowser.xml
suite/browser/test/browser/browser_popupNotification.js
suite/browser/test/browser/browser_selectTabAtIndex.js
suite/components/downloads/tests/chrome/test_select_all.xul
suite/components/feeds/FeedWriter.js
suite/components/pref/content/pref-applications.js
suite/components/pref/content/pref-cache.js
suite/components/pref/content/pref-content.js
suite/components/pref/content/pref-keynav.js
suite/components/search/content/engineManager.js
suite/components/search/content/search.xml
suite/components/shell/content/setDesktopBackground.js
suite/components/tests/browser/browser_354894.js
suite/components/tests/browser/browser_394759_behavior.js
suite/components/tests/browser/browser_477657.js
suite/mailnews/components/compose/content/MsgComposeCommands.js
suite/mailnews/components/prefs/content/pref-notifications.js
suite/mailnews/content/commandglue.js
suite/mailnews/content/tabmail.xml
suite/modules/Sanitizer.jsm
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -1,16 +1,17 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/WindowsPreviewPerTab.jsm");
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   NetUtil: "resource://gre/modules/NetUtil.jsm",
   PluralForm: "resource://gre/modules/PluralForm.jsm",
   PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
   PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",
   SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
   SitePermissions: "resource:///modules/SitePermissions.jsm",
@@ -2940,17 +2941,17 @@ function maybeInitPopupContext()
 
 function WindowIsClosing()
 {
   var browser = getBrowser();
   var cn = browser.tabContainer.childNodes;
   var numtabs = cn.length;
   var reallyClose = true;
 
-  if (!gPrivate && !/Mac/.test(navigator.platform) && isClosingLastBrowser()) {
+  if (!gPrivate && AppConstants.platform != "macosx" && isClosingLastBrowser()) {
     let closingCanceled = Cc["@mozilla.org/supports-PRBool;1"]
                             .createInstance(Ci.nsISupportsPRBool);
     Services.obs.notifyObservers(closingCanceled, "browser-lastwindow-close-requested");
     if (closingCanceled.data)
       return false;
 
     Services.obs.notifyObservers(null, "browser-lastwindow-close-granted");
 
--- a/suite/browser/sessionHistoryUI.js
+++ b/suite/browser/sessionHistoryUI.js
@@ -1,13 +1,15 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+
 function toggleTabsFromOtherComputers()
   {
     // enable/disable the Tabs From Other Computers menu
     let menuitem = document.getElementById("sync-tabs-menuitem");
 
     // If Sync isn't configured yet, then don't show the menuitem.
     if (Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED ||
         Weave.Svc.Prefs.get("firstSync", "") == "notReady") {
@@ -130,17 +132,17 @@ function createHistoryMenuItem(aParent, 
   menuitem.setAttribute("label", aEntry.title);
   menuitem.setAttribute("index", aIndex);
   if (aChecked)
   {
     menuitem.setAttribute("type", "radio");
     menuitem.setAttribute("checked", "true");
   }
 
-  if (!aChecked || /Mac/.test(navigator.platform))
+  if (!aChecked || AppConstants.platform == "macosx")
   {
     menuitem.className = "menuitem-iconic bookmark-item menuitem-with-favicon";
     PlacesUtils.favicons.getFaviconURLForPage(aEntry.URI,
       function faviconURLCallback(aURI) {
         if (aURI) {
           menuitem.setAttribute("image",
                                 PlacesUtils.favicons
                                            .getFaviconLinkForIcon(aURI).spec);
--- a/suite/browser/tabbrowser.xml
+++ b/suite/browser/tabbrowser.xml
@@ -155,33 +155,32 @@
         null
       </field>
       <field name="_keyEventHandler" readonly="true">
       <![CDATA[({
         handleEvent: function handleEvent(aEvent) {
           if (aEvent.altKey)
             return;
 
-          if (/Mac/.test(navigator.platform)) {
+          if (AppConstants.platform == "macosx") {
             if (!aEvent.metaKey)
               return;
 
             var offset = 1;
             switch (aEvent.charCode) {
               case '}'.charCodeAt(0):
                 offset = -1;
               case '{'.charCodeAt(0):
                 if (window.getComputedStyle(this, null).direction == "ltr")
                   offset *= -1;
                 this.tabContainer.advanceSelectedTab(offset, true);
                 aEvent.stopPropagation();
                 aEvent.preventDefault();
             }
-          }
-          else {
+          } else {
             if (aEvent.ctrlKey && !aEvent.shiftKey && !aEvent.metaKey &&
                 aEvent.keyCode == KeyEvent.DOM_VK_F4 &&
                 this.getStripVisibility()) {
               this.removeCurrentTab();
               aEvent.stopPropagation();
               aEvent.preventDefault();
             }
           }
@@ -3044,17 +3043,17 @@
       </property>
 
       <field name="_lastSearchString">null</field>
       <field name="_lastSearchHighlight">false</field>
 
       <constructor>
         <![CDATA[
           document.addEventListener("keypress", this._keyEventHandler);
-          this.arrowKeysShouldWrap = /Mac/.test(navigator.platform);
+          this.arrowKeysShouldWrap = AppConstants.platform == "macosx";
           // Bail out early if we are in tabmail. See Bug 521803.
           if (!this.mPanelContainer)
             return;
 
           this.mCurrentBrowser = this.mPanelContainer.firstChild.firstChild;
           this.mCurrentTab = this.tabContainer.firstChild;
 
           var uniqueId = "panel" + this.nextTabNumber++;
--- a/suite/browser/test/browser/browser_popupNotification.js
+++ b/suite/browser/test/browser/browser_popupNotification.js
@@ -751,17 +751,17 @@ function triggerSecondaryCommand(popup, 
     for (let i = 0; i <= index; i++)
       EventUtils.synthesizeKey("VK_DOWN", {});
 
     // Activate
     EventUtils.synthesizeKey("VK_RETURN", {});
   });
 
   // One down event to open the popup
-  EventUtils.synthesizeKey("VK_DOWN", { altKey: !navigator.platform.includes("Mac") });
+  EventUtils.synthesizeKey("VK_DOWN", { altKey: AppConstants.platform != "macosx" });
 }
 
 function loadURI(uri, callback) {
   if (callback) {
     gBrowser.addEventListener("load", function loadURIgBLoad() {
       // Ignore the about:blank load
       if (gBrowser.currentURI.spec != uri)
         return;
--- a/suite/browser/test/browser/browser_selectTabAtIndex.js
+++ b/suite/browser/test/browser/browser_selectTabAtIndex.js
@@ -1,15 +1,15 @@
 function test() {
   for (let i = 0; i < 9; i++)
     gBrowser.addTab();
 
 /* This part tests accel keys, which are not implemented in Seamonkey yet.
  * Commenting out for now ...
- * var isLinux = navigator.platform.indexOf("Linux") == 0;
+ * var isLinux = AppConstants.platform == "linux";
  * for (let i = 9; i >= 1; i--) {
  *   EventUtils.synthesizeKey(i.toString(), { altKey: isLinux, accelKey: !isLinux });
  *
  *   is(gBrowser.tabContainer.selectedIndex, (i == 9 ? gBrowser.tabs.length : i) - 1,
  *      (isLinux ? "Alt" : "Accel") + "+" + i + " selects expected tab");
  * }
  */
 
--- a/suite/components/downloads/tests/chrome/test_select_all.xul
+++ b/suite/components/downloads/tests/chrome/test_select_all.xul
@@ -108,17 +108,17 @@ function test()
   };
 
   function continueTest(win) {
       var downloadView = win.document.getElementById("downloadTree").view;
 
       is(downloadView.rowCount, sites.length, "All downloads displayed");
 
       // Select all downloads
-      var isMac = navigator.platform.search("Mac") == 0;
+      var isMac = AppConstants.platform == "macosx";
       synthesizeKey("a", { metaKey: isMac, ctrlKey: !isMac }, win);
       is(downloadView.selection.count, sites.length, "All downloads selected");
 
       // Delete all downloads
       synthesizeKey("VK_DELETE", {}, win);
       is(downloadView.rowCount, 0, "All downloads removed");
 
       // We're done!
--- a/suite/components/feeds/FeedWriter.js
+++ b/suite/components/feeds/FeedWriter.js
@@ -1,16 +1,17 @@
 /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 const FEEDWRITER_CID = Components.ID("{49bb6593-3aff-4eb3-a068-2712c28bd58e}");
 const FEEDWRITER_CONTRACTID = "@mozilla.org/browser/feeds/result-writer;1";
 
 const XML_NS = "http://www.w3.org/XML/1998/namespace";
 const HTML_NS = "http://www.w3.org/1999/xhtml";
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
@@ -575,24 +576,23 @@ FeedWriter.prototype = {
   /**
    * Get the human-readable display name of a file. This could be the
    * application name.
    * @param   file
    *          A nsIFile to look up the name of
    * @returns The display name of the application represented by the file.
    */
   _getFileDisplayName: function getFileDisplayName(file) {
-    if ("nsILocalFileWin" in Ci &&
+    if (AppConstants.platform == "win" &&
         file instanceof Ci.nsILocalFileWin) {
       try {
         return file.getVersionInfoField("FileDescription");
       } catch (e) {}
-    }
-    else if ("nsILocalFileMac" in Ci &&
-             file instanceof Ci.nsILocalFileMac) {
+    } else if (AppConstants.platform == "macosx" &&
+               file instanceof Ci.nsILocalFileMac) {
       try {
         return file.bundleDisplayName;
       } catch (e) {}
     }
     return file.leafName;
   },
 
   /**
--- a/suite/components/pref/content/pref-applications.js
+++ b/suite/components/pref/content/pref-applications.js
@@ -78,24 +78,23 @@ const PREF_AUDIO_FEED_SELECTED_READER = 
 const kActionUsePlugin = -3;
 const kActionChooseApp = -2;
 const kActionManageApp = -1;
 
 //****************************************************************************//
 // Utilities
 
 function getFileDisplayName(aFile) {
-  if ("nsILocalFileWin" in Ci &&
+  if (AppConstants.platform == "win" &&
       aFile instanceof Ci.nsILocalFileWin) {
     try {
       return aFile.getVersionInfoField("FileDescription");
     } catch (e) {}
-  }
-  else if ("nsILocalFileMac" in Ci &&
-           aFile instanceof Ci.nsILocalFileMac) {
+  } else if (AppConstants.platform == "macosx" &&
+             aFile instanceof Ci.nsILocalFileMac) {
     try {
       return aFile.bundleDisplayName;
     } catch (e) {}
   }
   return aFile.leafName;
 }
 
 function getLocalHandlerApp(aFile) {
--- a/suite/components/pref/content/pref-cache.js
+++ b/suite/components/pref/content/pref-cache.js
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/DownloadUtils.jsm");
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 function Startup()
 {
   updateActualCacheSize();
 }
 
 // Needs to be global because the cache service only keeps a weak reference.
 var CacheObserver = {
@@ -54,17 +55,17 @@ function ReadCacheFolder(aField)
       file = GetSpecialDirectory(Services.dirsvc.has("ProfLD") ? "ProfLD"
                                                                : "ProfD");
     }
     catch (ex) {}
   }
 
   if (file) {
     aField.file = file;
-    aField.label = (/Mac/.test(navigator.platform)) ? file.leafName : file.path;
+    aField.label = AppConstants.platform == "macosx" ? file.leafName : file.path;
   }
 }
 
 function CacheSelectFolder()
 {
   let fp = Cc["@mozilla.org/filepicker;1"]
              .createInstance(Ci.nsIFilePicker);
   let title = document.getElementById("bundle_prefutilities")
--- a/suite/components/pref/content/pref-content.js
+++ b/suite/components/pref/content/pref-content.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+
 var minMinValue;
 var maxMinValue;
 
 /**
  * When starting up, obtain min and max values for the zoom-range controls
  * from the first and last values of the zoom-levels array.
  */
 function Startup()
@@ -73,12 +75,12 @@ function AdjustMinZoom()
 }
 
 /**
  * When the user toggles the layers.acceleration.disabled pref,
  * sync its new value to the gfx.direct2d.disabled pref too.
  */
 function updateHardwareAcceleration(aVal)
 {
-  if (/^Win/.test(navigator.platform)) {
+  if (AppConstants.platform == "win") {
     document.getElementById("gfx.direct2d.disabled").value = aVal;
   }
 }
--- a/suite/components/pref/content/pref-keynav.js
+++ b/suite/components/pref/content/pref-keynav.js
@@ -1,21 +1,24 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+
 const kTabToLinks = 4;
 const kTabToForms = 2;
 const kTabToTextboxes = 1;
 
 function Startup()
 {
-  if (/Mac/.test(navigator.platform))
+  if (AppConstants.platform == "macosx") {
     document.getElementById("tabNavigationPrefs").setAttribute("hidden", true);
+  }
 
   UpdateBrowseWithCaretItems();
 }
 
 function ReadTabNav(aField)
 {
   var curval = document.getElementById("accessibility.tabfocus").value;
   // Return the right bit based on the id of "aField"
--- a/suite/components/search/content/engineManager.js
+++ b/suite/components/search/content/engineManager.js
@@ -176,20 +176,21 @@ var gEngineManagerDialog = {
   },
 
   onKeydown: function(aEvent) {
     var tree = document.getElementById("engineList");
     if (tree.editingColumn)
       return;
 
     if (aEvent.keyCode == (AppConstants.platform == "macosx" ?
-                           KeyEvent.DOM_VK_RETURN : KeyEvent.DOM_VK_F2))
-      if (tree.startEditing(gEngineView.selectedIndex,
-                            tree.columns.engineKeyword))
-        aEvent.preventDefault();
+                             KeyEvent.DOM_VK_RETURN : KeyEvent.DOM_VK_F2) &&
+        tree.startEditing(gEngineView.selectedIndex,
+                          tree.columns.engineKeyword)) {
+      aEvent.preventDefault();
+    }
   }
 };
 
 function onDragEngineStart(event) {
   var selectedIndex = gEngineView.selectedIndex;
   if (selectedIndex >= 0) {
     event.dataTransfer.setData(ENGINE_FLAVOR, selectedIndex.toString());
     event.dataTransfer.effectAllowed = "move";
--- a/suite/components/search/content/search.xml
+++ b/suite/components/search/content/search.xml
@@ -679,18 +679,19 @@
       <handler event="keypress" keycode="VK_DOWN" modifiers="alt"
                phase="capturing"
                action="return this.openSearch();"/>
 
       <handler event="keypress" keycode="VK_UP" modifiers="alt"
                phase="capturing"
                action="return this.openSearch();"/>
 
-      <handler event="keypress" keycode="VK_F4" phase="capturing"><![CDATA[
-        return /Mac/.test(navigator.platform) || this.openSearch();
+      <handler event="keypress" keycode="VK_F4" phase="capturing">
+      <![CDATA[
+        return (AppConstants.platform == "macosx") || this.openSearch()
       ]]></handler>
     </handlers>
   </binding>
 
   <binding id="input-box-search" extends="chrome://global/content/bindings/textbox.xml#input-box">
     <content context="_child">
       <children/>
       <xul:menupopup anonid="input-box-contextmenu"
--- a/suite/components/shell/content/setDesktopBackground.js
+++ b/suite/components/shell/content/setDesktopBackground.js
@@ -1,22 +1,24 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * 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/. */
 
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+
 var gShell = Cc["@mozilla.org/suite/shell-service;1"]
                .getService(Ci.nsIShellService);
 
 var gImage, gImageName, gPosition, gPicker, gDesktop;
 
 function onLoad()
 {
-  document.getElementById("itemsBox").hidden = /Mac/.test(navigator.platform);
+  document.getElementById("itemsBox").hidden = AppConstants.platform == "macosx";
   gImage = window.arguments[0];
   gImageName = window.arguments[1];
   gPosition = document.getElementById("position");
   gPicker = document.getElementById("picker");
   gDesktop = document.getElementById("desktop");
 
   sizeToContent();
   window.innerWidth += screen.width / 2 - gDesktop.boxObject.width;
--- a/suite/components/tests/browser/browser_354894.js
+++ b/suite/components/tests/browser/browser_354894.js
@@ -75,17 +75,17 @@ function browserWindowsCount(expected, m
                 .getService(Ci.nsISessionStore)
                 .getBrowserState();
   is(JSON.parse(state).windows.length, expected[1], msg + " (getBrowserState)");
 }
 
 function test() {
   browserWindowsCount(1, "Only one browser window should be open initially");
 
-  if (navigator.platform.match(/Mac/)) {
+  if (AppConstants.platform == "macosx") {
     todo(false, "Test disabled on MacOSX. (Bug 520787)");
     return;
   }
 
   waitForExplicitFinish();
   // This test takes some time to run, and it could timeout randomly.
   // So we require a longer timeout. See bug 528219.
   requestLongerTimeout(2);
@@ -421,17 +421,17 @@ function test() {
         executeSoon(nextFn);
       }
     });
   }
 
   // Execution starts here
 
   setupTestsuite();
-  if (navigator.platform.match(/Mac/)) {
+  if (AppConstants.platform == "macosx") {
     // Mac tests
     testMacNotifications(function () {
       testNotificationCount(function () {
         cleanupTestsuite();
         browserWindowsCount(1, "Only one browser window should be open eventually");
         finish();
       });
     });
--- a/suite/components/tests/browser/browser_394759_behavior.js
+++ b/suite/components/tests/browser/browser_394759_behavior.js
@@ -16,19 +16,19 @@ function test() {
   function openWindowRec(windowsToOpen, expectedResults, recCallback) {
     // do actual checking
     if (!windowsToOpen.length) {
       let closedWindowData = JSON.parse(ss.getClosedWindowData());
       let numPopups = closedWindowData.filter(function(el, i, arr) {
         return el.isPopup;
       }).length;
       let numNormal = ss.getClosedWindowCount() - numPopups;
-      // #ifdef doesn't work in browser-chrome tests, so do a simple regex on platform
-      let oResults = navigator.platform.match(/Mac/) ? expectedResults.mac
-                                                     : expectedResults.other;
+
+      let oResults = AppConstants.platform == "macosx" ? expectedResults.mac
+                                                       : expectedResults.other;
       is(numPopups, oResults.popup,
          "There were " + oResults.popup + " popup windows to repoen");
       is(numNormal, oResults.normal,
          "There were " + oResults.normal + " normal windows to repoen");
 
       // cleanup & return
       executeSoon(recCallback);
       return;
--- a/suite/components/tests/browser/browser_477657.js
+++ b/suite/components/tests/browser/browser_477657.js
@@ -1,29 +1,33 @@
 /* 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/. */
 
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+
 function browserWindowsCount() {
   let count = 0;
   let e = Services.wm.getEnumerator("navigator:browser");
   while (e.hasMoreElements()) {
     if (!e.getNext().closed)
       ++count;
   }
   return count;
 }
 
 function test() {
   /** Test for Bug 477657 **/
   is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   // Test fails randomly on OS X (bug 482975)
-  if ("nsILocalFileMac" in Ci)
+  if (AppConstants.platform == "macosx") {
     return;
+  }
 
   waitForExplicitFinish();
 
   let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
   newWin.addEventListener("load", function loadListener(aEvent) {
     newWin.removeEventListener("load", loadListener);
 
     let newState = { windows: [{
--- a/suite/mailnews/components/compose/content/MsgComposeCommands.js
+++ b/suite/mailnews/components/compose/content/MsgComposeCommands.js
@@ -1820,18 +1820,17 @@ function CheckValidEmailAddress(aTo, aCC
     return false;
   }
   return true;
 }
 
 function SendMessage()
 {
   let sendInBackground = Services.prefs.getBoolPref("mailnews.sendInBackground");
-  if (sendInBackground && !/Mac/.test(navigator.platform))
-  {
+  if (sendInBackground && AppConstants.platform != "macosx") {
     let enumerator = Services.wm.getEnumerator(null);
     let count = 0;
     while (enumerator.hasMoreElements() && count < 2)
     {
       enumerator.getNext();
       count++;
     }
     if (count == 1)
--- a/suite/mailnews/components/prefs/content/pref-notifications.js
+++ b/suite/mailnews/components/prefs/content/pref-notifications.js
@@ -1,15 +1,17 @@
 /* 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/. */
 
 // The contents of this file will be loaded into the scope of the object
 // <prefpane id="notifications_pane">!
 
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+
 var gSoundUrlPref = null;
 
 function Startup()
 {
   // if we don't have the alert service, hide the pref UI for using alerts to notify on new mail
   // see bug #158711
   var newMailNotificationAlertUI = document.getElementById("newMailNotificationAlertBox");
   newMailNotificationAlertUI.hidden = !("@mozilla.org/alerts-service;1" in Cc);
@@ -18,39 +20,38 @@ function Startup()
   // won't apply if mail.biff.show_new_alert is false and should be hidden
   document.getElementById("showAlertPreviewText").hidden =
   document.getElementById("showAlertSubject").hidden =
   document.getElementById("showAlertSender").hidden =
     !Services.prefs.getBoolPref("mail.biff.show_new_alert");
 
   // animate dock icon option currently available for Mac OSX only
   var newMailNotificationBouncePref = document.getElementById("newMailNotificationBounceBox");
-  newMailNotificationBouncePref.hidden = !navigator.platform.startsWith("Mac");
+  newMailNotificationBouncePref.hidden = AppConstants.platform != "macosx";
 
   // show tray icon option currently available for Windows only
   var newMailNotificationTrayIconPref = document.getElementById("newMailNotificationTrayIconBox");
-  newMailNotificationTrayIconPref.hidden = !navigator.platform.startsWith("Win");
+  newMailNotificationTrayIconPref.hidden = AppConstants.platform != "win";
 
   // use system alert option currently available for Linux only
   var useSystemAlertPref = document.getElementById("useSystemAlertBox");
-  useSystemAlertPref.hidden = !navigator.platform.startsWith("Linux");
+  useSystemAlertPref.hidden = AppConstants.platform != "linux";
 
   EnableAlert(document.getElementById("mail.biff.show_alert").value, false);
   EnableTrayIcon(document.getElementById("mail.biff.show_tray_icon").value);
 
   gSoundUrlPref = document.getElementById("mail.biff.play_sound.url");
 
   PlaySoundCheck(document.getElementById("mail.biff.play_sound").value);
 }
 
 function EnableAlert(aEnable, aFocus)
 {
   // switch off the balloon on Windows if the user wants regular alerts
-  if (aEnable && navigator.platform.startsWith("Win"))
-  {
+  if (aEnable && AppConstants.platform == "win") {
     let balloonAlert = document.getElementById("mail.biff.show_balloon");
     if (!balloonAlert.locked)
       balloonAlert.value = false;
   }
 
   EnableElementById("showAlertTime", aEnable, aFocus);
   EnableElementById("showAlertPreviewText", aEnable, false);
   EnableElementById("showAlertSubject", aEnable, false);
@@ -61,18 +62,17 @@ function EnableAlert(aEnable, aFocus)
 function EnableTrayIcon(aEnable)
 {
   EnableElementById("newMailNotificationBalloon", aEnable, false);
 }
 
 function ClearAlert(aEnable)
 {
   // switch off the regular alerts if the user wants the balloon
-  if (aEnable && navigator.platform.startsWith("Win"))
-  {
+  if (aEnable && AppConstants.platform == "win") {
     let showAlert = document.getElementById("mail.biff.show_alert");
     if (!showAlert.locked)
       showAlert.value = false;
   }
 }
 
 function PlaySoundCheck(aPlaySound)
 {
--- a/suite/mailnews/content/commandglue.js
+++ b/suite/mailnews/content/commandglue.js
@@ -102,18 +102,19 @@ function setTitleFromFolder(msgfolder, s
           middle = gMessengerBundle.getString("titleMailPreHost");
           end = server.prettyName;
         }
         if (middle) title += " " + middle;
         if (end) title += " " + end;
       }
     }
 
-    if (!/Mac/.test(navigator.platform))
+    if (AppConstants.platform != "macosx") {
       title += " - " + gBrandBundle.getString("brandShortName");
+    }
 
     document.title = title;
 
   // Notify the current tab, it might want to update also.
   var tabmail = GetTabMail();
   if (tabmail)
   {
     tabmail.saveCurrentTabState(); // gDBView may have changed!
--- a/suite/mailnews/content/tabmail.xml
+++ b/suite/mailnews/content/tabmail.xml
@@ -483,18 +483,19 @@
                 for (let tabMonitor of this.tabMonitors)
                   tabMonitor.onTabSwitched(tabInfo, oldTabInfo);
             }
 
             t.setAttribute("label", tabInfo.title);
             if (switchToNewTab)
             {
               let docTitle = tabInfo.title;
-              if (!/Mac/.test(navigator.platform))
+              if (AppConstants.platform != "macosx") {
                 docTitle += " - " + gBrandBundle.getString("brandFullName");
+              }
               document.title = docTitle;
 
               // Update the toolbar status - we don't need to do menus as they
               // do themselves when we open them.
               UpdateMailToolbar("tabmail");
             }
           ]]>
         </body>
@@ -630,18 +631,19 @@
                 showTabFunc.call(tabInfo.mode.tabType, tabInfo);
               if (this.tabMonitors.length)
               {
                 for (let tabMonitor of this.tabMonitors)
                   tabMonitor.onTabSwitched(tabInfo, oldTabInfo);
               }
 
               let docTitle = tabInfo.title;
-              if (!/Mac/.test(navigator.platform))
+              if (AppConstants.platform != "macosx") {
                 docTitle += " - " + gBrandBundle.getString("brandFullName");
+              }
               document.title = docTitle;
 
               // Update the toolbar status - we don't need to do menus as they
               // do themselves when we open them.
               UpdateMailToolbar("tabmail");
             }
           ]]>
         </body>
@@ -707,18 +709,19 @@
                   tabMonitor.onTabTitleChanged(tabInfo);
               }
               tabNode.setAttribute("label", tabInfo.title);
 
               // Update the window title if we're the displayed tab.
               if (index == this.tabContainer.selectedIndex)
               {
                 let docTitle = tabInfo.title;
-                if (!/Mac/.test(navigator.platform))
+                if (AppConstants.platform != "macosx") {
                   docTitle += " - " + gBrandBundle.getString("brandFullName");
+                }
                 document.title = docTitle;
 
                 // Update the toolbar status - we don't need to do menus as they
                 // do themselves when we open them.
                 UpdateMailToolbar("tabmail");
               }
             }
           ]]>
--- a/suite/modules/Sanitizer.jsm
+++ b/suite/modules/Sanitizer.jsm
@@ -44,18 +44,18 @@ var Sanitizer = {
     var itemPrefs = Services.prefs.getBranch("privacy.item.");
     for (var itemName in this.items) {
       var item = this.items[itemName];
       if ("clear" in item)
         item.willClear = itemPrefs.getBoolPref(itemName);
     }
     if (this._prefs.getBoolPref("promptOnSanitize")) {
       // make this an app-modal window on Mac.
-      var win = "nsILocalFileMac" in Ci ? null
-                                                           : aParentWindow;
+      let win = AppConstants.platform == "macosx" ? null : aParentWindow;
+
       Services.ww.openWindow(win,
                              "chrome://communicator/content/sanitize.xul",
                              "Sanitize",
                              "chrome,titlebar,centerscreen,dialog,modal",
                              null);
     }
   },