Bug 1245901 - Measure counts of browser CPOW usage which is now rejected, r?billm
MozReview-Commit-ID: GwLq9EoDEuR
--- 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",