Bug 1336920 - Display the presence/absence of a valid Google and Mozilla API key in about:support. r?florian draft
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 16 Feb 2017 13:01:21 +0100
changeset 485199 077cfbc121d815d6f004b548df5f4f662f6410cc
parent 485098 a9ec72f82299250e6023988e238931bbca0ef7fa
child 545969 03e9f7f1d0dcfe01264c771477cf24dfd4eed645
push id45681
push userarchaeopteryx@coole-files.de
push dateThu, 16 Feb 2017 12:02:28 +0000
reviewersflorian
bugs1336920
milestone54.0a1
Bug 1336920 - Display the presence/absence of a valid Google and Mozilla API key in about:support. r?florian 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
@@ -98,16 +98,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",