From 1b15246964bbbcd9ff8fc1ff7fefbb26b5988012 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 22 Sep 2016 18:35:48 -0400 Subject: [PATCH] Bug 1301123 - Add assertions ensuring that documents and inner windows cannot end up with an expanded principal; r=bholley --- dom/base/nsNodeInfoManager.cpp | 6 ++++++ toolkit/components/telemetry/Histograms.json | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/dom/base/nsNodeInfoManager.cpp b/dom/base/nsNodeInfoManager.cpp index ef34c108ae86..66c8c84cfd31 100644 --- a/dom/base/nsNodeInfoManager.cpp +++ b/dom/base/nsNodeInfoManager.cpp @@ -11,6 +11,7 @@ #include "nsNodeInfoManager.h" #include "mozilla/DebugOnly.h" +#include "mozilla/Telemetry.h" #include "mozilla/dom/NodeInfo.h" #include "mozilla/dom/NodeInfoInlines.h" #include "nsCOMPtr.h" @@ -389,6 +390,11 @@ nsNodeInfoManager::SetDocumentPrincipal(nsIPrincipal *aPrincipal) } NS_ASSERTION(aPrincipal, "Must have principal by this point!"); + MOZ_DIAGNOSTIC_ASSERT(!nsContentUtils::IsExpandedPrincipal(aPrincipal), + "Documents shouldn't have an expanded principal"); + if (nsContentUtils::IsExpandedPrincipal(aPrincipal)) { + Telemetry::Accumulate(Telemetry::DOCUMENT_WITH_EXPANDED_PRINCIPAL, 1); + } mPrincipal = aPrincipal; } diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index e707e36f8e1e..4a7eadaae7ee 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -10490,5 +10490,12 @@ "kind": "enumerated", "n_values": 4, "description": "Counts the number of asm.js vs WebAssembly modules instanciations, at the time modules are getting instanciated." + }, + "DOCUMENT_WITH_EXPANDED_PRINCIPAL": { + "alert_emails": ["dev-platform@lists.mozilla.org"], + "bug_numbers": [1301123], + "expires_in_version": "58", + "kind": "count", + "description": "Number of documents encountered using an expanded principal." } }