Bug 1336920 - Display the presence/absence of a valid Google and Mozilla API key in about:support. r=florian,francois
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 16 Feb 2017 13:01:21 +0100
changeset 373728 6a1d6726edd03e6b050db304e07a2c8abbc5997c
parent 373727 87ca04c38b8c470b77c389f82f417f33ce69d2fb
child 373729 fe71447202715639c9932b83d3f39d1ca47b67e0
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian, francois
bugs1336920
milestone54.0a1
Bug 1336920 - Display the presence/absence of a valid Google and Mozilla API key in about:support. r=florian,francois MozReview-Commit-ID: CRW3Ttb5DZm
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_aboutSupport.js
toolkit/content/aboutSupport.js
toolkit/content/aboutSupport.xhtml
toolkit/locales/en-US/chrome/global/aboutSupport.dtd
toolkit/locales/en-US/chrome/global/aboutSupport.properties
toolkit/modules/Troubleshoot.jsm
toolkit/modules/tests/browser/browser_Troubleshoot.js
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -101,16 +101,17 @@ support-files =
   !/toolkit/mozapps/extensions/test/xpinstall/slowinstall.sjs
 
 [browser_aboutAccounts.js]
 skip-if = os == "linux" # Bug 958026
 support-files =
   content_aboutAccounts.js
 [browser_aboutCertError.js]
 [browser_aboutNetError.js]
