Bug 1245901 - Measure counts of browser CPOW usage which is now rejected, r?billm draft
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 16 Feb 2016 11:21:11 -0500
changeset 331242 84a84edfea9628aeed53903bfa3c9897793df34f
parent 330506 185ca3638874991ea9976f37c62d8a6f2089cd71
child 514342 c22717bef4fd20263d03c1076f8baeac8a109b61
push id10942
push userbsmedberg@mozilla.com
push dateTue, 16 Feb 2016 16:21:56 +0000
reviewersbillm
bugs1245901
milestone47.0a1
Bug 1245901 - Measure counts of browser CPOW usage which is now rejected, r?billm MozReview-Commit-ID: GwLq9EoDEuR
js/ipc/JavaScriptParent.cpp
toolkit/components/telemetry/Histograms.json
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -10,16 +10,17 @@
 #include "mozilla/dom/ScriptSettings.h"
 #include "nsJSUtils.h"
 #include "jsfriendapi.h"
 #include "jswrapper.h"
 #include "js/Proxy.h"
 #include "js/HeapAPI.h"
 #include "xpcprivate.h"
 #include "mozilla/Casting.h"
+#include "mozilla/Telemetry.h"
 
 using namespace js;
 using namespace JS;
 using namespace mozilla;
 using namespace mozilla::jsipc;
 using namespace mozilla::dom;
 
 static void
@@ -69,16 +70,17 @@ JavaScriptParent::allowMessage(JSContext
         return true;
 
     if (ForbidUnsafeBrowserCPOWs()) {
         nsIGlobalObject* global = dom::GetIncumbentGlobal();
         JSObject* jsGlobal = global ? global->GetGlobalJSObject() : nullptr;
         if (jsGlobal) {
             JSAutoCompartment ac(cx, jsGlobal);
             if (!JS::AddonIdOfObject(jsGlobal) && !xpc::CompartmentPrivate::Get(jsGlobal)->allowCPOWs) {
+                Telemetry::Accumulate(Telemetry::BROWSER_SHIM_USAGE_BLOCKED, 1);
                 JS_ReportError(cx, "unsafe CPOW usage forbidden");
                 return false;
             }
         }
     }
 
     static bool disableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
     if (!disableUnsafeCPOWWarnings) {
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -29,16 +29,22 @@
   },
   "ADDON_SHIM_USAGE": {
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 15,
     "keyed": "true",
     "description": "Reasons why add-on shims were used, keyed by add-on ID."
   },
+  "BROWSER_SHIM_USAGE_BLOCKED": {
+    "expires_in_version": "never",
+    "kind": "count",
+    "description": "Counts the number of times a CPOW shim was blocked from being created by browser code.",
+    "releaseChannelCollection": "opt-out"
+  },
   "APPLICATION_REPUTATION_SHOULD_BLOCK": {
     "expires_in_version": "never",
     "kind": "boolean",
     "description": "Application reputation verdict (shouldBlock=false is OK)"
   },
   "APPLICATION_REPUTATION_LOCAL": {
     "expires_in_version": "never",
     "kind": "enumerated",