Bug 1399987. Send tracking and mixed content blocking status as part of browser details. r=Gijs
authorMike Taylor <miket@mozilla.com>
Thu, 19 Apr 2018 17:36:05 -0700
changeset 417680 3f48d59f9c4e
parent 417679 c70d70b99eb6
child 417760 d302824da0ea
push id63818
push usermitaylor@mozilla.com
push dateThu, 10 May 2018 16:42:35 +0000
treeherderautoland@3f48d59f9c4e [default view] [failures only]
reviewersGijs
bugs1399987
milestone62.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 1399987. Send tracking and mixed content blocking status as part of browser details. r=Gijs This should allow us to more quickly understand when site bustage is TP- or MC-related. If the tab had tracking content blocked, we capture if the user is using the basic or strict list, and set a label with that information. MozReview-Commit-ID: lkkZjo620E
browser/extensions/webcompat-reporter/content/WebCompatReporter.jsm
browser/extensions/webcompat-reporter/content/tab-frame.js
--- a/browser/extensions/webcompat-reporter/content/WebCompatReporter.jsm
+++ b/browser/extensions/webcompat-reporter/content/WebCompatReporter.jsm
@@ -20,16 +20,27 @@ XPCOMUtils.defineLazyGetter(this, "wcStr
 let details = {};
 XPCOMUtils.defineLazyPreferenceGetter(details, "gfx.webrender.all", "gfx.webrender.all", false);
 XPCOMUtils.defineLazyPreferenceGetter(details, "gfx.webrender.blob-images", "gfx.webrender.blob-images", true);
 XPCOMUtils.defineLazyPreferenceGetter(details, "gfx.webrender.enabled", "gfx.webrender.enabled", false);
 XPCOMUtils.defineLazyPreferenceGetter(details, "image.mem.shared", "image.mem.shared", true);
 details.buildID = Services.appinfo.appBuildID;
 details.channel = AppConstants.MOZ_UPDATE_CHANNEL;
 
+Object.defineProperty(details, "blockList", {
+  // We don't want this property to end up in the stringified details
+  enumerable: false,
+  get() {
+    let trackingTable = Services.prefs.getCharPref("urlclassifier.trackingTable");
+    // If content-track-digest256 is in the tracking table,
+    // the user has enabled the strict list.
+    return trackingTable.includes("content") ? "strict" : "basic";
+  }
+});
+
 if (AppConstants.platform == "linux") {
   XPCOMUtils.defineLazyPreferenceGetter(details, "layers.acceleration.force-enabled", "layers.acceleration.force-enabled", false);
 }
 
 let WebCompatReporter = {
   get endpoint() {
     return Services.urlFormatter.formatURLPref(
       "extensions.webcompat-reporter.newIssueEndpoint");
@@ -54,18 +65,19 @@ let WebCompatReporter = {
   onLocationChange(window) {
     let action = PageActions.actionForID("webcompat-reporter-button");
     let scheme = window.gBrowser.currentURI.scheme;
     let isReportable = ["http", "https"].includes(scheme);
     action.setDisabled(!isReportable, window);
   },
 
   // This method injects a framescript that should send back a screenshot blob
-  // of the top-level window of the currently selected tab, resolved as a
-  // Promise.
+  // of the top-level window of the currently selected tab, and some other details
+  // about the tab (url, tracking protection + mixed content blocking status)
+  // resolved as a Promise.
   getScreenshot(gBrowser) {
     const FRAMESCRIPT = "chrome://webcompat-reporter/content/tab-frame.js";
     const TABDATA_MESSAGE = "WebCompat:SendTabData";
 
     return new Promise((resolve) => {
       let mm = gBrowser.selectedBrowser.messageManager;
       mm.loadFrameScript(FRAMESCRIPT, false);
 
@@ -85,25 +97,37 @@ let WebCompatReporter = {
   // Note: openWebCompatTab arguments are passed in as an array because they
   // are the result of a promise resolution.
   openWebCompatTab([gBrowser, tabData]) {
     const SCREENSHOT_MESSAGE = "WebCompat:SendScreenshot";
     const FRAMESCRIPT = "chrome://webcompat-reporter/content/wc-frame.js";
     let win = Services.wm.getMostRecentWindow("navigator:browser");
     const WEBCOMPAT_ORIGIN = new win.URL(WebCompatReporter.endpoint).origin;
 
+    // Grab the relevant tab environment details that might change per site
+    details["mixed active content blocked"] = tabData.hasMixedActiveContentBlocked;
+    details["mixed passive content blocked"] = tabData.hasMixedDisplayContentBlocked;
+    details["tracking content blocked"] = tabData.hasTrackingContentBlocked ?
+      `true (${details.blockList})` : "false";
+
+      // question: do i add a label for basic vs strict?
+
     let params = new URLSearchParams();
     params.append("url", `${tabData.url}`);
     params.append("src", "desktop-reporter");
     params.append("details", JSON.stringify(details));
 
     if (details["gfx.webrender.all"] || details["gfx.webrender.enabled"]) {
       params.append("label", "type-webrender-enabled");
     }
 
+    if (tabData.hasTrackingContentBlocked) {
+      params.append("label", `type-tracking-protection-${details.blockList}`);
+    }
+
     let tab = gBrowser.loadOneTab(
       `${WebCompatReporter.endpoint}?${params}`,
       {inBackground: false, triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()});
 
     // If we successfully got a screenshot blob, add a listener to know when
     // the new tab is loaded before sending it over.
     if (tabData && tabData.blob) {
       let browser = gBrowser.getBrowserForTab(tab);
--- a/browser/extensions/webcompat-reporter/content/tab-frame.js
+++ b/browser/extensions/webcompat-reporter/content/tab-frame.js
@@ -17,17 +17,23 @@ let getScreenshot = function(win) {
       let y = win.document.documentElement.scrollTop;
       let w = win.innerWidth;
       let h = win.innerHeight;
       canvas.width = dpr * w;
       canvas.height = dpr * h;
       ctx.scale(dpr, dpr);
       ctx.drawWindow(win, x, y, w, h, "#fff");
       canvas.toBlob(blob => {
-        resolve({url, blob});
+        resolve({
+          blob,
+          hasMixedActiveContentBlocked: docShell.hasMixedActiveContentBlocked,
+          hasMixedDisplayContentBlocked: docShell.hasMixedDisplayContentBlocked,
+          url,
+          hasTrackingContentBlocked: docShell.hasTrackingContentBlocked
+        });
       });
     } catch (ex) {
       // CanvasRenderingContext2D.drawWindow can fail depending on memory or
       // surface size. Rather than reject, resolve the URL so the user can
       // file an issue without a screenshot.
       Cu.reportError(`WebCompatReporter: getting a screenshot failed: ${ex}`);
       resolve({url});
     }