Bug 1139958 - Start using AppConstants.jsm in Toolkit r=mossop
authorPhilip Chee <philip.chee@gmail.com>
Sat, 28 Mar 2015 19:17:24 +0800
changeset 266672 764b057e1c3f32e5e29de1097fac25b65444f612
parent 266671 0c030f97a04f4e34c138b878c4352423f5e920f9
child 266673 0a7fd420b3eb5b214cb5a05fe87ee6a1754f8c12
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1139958
milestone39.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 1139958 - Start using AppConstants.jsm in Toolkit r=mossop
testing/mochitest/browser-test.js
toolkit/modules/AppConstants.jsm
toolkit/modules/CertUtils.jsm
toolkit/modules/GMPInstallManager.jsm
toolkit/modules/LightweightThemeConsumer.jsm
toolkit/modules/ResetProfile.jsm
toolkit/modules/Troubleshoot.jsm
toolkit/modules/UpdateChannel.jsm
toolkit/modules/WindowDraggingUtils.jsm
toolkit/modules/moz.build
toolkit/modules/secondscreen/RokuApp.jsm
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -10,16 +10,17 @@ if (Ci === undefined) {
   var Ci = Components.interfaces;
 }
 if (Cu === undefined) {
   var Cu = Components.utils;
 }
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
+Cu.import("resource://gre/modules/AppConstants.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
   "resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizationTabPreloader",
   "resource:///modules/CustomizationTabPreloader.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "ContentSearch",
@@ -547,48 +548,51 @@ Tester.prototype = {
     // is invoked to start the tests.
     this.waitForWindowsState((function () {
       if (this.done) {
 
         // Uninitialize a few things explicitly so that they can clean up
         // frames and browser intentionally kept alive until shutdown to
         // eliminate false positives.
         if (gConfig.testRoot == "browser") {
-          // Replace the document currently loaded in the browser's sidebar.
-          // This will prevent false positives for tests that were the last
-          // to touch the sidebar. They will thus not be blamed for leaking
-          // a document.
-          let sidebar = document.getElementById("sidebar");
-          sidebar.setAttribute("src", "data:text/html;charset=utf-8,");
-          sidebar.docShell.createAboutBlankContentViewer(null);
-          sidebar.setAttribute("src", "about:blank");
+          // Skip if not Firefox e.g. SeaMonkey.
+          if (AppConstants.MOZ_APP_NAME == "browser") {
+            // Replace the document currently loaded in the Firefox sidebar.
+            // This will prevent false positives for tests that were the last
+            // to touch the sidebar. They will thus not be blamed for leaking
+            // a document.
+            let sidebar = document.getElementById("sidebar");
+            sidebar.setAttribute("src", "data:text/html;charset=utf-8,");
+            sidebar.docShell.createAboutBlankContentViewer(null);
+            sidebar.setAttribute("src", "about:blank");
 
-          // Do the same for the social sidebar.
-          let socialSidebar = document.getElementById("social-sidebar-browser");
-          socialSidebar.setAttribute("src", "data:text/html;charset=utf-8,");
-          socialSidebar.docShell.createAboutBlankContentViewer(null);
-          socialSidebar.setAttribute("src", "about:blank");
+            // Do the same for the social sidebar.
+            let socialSidebar = document.getElementById("social-sidebar-browser");
+            socialSidebar.setAttribute("src", "data:text/html;charset=utf-8,");
+            socialSidebar.docShell.createAboutBlankContentViewer(null);
+            socialSidebar.setAttribute("src", "about:blank");
+
+            SelfSupportBackend.uninit();
+            CustomizationTabPreloader.uninit();
+            SocialFlyout.unload();
+            SocialShare.uninit();
+            TabView.uninit();
+          }
 
           // Destroy BackgroundPageThumbs resources.
           let {BackgroundPageThumbs} =
             Cu.import("resource://gre/modules/BackgroundPageThumbs.jsm", {});
           BackgroundPageThumbs._destroy();
 
           // Destroy preloaded browsers.
           if (gBrowser._preloadedBrowser) {
             let browser = gBrowser._preloadedBrowser;
             gBrowser._preloadedBrowser = null;
             gBrowser.getNotificationBox(browser).remove();
           }
-
-          SelfSupportBackend.uninit();
-          CustomizationTabPreloader.uninit();
-          SocialFlyout.unload();
-          SocialShare.uninit();
-          TabView.uninit();
         }
 
         // Schedule GC and CC runs before finishing in order to detect
         // DOM windows leaked by our tests or the tested code. Note that we
         // use a shrinking GC so that the JS engine will discard JIT code and
         // JIT caches more aggressively.
 
         let checkForLeakedGlobalWindows = aCallback => {
--- a/toolkit/modules/AppConstants.jsm
+++ b/toolkit/modules/AppConstants.jsm
@@ -65,35 +65,62 @@ let AppConstants = Object.freeze({
 
   MOZ_SAFE_BROWSING:
 #ifdef MOZ_SAFE_BROWSING
   true,
 #else
   false,
 #endif
 
+  MOZ_SANDBOX:
+#ifdef MOZ_SANDBOX
+  true,
+#else
+  false,
+#endif
+
+  MOZ_SHARK:
+#ifdef XP_MACOSX
+#ifdef MOZ_SHARK
+  true,
+#else
+  false,
+#endif
+#else
+  false,
+#endif
+
   MOZ_TELEMETRY_REPORTING:
 #ifdef MOZ_TELEMETRY_REPORTING
   true,
 #else
   false,
 #endif
 
+  MOZ_UPDATER:
+#ifdef MOZ_UPDATER
+  true,
+#else
+  false,
+#endif
+
   MOZ_WEBRTC:
 #ifdef MOZ_WEBRTC
   true,
 #else
   false,
 #endif
 
   platform:
 #ifdef MOZ_WIDGET_GTK
   "linux",
 #elif MOZ_WIDGET_QT
   "linux",
+#elif XP_LINUX
+  "linux",
 #elif XP_WIN
   "win",
 #elif XP_MACOSX
   "macosx",
 #elif MOZ_WIDGET_ANDROID
   "android",
 #elif MOZ_WIDGET_GONK
   "gonk",
@@ -110,12 +137,15 @@ let AppConstants = Object.freeze({
 
   E10S_TESTING_ONLY:
 #ifdef E10S_TESTING_ONLY
   true,
 #else
   false,
 #endif
 
+  MOZ_APP_NAME: "@MOZ_APP_NAME@",
   MOZ_APP_VERSION: "@MOZ_APP_VERSION@",
-
+  MOZ_BUILD_APP: "@MOZ_BUILD_APP@",
+  MOZ_UPDATE_CHANNEL: "@MOZ_UPDATE_CHANNEL@",
+  MOZ_WIDGET_TOOLKIT: "@MOZ_WIDGET_TOOLKIT@",
   ANDROID_PACKAGE_NAME: "@ANDROID_PACKAGE_NAME@",
 });
--- a/toolkit/modules/CertUtils.jsm
+++ b/toolkit/modules/CertUtils.jsm
@@ -1,14 +1,12 @@
-#if 0
 /* -*- 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/. */
-#endif
 this.EXPORTED_SYMBOLS = [ "BadCertHandler", "checkCert", "readCertPrefs", "validateCert" ];
 
 const Ce = Components.Exception;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
 Components.utils.import("resource://gre/modules/Services.jsm");
--- a/toolkit/modules/GMPInstallManager.jsm
+++ b/toolkit/modules/GMPInstallManager.jsm
@@ -20,16 +20,17 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://gre/modules/osfile.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/ctypes.jsm");
 Cu.import("resource://gre/modules/GMPUtils.jsm");
+Cu.import("resource://gre/modules/AppConstants.jsm");
 
 this.EXPORTED_SYMBOLS = ["GMPInstallManager", "GMPExtractor", "GMPDownloader",
                          "GMPAddon"];
 
 var gLocale = null;
 
 // Shared code for suppressing bad cert dialogs
 XPCOMUtils.defineLazyGetter(this, "gCertUtils", function() {
@@ -67,122 +68,122 @@ XPCOMUtils.defineLazyGetter(this, "gOSVe
   try {
     osVersion = sysInfo.getProperty("name") + " " + sysInfo.getProperty("version");
   }
   catch (e) {
     LOG("gOSVersion - OS Version unknown: updates are not possible.");
   }
 
   if (osVersion) {
-#ifdef XP_WIN
-    const BYTE = ctypes.uint8_t;
-    const WORD = ctypes.uint16_t;
-    const DWORD = ctypes.uint32_t;
-    const WCHAR = ctypes.char16_t;
-    const BOOL = ctypes.int;
-
-    // This structure is described at:
-    // http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
-    const SZCSDVERSIONLENGTH = 128;
-    const OSVERSIONINFOEXW = new ctypes.StructType('OSVERSIONINFOEXW',
-        [
-        {dwOSVersionInfoSize: DWORD},
-        {dwMajorVersion: DWORD},
-        {dwMinorVersion: DWORD},
-        {dwBuildNumber: DWORD},
-        {dwPlatformId: DWORD},
-        {szCSDVersion: ctypes.ArrayType(WCHAR, SZCSDVERSIONLENGTH)},
-        {wServicePackMajor: WORD},
-        {wServicePackMinor: WORD},
-        {wSuiteMask: WORD},
-        {wProductType: BYTE},
-        {wReserved: BYTE}
-        ]);
-
-    // This structure is described at:
-    // http://msdn.microsoft.com/en-us/library/ms724958%28v=vs.85%29.aspx
-    const SYSTEM_INFO = new ctypes.StructType('SYSTEM_INFO',
-        [
-        {wProcessorArchitecture: WORD},
-        {wReserved: WORD},
-        {dwPageSize: DWORD},
-        {lpMinimumApplicationAddress: ctypes.voidptr_t},
-        {lpMaximumApplicationAddress: ctypes.voidptr_t},
-        {dwActiveProcessorMask: DWORD.ptr},
-        {dwNumberOfProcessors: DWORD},
-        {dwProcessorType: DWORD},
-        {dwAllocationGranularity: DWORD},
-        {wProcessorLevel: WORD},
-        {wProcessorRevision: WORD}
-        ]);
-
-    let kernel32 = false;
-    try {
-      kernel32 = ctypes.open("Kernel32");
-    } catch (e) {
-      LOG("gOSVersion - Unable to open kernel32! " + e);
-      osVersion += ".unknown (unknown)";
-    }
-
-    if(kernel32) {
+    if (AppConstants.platform == "win") {
+      const BYTE = ctypes.uint8_t;
+      const WORD = ctypes.uint16_t;
+      const DWORD = ctypes.uint32_t;
+      const WCHAR = ctypes.char16_t;
+      const BOOL = ctypes.int;
+  
+      // This structure is described at:
+      // http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
+      const SZCSDVERSIONLENGTH = 128;
+      const OSVERSIONINFOEXW = new ctypes.StructType('OSVERSIONINFOEXW',
+          [
+          {dwOSVersionInfoSize: DWORD},
+          {dwMajorVersion: DWORD},
+          {dwMinorVersion: DWORD},
+          {dwBuildNumber: DWORD},
+          {dwPlatformId: DWORD},
+          {szCSDVersion: ctypes.ArrayType(WCHAR, SZCSDVERSIONLENGTH)},
+          {wServicePackMajor: WORD},
+          {wServicePackMinor: WORD},
+          {wSuiteMask: WORD},
+          {wProductType: BYTE},
+          {wReserved: BYTE}
+          ]);
+  
+      // This structure is described at:
+      // http://msdn.microsoft.com/en-us/library/ms724958%28v=vs.85%29.aspx
+      const SYSTEM_INFO = new ctypes.StructType('SYSTEM_INFO',
+          [
+          {wProcessorArchitecture: WORD},
+          {wReserved: WORD},
+          {dwPageSize: DWORD},
+          {lpMinimumApplicationAddress: ctypes.voidptr_t},
+          {lpMaximumApplicationAddress: ctypes.voidptr_t},
+          {dwActiveProcessorMask: DWORD.ptr},
+          {dwNumberOfProcessors: DWORD},
+          {dwProcessorType: DWORD},
+          {dwAllocationGranularity: DWORD},
+          {wProcessorLevel: WORD},
+          {wProcessorRevision: WORD}
+          ]);
+  
+      let kernel32 = false;
       try {
-        // Get Service pack info
+        kernel32 = ctypes.open("Kernel32");
+      } catch (e) {
+        LOG("gOSVersion - Unable to open kernel32! " + e);
+        osVersion += ".unknown (unknown)";
+      }
+  
+      if(kernel32) {
         try {
-          let GetVersionEx = kernel32.declare("GetVersionExW",
-                                              ctypes.default_abi,
-                                              BOOL,
-                                              OSVERSIONINFOEXW.ptr);
-          let winVer = OSVERSIONINFOEXW();
-          winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
-
-          if(0 !== GetVersionEx(winVer.address())) {
-            osVersion += "." + winVer.wServicePackMajor
-                      +  "." + winVer.wServicePackMinor;
-          } else {
-            LOG("gOSVersion - Unknown failure in GetVersionEX (returned 0)");
+          // Get Service pack info
+          try {
+            let GetVersionEx = kernel32.declare("GetVersionExW",
+                                                ctypes.default_abi,
+                                                BOOL,
+                                                OSVERSIONINFOEXW.ptr);
+            let winVer = OSVERSIONINFOEXW();
+            winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
+  
+            if(0 !== GetVersionEx(winVer.address())) {
+              osVersion += "." + winVer.wServicePackMajor
+                        +  "." + winVer.wServicePackMinor;
+            } else {
+              LOG("gOSVersion - Unknown failure in GetVersionEX (returned 0)");
+              osVersion += ".unknown";
+            }
+          } catch (e) {
+            LOG("gOSVersion - error getting service pack information. Exception: " + e);
             osVersion += ".unknown";
           }
-        } catch (e) {
-          LOG("gOSVersion - error getting service pack information. Exception: " + e);
-          osVersion += ".unknown";
+  
+          // Get processor architecture
+          let arch = "unknown";
+          try {
+            let GetNativeSystemInfo = kernel32.declare("GetNativeSystemInfo",
+                                                       ctypes.default_abi,
+                                                       ctypes.void_t,
+                                                       SYSTEM_INFO.ptr);
+            let sysInfo = SYSTEM_INFO();
+            // Default to unknown
+            sysInfo.wProcessorArchitecture = 0xffff;
+  
+            GetNativeSystemInfo(sysInfo.address());
+            switch(sysInfo.wProcessorArchitecture) {
+              case 9:
+                arch = "x64";
+                break;
+              case 6:
+                arch = "IA64";
+                break;
+              case 0:
+                arch = "x86";
+                break;
+            }
+          } catch (e) {
+            LOG("gOSVersion - error getting processor architecture.  Exception: " + e);
+          } finally {
+            osVersion += " (" + arch + ")";
+          }
+        } finally {
+          kernel32.close();
         }
-
-        // Get processor architecture
-        let arch = "unknown";
-        try {
-          let GetNativeSystemInfo = kernel32.declare("GetNativeSystemInfo",
-                                                     ctypes.default_abi,
-                                                     ctypes.void_t,
-                                                     SYSTEM_INFO.ptr);
-          let sysInfo = SYSTEM_INFO();
-          // Default to unknown
-          sysInfo.wProcessorArchitecture = 0xffff;
-
-          GetNativeSystemInfo(sysInfo.address());
-          switch(sysInfo.wProcessorArchitecture) {
-            case 9:
-              arch = "x64";
-              break;
-            case 6:
-              arch = "IA64";
-              break;
-            case 0:
-              arch = "x86";
-              break;
-          }
-        } catch (e) {
-          LOG("gOSVersion - error getting processor architecture.  Exception: " + e);
-        } finally {
-          osVersion += " (" + arch + ")";
-        }
-      } finally {
-        kernel32.close();
       }
     }
-#endif
 
     try {
       osVersion += " (" + sysInfo.getProperty("secondaryLibrary") + ")";
     }
     catch (e) {
       // Not all platforms have a secondary widget library, so an error is nothing to worry about.
     }
     osVersion = encodeURIComponent(osVersion);
@@ -196,29 +197,29 @@ XPCOMUtils.defineLazyGetter(this, "gOSVe
 XPCOMUtils.defineLazyGetter(this, "gABI", function aus_gABI() {
   let abi = null;
   try {
     abi = Services.appinfo.XPCOMABI;
   }
   catch (e) {
     LOG("gABI - XPCOM ABI unknown: updates are not possible.");
   }
-#ifdef XP_MACOSX
-  // Mac universal build should report a different ABI than either macppc
-  // or mactel.
-  let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
-                 getService(Ci.nsIMacUtils);
+  if (AppConstants.platform == "macosx") {
+    // Mac universal build should report a different ABI than either macppc
+    // or mactel.
+    let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
+                   getService(Ci.nsIMacUtils);
 
-  if (macutils.isUniversalBinary)
-    abi += "-u-" + macutils.architecturesInBinary;
-#ifdef MOZ_SHARK
-  // Disambiguate optimised and shark nightlies
-  abi += "-shark"
-#endif
-#endif
+    if (macutils.isUniversalBinary)
+      abi += "-u-" + macutils.architecturesInBinary;
+    if (AppConstants.MOZ_SHARK) {
+      // Disambiguate optimised and shark nightlies
+      abi += "-shark"
+    }
+  }
   return abi;
 });
 
 /**
  * Provides an easy API for downloading and installing GMP Addons
  */
 function GMPInstallManager() {
 }
--- a/toolkit/modules/LightweightThemeConsumer.jsm
+++ b/toolkit/modules/LightweightThemeConsumer.jsm
@@ -3,16 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 this.EXPORTED_SYMBOLS = ["LightweightThemeConsumer"];
 
 const {utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/AppConstants.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeImageOptimizer",
   "resource://gre/modules/addons/LightweightThemeImageOptimizer.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
   "resource://gre/modules/PrivateBrowsingUtils.jsm");
 
 this.LightweightThemeConsumer =
@@ -133,39 +134,37 @@ LightweightThemeConsumer.prototype = {
       footer.style.backgroundColor = active ? aData.accentcolor || "white" : "";
       _setImage(footer, active, aData.footerURL);
       if (active && aData.footerURL)
         footer.setAttribute("lwthemefooter", "true");
       else
         footer.removeAttribute("lwthemefooter");
     }
 
-#ifdef XP_MACOSX
     // On OS X, we extend the lightweight theme into the titlebar, which means setting
     // the chromemargin attribute. Some XUL applications already draw in the titlebar,
     // so we need to save the chromemargin value before we overwrite it with the value
     // that lets us draw in the titlebar. We stash this value on the root attribute so
     // that XUL applications have the ability to invalidate the saved value.
-    if (stateChanging) {
+    if (AppConstants.platform == "macosx" && stateChanging) {
       if (!root.hasAttribute("chromemargin-nonlwtheme")) {
         root.setAttribute("chromemargin-nonlwtheme", root.getAttribute("chromemargin"));
       }
 
       if (active) {
         root.setAttribute("chromemargin", "0,-1,-1,-1");
       } else {
         let defaultChromemargin = root.getAttribute("chromemargin-nonlwtheme");
         if (defaultChromemargin) {
           root.setAttribute("chromemargin", defaultChromemargin);
         } else {
           root.removeAttribute("chromemargin");
         }
       }
     }
-#endif
     Services.obs.notifyObservers(this._win, "lightweight-theme-window-updated",
                                  JSON.stringify(aData));
   }
 }
 
 function _setImage(aElement, aActive, aURL) {
   aElement.style.backgroundImage =
     (aActive && aURL) ? 'url("' + aURL.replace(/"/g, '\\"') + '")' : "";
--- a/toolkit/modules/ResetProfile.jsm
+++ b/toolkit/modules/ResetProfile.jsm
@@ -2,20 +2,22 @@
  * 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/. */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["ResetProfile"];
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-#expand const MOZ_APP_NAME = "__MOZ_APP_NAME__";
-#expand const MOZ_BUILD_APP = "__MOZ_BUILD_APP__";
 
 Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/AppConstants.jsm");
+
+const MOZ_APP_NAME = AppConstants.MOZ_APP_NAME;
+const MOZ_BUILD_APP = AppConstants.MOZ_BUILD_APP;
 
 this.ResetProfile = {
   /**
    * Check if reset is supported for the currently running profile.
    *
    * @return boolean whether reset is supported.
    */
   resetSupported: function() {
--- a/toolkit/modules/Troubleshoot.jsm
+++ b/toolkit/modules/Troubleshoot.jsm
@@ -5,20 +5,17 @@
 this.EXPORTED_SYMBOLS = [
   "Troubleshoot",
 ];
 
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/AddonManager.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
-
-#ifdef MOZ_CRASHREPORTER
-Cu.import("resource://gre/modules/CrashReports.jsm");
-#endif
+Cu.import("resource://gre/modules/AppConstants.jsm");
 
 let Experiments;
 try {
   Experiments = Cu.import("resource:///modules/experiments/Experiments.jsm").Experiments;
 }
 catch (e) {
 }
 
@@ -149,19 +146,18 @@ let dataProviders = {
       name: Services.appinfo.name,
       version: Services.appinfo.version,
       buildID: Services.appinfo.appBuildID,
       userAgent: Cc["@mozilla.org/network/protocol;1?name=http"].
                  getService(Ci.nsIHttpProtocolHandler).
                  userAgent,
     };
 
-#ifdef MOZ_UPDATER
-    data.updateChannel = Cu.import("resource://gre/modules/UpdateChannel.jsm", {}).UpdateChannel.get();
-#endif
+    if (AppConstants.MOZ_UPDATER)
+      data.updateChannel = Cu.import("resource://gre/modules/UpdateChannel.jsm", {}).UpdateChannel.get();
 
     try {
       data.vendor = Services.prefs.getCharPref("app.support.vendor");
     }
     catch (e) {}
     let urlFormatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
                        getService(Ci.nsIURLFormatter);
     try {
@@ -184,28 +180,16 @@ let dataProviders = {
       }
     }
 
     data.remoteAutoStart = Services.appinfo.browserTabsRemoteAutostart;
 
     done(data);
   },
 
-#ifdef MOZ_CRASHREPORTER
-  crashes: function crashes(done) {
-    let reports = CrashReports.getReports();
-    let now = new Date();
-    let reportsNew = reports.filter(report => (now - report.date < Troubleshoot.kMaxCrashAge));
-    let reportsSubmitted = reportsNew.filter(report => (!report.pending));
-    let reportsPendingCount = reportsNew.length - reportsSubmitted.length;
-    let data = {submitted : reportsSubmitted, pending : reportsPendingCount};
-    done(data);
-  },
-#endif
-
   extensions: function extensions(done) {
     AddonManager.getAddonsByTypes(["extension"], function (extensions) {
       extensions.sort(function (a, b) {
         if (a.isActive != b.isActive)
           return b.isActive ? 1 : -1;
         let lc = a.name.localeCompare(b.name);
         if (lc != 0)
           return lc;
@@ -333,22 +317,19 @@ let dataProviders = {
       catch (e) {
         continue;
       }
       if (data.windowLayerManagerType != "Basic")
         data.numAcceleratedWindows++;
     }
 
     if (!data.numAcceleratedWindows && gfxInfo) {
-      let feature =
-#ifdef XP_WIN
-        gfxInfo.FEATURE_DIRECT3D_9_LAYERS;
-#else
-        gfxInfo.FEATURE_OPENGL_LAYERS;
-#endif
+      let win = AppConstants.platform == "win";
+      let feature = win ? gfxInfo.FEATURE_DIRECT3D_9_LAYERS :
+                          gfxInfo.FEATURE_OPENGL_LAYERS;
       data.numAcceleratedWindowsMessage = statusMsgForFeature(feature);
     }
 
     if (!gfxInfo) {
       done(data);
       return;
     }
 
@@ -409,30 +390,30 @@ let dataProviders = {
 
     if (gl) {
       let ext = gl.getExtension("WEBGL_debug_renderer_info");
       // this extension is unconditionally available to chrome. No need to check.
       data.webglRenderer = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL)
                            + " -- "
                            + gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
     } else {
-      let feature =
-#ifdef XP_WIN
+      let feature;
+      if (AppConstants.platform == "win") {
         // If ANGLE is not available but OpenGL is, we want to report on the
         // OpenGL feature, because that's what's going to get used.  In all
         // other cases we want to report on the ANGLE feature.
-        gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_ANGLE) !=
-          Ci.nsIGfxInfo.FEATURE_STATUS_OK &&
-        gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_OPENGL) ==
-          Ci.nsIGfxInfo.FEATURE_STATUS_OK ?
-        Ci.nsIGfxInfo.FEATURE_WEBGL_OPENGL :
-        Ci.nsIGfxInfo.FEATURE_WEBGL_ANGLE;
-#else
-        Ci.nsIGfxInfo.FEATURE_WEBGL_OPENGL;
-#endif
+        let angle = gfxInfo.getFeatureStatus(gfxInfo.FEATURE_WEBGL_ANGLE) ==
+                    gfxInfo.FEATURE_STATUS_OK;
+        let opengl = gfxInfo.getFeatureStatus(gfxInfo.FEATURE_WEBGL_OPENGL) ==
+                     gfxInfo.FEATURE_STATUS_OK;
+        feature = !angle && opengl ? gfxInfo.FEATURE_WEBGL_OPENGL :
+                                     gfxInfo.FEATURE_WEBGL_ANGLE;
+      } else {
+        feature = gfxInfo.FEATURE_WEBGL_OPENGL;
+      }
       data.webglRendererMessage = statusMsgForFeature(feature);
     }
 
     let infoInfo = gfxInfo.getInfo();
     if (infoInfo)
       data.info = infoInfo;
 
     let failureCount = {};
@@ -495,28 +476,41 @@ let dataProviders = {
   },
 
   userJS: function userJS(done) {
     let userJSFile = Services.dirsvc.get("PrefD", Ci.nsIFile);
     userJSFile.append("user.js");
     done({
       exists: userJSFile.exists() && userJSFile.fileSize > 0,
     });
-  },
+  }
+};
 
-#if defined(XP_LINUX) && defined (MOZ_SANDBOX)
-  sandbox: function sandbox(done) {
+if (AppConstants.MOZ_CRASHREPORTER) {
+  dataProviders.crashes = function crashes(done) {
+    let CrashReports = Cu.import("resource://gre/modules/CrashReports.jsm").CrashReports;
+    let reports = CrashReports.getReports();
+    let now = new Date();
+    let reportsNew = reports.filter(report => (now - report.date < Troubleshoot.kMaxCrashAge));
+    let reportsSubmitted = reportsNew.filter(report => (!report.pending));
+    let reportsPendingCount = reportsNew.length - reportsSubmitted.length;
+    let data = {submitted : reportsSubmitted, pending : reportsPendingCount};
+    done(data);
+  }
+}
+
+if (AppConstants.platform == "linux" && AppConstants.MOZ_SANDBOX) {
+  dataProviders.sandbox = function sandbox(done) {
     const keys = ["hasSeccompBPF", "hasSeccompTSync",
                   "hasPrivilegedUserNamespaces", "hasUserNamespaces",
                   "canSandboxContent", "canSandboxMedia"];
 
     let sysInfo = Cc["@mozilla.org/system-info;1"].
                   getService(Ci.nsIPropertyBag2);
     let data = {};
     for (let key of keys) {
       if (sysInfo.hasKey(key)) {
         data[key] = sysInfo.getPropertyAsBool(key);
       }
     }
     done(data);
   }
-#endif
-};
+}
--- a/toolkit/modules/UpdateChannel.jsm
+++ b/toolkit/modules/UpdateChannel.jsm
@@ -1,31 +1,30 @@
-#filter substitution
-
 /* 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.EXPORTED_SYMBOLS = ["UpdateChannel"];
 
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/AppConstants.jsm");
 
 this.UpdateChannel = {
   /**
    * Read the update channel from defaults only.  We do this to ensure that
    * the channel is tightly coupled with the application and does not apply
    * to other instances of the application that may use the same profile.
    *
    * @param [optional] aIncludePartners
    *        Whether or not to include the partner bits. Default: true.
    */
   get: function UpdateChannel_get(aIncludePartners = true) {
-    let channel = "@MOZ_UPDATE_CHANNEL@";
+    let channel = AppConstants.MOZ_UPDATE_CHANNEL;
     let defaults = Services.prefs.getDefaultBranch(null);
     try {
       channel = defaults.getCharPref("app.update.channel");
     } catch (e) {
       // use default value when pref not found
     }
 
     if (aIncludePartners) {
--- a/toolkit/modules/WindowDraggingUtils.jsm
+++ b/toolkit/modules/WindowDraggingUtils.jsm
@@ -1,29 +1,26 @@
 /* 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/. */
 
-#ifdef XP_WIN
-#define USE_HITTEST
-#elifdef MOZ_WIDGET_COCOA
-#define USE_HITTEST
-#endif
+Components.utils.import("resource://gre/modules/AppConstants.jsm");
+
+const USE_HITTEST = /^(win|macosx)/i.test(AppConstants.platform);
 
 this.EXPORTED_SYMBOLS = [ "WindowDraggingElement" ];
 
 this.WindowDraggingElement = function WindowDraggingElement(elem) {
   this._elem = elem;
   this._window = elem.ownerDocument.defaultView;
-#ifdef USE_HITTEST
-  if (!this.isPanel())
+
+  if (USE_HITTEST && !this.isPanel())
     this._elem.addEventListener("MozMouseHittest", this, false);
   else
-#endif
-  this._elem.addEventListener("mousedown", this, false);
+    this._elem.addEventListener("mousedown", this, false);
 };
 
 WindowDraggingElement.prototype = {
   mouseDownCheck: function(e) { return true; },
   dragTags: ["box", "hbox", "vbox", "spacer", "label", "statusbarpanel", "stack",
              "toolbaritem", "toolbarseparator", "toolbarspring", "toolbarspacer",
              "radiogroup", "deck", "scrollbox", "arrowscrollbox", "tabs"],
   shouldDrag: function(aEvent) {
@@ -55,47 +52,45 @@ WindowDraggingElement.prototype = {
     return true;
   },
   isPanel : function() {
     return this._elem instanceof Components.interfaces.nsIDOMXULElement &&
            this._elem.localName == "panel";
   },
   handleEvent: function(aEvent) {
     let isPanel = this.isPanel();
-#ifdef USE_HITTEST
-    if (!isPanel) {
+    if (USE_HITTEST && !isPanel) {
       if (this.shouldDrag(aEvent))
         aEvent.preventDefault();
       return;
     }
-#endif
 
     switch (aEvent.type) {
       case "mousedown":
         if (!this.shouldDrag(aEvent))
           return;
 
-#ifdef MOZ_WIDGET_GTK
-        // On GTK, there is a toolkit-level function which handles
-        // window dragging, which must be used.
-        this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
-#else
+        if (/^gtk/i.test(AppConstants.MOZ_WIDGET_TOOLKIT)) {
+          // On GTK, there is a toolkit-level function which handles
+          // window dragging, which must be used.
+          this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
+          break;
+        }
         if (isPanel) {
           let screenRect = this._elem.getOuterScreenRect();
           this._deltaX = aEvent.screenX - screenRect.left;
           this._deltaY = aEvent.screenY - screenRect.top;
         }
         else {
           this._deltaX = aEvent.screenX - this._window.screenX;
           this._deltaY = aEvent.screenY - this._window.screenY;
         }
         this._draggingWindow = true;
         this._window.addEventListener("mousemove", this, false);
         this._window.addEventListener("mouseup", this, false);
-#endif
         break;
       case "mousemove":
         if (this._draggingWindow) {
           let toDrag = this.isPanel() ? this._elem : this._window;
           toDrag.moveTo(aEvent.screenX - this._deltaX, aEvent.screenY - this._deltaY);
         }
         break;
       case "mouseup":
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -11,24 +11,27 @@ MOCHITEST_CHROME_MANIFESTS += ['tests/ch
 
 SPHINX_TREES['toolkit_modules'] = 'docs'
 
 EXTRA_JS_MODULES += [
     'AddonWatcher.jsm',
     'Battery.jsm',
     'BinarySearch.jsm',
     'BrowserUtils.jsm',
+    'CertUtils.jsm',
     'CharsetMenu.jsm',
     'debug.js',
     'DeferredTask.jsm',
     'Deprecated.jsm',
     'Dict.jsm',
     'FileUtils.jsm',
     'Finder.jsm',
     'Geometry.jsm',
+    'GMPInstallManager.jsm',
+    'GMPUtils.jsm',
     'Http.jsm',
     'InlineSpellChecker.jsm',
     'InlineSpellCheckerContent.jsm',
     'LoadContextInfo.jsm',
     'Log.jsm',
     'NewTabUtils.jsm',
     'PageMenu.jsm',
     'PageMetadata.jsm',
@@ -42,64 +45,63 @@ EXTRA_JS_MODULES += [
     'PromiseUtils.jsm',
     'PropertyListUtils.jsm',
     'RemoteController.jsm',
     'RemoteFinder.jsm',
     'RemotePageManager.jsm',
     'RemoteSecurityUI.jsm',
     'RemoteWebNavigation.jsm',
     'RemoteWebProgress.jsm',
+    'ResetProfile.jsm',
+    'secondscreen/RokuApp.jsm',
     'secondscreen/SimpleServiceDiscovery.jsm',
     'SelectContentHelper.jsm',
     'SelectParentHelper.jsm',
     'sessionstore/FormData.jsm',
     'sessionstore/ScrollPosition.jsm',
     'sessionstore/XPathGenerator.jsm',
     'ShortcutUtils.jsm',
     'Sntp.jsm',
     'SpatialNavigation.jsm',
     'Sqlite.jsm',
     'Task.jsm',
     'TelemetryTimestamps.jsm',
     'Timer.jsm',
+    'Troubleshoot.jsm',
+    'UpdateChannel.jsm',
     'WebChannel.jsm',
+    'WindowDraggingUtils.jsm',
     'ZipUtils.jsm',
 ]
 
 EXTRA_PP_JS_MODULES += [
-    'CertUtils.jsm',
-    'GMPInstallManager.jsm',
-    'GMPUtils.jsm',
-    'ResetProfile.jsm',
-    'secondscreen/RokuApp.jsm',
     'Services.jsm',
-    'Troubleshoot.jsm',
-    'UpdateChannel.jsm',
-    'WindowDraggingUtils.jsm',
     'WindowsPrefSync.jsm',
 ]
 
 if 'Android' != CONFIG['OS_TARGET']:
-    EXTRA_PP_JS_MODULES += [
+    EXTRA_JS_MODULES += [
         'LightweightThemeConsumer.jsm',
     ]
 else:
     DEFINES['ANDROID'] = True
 
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     EXTRA_JS_MODULES += [
         'WindowsRegistry.jsm',
     ]
 
 for var in ('ANDROID_PACKAGE_NAME',
             'MOZ_APP_NAME',
-            'MOZ_APP_VERSION'):
+            'MOZ_APP_VERSION',
+            'MOZ_WIDGET_TOOLKIT'):
             DEFINES[var] = CONFIG[var]
 
 for var in ('MOZILLA_OFFICIAL',
-            'MOZ_TOOLKIT_SEARCH'):
+            'MOZ_TOOLKIT_SEARCH',
+            'MOZ_UPDATER'):
     if CONFIG[var]:
         DEFINES[var] = True
 
 EXTRA_PP_JS_MODULES += [
     'AppConstants.jsm',
 ]
--- a/toolkit/modules/secondscreen/RokuApp.jsm
+++ b/toolkit/modules/secondscreen/RokuApp.jsm
@@ -5,16 +5,17 @@
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["RokuApp"];
 
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/AppConstants.jsm");
 
 const WEBRTC_PLAYER_NAME = "WebRTC Player";
 const MIRROR_PORT = 8011;
 const JSON_MESSAGE_TERMINATOR = "\r\n";
 
 function log(msg) {
   //Services.console.logStringMessage(msg);
 }
@@ -23,21 +24,17 @@ const PROTOCOL_VERSION = 1;
 
 /* RokuApp is a wrapper for interacting with a Roku channel.
  * The basic interactions all use a REST API.
  * spec: http://sdkdocs.roku.com/display/sdkdoc/External+Control+Guide
  */
 function RokuApp(service) {
   this.service = service;
   this.resourceURL = this.service.location;
-#ifdef RELEASE_BUILD
-  this.app = "Firefox";
-#else
-  this.app = "Firefox Nightly";
-#endif
+  this.app = AppConstants.RELEASE_BUILD ? "Firefox" : "Firefox Nightly";
   this.mediaAppID = -1;
   this.mirrorAppID = -1;
 }
 
 RokuApp.prototype = {
   status: function status(callback) {
     // We have no way to know if the app is running, so just return "unknown"
     // but we use this call to fetch the mediaAppID for the given app name