Bug 1411532 part 2 - Add a line to about:support that says whether stylo is enabled for chrome. r?bz draft
authorXidorn Quan <me@upsuper.org>
Fri, 27 Oct 2017 15:37:22 +1100
changeset 688016 49433038e2f55217843cc2508c21ae9575aa25ff
parent 688015 b9507dca1811d7f78dbe9600571e42e8e49b79b7
child 737775 1fbed292fb81a43b4a6a73f7a822b9bcbbf43e51
push id86643
push userxquan@mozilla.com
push dateFri, 27 Oct 2017 23:51:59 +0000
reviewersbz
bugs1411532
milestone58.0a1
Bug 1411532 part 2 - Add a line to about:support that says whether stylo is enabled for chrome. r?bz MozReview-Commit-ID: K1DU9KbtQJZ
toolkit/content/aboutSupport.js
toolkit/modules/Troubleshoot.jsm
toolkit/modules/tests/browser/browser_Troubleshoot.js
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -76,31 +76,46 @@ var snapshotFormatters = {
     if (data.remoteAutoStart) {
       $("contentprocesses-box").textContent = data.currentContentProcesses +
                                               "/" +
                                               data.maxContentProcesses;
     } else {
       $("contentprocesses-row").hidden = true;
     }
 
-    let styloReason;
-    if (!data.styloBuild) {
-      styloReason = strings.GetStringFromName("disabledByBuild");
-    } else if (data.styloResult != data.styloDefault) {
-      if (data.styloResult) {
-        styloReason = strings.GetStringFromName("enabledByUser");
+    function getReasonStringName(resultValue, defaultValue) {
+      if (resultValue != defaultValue) {
+        if (resultValue) {
+          return "enabledByUser";
+        } else {
+          return "disabledByUser";
+        }
       } else {
-        styloReason = strings.GetStringFromName("disabledByUser");
+        if (resultValue) {
+          return "enabledByDefault";
+        } else {
+          return "disabledByDefault";
+        }
       }
-    } else if (data.styloDefault) {
-      styloReason = strings.GetStringFromName("enabledByDefault");
+    }
+    let styloReason;
+    let styloChromeReason;
+    if (!data.styloBuild) {
+      styloReason = "disabledByBuild";
+      styloChromeReason = "disabledByBuild";
     } else {
-      styloReason = strings.GetStringFromName("disabledByDefault");
+      styloReason = getReasonStringName(data.styloResult, data.styloDefault);
+      styloChromeReason = getReasonStringName(data.styloChromeResult,
+                                              data.styloChromeDefault);
     }
-    $("stylo-box").textContent = `${data.styloResult} (${styloReason})`;
+    styloReason = strings.GetStringFromName(styloReason);
+    styloChromeReason = strings.GetStringFromName(styloChromeReason);
+    $("stylo-box").textContent =
+      `content = ${data.styloResult} (${styloReason}), ` +
+      `chrome = ${data.styloChromeResult} (${styloChromeReason})`;
 
     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;
--- a/toolkit/modules/Troubleshoot.jsm
+++ b/toolkit/modules/Troubleshoot.jsm
@@ -64,17 +64,17 @@ const PREFS_WHITELIST = [
   "general.useragent.",
   "gfx.",
   "html5.",
   "image.",
   "javascript.",
   "keyword.",
   "layers.",
   "layout.css.dpi",
-  "layout.css.servo.enabled",
+  "layout.css.servo.",
   "layout.display-list.",
   "media.",
   "mousewheel.",
   "network.",
   "permissions.default.image",
   "places.",
   "plugin.",
   "plugins.",
@@ -244,16 +244,26 @@ var dataProviders = {
         data.styloResult = true;
       } else if (env.get("STYLO_FORCE_DISABLED")) {
         data.styloResult = false;
       } else {
         data.styloResult =
           Services.prefs.getBoolPref("layout.css.servo.enabled", false);
       }
     }
+    data.styloChromeDefault =
+      Services.prefs.getDefaultBranch(null)
+              .getBoolPref("layout.css.servo.chrome.enabled", false);
+    data.styloChromeResult = false;
+    if (data.styloResult) {
+      let winUtils = Services.wm.getMostRecentWindow("").
+                     QueryInterface(Ci.nsIInterfaceRequestor).
+                     getInterface(Ci.nsIDOMWindowUtils);
+      data.styloChromeResult = winUtils.isStyledByServo;
+    }
 
     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);
--- a/toolkit/modules/tests/browser/browser_Troubleshoot.js
+++ b/toolkit/modules/tests/browser/browser_Troubleshoot.js
@@ -148,16 +148,22 @@ const SNAPSHOT_SCHEMA = {
           type: "boolean",
         },
         styloDefault: {
           type: "boolean",
         },
         styloResult: {
           type: "boolean",
         },
+        styloChromeDefault: {
+          type: "boolean",
+        },
+        styloChromeResult: {
+          type: "boolean",
+        },
         keyGoogleFound: {
           type: "boolean",
         },
         keyMozillaFound: {
           type: "boolean",
         },
         safeMode: {
           type: "boolean",