mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1517588. Use nsIPrincipal::IsSystemPrincipal instead of nsContentUtils::IsSystemPrincipal r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D53067 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7f061cc7b1
commit
75124bdd98
@ -13,7 +13,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsStringBuffer.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/StructuredCloneTags.h"
|
||||
// for mozilla::dom::workerinternals::kJSPrincipalsDebugToken
|
||||
#include "mozilla/dom/workerinternals/JSSettings.h"
|
||||
|
@ -5196,7 +5196,7 @@ nsDocShell::GetAllowMixedContentAndConnectionData(
|
||||
// For things with system principal (e.g. scratchpad) there is no uri
|
||||
// aRootHasSecureConnection should be false.
|
||||
nsCOMPtr<nsIURI> rootUri = rootPrincipal->GetURI();
|
||||
if (nsContentUtils::IsSystemPrincipal(rootPrincipal) || !rootUri ||
|
||||
if (rootPrincipal->IsSystemPrincipal() || !rootUri ||
|
||||
!SchemeIsHTTPS(rootUri)) {
|
||||
*aRootHasSecureConnection = false;
|
||||
}
|
||||
@ -6682,7 +6682,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
|
||||
AutoRestore<bool> creatingDocument(mCreatingDocument);
|
||||
mCreatingDocument = true;
|
||||
|
||||
if (aPrincipal && !nsContentUtils::IsSystemPrincipal(aPrincipal) &&
|
||||
if (aPrincipal && !aPrincipal->IsSystemPrincipal() &&
|
||||
mItemType != typeChrome) {
|
||||
MOZ_ASSERT(aPrincipal->OriginAttributesRef() == mOriginAttributes);
|
||||
}
|
||||
@ -9456,7 +9456,7 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
|
||||
// Don't allow loads in typeContent docShells to inherit the system
|
||||
// principal from existing documents.
|
||||
if (inheritedFromCurrent && mItemType == typeContent &&
|
||||
nsContentUtils::IsSystemPrincipal(docPrincipal)) {
|
||||
docPrincipal->IsSystemPrincipal()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -11244,7 +11244,7 @@ bool nsDocShell::ShouldAddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel) {
|
||||
rv = nsContentUtils::GetSecurityManager()->GetChannelResultPrincipal(
|
||||
aChannel, getter_AddRefs(resultPrincipal));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
return !nsContentUtils::IsSystemPrincipal(resultPrincipal);
|
||||
return !resultPrincipal->IsSystemPrincipal();
|
||||
}
|
||||
}
|
||||
|
||||
@ -12551,8 +12551,7 @@ nsresult nsDocShell::OnLinkClickSync(
|
||||
}
|
||||
|
||||
if (targetBlank && StaticPrefs::dom_targetBlankNoOpener_enabled() &&
|
||||
!explicitOpenerSet &&
|
||||
!nsContentUtils::IsSystemPrincipal(triggeringPrincipal)) {
|
||||
!explicitOpenerSet && !triggeringPrincipal->IsSystemPrincipal()) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_NO_OPENER;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIChildChannel.h"
|
||||
#include "ReferrerInfo.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
#include "mozilla/StaticPrefs_fission.h"
|
||||
|
||||
@ -522,7 +523,7 @@ nsresult nsDocShellLoadState::SetupInheritingPrincipal(
|
||||
// created later from the channel's internal data.
|
||||
mPrincipalToInherit = mTriggeringPrincipal;
|
||||
if (mPrincipalToInherit && aItemType != nsIDocShellTreeItem::typeChrome) {
|
||||
if (nsContentUtils::IsSystemPrincipal(mPrincipalToInherit)) {
|
||||
if (mPrincipalToInherit->IsSystemPrincipal()) {
|
||||
if (mPrincipalIsExplicit) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
@ -591,8 +592,9 @@ void nsDocShellLoadState::CalculateLoadURIFlags() {
|
||||
mLoadFlags = 0;
|
||||
|
||||
if (mInheritPrincipal) {
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(mPrincipalToInherit),
|
||||
"Should not inherit SystemPrincipal");
|
||||
MOZ_ASSERT(
|
||||
!mPrincipalToInherit || !mPrincipalToInherit->IsSystemPrincipal(),
|
||||
"Should not inherit SystemPrincipal");
|
||||
mLoadFlags |= nsDocShell::INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsError.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
@ -107,7 +108,7 @@ already_AddRefed<Document> DOMParser::ParseFromSafeString(const nsAString& aStr,
|
||||
// new document with the system principal, then the new document will be
|
||||
// placed in the same docGroup as the chrome document.
|
||||
nsCOMPtr<nsIPrincipal> docPrincipal = mPrincipal;
|
||||
if (!nsContentUtils::IsSystemPrincipal(mPrincipal)) {
|
||||
if (!mPrincipal->IsSystemPrincipal()) {
|
||||
mPrincipal = SystemPrincipal::Create();
|
||||
}
|
||||
|
||||
@ -250,7 +251,7 @@ already_AddRefed<DOMParser> DOMParser::Constructor(const GlobalObject& aOwner,
|
||||
nsCOMPtr<nsIPrincipal> docPrincipal = aOwner.GetSubjectPrincipal();
|
||||
nsCOMPtr<nsIURI> documentURI;
|
||||
nsIURI* baseURI = nullptr;
|
||||
if (nsContentUtils::IsSystemPrincipal(docPrincipal)) {
|
||||
if (docPrincipal->IsSystemPrincipal()) {
|
||||
docPrincipal = NullPrincipal::CreateWithoutOriginAttributes();
|
||||
docPrincipal->GetURI(getter_AddRefs(documentURI));
|
||||
} else {
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "mozilla/URLDecorationStripper.h"
|
||||
#include "mozilla/URLExtraData.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
@ -2466,7 +2467,7 @@ already_AddRefed<nsIPrincipal> Document::MaybeDowngradePrincipal(
|
||||
return do_AddRef(expanded->AllowList().LastElement());
|
||||
}
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
// We basically want the parent document here, but because this is very
|
||||
// early in the load, GetInProcessParentDocument() returns null, so we use
|
||||
// the docshell hierarchy to get this information instead.
|
||||
@ -2479,8 +2480,7 @@ already_AddRefed<nsIPrincipal> Document::MaybeDowngradePrincipal(
|
||||
if (parentDocShell) {
|
||||
nsCOMPtr<Document> parentDoc;
|
||||
parentDoc = parentDocShell->GetDocument();
|
||||
if (!parentDoc ||
|
||||
!nsContentUtils::IsSystemPrincipal(parentDoc->NodePrincipal())) {
|
||||
if (!parentDoc || !parentDoc->NodePrincipal()->IsSystemPrincipal()) {
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
return nullPrincipal.forget();
|
||||
@ -2859,7 +2859,7 @@ bool Document::IsSynthesized() {
|
||||
// static
|
||||
bool Document::IsCallerChromeOrAddon(JSContext* aCx, JSObject* aObject) {
|
||||
nsIPrincipal* principal = nsContentUtils::SubjectPrincipal(aCx);
|
||||
return principal && (nsContentUtils::IsSystemPrincipal(principal) ||
|
||||
return principal && (principal->IsSystemPrincipal() ||
|
||||
principal->GetIsAddonOrExpandedAddonPrincipal());
|
||||
}
|
||||
|
||||
@ -4697,8 +4697,7 @@ bool Document::QueryCommandEnabled(const nsAString& aHTMLCommandName,
|
||||
}
|
||||
|
||||
// Report false for restricted commands
|
||||
if (commandData.IsPasteCommand() &&
|
||||
!nsContentUtils::IsSystemPrincipal(&aSubjectPrincipal)) {
|
||||
if (commandData.IsPasteCommand() && !aSubjectPrincipal.IsSystemPrincipal()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -6992,7 +6991,7 @@ void Document::DispatchContentLoadedEvents() {
|
||||
if (os) {
|
||||
nsIPrincipal* principal = NodePrincipal();
|
||||
os->NotifyObservers(ToSupports(this),
|
||||
nsContentUtils::IsSystemPrincipal(principal)
|
||||
principal->IsSystemPrincipal()
|
||||
? "chrome-document-interactive"
|
||||
: "content-document-interactive",
|
||||
nullptr);
|
||||
@ -10598,9 +10597,8 @@ void Document::OnPageShow(bool aPersisted, EventTarget* aDispatchStartTarget,
|
||||
if (os) {
|
||||
nsIPrincipal* principal = NodePrincipal();
|
||||
os->NotifyObservers(ToSupports(this),
|
||||
nsContentUtils::IsSystemPrincipal(principal)
|
||||
? "chrome-page-shown"
|
||||
: "content-page-shown",
|
||||
principal->IsSystemPrincipal() ? "chrome-page-shown"
|
||||
: "content-page-shown",
|
||||
nullptr);
|
||||
}
|
||||
|
||||
@ -10692,7 +10690,7 @@ void Document::OnPageHide(bool aPersisted, EventTarget* aDispatchStartTarget,
|
||||
if (os) {
|
||||
nsIPrincipal* principal = NodePrincipal();
|
||||
os->NotifyObservers(ToSupports(this),
|
||||
nsContentUtils::IsSystemPrincipal(principal)
|
||||
principal->IsSystemPrincipal()
|
||||
? "chrome-page-hidden"
|
||||
: "content-page-hidden",
|
||||
nullptr);
|
||||
@ -11000,7 +10998,7 @@ void Document::SetReadyStateInternal(ReadyState aReadyState,
|
||||
// At the time of loading start, we don't have timing object, record time.
|
||||
|
||||
if (READYSTATE_INTERACTIVE == aReadyState &&
|
||||
nsContentUtils::IsSystemPrincipal(NodePrincipal())) {
|
||||
NodePrincipal()->IsSystemPrincipal()) {
|
||||
if (!mXULPersist) {
|
||||
mXULPersist = new XULPersist(this);
|
||||
mXULPersist->Init();
|
||||
@ -14557,7 +14555,7 @@ Document::DocumentTheme Document::GetDocumentLWTheme() {
|
||||
}
|
||||
|
||||
Document::DocumentTheme Document::ThreadSafeGetDocumentLWTheme() const {
|
||||
if (!nsContentUtils::IsSystemPrincipal(NodePrincipal())) {
|
||||
if (!NodePrincipal()->IsSystemPrincipal()) {
|
||||
return Doc_Theme_None;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "mozilla/dom/PopupBlocker.h"
|
||||
#include "mozilla/dom/UserActivation.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
@ -147,7 +148,7 @@ bool PopupBlocker::TryUsePopupOpeningToken(nsIPrincipal* aPrincipal) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aPrincipal && nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal && aPrincipal->IsSystemPrincipal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mozilla/dom/PMessagePort.h"
|
||||
#include "mozilla/dom/StructuredCloneTags.h"
|
||||
#include "mozilla/dom/UnionConversions.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "nsDocShell.h"
|
||||
@ -145,10 +146,10 @@ PostMessageEvent::Run() {
|
||||
rv = NS_GetSanitizedURIStringFromURI(callerDocumentURI, uriSpec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = errorObject->Init(
|
||||
errorText, uriSpec, EmptyString(), 0, 0, nsIScriptError::errorFlag,
|
||||
"DOM Window", mIsFromPrivateWindow,
|
||||
nsContentUtils::IsSystemPrincipal(mProvidedPrincipal));
|
||||
rv = errorObject->Init(errorText, uriSpec, EmptyString(), 0, 0,
|
||||
nsIScriptError::errorFlag, "DOM Window",
|
||||
mIsFromPrivateWindow,
|
||||
mProvidedPrincipal->IsSystemPrincipal());
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/AutoCopyListener.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ContentIterator.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/SelectionBinding.h"
|
||||
@ -849,7 +850,7 @@ nsresult Selection::AddRangesForSelectableNodes(nsRange* aItem,
|
||||
Document* doc = GetDocument();
|
||||
bool selectEventsEnabled =
|
||||
StaticPrefs::dom_select_events_enabled() ||
|
||||
(doc && nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()));
|
||||
(doc && doc->NodePrincipal()->IsSystemPrincipal());
|
||||
|
||||
if (!aNoStartSelect && mSelectionType == SelectionType::eNormal &&
|
||||
selectEventsEnabled && IsCollapsed() &&
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "SelectionChangeEventDispatcher.h"
|
||||
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -76,7 +77,7 @@ void SelectionChangeEventDispatcher::OnSelectionChange(Document* aDoc,
|
||||
Selection* aSel,
|
||||
int16_t aReason) {
|
||||
Document* doc = aSel->GetParentObject();
|
||||
if (!(doc && nsContentUtils::IsSystemPrincipal(doc->NodePrincipal())) &&
|
||||
if (!(doc && doc->NodePrincipal()->IsSystemPrincipal()) &&
|
||||
!StaticPrefs::dom_select_events_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
@ -1693,7 +1693,7 @@ bool nsContentUtils::PrincipalAllowsL10n(nsIPrincipal* aPrincipal,
|
||||
}
|
||||
|
||||
// The system principal is always allowed.
|
||||
if (IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1856,7 +1856,7 @@ bool nsContentUtils::CanCallerAccess(nsIPrincipal* aSubjectPrincipal,
|
||||
// static
|
||||
bool nsContentUtils::CanCallerAccess(const nsINode* aNode) {
|
||||
nsIPrincipal* subject = SubjectPrincipal();
|
||||
if (IsSystemPrincipal(subject)) {
|
||||
if (subject->IsSystemPrincipal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1879,7 +1879,7 @@ bool nsContentUtils::CanCallerAccess(nsPIDOMWindowInner* aWindow) {
|
||||
bool nsContentUtils::PrincipalHasPermission(nsIPrincipal* aPrincipal,
|
||||
const nsAtom* aPerm) {
|
||||
// Chrome gets access by default.
|
||||
if (IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2008,7 +2008,7 @@ bool nsContentUtils::ShouldResistFingerprinting(nsIPrincipal* aPrincipal) {
|
||||
if (!aPrincipal) {
|
||||
return false;
|
||||
}
|
||||
bool isChrome = nsContentUtils::IsSystemPrincipal(aPrincipal);
|
||||
bool isChrome = aPrincipal->IsSystemPrincipal();
|
||||
return !isChrome && ShouldResistFingerprinting();
|
||||
}
|
||||
|
||||
@ -4718,7 +4718,7 @@ nsresult nsContentUtils::ParseFragmentHTML(const nsAString& aSourceBuffer,
|
||||
// If this is a chrome-privileged document, create a fragment first, and
|
||||
// sanitize it before insertion.
|
||||
RefPtr<DocumentFragment> fragment;
|
||||
if (IsSystemPrincipal(aTargetNode->NodePrincipal())) {
|
||||
if (aTargetNode->NodePrincipal()->IsSystemPrincipal()) {
|
||||
fragment = new DocumentFragment(aTargetNode->OwnerDoc()->NodeInfoManager());
|
||||
target = fragment;
|
||||
}
|
||||
@ -4812,7 +4812,7 @@ nsresult nsContentUtils::ParseFragmentXML(const nsAString& aSourceBuffer,
|
||||
|
||||
// If this is a chrome-privileged document, sanitize the fragment before
|
||||
// returning.
|
||||
if (IsSystemPrincipal(aDocument->NodePrincipal())) {
|
||||
if (aDocument->NodePrincipal()->IsSystemPrincipal()) {
|
||||
// Don't fire mutation events for nodes removed by the sanitizer.
|
||||
nsAutoScriptBlockerSuppressNodeRemoved scriptBlocker;
|
||||
|
||||
@ -5049,12 +5049,6 @@ bool nsContentUtils::SchemeIs(nsIURI* aURI, const char* aScheme) {
|
||||
return baseURI->SchemeIs(aScheme);
|
||||
}
|
||||
|
||||
bool nsContentUtils::IsSystemPrincipal(nsIPrincipal* aPrincipal) {
|
||||
// Some consumers call us with a null aPrincipal and expect a false return
|
||||
// value...
|
||||
return aPrincipal && aPrincipal->IsSystemPrincipal();
|
||||
}
|
||||
|
||||
bool nsContentUtils::IsExpandedPrincipal(nsIPrincipal* aPrincipal) {
|
||||
nsCOMPtr<nsIExpandedPrincipal> ep = do_QueryInterface(aPrincipal);
|
||||
return !!ep;
|
||||
@ -5269,7 +5263,7 @@ void nsContentUtils::WarnScriptWasIgnored(Document* aDocument) {
|
||||
}
|
||||
privateBrowsing =
|
||||
!!aDocument->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId;
|
||||
chromeContext = IsSystemPrincipal(aDocument->NodePrincipal());
|
||||
chromeContext = aDocument->NodePrincipal()->IsSystemPrincipal();
|
||||
}
|
||||
|
||||
msg.AppendLiteral(
|
||||
|
@ -1856,14 +1856,6 @@ class nsContentUtils {
|
||||
*/
|
||||
static bool SchemeIs(nsIURI* aURI, const char* aScheme);
|
||||
|
||||
/**
|
||||
* Returns true if aPrincipal is the system principal.
|
||||
*
|
||||
* @deprecated Use nsIPrincipal::IsSystemPrincipal instead!
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=1517588 tracks removing this.
|
||||
*/
|
||||
static bool IsSystemPrincipal(nsIPrincipal* aPrincipal);
|
||||
|
||||
/**
|
||||
* Returns true if aPrincipal is an ExpandedPrincipal.
|
||||
*/
|
||||
@ -1873,7 +1865,8 @@ class nsContentUtils {
|
||||
* Returns true if aPrincipal is the system or an ExpandedPrincipal.
|
||||
*/
|
||||
static bool IsSystemOrExpandedPrincipal(nsIPrincipal* aPrincipal) {
|
||||
return IsSystemPrincipal(aPrincipal) || IsExpandedPrincipal(aPrincipal);
|
||||
return (aPrincipal && aPrincipal->IsSystemPrincipal()) ||
|
||||
IsExpandedPrincipal(aPrincipal);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2106,8 +2106,7 @@ nsresult nsFrameLoader::MaybeCreateDocShell() {
|
||||
//
|
||||
// For example, firstPartyDomain is computed from top-level document, it
|
||||
// doesn't exist in the top-level docshell.
|
||||
if (parentIsContent &&
|
||||
!nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()) &&
|
||||
if (parentIsContent && !doc->NodePrincipal()->IsSystemPrincipal() &&
|
||||
!OwnerIsMozBrowserFrame()) {
|
||||
OriginAttributes oa = doc->NodePrincipal()->OriginAttributesRef();
|
||||
|
||||
|
@ -2835,8 +2835,7 @@ bool nsGlobalWindowInner::DoResolve(
|
||||
aId == XPCJSRuntime::Get()->GetStringID(
|
||||
XPCJSContext::IDX_CONTROLLERS_CLASS)) &&
|
||||
!xpc::IsXrayWrapper(aObj) &&
|
||||
!nsContentUtils::IsSystemPrincipal(
|
||||
nsContentUtils::ObjectPrincipal(aObj))) {
|
||||
!nsContentUtils::ObjectPrincipal(aObj)->IsSystemPrincipal()) {
|
||||
if (GetExtantDoc()) {
|
||||
GetExtantDoc()->WarnOnceAbout(Document::eWindow_Cc_ontrollers);
|
||||
}
|
||||
|
@ -240,6 +240,7 @@
|
||||
#include "mozilla/dom/U2F.h"
|
||||
#include "mozilla/dom/WebIDLGlobalNameHash.h"
|
||||
#include "mozilla/dom/Worklet.h"
|
||||
|
||||
#ifdef HAVE_SIDEBAR
|
||||
# include "mozilla/dom/ExternalBinding.h"
|
||||
#endif
|
||||
@ -1543,7 +1544,7 @@ void nsGlobalWindowOuter::SetInitialPrincipalToSubject(
|
||||
// docshell.
|
||||
// NOTE: Please keep this logic in sync with AppWindow::Initialize().
|
||||
if (nsContentUtils::IsExpandedPrincipal(newWindowPrincipal) ||
|
||||
(nsContentUtils::IsSystemPrincipal(newWindowPrincipal) &&
|
||||
(newWindowPrincipal->IsSystemPrincipal() &&
|
||||
GetDocShell()->ItemType() != nsIDocShellTreeItem::typeChrome)) {
|
||||
newWindowPrincipal = nullptr;
|
||||
}
|
||||
@ -1642,7 +1643,7 @@ NS_IMPL_ISUPPORTS(WindowStateHolder, WindowStateHolder)
|
||||
bool nsGlobalWindowOuter::ComputeIsSecureContext(Document* aDocument,
|
||||
SecureContextFlags aFlags) {
|
||||
nsCOMPtr<nsIPrincipal> principal = aDocument->NodePrincipal();
|
||||
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
if (principal->IsSystemPrincipal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1716,7 +1717,7 @@ bool nsGlobalWindowOuter::ComputeIsSecureContext(Document* aDocument,
|
||||
// don't want that behavior to take effect in automation, because we whitelist
|
||||
// all the mochitest domains. So we need to check a pref here.
|
||||
static bool TreatAsRemoteXUL(nsIPrincipal* aPrincipal) {
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(aPrincipal));
|
||||
MOZ_ASSERT(!aPrincipal->IsSystemPrincipal());
|
||||
return nsContentUtils::AllowXULXBLForPrincipal(aPrincipal) &&
|
||||
!Preferences::GetBool("dom.use_xbl_scopes_for_remote_xul", false);
|
||||
}
|
||||
@ -1799,7 +1800,7 @@ static JS::RealmCreationOptions& SelectZone(
|
||||
JSContext* aCx, nsIPrincipal* aPrincipal, nsGlobalWindowInner* aNewInner,
|
||||
JS::RealmCreationOptions& aOptions) {
|
||||
// Use the shared system compartment for chrome windows.
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
return aOptions.setExistingCompartment(xpc::PrivilegedJunkScope());
|
||||
}
|
||||
|
||||
@ -1858,8 +1859,8 @@ static nsresult CreateNativeGlobalForInner(JSContext* aCx,
|
||||
xpc::InitGlobalObjectOptions(options, aPrincipal);
|
||||
|
||||
// Determine if we need the Components object.
|
||||
bool needComponents = nsContentUtils::IsSystemPrincipal(aPrincipal) ||
|
||||
TreatAsRemoteXUL(aPrincipal);
|
||||
bool needComponents =
|
||||
aPrincipal->IsSystemPrincipal() || TreatAsRemoteXUL(aPrincipal);
|
||||
uint32_t flags = needComponents ? 0 : xpc::OMIT_COMPONENTS_OBJECT;
|
||||
flags |= xpc::DONT_FIRE_ONNEWGLOBALHOOK;
|
||||
|
||||
@ -2243,7 +2244,7 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
|
||||
// it runs JS code for this realm. We skip the check if this window is for
|
||||
// chrome JS or an add-on.
|
||||
nsCOMPtr<nsIPrincipal> principal = mDoc->NodePrincipal();
|
||||
if (GetDocGroup() && !nsContentUtils::IsSystemPrincipal(principal) &&
|
||||
if (GetDocGroup() && !principal->IsSystemPrincipal() &&
|
||||
!BasePrincipal::Cast(principal)->AddonPolicy()) {
|
||||
js::SetRealmValidAccessPtr(
|
||||
cx, newInnerGlobal, newInnerWindow->GetDocGroup()->GetValidAccessPtr());
|
||||
@ -2264,7 +2265,7 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
|
||||
// until we have a real chrome doc.
|
||||
if (!mDocShell ||
|
||||
mDocShell->ItemType() != nsIDocShellTreeItem::typeChrome ||
|
||||
nsContentUtils::IsSystemPrincipal(mDoc->NodePrincipal())) {
|
||||
mDoc->NodePrincipal()->IsSystemPrincipal()) {
|
||||
newInnerWindow->mHasNotifiedGlobalCreated = true;
|
||||
nsContentUtils::AddScriptRunner(NewRunnableMethod(
|
||||
"nsGlobalWindowOuter::DispatchDOMWindowCreated", this,
|
||||
@ -2397,12 +2398,11 @@ void nsGlobalWindowOuter::DispatchDOMWindowCreated() {
|
||||
nsAutoString origin;
|
||||
nsIPrincipal* principal = mDoc->NodePrincipal();
|
||||
nsContentUtils::GetUTFOrigin(principal, origin);
|
||||
observerService->NotifyObservers(
|
||||
static_cast<nsIDOMWindow*>(this),
|
||||
nsContentUtils::IsSystemPrincipal(principal)
|
||||
? "chrome-document-global-created"
|
||||
: "content-document-global-created",
|
||||
origin.get());
|
||||
observerService->NotifyObservers(static_cast<nsIDOMWindow*>(this),
|
||||
principal->IsSystemPrincipal()
|
||||
? "chrome-document-global-created"
|
||||
: "content-document-global-created",
|
||||
origin.get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -5871,7 +5871,7 @@ bool nsGlobalWindowOuter::GatherPostMessageData(
|
||||
nsContentUtils::GetUTFOrigin(*aCallerDocumentURI, aOrigin);
|
||||
} else {
|
||||
// in case of a sandbox with a system principal origin can be empty
|
||||
if (!nsContentUtils::IsSystemPrincipal(callerPrin)) {
|
||||
if (!callerPrin->IsSystemPrincipal()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -5959,7 +5959,7 @@ bool nsGlobalWindowOuter::GetPrincipalForPostMessage(
|
||||
R"(origin "%s".)",
|
||||
targetURL.get(), targetOrigin.get(), sourceOrigin.get())),
|
||||
"DOM", !!principal->PrivateBrowsingId(),
|
||||
nsContentUtils::IsSystemPrincipal(principal));
|
||||
principal->IsSystemPrincipal());
|
||||
|
||||
attrs = principal->OriginAttributesRef();
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "nsNodeInfoManager.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/NodeInfo.h"
|
||||
@ -305,7 +306,7 @@ void nsNodeInfoManager::RemoveNodeInfo(NodeInfo* aNodeInfo) {
|
||||
}
|
||||
|
||||
static bool IsSystemOrAddonPrincipal(nsIPrincipal* aPrincipal) {
|
||||
return nsContentUtils::IsSystemPrincipal(aPrincipal) ||
|
||||
return aPrincipal->IsSystemPrincipal() ||
|
||||
BasePrincipal::Cast(aPrincipal)->AddonPolicy();
|
||||
}
|
||||
|
||||
@ -346,8 +347,8 @@ bool nsNodeInfoManager::InternalMathMLEnabled() {
|
||||
// If the mathml.disabled pref. is true, convert all MathML nodes into
|
||||
// disabled MathML nodes by swapping the namespace.
|
||||
nsNameSpaceManager* nsmgr = nsNameSpaceManager::GetInstance();
|
||||
bool conclusion = ((nsmgr && !nsmgr->mMathMLDisabled) ||
|
||||
nsContentUtils::IsSystemPrincipal(mPrincipal));
|
||||
bool conclusion =
|
||||
((nsmgr && !nsmgr->mMathMLDisabled) || mPrincipal->IsSystemPrincipal());
|
||||
mMathMLEnabled = Some(conclusion);
|
||||
return conclusion;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsIExternalProtocolHandler.h"
|
||||
@ -3031,7 +3032,7 @@ bool nsObjectLoadingContent::ShouldPlay(FallbackType& aReason) {
|
||||
// we really should do is disable plugins entirely in pages that use the
|
||||
// system principal, i.e. in chrome pages. That way the click-to-play code
|
||||
// here wouldn't matter at all. Bug 775301 is tracking this.
|
||||
if (!nsContentUtils::IsSystemPrincipal(topDoc->NodePrincipal())) {
|
||||
if (!topDoc->NodePrincipal()->IsSystemPrincipal()) {
|
||||
nsAutoCString permissionString;
|
||||
rv = pluginHost->GetPermissionStringForType(
|
||||
mContentType, nsPluginHost::eExcludeNone, permissionString);
|
||||
|
@ -7534,7 +7534,7 @@ class CGCallGenerator(CGThing):
|
||||
if needsNonSystemPrincipal:
|
||||
checkPrincipal = dedent(
|
||||
"""
|
||||
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
if (principal->IsSystemPrincipal()) {
|
||||
principal = nullptr;
|
||||
}
|
||||
""")
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsISensitiveInfoHiddenURI.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
static_assert(nsIScriptError::errorFlag == JSREPORT_ERROR &&
|
||||
nsIScriptError::warningFlag == JSREPORT_WARNING &&
|
||||
@ -430,16 +431,18 @@ bool nsScriptErrorBase::ComputeIsFromPrivateWindow(
|
||||
nsGlobalWindowInner* aWindow) {
|
||||
// Never mark exceptions from chrome windows as having come from private
|
||||
// windows, since we always want them to be reported.
|
||||
// winPrincipal needs to be null-checked - Bug 1601175
|
||||
nsIPrincipal* winPrincipal = aWindow->GetPrincipal();
|
||||
return aWindow->IsPrivateBrowsing() &&
|
||||
!nsContentUtils::IsSystemPrincipal(winPrincipal);
|
||||
(!winPrincipal || !winPrincipal->IsSystemPrincipal());
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsScriptErrorBase::ComputeIsFromChromeContext(
|
||||
nsGlobalWindowInner* aWindow) {
|
||||
nsIPrincipal* winPrincipal = aWindow->GetPrincipal();
|
||||
return nsContentUtils::IsSystemPrincipal(winPrincipal);
|
||||
// winPrincipal needs to be null-checked - Bug 1601175
|
||||
return (winPrincipal && winPrincipal->IsSystemPrincipal());
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsScriptError, nsIConsoleMessage, nsIScriptError)
|
||||
|
1
dom/cache/PrincipalVerifier.cpp
vendored
1
dom/cache/PrincipalVerifier.cpp
vendored
@ -11,6 +11,7 @@
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
#include "mozilla/ipc/PBackgroundParent.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/dom/BrowserChild.h"
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
#include "mozilla/dom/UserActivation.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/StaticPrefs_privacy.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
@ -60,7 +61,7 @@ bool IsImageExtractionAllowed(Document* aDocument, JSContext* aCx,
|
||||
}
|
||||
|
||||
// The system principal can always extract canvas data.
|
||||
if (nsContentUtils::IsSystemPrincipal(&aPrincipal)) {
|
||||
if (aPrincipal.IsSystemPrincipal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "mozilla/dom/WorkletGlobalScope.h"
|
||||
#include "mozilla/dom/WorkletImpl.h"
|
||||
#include "mozilla/dom/WorkletThread.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/StaticPrefs_devtools.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@ -1435,7 +1436,7 @@ void Console::MethodInternal(JSContext* aCx, MethodName aMethodName,
|
||||
callData->SetAddonId(principal);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
if (!principal->IsSystemPrincipal()) {
|
||||
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(mGlobal);
|
||||
if (webNav) {
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
|
||||
|
@ -5,11 +5,11 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Span.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
|
||||
#include "DataTransfer.h"
|
||||
|
||||
#include "nsISupportsPrimitives.h"
|
||||
@ -561,8 +561,7 @@ nsresult DataTransfer::GetDataAtInternal(const nsAString& aFormat,
|
||||
}
|
||||
|
||||
// If we have chrome only content, and we aren't chrome, don't allow access
|
||||
if (!nsContentUtils::IsSystemPrincipal(aSubjectPrincipal) &&
|
||||
item->ChromeOnly()) {
|
||||
if (!aSubjectPrincipal->IsSystemPrincipal() && item->ChromeOnly()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -605,7 +604,7 @@ void DataTransfer::MozGetDataAt(JSContext* aCx, const nsAString& aFormat,
|
||||
bool DataTransfer::PrincipalMaySetData(const nsAString& aType,
|
||||
nsIVariant* aData,
|
||||
nsIPrincipal* aPrincipal) {
|
||||
if (!nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (!aPrincipal->IsSystemPrincipal()) {
|
||||
DataTransferItem::eKind kind = DataTransferItem::KindFromData(aData);
|
||||
if (kind == DataTransferItem::KIND_OTHER) {
|
||||
NS_WARNING("Disallowing adding non string/file types to DataTransfer");
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "DataTransferItemList.h"
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/dom/DataTransferItemBinding.h"
|
||||
@ -491,7 +492,7 @@ already_AddRefed<nsIVariant> DataTransferItem::Data(nsIPrincipal* aPrincipal,
|
||||
|
||||
// If the inbound principal is system, we can skip the below checks, as
|
||||
// they will trivially succeed.
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
return DataNoSecurityCheck();
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsVariant.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/storage/Variant.h"
|
||||
@ -220,7 +221,7 @@ already_AddRefed<FileList> DataTransferItemList::Files(
|
||||
// release builds. If this functionality is required in the future, a more
|
||||
// advanced caching mechanism for the FileList objects will be required.
|
||||
RefPtr<FileList> files;
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
files = new FileList(mDataTransfer);
|
||||
GenerateFiles(files, aPrincipal);
|
||||
return files.forget();
|
||||
@ -528,8 +529,7 @@ void DataTransferItemList::GenerateFiles(FileList* aFiles,
|
||||
|
||||
// For non-system principals, the Files list should be empty if the
|
||||
// DataTransfer is protected.
|
||||
if (!nsContentUtils::IsSystemPrincipal(aFilesPrincipal) &&
|
||||
mDataTransfer->IsProtected()) {
|
||||
if (!aFilesPrincipal->IsSystemPrincipal() && mDataTransfer->IsProtected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
@ -716,8 +717,7 @@ double Event::TimeStamp() {
|
||||
double ret =
|
||||
perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp);
|
||||
MOZ_ASSERT(mOwner->PrincipalOrNull());
|
||||
if (nsContentUtils::IsSystemPrincipal(mOwner->PrincipalOrNull()))
|
||||
return ret;
|
||||
if (mOwner->PrincipalOrNull()->IsSystemPrincipal()) return ret;
|
||||
|
||||
return nsRFPService::ReduceTimePrecisionAsMSecs(
|
||||
ret, perf->GetRandomTimelineSeed());
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "GeckoProfiler.h"
|
||||
#include "KeyboardEvent.h"
|
||||
#include "Layers.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/dom/CloseEvent.h"
|
||||
#include "mozilla/dom/CustomEvent.h"
|
||||
@ -121,7 +122,7 @@ static bool IsEventTargetChrome(EventTarget* aEventTarget,
|
||||
}
|
||||
} else if (nsCOMPtr<nsIScriptObjectPrincipal> sop =
|
||||
do_QueryInterface(aEventTarget->GetOwnerGlobal())) {
|
||||
isChrome = nsContentUtils::IsSystemPrincipal(sop->GetPrincipal());
|
||||
isChrome = sop->GetPrincipal()->IsSystemPrincipal();
|
||||
}
|
||||
return isChrome;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "mozilla/dom/TouchEvent.h"
|
||||
#include "mozilla/dom/Touch.h"
|
||||
#include "mozilla/dom/TouchListBinding.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
@ -278,7 +279,7 @@ bool TouchEvent::PrefEnabled(nsIDocShell* aDocShell) {
|
||||
// static
|
||||
bool TouchEvent::LegacyAPIEnabled(JSContext* aCx, JSObject* aGlobal) {
|
||||
nsIPrincipal* principal = nsContentUtils::SubjectPrincipal(aCx);
|
||||
bool isSystem = principal && nsContentUtils::IsSystemPrincipal(principal);
|
||||
bool isSystem = principal && principal->IsSystemPrincipal();
|
||||
|
||||
nsIDocShell* docShell = nullptr;
|
||||
if (aGlobal) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsSerializationHelper.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/net/HttpBaseChannel.h"
|
||||
#include "mozilla/ipc/ChannelInfo.h"
|
||||
#include "nsNetUtil.h"
|
||||
@ -47,8 +48,7 @@ void ChannelInfo::InitFromChromeGlobal(nsIGlobalObject* aGlobal) {
|
||||
MOZ_ASSERT(!mInited, "Cannot initialize the object twice");
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
MOZ_RELEASE_ASSERT(
|
||||
nsContentUtils::IsSystemPrincipal(aGlobal->PrincipalOrNull()));
|
||||
MOZ_RELEASE_ASSERT(aGlobal->PrincipalOrNull()->IsSystemPrincipal());
|
||||
|
||||
mSecurityInfo.Truncate();
|
||||
mInited = true;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/BodyStream.h"
|
||||
#include "mozilla/dom/FetchBinding.h"
|
||||
@ -218,7 +218,7 @@ already_AddRefed<Response> Response::Constructor(
|
||||
}
|
||||
|
||||
internalResponse->InitChannelInfo(info);
|
||||
} else if (nsContentUtils::IsSystemPrincipal(global->PrincipalOrNull())) {
|
||||
} else if (global->PrincipalOrNull()->IsSystemPrincipal()) {
|
||||
info.InitFromChromeGlobal(global);
|
||||
|
||||
internalResponse->InitChannelInfo(info);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "mozilla/dom/IPCBlobUtils.h"
|
||||
#include "mozilla/dom/MediaSource.h"
|
||||
#include "mozilla/ipc/IPCStreamUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -832,7 +833,8 @@ BlobURLProtocolHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
|
||||
// principal and which is never mutated to have a non-zero mPrivateBrowsingId
|
||||
// or container.
|
||||
if (aLoadInfo &&
|
||||
!nsContentUtils::IsSystemPrincipal(aLoadInfo->LoadingPrincipal()) &&
|
||||
(!aLoadInfo->LoadingPrincipal() ||
|
||||
!aLoadInfo->LoadingPrincipal()->IsSystemPrincipal()) &&
|
||||
!ChromeUtils::IsOriginAttributesEqualIgnoringFPD(
|
||||
aLoadInfo->GetOriginAttributes(),
|
||||
BasePrincipal::Cast(info->mPrincipal)->OriginAttributesRef())) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "MediaTrackGraph.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/dom/CanvasCaptureMediaStream.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2D.h"
|
||||
@ -850,7 +851,7 @@ already_AddRefed<File> HTMLCanvasElement::MozGetAsFile(
|
||||
OwnerDoc()->WarnOnceAbout(Document::eMozGetAsFile);
|
||||
|
||||
// do a trust check if this is a write-only canvas
|
||||
if (mWriteOnly && !nsContentUtils::IsSystemPrincipal(&aSubjectPrincipal)) {
|
||||
if (mWriteOnly && !aSubjectPrincipal.IsSystemPrincipal()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "mozilla/dom/HTMLFormElement.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/Date.h"
|
||||
#include "mozilla/dom/Directory.h"
|
||||
@ -2187,8 +2188,7 @@ HTMLInputElement* HTMLInputElement::GetOwnerNumberControl() {
|
||||
|
||||
void HTMLInputElement::SetUserInput(const nsAString& aValue,
|
||||
nsIPrincipal& aSubjectPrincipal) {
|
||||
if (mType == NS_FORM_INPUT_FILE &&
|
||||
!nsContentUtils::IsSystemPrincipal(&aSubjectPrincipal)) {
|
||||
if (mType == NS_FORM_INPUT_FILE && !aSubjectPrincipal.IsSystemPrincipal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "BackgroundChildImpl.h"
|
||||
#include "IDBRequest.h"
|
||||
#include "IndexedDatabaseManager.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/SystemGroup.h"
|
||||
@ -29,7 +30,6 @@
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsIAboutModule.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
@ -344,7 +344,7 @@ nsresult IDBFactory::AllowedForWindowInternal(nsPIDOMWindowInner* aWindow,
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
if (principal->IsSystemPrincipal()) {
|
||||
principal.forget(aPrincipal);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -379,7 +379,7 @@ bool IDBFactory::AllowedForPrincipal(nsIPrincipal* aPrincipal,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
if (aIsSystemPrincipal) {
|
||||
*aIsSystemPrincipal = true;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/BackgroundHangMonitor.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/CancelContentJSOptionsBinding.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsIWritablePropertyBag2.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/PopupBlocker.h"
|
||||
@ -270,7 +271,7 @@ nsresult nsJSThunk::EvaluateScript(
|
||||
}
|
||||
|
||||
// Fail if someone tries to execute in a global with system principal.
|
||||
if (nsContentUtils::IsSystemPrincipal(objectPrincipal)) {
|
||||
if (objectPrincipal->IsSystemPrincipal()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "ActorsChild.h"
|
||||
#include "IPCBlobInputStreamThread.h"
|
||||
#include "LocalStorageCommon.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/ThreadEventQueue.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
@ -261,7 +262,7 @@ nsresult LSObject::CreateForWindow(nsPIDOMWindowInner* aWindow,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
if (principal->IsSystemPrincipal()) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "TCPSocket.h"
|
||||
#include "TCPServerSocket.h"
|
||||
@ -1042,6 +1043,5 @@ TCPSocket::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
/* static */
|
||||
bool TCPSocket::ShouldTCPSocketExist(JSContext* aCx, JSObject* aGlobal) {
|
||||
JS::Rooted<JSObject*> global(aCx, aGlobal);
|
||||
return nsContentUtils::IsSystemPrincipal(
|
||||
nsContentUtils::ObjectPrincipal(global));
|
||||
return nsContentUtils::ObjectPrincipal(global)->IsSystemPrincipal();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "mozilla/dom/Notification.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Components.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
@ -471,7 +472,7 @@ NS_IMPL_QUERY_INTERFACE_CYCLE_COLLECTION_INHERITED(
|
||||
|
||||
NS_IMETHODIMP
|
||||
NotificationPermissionRequest::Run() {
|
||||
bool isSystem = nsContentUtils::IsSystemPrincipal(mPrincipal);
|
||||
bool isSystem = mPrincipal->IsSystemPrincipal();
|
||||
bool blocked = false;
|
||||
if (isSystem) {
|
||||
mPermission = NotificationPermission::Granted;
|
||||
@ -1513,7 +1514,7 @@ NotificationPermission Notification::GetPermissionInternal(
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
return NotificationPermission::Granted;
|
||||
} else {
|
||||
// Allow files to show notifications by default.
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "PerformanceResourceTiming.h"
|
||||
#include "PerformanceService.h"
|
||||
#include "PerformanceWorker.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/PerformanceBinding.h"
|
||||
#include "mozilla/dom/PerformanceEntryEvent.h"
|
||||
@ -53,9 +54,8 @@ already_AddRefed<Performance> Performance::CreateForMainThread(
|
||||
nsDOMNavigationTiming* aDOMTiming, nsITimedChannel* aChannel) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
RefPtr<Performance> performance =
|
||||
new PerformanceMainThread(aWindow, aDOMTiming, aChannel,
|
||||
nsContentUtils::IsSystemPrincipal(aPrincipal));
|
||||
RefPtr<Performance> performance = new PerformanceMainThread(
|
||||
aWindow, aDOMTiming, aChannel, aPrincipal->IsSystemPrincipal());
|
||||
return performance.forget();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "PerformanceTiming.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/PerformanceTimingBinding.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define mozilla_dom_PerformanceTiming_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "js/Debug.h"
|
||||
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/OwningNonNull.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -512,9 +513,10 @@ void Promise::ReportRejectedPromise(JSContext* aCx, JS::HandleObject aPromise) {
|
||||
|
||||
RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
|
||||
bool isMainThread = MOZ_LIKELY(NS_IsMainThread());
|
||||
bool isChrome = isMainThread ? nsContentUtils::IsSystemPrincipal(
|
||||
nsContentUtils::ObjectPrincipal(aPromise))
|
||||
: IsCurrentThreadRunningChromeWorker();
|
||||
bool isChrome =
|
||||
isMainThread
|
||||
? nsContentUtils::ObjectPrincipal(aPromise)->IsSystemPrincipal()
|
||||
: IsCurrentThreadRunningChromeWorker();
|
||||
nsGlobalWindowInner* win =
|
||||
isMainThread ? xpc::WindowGlobalOrNull(aPromise) : nullptr;
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "mozilla/dom/ServiceWorkerManager.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
@ -256,7 +256,7 @@ bool PushDispatcher::ShouldNotifyWorkers() {
|
||||
// System subscriptions use observer notifications instead of service worker
|
||||
// events. The `testing.notifyWorkers` pref disables worker events for
|
||||
// non-system subscriptions.
|
||||
if (nsContentUtils::IsSystemPrincipal(mPrincipal) ||
|
||||
if (mPrincipal->IsSystemPrincipal() ||
|
||||
!Preferences::GetBool("dom.push.testing.notifyWorkers", true)) {
|
||||
return false;
|
||||
}
|
||||
@ -429,7 +429,7 @@ nsresult PushErrorDispatcher::NotifyObservers() { return NS_OK; }
|
||||
|
||||
nsresult PushErrorDispatcher::NotifyWorkers() {
|
||||
if (!ShouldNotifyWorkers() &&
|
||||
(!mPrincipal || nsContentUtils::IsSystemPrincipal(mPrincipal))) {
|
||||
(!mPrincipal || mPrincipal->IsSystemPrincipal())) {
|
||||
// For system subscriptions, log the error directly to the browser console.
|
||||
return nsContentUtils::ReportToConsoleNonLocalized(
|
||||
mMessage, mFlags, NS_LITERAL_CSTRING("Push"), nullptr, /* aDocument */
|
||||
|
@ -7346,7 +7346,7 @@ nsresult QuotaManager::GetInfoFromPrincipal(nsIPrincipal* aPrincipal,
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
GetInfoForChrome(aSuffix, aGroup, aOrigin);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -5,9 +5,10 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/ThreadLocal.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/ThreadLocal.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
@ -499,8 +500,8 @@ void AutoJSAPI::ReportException() {
|
||||
RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
|
||||
|
||||
RefPtr<nsGlobalWindowInner> inner = xpc::WindowOrNull(errorGlobal);
|
||||
bool isChrome = nsContentUtils::IsSystemPrincipal(
|
||||
nsContentUtils::ObjectPrincipal(errorGlobal));
|
||||
bool isChrome =
|
||||
nsContentUtils::ObjectPrincipal(errorGlobal)->IsSystemPrincipal();
|
||||
xpcReport->Init(jsReport.report(), jsReport.toStringResult().c_str(),
|
||||
isChrome, inner ? inner->WindowID() : 0);
|
||||
if (inner && jsReport.report()->errorNumber != JSMSG_OUT_OF_MEMORY) {
|
||||
|
@ -5,11 +5,12 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/CSPEvalChecker.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/dom/WorkerRunnable.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsContentSecurityUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/nsCSPUtils.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ReferrerInfo.h"
|
||||
|
||||
#include "mozilla/AntiTrackingCommon.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "mozilla/net/HttpBaseChannel.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
@ -98,7 +98,7 @@ bool nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
|
||||
// Redirecting to a toplevel data: URI is not allowed, hence we make
|
||||
// sure the RedirectChain is empty.
|
||||
if (!loadInfo->GetLoadTriggeredFromExternal() &&
|
||||
nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal()) &&
|
||||
loadInfo->TriggeringPrincipal()->IsSystemPrincipal() &&
|
||||
loadInfo->RedirectChain().IsEmpty()) {
|
||||
return true;
|
||||
}
|
||||
@ -189,7 +189,7 @@ nsresult nsContentSecurityManager::CheckFTPSubresourceLoad(
|
||||
// Allow the system principal to load everything. This is meant to
|
||||
// temporarily fix downloads and pdf.js.
|
||||
nsIPrincipal* triggeringPrincipal = loadInfo->TriggeringPrincipal();
|
||||
if (nsContentUtils::IsSystemPrincipal(triggeringPrincipal)) {
|
||||
if (triggeringPrincipal->IsSystemPrincipal()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -344,7 +344,7 @@ static nsresult DoCORSChecks(nsIChannel* aChannel, nsILoadInfo* aLoadInfo,
|
||||
// No need to set up CORS if TriggeringPrincipal is the SystemPrincipal.
|
||||
// For example, allow user stylesheets to load XBL from external files
|
||||
// without requiring CORS.
|
||||
if (nsContentUtils::IsSystemPrincipal(aLoadInfo->TriggeringPrincipal())) {
|
||||
if (aLoadInfo->TriggeringPrincipal()->IsSystemPrincipal()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -594,7 +594,7 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
|
||||
|
||||
static void LogPrincipal(nsIPrincipal* aPrincipal,
|
||||
const nsAString& aPrincipalName) {
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal && aPrincipal->IsSystemPrincipal()) {
|
||||
MOZ_LOG(sCSMLog, LogLevel::Debug,
|
||||
(" %s: SystemPrincipal\n",
|
||||
NS_ConvertUTF16toUTF8(aPrincipalName).get()));
|
||||
@ -765,7 +765,8 @@ nsresult nsContentSecurityManager::CheckSystemPrincipalLoads(
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||
|
||||
// bail out, if we're not loading with a SystemPrincipal
|
||||
if (!nsContentUtils::IsSystemPrincipal(loadInfo->LoadingPrincipal())) {
|
||||
if (!loadInfo->LoadingPrincipal() ||
|
||||
!loadInfo->LoadingPrincipal()->IsSystemPrincipal()) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsContentPolicyType contentPolicyType =
|
||||
@ -1010,7 +1011,7 @@ nsresult nsContentSecurityManager::CheckChannel(nsIChannel* aChannel) {
|
||||
|
||||
// Allow subresource loads if TriggeringPrincipal is the SystemPrincipal.
|
||||
// For example, allow user stylesheets to load XBL from external files.
|
||||
if (nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal()) &&
|
||||
if (loadInfo->TriggeringPrincipal()->IsSystemPrincipal() &&
|
||||
loadInfo->GetExternalContentPolicyType() !=
|
||||
nsIContentPolicy::TYPE_DOCUMENT &&
|
||||
loadInfo->GetExternalContentPolicyType() !=
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "nsISiteSecurityService.h"
|
||||
#include "prnetdb.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
@ -312,7 +313,7 @@ nsMixedContentBlocker::AsyncOnChannelRedirect(
|
||||
if (requestingPrincipal) {
|
||||
// We check to see if the loadingPrincipal is systemPrincipal and return
|
||||
// early if it is
|
||||
if (nsContentUtils::IsSystemPrincipal(requestingPrincipal)) {
|
||||
if (requestingPrincipal->IsSystemPrincipal()) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
@ -709,7 +710,7 @@ nsresult nsMixedContentBlocker::ShouldLoad(
|
||||
// 2) if aRequestingContext yields a principal but no location, we check if
|
||||
// its a system principal.
|
||||
if (principal && !requestingLocation) {
|
||||
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
if (principal->IsSystemPrincipal()) {
|
||||
*aDecision = ACCEPT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/StorageAccess.h"
|
||||
#include "mozilla/dom/ClientIPCTypes.h"
|
||||
@ -640,7 +640,7 @@ nsIGlobalObject* ServiceWorkerContainer::GetGlobalIfValid(
|
||||
}
|
||||
|
||||
// Don't allow service workers when the document is chrome.
|
||||
if (NS_WARN_IF(nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()))) {
|
||||
if (NS_WARN_IF(doc->NodePrincipal()->IsSystemPrincipal())) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include "StorageNotifierService.h"
|
||||
|
||||
#include "mozilla/dom/StorageBinding.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/StorageAccess.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -36,7 +36,7 @@ Storage::Storage(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal,
|
||||
mIsSessionOnly(false) {
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
|
||||
if (mPrincipal->IsSystemPrincipal()) {
|
||||
mIsSessionOnly = false;
|
||||
} else if (mWindow) {
|
||||
uint32_t rejectedReason = 0;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/net/WebSocketChannel.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
@ -1530,7 +1531,7 @@ nsresult WebSocketImpl::Init(JSContext* aCx, nsIPrincipal* aLoadingPrincipal,
|
||||
}
|
||||
|
||||
mPrivateBrowsing = !!aPrincipal->OriginAttributesRef().mPrivateBrowsingId;
|
||||
mIsChromeContext = nsContentUtils::IsSystemPrincipal(aPrincipal);
|
||||
mIsChromeContext = aPrincipal->IsSystemPrincipal();
|
||||
|
||||
// parses the url
|
||||
rv = ParseURL(aURL);
|
||||
|
@ -104,7 +104,7 @@ nsresult WorkerLoadInfo::SetPrincipalsAndCSPOnMainThread(
|
||||
|
||||
mPrincipal = aPrincipal;
|
||||
mStoragePrincipal = aStoragePrincipal;
|
||||
mPrincipalIsSystem = nsContentUtils::IsSystemPrincipal(aPrincipal);
|
||||
mPrincipalIsSystem = aPrincipal->IsSystemPrincipal();
|
||||
mPrincipalIsAddonOrExpandedAddon =
|
||||
aPrincipal->GetIsAddonOrExpandedAddonPrincipal();
|
||||
|
||||
@ -193,8 +193,8 @@ nsresult WorkerLoadInfo::GetPrincipalsAndLoadGroupFromChannel(
|
||||
// mPrincipalIsSystem to true in WorkerPrivate::GetLoadInfo()). Otherwise
|
||||
// this channel principal must be same origin with the load principal (we
|
||||
// check again here in case redirects changed the location of the script).
|
||||
if (nsContentUtils::IsSystemPrincipal(mLoadingPrincipal)) {
|
||||
if (!nsContentUtils::IsSystemPrincipal(channelPrincipal)) {
|
||||
if (mLoadingPrincipal->IsSystemPrincipal()) {
|
||||
if (!channelPrincipal->IsSystemPrincipal()) {
|
||||
nsCOMPtr<nsIURI> finalURI;
|
||||
rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(finalURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -11,6 +11,7 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/dom/BlobBinding.h"
|
||||
#include "mozilla/dom/BlobURLProtocolHandler.h"
|
||||
@ -1350,7 +1351,7 @@ XMLHttpRequestMainThread::GetCurrentJARChannel() {
|
||||
}
|
||||
|
||||
bool XMLHttpRequestMainThread::IsSystemXHR() const {
|
||||
return mIsSystem || nsContentUtils::IsSystemPrincipal(mPrincipal);
|
||||
return mIsSystem || mPrincipal->IsSystemPrincipal();
|
||||
}
|
||||
|
||||
bool XMLHttpRequestMainThread::InUploadPhase() const {
|
||||
@ -2030,7 +2031,7 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest* request) {
|
||||
mResponseXML->SetSuppressParserErrorConsoleMessages(true);
|
||||
}
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
|
||||
if (mPrincipal->IsSystemPrincipal()) {
|
||||
mResponseXML->ForceEnableXULXBL();
|
||||
}
|
||||
|
||||
@ -2382,7 +2383,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
|
||||
|
||||
nsSecurityFlags secFlags;
|
||||
nsLoadFlags loadFlags = nsIRequest::LOAD_BACKGROUND;
|
||||
if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
|
||||
if (mPrincipal->IsSystemPrincipal()) {
|
||||
// When chrome is loading we want to make sure to sandbox any potential
|
||||
// result document. We also want to allow cross-origin loads.
|
||||
secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL |
|
||||
|
@ -12,7 +12,7 @@
|
||||
# include "nsIXULStore.h"
|
||||
# include "nsIStringEnumerator.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "nsIAppWindow.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -86,7 +86,7 @@ void XULPersist::Persist(Element* aElement, int32_t aNameSpaceID,
|
||||
return;
|
||||
}
|
||||
// For non-chrome documents, persistance is simply broken
|
||||
if (!nsContentUtils::IsSystemPrincipal(mDocument->NodePrincipal())) {
|
||||
if (!mDocument->NodePrincipal()->IsSystemPrincipal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ nsresult XULPersist::ApplyPersistentAttributes() {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
// For non-chrome documents, persistance is simply broken
|
||||
if (!nsContentUtils::IsSystemPrincipal(mDocument->NodePrincipal())) {
|
||||
if (!mDocument->NodePrincipal()->IsSystemPrincipal()) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/ReflowInput.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -134,7 +135,7 @@ nsresult nsXULPopupListener::HandleEvent(Event* aEvent) {
|
||||
// The user wants his contextmenus. Let's make sure that this is a
|
||||
// website and not chrome since there could be places in chrome which
|
||||
// don't want contextmenus.
|
||||
if (!nsContentUtils::IsSystemPrincipal(targetContent->NodePrincipal())) {
|
||||
if (!targetContent->NodePrincipal()->IsSystemPrincipal()) {
|
||||
// This isn't chrome. Cancel the preventDefault() and
|
||||
// let the event go forth.
|
||||
preventDefault = false;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "nsXULPrototypeCache.h"
|
||||
#include "mozilla/DeclarationBlock.h"
|
||||
@ -263,8 +264,7 @@ nsXULPrototypeDocument::Write(nsIObjectOutputStream* aStream) {
|
||||
|
||||
#ifdef DEBUG
|
||||
// XXX Worrisome if we're caching things without system principal.
|
||||
if (!nsContentUtils::IsSystemPrincipal(
|
||||
mNodeInfoManager->DocumentPrincipal())) {
|
||||
if (!mNodeInfoManager->DocumentPrincipal()->IsSystemPrincipal()) {
|
||||
NS_WARNING("Serializing document without system principal");
|
||||
}
|
||||
#endif
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/StaticPrefs_permissions.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/FeaturePolicyUtils.h"
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/AntiTrackingCommon.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ContentPrincipal.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Pair.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/SystemGroup.h"
|
||||
@ -1668,7 +1668,7 @@ nsPermissionManager::AddFromPrincipal(nsIPrincipal* aPrincipal,
|
||||
|
||||
// We don't add the system principal because it actually has no URI and we
|
||||
// always allow action for them.
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1977,7 +1977,7 @@ nsPermissionManager::RemoveFromPrincipal(nsIPrincipal* aPrincipal,
|
||||
NS_ENSURE_ARG_POINTER(aPrincipal);
|
||||
|
||||
// System principals are never added to the database, no need to remove them.
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2205,7 +2205,7 @@ nsPermissionManager::GetPermissionObject(nsIPrincipal* aPrincipal,
|
||||
|
||||
*aResult = nullptr;
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIconChannel.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/EndianUtils.h"
|
||||
#include "nsIIconURI.h"
|
||||
#include "nsIServiceManager.h"
|
||||
@ -185,7 +186,7 @@ nsIconChannel::AsyncOpen(nsIStreamListener* aListener) {
|
||||
MOZ_ASSERT(
|
||||
!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 || mLoadInfo->GetInitialSecurityCheckDone() ||
|
||||
(mLoadInfo->GetSecurityMode() == nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL &&
|
||||
nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal())),
|
||||
mLoadInfo->LoadingPrincipal() && mLoadInfo->LoadingPrincipal()->IsSystemPrincipal()),
|
||||
"security flags in loadInfo but doContentSecurityCheck() not called");
|
||||
|
||||
nsCOMPtr<nsIInputStream> inStream;
|
||||
|
@ -5,6 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
|
||||
#include "nsIconChannel.h"
|
||||
@ -350,7 +351,8 @@ nsIconChannel::AsyncOpen(nsIStreamListener* aListener) {
|
||||
mLoadInfo->GetInitialSecurityCheckDone() ||
|
||||
(mLoadInfo->GetSecurityMode() ==
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL &&
|
||||
nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal())),
|
||||
mLoadInfo->LoadingPrincipal() &&
|
||||
mLoadInfo->LoadingPrincipal()->IsSystemPrincipal()),
|
||||
"security flags in loadInfo but doContentSecurityCheck() not called");
|
||||
|
||||
nsCOMPtr<nsIInputStream> inStream;
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsINetworkPredictor.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/nsMixedContentBlocker.h"
|
||||
#include "mozilla/image/ImageMemoryReporter.h"
|
||||
@ -685,7 +686,7 @@ static bool ShouldLoadCachedImage(imgRequest* aImgRequest,
|
||||
}
|
||||
}
|
||||
|
||||
if (!nsContentUtils::IsSystemPrincipal(aTriggeringPrincipal)) {
|
||||
if (!aTriggeringPrincipal || !aTriggeringPrincipal->IsSystemPrincipal()) {
|
||||
// Set the requestingLocation from the aTriggeringPrincipal.
|
||||
nsCOMPtr<nsIURI> requestingLocation;
|
||||
if (aTriggeringPrincipal) {
|
||||
@ -1381,8 +1382,7 @@ imgLoader::RemoveEntriesFromPrincipal(nsIPrincipal* aPrincipal) {
|
||||
|
||||
AutoTArray<RefPtr<imgCacheEntry>, 128> entriesToBeRemoved;
|
||||
|
||||
imgCacheTable& cache =
|
||||
GetCache(nsContentUtils::IsSystemPrincipal(aPrincipal));
|
||||
imgCacheTable& cache = GetCache(aPrincipal->IsSystemPrincipal());
|
||||
for (auto iter = cache.Iter(); !iter.Done(); iter.Next()) {
|
||||
auto& key = iter.Key();
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "Localization.h"
|
||||
#include "nsImportModule.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
#define INTL_APP_LOCALES_CHANGED "intl:app-locales-changed"
|
||||
#define L10N_PSEUDO_PREF "intl.l10n.pseudo"
|
||||
@ -299,7 +300,7 @@ already_AddRefed<Promise> Localization::MaybeWrapPromise(
|
||||
// For system principal we don't need to wrap the
|
||||
// result promise at all.
|
||||
nsIPrincipal* principal = mGlobal->PrincipalOrNull();
|
||||
if (principal && nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
if (principal && principal->IsSystemPrincipal()) {
|
||||
return RefPtr<Promise>(aInnerPromise).forget();
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "MainThreadUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ContentPrincipal.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "mozilla/LoadContext.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/ResultExtensions.h"
|
||||
#include "mozilla/URLPreloader.h"
|
||||
@ -2142,7 +2143,7 @@ nsXPCComponents_Utils::BlockScriptForGlobal(HandleValue globalArg,
|
||||
RootedObject global(cx, UncheckedUnwrap(&globalArg.toObject(),
|
||||
/* stopAtWindowProxy = */ false));
|
||||
NS_ENSURE_TRUE(JS_IsGlobalObject(global), NS_ERROR_INVALID_ARG);
|
||||
if (nsContentUtils::IsSystemPrincipal(xpc::GetObjectPrincipal(global))) {
|
||||
if (xpc::GetObjectPrincipal(global)->IsSystemPrincipal()) {
|
||||
JS_ReportErrorASCII(cx, "Script may not be disabled for system globals");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -2157,7 +2158,7 @@ nsXPCComponents_Utils::UnblockScriptForGlobal(HandleValue globalArg,
|
||||
RootedObject global(cx, UncheckedUnwrap(&globalArg.toObject(),
|
||||
/* stopAtWindowProxy = */ false));
|
||||
NS_ENSURE_TRUE(JS_IsGlobalObject(global), NS_ERROR_INVALID_ARG);
|
||||
if (nsContentUtils::IsSystemPrincipal(xpc::GetObjectPrincipal(global))) {
|
||||
if (xpc::GetObjectPrincipal(global)->IsSystemPrincipal()) {
|
||||
JS_ReportErrorASCII(cx, "Script may not be disabled for system globals");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsThreadPool.h"
|
||||
#include "nsWindowSizes.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/Services.h"
|
||||
@ -3277,8 +3278,7 @@ void XPCJSRuntime::RemoveGCCallback(xpcGCCallback cb) {
|
||||
|
||||
JSObject* XPCJSRuntime::GetUAWidgetScope(JSContext* cx,
|
||||
nsIPrincipal* principal) {
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(principal),
|
||||
"Running UA Widget in chrome");
|
||||
MOZ_ASSERT(!principal->IsSystemPrincipal(), "Running UA Widget in chrome");
|
||||
|
||||
RootedObject scope(cx);
|
||||
do {
|
||||
|
@ -206,7 +206,7 @@ JSObject* GetUAWidgetScope(JSContext* cx, JSObject* contentScopeArg) {
|
||||
JSAutoRealm ar(cx, contentScope);
|
||||
nsIPrincipal* principal = GetObjectPrincipal(contentScope);
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
if (principal->IsSystemPrincipal()) {
|
||||
return JS::GetNonCCWObjectGlobal(contentScope);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "WrapperFactory.h"
|
||||
#include "AccessCheck.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
#include "mozilla/dom/Exceptions.h"
|
||||
@ -492,7 +493,7 @@ void InitGlobalObjectOptions(JS::RealmOptions& aOptions,
|
||||
bool shouldDiscardSystemSource = ShouldDiscardSystemSource();
|
||||
bool extraWarningsForSystemJS = ExtraWarningsForSystemJS();
|
||||
|
||||
bool isSystem = nsContentUtils::IsSystemPrincipal(aPrincipal);
|
||||
bool isSystem = aPrincipal->IsSystemPrincipal();
|
||||
|
||||
if (isSystem) {
|
||||
// Make sure [SecureContext] APIs are visible:
|
||||
|
@ -115,7 +115,7 @@
|
||||
|
||||
// paint forcing
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
@ -1095,7 +1095,7 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) {
|
||||
if (os) {
|
||||
nsIPrincipal* principal = d->NodePrincipal();
|
||||
os->NotifyObservers(ToSupports(d),
|
||||
nsContentUtils::IsSystemPrincipal(principal)
|
||||
principal->IsSystemPrincipal()
|
||||
? "chrome-document-loaded"
|
||||
: "content-document-loaded",
|
||||
nullptr);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/IntegerRange.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/HTMLEditor.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
@ -603,8 +604,7 @@ void nsFrameSelection::Init(mozilla::PresShell* aPresShell,
|
||||
: StaticPrefs::dom_select_events_enabled();
|
||||
|
||||
Document* doc = aPresShell->GetDocument();
|
||||
if (initSelectEvents ||
|
||||
(doc && nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()))) {
|
||||
if (initSelectEvents || (doc && doc->NodePrincipal()->IsSystemPrincipal())) {
|
||||
int8_t index = GetIndexFromSelectionType(SelectionType::eNormal);
|
||||
if (mDomSelections[index]) {
|
||||
mDomSelections[index]->EnableSelectionChangeEvent();
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
|
@ -5,7 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/StyleSheet.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ComputedStyleInlines.h"
|
||||
#include "mozilla/css/ErrorReporter.h"
|
||||
#include "mozilla/css/GroupRule.h"
|
||||
@ -1166,7 +1166,7 @@ const ServoCssRules* StyleSheet::ToShared(
|
||||
MOZ_ASSERT(!nsCOMPtr<nsIURI>(GetReferrerInfo()->GetComputedReferrer()));
|
||||
MOZ_ASSERT(GetCORSMode() == CORS_NONE);
|
||||
MOZ_ASSERT(Inner().mIntegrity.IsEmpty());
|
||||
MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(Principal()));
|
||||
MOZ_ASSERT(Principal()->IsSystemPrincipal());
|
||||
|
||||
return Servo_SharedMemoryBuilder_AddStylesheet(aBuilder, Inner().mContents);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsIDOMXULSelectCntrlItemEl.h"
|
||||
#include "mozilla/AnimationUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIFileURL.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsIBrowserChild.h"
|
||||
@ -863,7 +864,8 @@ nsJARChannel::AsyncOpen(nsIStreamListener* aListener) {
|
||||
mLoadInfo->GetInitialSecurityCheckDone() ||
|
||||
(mLoadInfo->GetSecurityMode() ==
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL &&
|
||||
nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal())),
|
||||
mLoadInfo->LoadingPrincipal() &&
|
||||
mLoadInfo->LoadingPrincipal()->IsSystemPrincipal()),
|
||||
"security flags in loadInfo but doContentSecurityCheck() not called");
|
||||
|
||||
NS_ENSURE_ARG_POINTER(listener);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "LoadInfo.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsRedirectHistoryEntry.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -654,7 +655,8 @@ nsBaseChannel::AsyncOpen(nsIStreamListener* aListener) {
|
||||
mLoadInfo->GetInitialSecurityCheckDone() ||
|
||||
(mLoadInfo->GetSecurityMode() ==
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL &&
|
||||
nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal())),
|
||||
mLoadInfo->LoadingPrincipal() &&
|
||||
mLoadInfo->LoadingPrincipal()->IsSystemPrincipal()),
|
||||
"security flags in loadInfo but doContentSecurityCheck() not called");
|
||||
|
||||
NS_ENSURE_TRUE(mURI, NS_ERROR_NOT_INITIALIZED);
|
||||
|
@ -3005,7 +3005,8 @@ nsresult NS_CompareLoadInfoAndLoadContext(nsIChannel* aChannel) {
|
||||
// the loadInfo will use originAttributes from the content. Thus, the
|
||||
// originAttributes between loadInfo and loadContext will be different.
|
||||
// That's why we have to skip the comparison for the favicon loading.
|
||||
if (nsContentUtils::IsSystemPrincipal(loadInfo->LoadingPrincipal()) &&
|
||||
if (loadInfo->LoadingPrincipal() &&
|
||||
loadInfo->LoadingPrincipal()->IsSystemPrincipal() &&
|
||||
loadInfo->InternalContentPolicyType() ==
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
|
||||
return NS_OK;
|
||||
@ -3126,7 +3127,7 @@ bool NS_ShouldClassifyChannel(nsIChannel* aChannel) {
|
||||
nsContentPolicyType type = loadInfo->GetExternalContentPolicyType();
|
||||
// Skip classifying channel triggered by system unless it is a top-level
|
||||
// load.
|
||||
if (nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal()) &&
|
||||
if (loadInfo->TriggeringPrincipal()->IsSystemPrincipal() &&
|
||||
nsIContentPolicy::TYPE_DOCUMENT != type) {
|
||||
return false;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "nsICachingChannel.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIScriptError.h"
|
||||
@ -2890,7 +2891,8 @@ void HttpBaseChannel::AssertPrivateBrowsingId() {
|
||||
// We skip testing of favicon loading here since it could be triggered by XUL
|
||||
// image which uses SystemPrincipal. The SystemPrincpal doesn't have
|
||||
// mPrivateBrowsingId.
|
||||
if (nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal()) &&
|
||||
if (mLoadInfo->LoadingPrincipal() &&
|
||||
mLoadInfo->LoadingPrincipal()->IsSystemPrincipal() &&
|
||||
mLoadInfo->InternalContentPolicyType() ==
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
|
||||
return;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsHttp.h"
|
||||
#include "nsICacheEntry.h"
|
||||
#include "mozilla/AntiTrackingCommon.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/DocGroup.h"
|
||||
@ -2442,7 +2443,8 @@ nsresult HttpChannelChild::AsyncOpenInternal(nsIStreamListener* aListener) {
|
||||
mLoadInfo->GetInitialSecurityCheckDone() ||
|
||||
(mLoadInfo->GetSecurityMode() ==
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL &&
|
||||
nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal())),
|
||||
mLoadInfo->LoadingPrincipal() &&
|
||||
mLoadInfo->LoadingPrincipal()->IsSystemPrincipal()),
|
||||
"security flags in loadInfo but doContentSecurityCheck() not called");
|
||||
|
||||
LogCallingScriptLocation(this);
|
||||
@ -3970,7 +3972,7 @@ HttpChannelChild::LogBlockedCORSRequest(const nsAString& aMessage,
|
||||
bool privateBrowsing =
|
||||
!!mLoadInfo->GetOriginAttributes().mPrivateBrowsingId;
|
||||
bool fromChromeContext =
|
||||
nsContentUtils::IsSystemPrincipal(mLoadInfo->TriggeringPrincipal());
|
||||
mLoadInfo->TriggeringPrincipal()->IsSystemPrincipal();
|
||||
nsCORSListenerProxy::LogBlockedCORSRequest(
|
||||
innerWindowID, privateBrowsing, fromChromeContext, aMessage, aCategory);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "nsICorsPreflightCallback.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsHttpChannel.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
@ -110,8 +111,7 @@ static void LogBlockedRequest(nsIRequest* aRequest, const char* aProperty,
|
||||
bool fromChromeContext = false;
|
||||
if (channel) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
|
||||
fromChromeContext =
|
||||
nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal());
|
||||
fromChromeContext = loadInfo->TriggeringPrincipal()->IsSystemPrincipal();
|
||||
}
|
||||
|
||||
// we are passing aProperty as the category so we can link to the
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "nsIConsoleService.h"
|
||||
#include "mozilla/AntiTrackingCommon.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
@ -6392,7 +6393,8 @@ nsHttpChannel::AsyncOpen(nsIStreamListener* aListener) {
|
||||
mLoadInfo->GetInitialSecurityCheckDone() ||
|
||||
(mLoadInfo->GetSecurityMode() ==
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL &&
|
||||
nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal())),
|
||||
mLoadInfo->LoadingPrincipal() &&
|
||||
mLoadInfo->LoadingPrincipal()->IsSystemPrincipal()),
|
||||
"security flags in loadInfo but doContentSecurityCheck() not called");
|
||||
|
||||
LOG(("nsHttpChannel::AsyncOpen [this=%p]\n", this));
|
||||
|
@ -7,6 +7,7 @@
|
||||
// HttpLog.h should generally be included first
|
||||
#include "HttpLog.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsHttpChannelAuthProvider.h"
|
||||
#include "nsNetUtil.h"
|
||||
@ -920,7 +921,7 @@ bool nsHttpChannelAuthProvider::BlockPrompt(bool proxyAuth) {
|
||||
|
||||
if (!topDoc) {
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrinc = loadInfo->TriggeringPrincipal();
|
||||
if (nsContentUtils::IsSystemPrincipal(triggeringPrinc)) {
|
||||
if (triggeringPrinc->IsSystemPrincipal()) {
|
||||
nonWebContent = true;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsXPCOMCIDInternal.h"
|
||||
#include "nsUnicharInputStream.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "mozilla/MemoryChecking.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "nsThread.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/HangTypes.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "mozilla/extensions/WebExtensionContentScript.h"
|
||||
#include "mozilla/extensions/WebExtensionPolicy.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ResultExtensions.h"
|
||||
@ -433,7 +434,7 @@ static bool CheckParentFrames(nsPIDOMWindowOuter* aWindow,
|
||||
auto* win = nsGlobalWindowOuter::Cast(piWin);
|
||||
|
||||
auto* principal = BasePrincipal::Cast(win->GetPrincipal());
|
||||
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
if (principal->IsSystemPrincipal()) {
|
||||
// The add-on manager is a special case, since it contains extension
|
||||
// options pages in same-type <browser> frames.
|
||||
nsIURI* uri = win->GetDocumentURI();
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/Components.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/ErrorNames.h"
|
||||
@ -1715,7 +1716,7 @@ nsUrlClassifierDBService::Classify(nsIPrincipal* aPrincipal,
|
||||
NS_ENSURE_ARG(aPrincipal);
|
||||
NS_ENSURE_ARG(aResult);
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
*aResult = false;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2035,7 +2036,7 @@ nsUrlClassifierDBService::Lookup(nsIPrincipal* aPrincipal,
|
||||
nsIUrlClassifierCallback* aCallback) {
|
||||
// We don't expect someone with SystemPrincipal calls this API(See Bug
|
||||
// 813897).
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(aPrincipal));
|
||||
MOZ_ASSERT(!aPrincipal->IsSystemPrincipal());
|
||||
|
||||
NS_ENSURE_TRUE(gDbBackgroundThread, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "nsSimpleEnumerator.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -401,7 +402,7 @@ static bool CheckUserContextCompatibility(nsIDocShell* aDocShell) {
|
||||
|
||||
// DocShell can have UsercontextID set but loading a document with system
|
||||
// principal. In this case, we consider everything ok.
|
||||
if (nsContentUtils::IsSystemPrincipal(subjectPrincipal)) {
|
||||
if (subjectPrincipal->IsSystemPrincipal()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsExternalProtocolHandler.h"
|
||||
@ -216,7 +217,8 @@ NS_IMETHODIMP nsExtProtocolChannel::AsyncOpen(nsIStreamListener* aListener) {
|
||||
mLoadInfo->GetInitialSecurityCheckDone() ||
|
||||
(mLoadInfo->GetSecurityMode() ==
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL &&
|
||||
nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal())),
|
||||
mLoadInfo->LoadingPrincipal() &&
|
||||
mLoadInfo->LoadingPrincipal()->IsSystemPrincipal()),
|
||||
"security flags in loadInfo but doContentSecurityCheck() not called");
|
||||
|
||||
NS_ENSURE_ARG_POINTER(listener);
|
||||
|
Loading…
Reference in New Issue
Block a user