Bug 1301123 - Add assertions ensuring that documents and inner windows cannot end up with an expanded principal; r=bholley

This commit is contained in:
Ehsan Akhgari 2016-09-22 18:35:48 -04:00
parent e124c53ded
commit 1b15246964
2 changed files with 13 additions and 0 deletions

View File

@ -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;
}

View File

@ -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."
}
}