+[browser_aboutSupport.js]
 [browser_aboutSupport_newtab_security_state.js]
 [browser_aboutHealthReport.js]
 skip-if = os == "linux" # Bug 924307
 [browser_aboutHome.js]
 [browser_aboutHome_wrapsCorrectly.js]
 [browser_addKeywordSearch.js]
 [browser_alltabslistener.js]
 [browser_audioTabIcon.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_aboutSupport.js
@@ -0,0 +1,32 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+Cu.import("resource://gre/modules/AppConstants.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+add_task(function* () {
+  yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:support" }, function* (browser) {
+    const strings = Services.strings.createBundle(
+                      "chrome://global/locale/aboutSupport.properties");
+    let allowedStates = [strings.GetStringFromName("found"),
+                         strings.GetStringFromName("missing")];
+
+    let keyGoogleStatus = yield ContentTask.spawn(browser, null, function* () {
+      let textBox = content.document.getElementById("key-google-box");
+      yield ContentTaskUtils.waitForCondition(() => textBox.textContent.trim(),
+        "Google API key status loaded");
+      return textBox.textContent;
+    });
+    ok(allowedStates.includes(keyGoogleStatus), "Google API key status shown");
+
+    let keyMozillaStatus = yield ContentTask.spawn(browser, null, function* () {
+      let textBox = content.document.getElementById("key-mozilla-box");
+      yield ContentTaskUtils.waitForCondition(() => textBox.textContent.trim(),
+        "Mozilla API key status loaded");
+      return textBox.textContent;
+    });
+    ok(allowedStates.includes(keyMozillaStatus), "Mozilla API key status shown");
+  });
+});
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -32,50 +32,57 @@ window.addEventListener("load", function
 });
 
 // Each property in this object corresponds to a property in Troubleshoot.jsm's
 // snapshot data.  Each function is passed its property's corresponding data,
 // and it's the function's job to update the page with it.
 var snapshotFormatters = {
 
   application: function application(data) {
+    let strings = stringBundle();
     $("application-box").textContent = data.name;
     $("useragent-box").textContent = data.userAgent;
     $("os-box").textContent = data.osVersion;
     $("supportLink").href = data.supportURL;
     let version = AppConstants.MOZ_APP_VERSION_DISPLAY;
     if (data.vendor)
       version += " (" + data.vendor + ")";
     $("version-box").textContent = version;
     $("buildid-box").textContent = data.buildID;
     if (data.updateChannel)
       $("updatechannel-box").textContent = data.updateChannel;
 
-    let statusText = stringBundle().GetStringFromName("multiProcessStatus.unknown");
+    let statusText = strings.GetStringFromName("multiProcessStatus.unknown");
 
     // Whitelist of known values with string descriptions:
     switch (data.autoStartStatus) {
       case 0:
       case 1:
       case 2:
       case 4:
       case 6:
       case 7:
       case 8:
-        statusText = stringBundle().GetStringFromName("multiProcessStatus." + data.autoStartStatus);
+        statusText = strings.GetStringFromName("multiProcessStatus." + data.autoStartStatus);
         break;
 
       case 10:
         statusText = (Services.appinfo.OS == "Darwin" ? "OS X 10.6 - 10.8" : "Windows XP");
         break;
     }
 
-    $("multiprocess-box").textContent = stringBundle().formatStringFromName("multiProcessWindows",
+    $("multiprocess-box").textContent = strings.formatStringFromName("multiProcessWindows",
       [data.numRemoteWindows, data.numTotalWindows, statusText], 3);
 
+    let keyGoogleFound = data.keyGoogleFound ? "found" : "missing";
+    $("key-google-box").textContent = strings.GetStringFromName(keyGoogleFound);
+
+    let keyMozillaFound = data.keyMozillaFound ? "found" : "missing";
+    $("key-mozilla-box").textContent = strings.GetStringFromName(keyMozillaFound);
+
     $("safemode-box").textContent = data.safeMode;
   },
 
   crashes: function crashes(data) {
     if (!AppConstants.MOZ_CRASHREPORTER)
       return;
 
     let strings = stringBundle();
--- a/toolkit/content/aboutSupport.xhtml
+++ b/toolkit/content/aboutSupport.xhtml
@@ -225,16 +225,34 @@
             </th>
 
             <td id="multiprocess-box">
             </td>
           </tr>
 
           <tr>
             <th class="column">
+              &aboutSupport.appBasicsKeyGoogle;
+            </th>
+
+            <td id="key-google-box">
+            </td>
+          </tr>
+
+          <tr>
+            <th class="column">
+              &aboutSupport.appBasicsKeyMozilla;
+            </th>
+
+            <td id="key-mozilla-box">
+            </td>
+          </tr>
+
+          <tr>
+            <th class="column">
               &aboutSupport.appBasicsSafeMode;
             </th>
 
             <td id="safemode-box">
             </td>
           </tr>
 
 #ifndef ANDROID
--- a/toolkit/locales/en-US/chrome/global/aboutSupport.dtd
+++ b/toolkit/locales/en-US/chrome/global/aboutSupport.dtd
@@ -60,16 +60,19 @@ Windows/Mac use the term "Folder" instea
 
 <!-- LOCALIZATION NOTE the term "Service Workers" should not be translated. -->
 <!ENTITY aboutSupport.appBasicsServiceWorkers "Registered Service Workers">
 
 <!ENTITY aboutSupport.appBasicsProfiles "Profiles">
 
 <!ENTITY aboutSupport.appBasicsMultiProcessSupport "Multiprocess Windows">
 
+<!ENTITY aboutSupport.appBasicsKeyGoogle "Google Key">
+<!ENTITY aboutSupport.appBasicsKeyMozilla "Mozilla Location Service Key">
+
 <!ENTITY aboutSupport.appBasicsSafeMode "Safe Mode">
 
 <!ENTITY aboutSupport.showDir.label "Open Directory">
 <!-- LOCALIZATION NOTE (aboutSupport.showMac.label): This is the Mac-specific
 variant of aboutSupport.showDir.label.  This allows us to use the preferred
 "Finder" terminology on Mac. -->
 <!ENTITY aboutSupport.showMac.label "Show in Finder">
 <!-- LOCALIZATION NOTE (aboutSupport.showWin2.label): This is the Windows-specific
--- a/toolkit/locales/en-US/chrome/global/aboutSupport.properties
+++ b/toolkit/locales/en-US/chrome/global/aboutSupport.properties
@@ -56,16 +56,21 @@ blockedMismatchedVersion = Blocked for y
 clearTypeParameters = ClearType Parameters
 
 compositing = Compositing
 hardwareH264 = Hardware H264 Decoding
 audioBackend = Audio Backend
 mainThreadNoOMTC = main thread, no OMTC
 yes = Yes
 no = No
+# LOCALIZATION NOTE The following strings indicate if an API key has been found.
+# In some development versions, it's expected for some API keys that they are
+# not found.
+found = Found
+missing = Missing
 
 gpuDescription = Description
 gpuVendorID = Vendor ID
 gpuDeviceID = Device ID
 gpuSubsysID = Subsys ID
 gpuDrivers = Drivers
 gpuRAM = RAM
 gpuDriverVersion = Driver Version
--- a/toolkit/modules/Troubleshoot.jsm
+++ b/toolkit/modules/Troubleshoot.jsm
@@ -225,16 +225,22 @@ var dataProviders = {
                          .createInstance(Ci.nsISupportsPRUint64);
       let appinfo = Services.appinfo.QueryInterface(Ci.nsIObserver);
       appinfo.observe(e10sStatus, "getE10SBlocked", "");
       data.autoStartStatus = e10sStatus.data;
     } catch (e) {
       data.autoStartStatus = -1;
     }
 
+    const keyGoogle = Services.urlFormatter.formatURL("%GOOGLE_API_KEY%").trim();
+    data.keyGoogleFound = keyGoogle != "no-google-api-key" && keyGoogle.length > 0;
+
+    const keyMozilla = Services.urlFormatter.formatURL("%MOZILLA_API_KEY%").trim();
+    data.keyMozillaFound = keyMozilla != "no-mozilla-api-key" && keyMozilla.length > 0;
+
     done(data);
   },
 
   extensions: function extensions(done) {
     AddonManager.getAddonsByTypes(["extension"], function(extensions) {
       extensions.sort(function(a, b) {
         if (a.isActive != b.isActive)
           return b.isActive ? 1 : -1;
--- a/toolkit/modules/tests/browser/browser_Troubleshoot.js
+++ b/toolkit/modules/tests/browser/browser_Troubleshoot.js
@@ -133,16 +133,22 @@ const SNAPSHOT_SCHEMA = {
           type: "number",
         },
         numTotalWindows: {
           type: "number",
         },
         numRemoteWindows: {
           type: "number",
         },
+        keyGoogleFound: {
+          type: "boolean",
+        },
+        keyMozillaFound: {
+          type: "boolean",
+        },
         safeMode: {
           type: "boolean",
         },
       },
     },
     crashes: {
       required: false,
       type: "object",