author | Boris Zbarsky <bzbarsky@mit.edu> |
Thu, 03 Jan 2019 20:55:38 +0000 | |
changeset 509577 | 840ea11d3b3efb306c862c9984e089f226f3bfc4 |
parent 509576 | 417769fb3f0f9c5be5f3cc098a567359eb19c30c |
child 509578 | 1853f95c94b101e7e24a180f6eacaf2a628e5863 |
push id | 10547 |
push user | ffxbld-merge |
push date | Mon, 21 Jan 2019 13:03:58 +0000 |
treeherder | mozilla-beta@24ec1916bffe [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mccr8 |
bugs | 1517434 |
milestone | 66.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/caps/nsIPrincipal.idl +++ b/caps/nsIPrincipal.idl @@ -326,19 +326,20 @@ interface nsIPrincipal : nsISerializable [infallible] readonly attribute boolean isCodebasePrincipal; /** * Returns true iff this is an expanded principal. */ [infallible] readonly attribute boolean isExpandedPrincipal; /** - * Returns true iff this is the system principal. + * Returns true iff this is the system principal. C++ callers should use + * IsSystemPrincipal() instead of this scriptable accessor. */ - [infallible] readonly attribute boolean isSystemPrincipal; + readonly attribute boolean isSystemPrincipal; /** * Faster and nicer version callable from C++. Callers must include * BasePrincipal.h, where it's implemented. */ %{C++ inline bool IsSystemPrincipal() const; %}
--- a/caps/nsIScriptSecurityManager.idl +++ b/caps/nsIScriptSecurityManager.idl @@ -219,16 +219,20 @@ interface nsIScriptSecurityManager : nsI * aChannel must not be null. */ nsIPrincipal getChannelURIPrincipal(in nsIChannel aChannel); /** * Check whether a given principal is a system principal. This allows us * to avoid handing back the system principal to script while allowing * script to check whether a given principal is system. + * + * @deprecated use nsIPrincipal's accessors for this boolean. + * https://bugzilla.mozilla.org/show_bug.cgi?id=1517483 tracks removing + * this. */ boolean isSystemPrincipal(in nsIPrincipal aPrincipal); %{C++ bool IsSystemPrincipal(nsIPrincipal* aPrincipal) { bool isSystem = false; IsSystemPrincipal(aPrincipal, &isSystem); return isSystem; }
--- a/dom/base/nsContentPolicyUtils.h +++ b/dom/base/nsContentPolicyUtils.h @@ -9,30 +9,30 @@ * * XXXbz it would be nice if some of this stuff could be out-of-lined in * nsContentUtils. That would work for almost all the callers... */ #ifndef __nsContentPolicyUtils_h__ #define __nsContentPolicyUtils_h__ +#include "mozilla/BasePrincipal.h" + #include "nsContentUtils.h" #include "nsIContentPolicy.h" #include "nsIContent.h" #include "nsIScriptSecurityManager.h" #include "nsIURI.h" #include "nsServiceManagerUtils.h" #include "nsStringFwd.h" // XXXtw sadly, this makes consumers of nsContentPolicyUtils depend on widget #include "nsIDocument.h" #include "nsPIDOMWindow.h" -class nsIPrincipal; - #define NS_CONTENTPOLICY_CONTRACTID "@mozilla.org/layout/content-policy;1" #define NS_CONTENTPOLICY_CATEGORY "content-policy" #define NS_CONTENTPOLICY_CID \ { \ 0x0e3afd3d, 0xeb60, 0x4c2b, { \ 0x96, 0x3b, 0x56, 0xd7, 0xc4, 0x39, 0xf1, 0x24 \ } \ } @@ -167,17 +167,17 @@ inline const char *NS_CP_ContentTypeName #define CHECK_PRINCIPAL_AND_DATA(action) \ nsCOMPtr<nsIURI> requestOrigin; \ PR_BEGIN_MACRO \ if (loadingPrincipal) { \ /* We exempt most loads into any document with the system principal \ * from content policy checks, mostly as an optimization. Which means \ * that we need to apply this check to the loading principal, not the \ * principal that triggered the load. */ \ - bool isSystem = loadingPrincipal->GetIsSystemPrincipal(); \ + bool isSystem = loadingPrincipal->IsSystemPrincipal(); \ if (isSystem && contentType != nsIContentPolicy::TYPE_DOCUMENT) { \ *decision = nsIContentPolicy::ACCEPT; \ nsCOMPtr<nsINode> n = do_QueryInterface(context); \ if (!n) { \ nsCOMPtr<nsPIDOMWindowOuter> win = do_QueryInterface(context); \ n = win ? win->GetExtantDoc() : nullptr; \ } \ if (n) { \
--- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -33,16 +33,17 @@ #include "mozAutoDocUpdate.h" #include "mozilla/AntiTrackingCommon.h" #include "mozilla/ArrayUtils.h" #include "mozilla/Attributes.h" #include "mozilla/AutoRestore.h" #include "mozilla/AutoTimelineMarker.h" #include "mozilla/BackgroundHangMonitor.h" #include "mozilla/Base64.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/CheckedInt.h" #include "mozilla/DebugOnly.h" #include "mozilla/LoadInfo.h" #include "mozilla/dom/BlobURLProtocolHandler.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/CustomElementRegistry.h" #include "mozilla/dom/MessageBroadcaster.h" #include "mozilla/dom/DocumentFragment.h" @@ -5018,18 +5019,19 @@ void nsContentUtils::NotifyInstalledMenu nsCOMPtr<nsIURI> baseURI = NS_GetInnermostURI(aURI); NS_ENSURE_TRUE(baseURI, false); bool isScheme = false; return NS_SUCCEEDED(baseURI->SchemeIs(aScheme, &isScheme)) && isScheme; } bool nsContentUtils::IsSystemPrincipal(nsIPrincipal* aPrincipal) { - MOZ_ASSERT(IsInitialized()); - return aPrincipal == sSystemPrincipal; + // 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; } nsIPrincipal* nsContentUtils::GetSystemPrincipal() { @@ -6360,17 +6362,17 @@ nsContentUtils::PersistentLayerManagerFo return LayerManagerForDocumentInternal(aDoc, true); } bool nsContentUtils::AllowXULXBLForPrincipal(nsIPrincipal* aPrincipal) { if (!aPrincipal) { return false; } - if (IsSystemPrincipal(aPrincipal)) { + if (aPrincipal->IsSystemPrincipal()) { return true; } nsCOMPtr<nsIURI> princURI; aPrincipal->GetURI(getter_AddRefs(princURI)); return princURI && ((sAllowXULXBL_for_file && SchemeIs(princURI, "file")) || IsSitePermAllow(aPrincipal, "allowXULXBL")); @@ -6551,17 +6553,17 @@ bool nsContentUtils::ChannelShouldInheri // to inherit the owner from the referrer so they can script each other. // If we don't set the owner explicitly then each file: gets an owner // based on its own codebase later. // (URIIsLocalFile(aURI) && NS_SUCCEEDED(aLoadingPrincipal->CheckMayLoad(aURI, false, false)) && // One more check here. CheckMayLoad will always return true for the // system principal, but we do NOT want to inherit in that case. - !IsSystemPrincipal(aLoadingPrincipal)); + !aLoadingPrincipal->IsSystemPrincipal()); } return inherit; } /* static */ bool nsContentUtils::IsFullscreenApiEnabled() { return sIsFullscreenApiEnabled; } @@ -7955,17 +7957,17 @@ bool nsContentUtils::IsUpgradableDisplay nsresult nsContentUtils::SetFetchReferrerURIWithPolicy( nsIPrincipal* aPrincipal, nsIDocument* aDoc, nsIHttpChannel* aChannel, mozilla::net::ReferrerPolicy aReferrerPolicy) { NS_ENSURE_ARG_POINTER(aPrincipal); NS_ENSURE_ARG_POINTER(aChannel); nsCOMPtr<nsIURI> principalURI; - if (IsSystemPrincipal(aPrincipal)) { + if (aPrincipal->IsSystemPrincipal()) { return NS_OK; } aPrincipal->GetURI(getter_AddRefs(principalURI)); if (!aDoc) { return aChannel->SetReferrerWithPolicy(principalURI, aReferrerPolicy); } @@ -9228,34 +9230,34 @@ bool nsContentUtils::IsSpecificAboutPage */ /* static */ bool nsContentUtils::HttpsStateIsModern(nsIDocument* aDocument) { if (!aDocument) { return false; } nsCOMPtr<nsIPrincipal> principal = aDocument->NodePrincipal(); - if (principal->GetIsSystemPrincipal()) { + if (principal->IsSystemPrincipal()) { return true; } // If aDocument is sandboxed, try and get the principal that it would have // been given had it not been sandboxed: if (principal->GetIsNullPrincipal() && (aDocument->GetSandboxFlags() & SANDBOXED_ORIGIN)) { nsIChannel* channel = aDocument->GetChannel(); if (channel) { nsCOMPtr<nsIScriptSecurityManager> ssm = nsContentUtils::GetSecurityManager(); nsresult rv = ssm->GetChannelResultPrincipalIfNotSandboxed( channel, getter_AddRefs(principal)); if (NS_FAILED(rv)) { return false; } - if (principal->GetIsSystemPrincipal()) { + if (principal->IsSystemPrincipal()) { // If a document with the system principal is sandboxing a subdocument // that would normally inherit the embedding element's principal (e.g. // a srcdoc document) then the embedding document does not trust the // content that is written to the embedded document. Unlike when the // embedding document is https, in this case we have no indication as // to whether the embedded document's contents are delivered securely // or not, and the sandboxing would possibly indicate that they were // not. To play it safe we return false here. (See bug 1162772 @@ -9846,17 +9848,17 @@ static void AppendNativeAnonymousChildre bool result = false; nsCOMPtr<nsIPrincipal> loadingPrincipal = aDefaultPrincipal; if (!loadingPrincipal) { loadingPrincipal = aLoadingNode->NodePrincipal(); } // If aLoadingNode is content, bail out early. - if (!aLoadingNode->NodePrincipal()->GetIsSystemPrincipal()) { + if (!aLoadingNode->NodePrincipal()->IsSystemPrincipal()) { loadingPrincipal.forget(aTriggeringPrincipal); return result; } nsAutoString loadingStr; if (aLoadingNode->IsElement()) { aLoadingNode->AsElement()->GetAttr( kNameSpaceID_None, nsGkAtoms::triggeringprincipal, loadingStr);
--- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1793,16 +1793,19 @@ class nsContentUtils { * * Note that this will check the innermost URI rather than that of * the nsIURI itself. */ 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. */ static bool IsExpandedPrincipal(nsIPrincipal* aPrincipal);
--- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -5517,17 +5517,17 @@ bool nsGlobalWindowOuter::GetPrincipalFo nsCOMPtr<nsIPrincipal> providedPrincipal; if (aTargetOrigin.EqualsASCII("/")) { providedPrincipal = aCallerPrincipal; } // "*" indicates no specific origin is required. else if (!aTargetOrigin.EqualsASCII("*")) { OriginAttributes attrs = aSubjectPrincipal.OriginAttributesRef(); - if (aSubjectPrincipal.GetIsSystemPrincipal()) { + if (aSubjectPrincipal.IsSystemPrincipal()) { auto principal = BasePrincipal::Cast(GetPrincipal()); if (attrs != principal->OriginAttributesRef()) { nsCOMPtr<nsIURI> targetURI; nsAutoCString targetURL; nsAutoCString sourceOrigin; nsAutoCString targetOrigin; @@ -5569,23 +5569,23 @@ bool nsGlobalWindowOuter::GetPrincipalFo OriginAttributes sourceAttrs = aSubjectPrincipal.OriginAttributesRef(); // We have to exempt the check of OA if the subject prioncipal is a system // principal since there are many tests try to post messages to content from // chrome with a mismatch OA. For example, using the ContentTask.spawn() to // post a message into a private browsing window. The injected code in // ContentTask.spawn() will be executed under the system principal and the // OA of the system principal mismatches with the OA of a private browsing // window. - MOZ_DIAGNOSTIC_ASSERT(aSubjectPrincipal.GetIsSystemPrincipal() || + MOZ_DIAGNOSTIC_ASSERT(aSubjectPrincipal.IsSystemPrincipal() || sourceAttrs.EqualsIgnoringFPD(targetAttrs)); // If 'privacy.firstparty.isolate.block_post_message' is true, we will block // postMessage across different first party domains. if (OriginAttributes::IsBlockPostMessageForFPI() && - !aSubjectPrincipal.GetIsSystemPrincipal() && + !aSubjectPrincipal.IsSystemPrincipal() && sourceAttrs.mFirstPartyDomain != targetAttrs.mFirstPartyDomain) { return false; } } providedPrincipal.forget(aProvidedPrincipal); return true; }
--- a/dom/events/Clipboard.cpp +++ b/dom/events/Clipboard.cpp @@ -1,15 +1,16 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * 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/AbstractThread.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/dom/Clipboard.h" #include "mozilla/dom/ClipboardBinding.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/DataTransfer.h" #include "mozilla/dom/DataTransferItemList.h" #include "mozilla/dom/DataTransferItem.h" #include "nsIClipboard.h" #include "nsISupportsPrimitives.h" @@ -178,17 +179,17 @@ JSObject* Clipboard::WrapObject(JSContex } /* static */ LogModule* Clipboard::GetClipboardLog() { return gClipboardLog; } /* static */ bool Clipboard::ReadTextEnabled(JSContext* aCx, JSObject* aGlobal) { nsIPrincipal* prin = nsContentUtils::SubjectPrincipal(aCx); return IsTestingPrefEnabled() || prin->GetIsAddonOrExpandedAddonPrincipal() || - prin->GetIsSystemPrincipal(); + prin->IsSystemPrincipal(); } /* static */ bool Clipboard::IsTestingPrefEnabled() { static bool sPrefCached = false; static bool sPrefCacheValue = false; if (!sPrefCached) { sPrefCached = true;
--- a/dom/media/DOMMediaStream.cpp +++ b/dom/media/DOMMediaStream.cpp @@ -8,16 +8,17 @@ #include "AudioCaptureStream.h" #include "AudioChannelAgent.h" #include "AudioStreamTrack.h" #include "Layers.h" #include "MediaStreamGraph.h" #include "MediaStreamGraphImpl.h" #include "MediaStreamListener.h" #include "VideoStreamTrack.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/dom/AudioNode.h" #include "mozilla/dom/AudioTrack.h" #include "mozilla/dom/AudioTrackList.h" #include "mozilla/dom/DocGroup.h" #include "mozilla/dom/HTMLCanvasElement.h" #include "mozilla/dom/MediaStreamBinding.h" #include "mozilla/dom/MediaStreamTrackEvent.h" #include "mozilla/dom/Promise.h" @@ -727,17 +728,17 @@ void DOMMediaStream::NotifyPrincipalChan LOG(LogLevel::Info, ("DOMMediaStream %p Principal changed to nothing.", this)); } else { LOG(LogLevel::Info, ("DOMMediaStream %p Principal changed. Now: " "null=%d, codebase=%d, expanded=%d, system=%d", this, mPrincipal->GetIsNullPrincipal(), mPrincipal->GetIsCodebasePrincipal(), mPrincipal->GetIsExpandedPrincipal(), - mPrincipal->GetIsSystemPrincipal())); + mPrincipal->IsSystemPrincipal())); } for (uint32_t i = 0; i < mPrincipalChangeObservers.Length(); ++i) { mPrincipalChangeObservers[i]->PrincipalChanged(this); } } bool DOMMediaStream::AddPrincipalChangeObserver(
--- a/dom/media/MediaStreamTrack.cpp +++ b/dom/media/MediaStreamTrack.cpp @@ -4,16 +4,17 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "MediaStreamTrack.h" #include "DOMMediaStream.h" #include "MediaStreamError.h" #include "MediaStreamGraph.h" #include "MediaStreamListener.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/dom/Promise.h" #include "nsContentUtils.h" #include "nsIUUIDGenerator.h" #include "nsServiceManagerUtils.h" #include "systemservices/MediaUtils.h" #ifdef LOG #undef LOG @@ -392,22 +393,22 @@ MediaStreamGraphImpl* MediaStreamTrack:: } void MediaStreamTrack::SetPrincipal(nsIPrincipal* aPrincipal) { if (aPrincipal == mPrincipal) { return; } mPrincipal = aPrincipal; - LOG(LogLevel::Info, ("MediaStreamTrack %p principal changed to %p. Now: " - "null=%d, codebase=%d, expanded=%d, system=%d", - this, mPrincipal.get(), mPrincipal->GetIsNullPrincipal(), - mPrincipal->GetIsCodebasePrincipal(), - mPrincipal->GetIsExpandedPrincipal(), - mPrincipal->GetIsSystemPrincipal())); + LOG(LogLevel::Info, + ("MediaStreamTrack %p principal changed to %p. Now: " + "null=%d, codebase=%d, expanded=%d, system=%d", + this, mPrincipal.get(), mPrincipal->GetIsNullPrincipal(), + mPrincipal->GetIsCodebasePrincipal(), + mPrincipal->GetIsExpandedPrincipal(), mPrincipal->IsSystemPrincipal())); for (PrincipalChangeObserver<MediaStreamTrack>* observer : mPrincipalChangeObservers) { observer->PrincipalChanged(this); } } void MediaStreamTrack::PrincipalChanged() { mPendingPrincipal = GetSource().GetPrincipal();
--- a/dom/security/nsContentSecurityManager.cpp +++ b/dom/security/nsContentSecurityManager.cpp @@ -16,16 +16,17 @@ #include "nsContentUtils.h" #include "nsCORSListenerProxy.h" #include "nsIStreamListener.h" #include "nsCDefaultURIFixup.h" #include "nsIURIFixup.h" #include "nsIImageLoadingContent.h" #include "nsIRedirectHistoryEntry.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/nsMixedContentBlocker.h" #include "mozilla/dom/TabChild.h" #include "mozilla/Logging.h" NS_IMPL_ISUPPORTS(nsContentSecurityManager, nsIContentSecurityManager, nsIChannelEventSink) @@ -998,17 +999,17 @@ nsContentSecurityManager::PerformSecurit NS_IMETHODIMP nsContentSecurityManager::IsOriginPotentiallyTrustworthy( nsIPrincipal* aPrincipal, bool* aIsTrustWorthy) { MOZ_ASSERT(NS_IsMainThread()); NS_ENSURE_ARG_POINTER(aPrincipal); NS_ENSURE_ARG_POINTER(aIsTrustWorthy); - if (aPrincipal->GetIsSystemPrincipal()) { + if (aPrincipal->IsSystemPrincipal()) { *aIsTrustWorthy = true; return NS_OK; } // The following implements: // https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy *aIsTrustWorthy = false;
--- a/dom/workers/WorkerLoadInfo.cpp +++ b/dom/workers/WorkerLoadInfo.cpp @@ -2,16 +2,17 @@ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * 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 "WorkerLoadInfo.h" #include "WorkerPrivate.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/dom/TabChild.h" #include "mozilla/ipc/BackgroundUtils.h" #include "mozilla/ipc/PBackgroundSharedTypes.h" #include "mozilla/LoadContext.h" #include "nsContentUtils.h" #include "nsIContentSecurityPolicy.h" #include "nsINetworkInterceptController.h" #include "nsIProtocolHandler.h" @@ -248,17 +249,17 @@ bool WorkerLoadInfo::PrincipalIsValid() bool WorkerLoadInfo::PrincipalURIMatchesScriptURL() { AssertIsOnMainThread(); nsAutoCString scheme; nsresult rv = mBaseURI->GetScheme(scheme); NS_ENSURE_SUCCESS(rv, false); // A system principal must either be a blob URL or a resource JSM. - if (mPrincipal->GetIsSystemPrincipal()) { + if (mPrincipal->IsSystemPrincipal()) { if (scheme == NS_LITERAL_CSTRING("blob")) { return true; } bool isResource = false; nsresult rv = NS_URIChainHasFlags( mBaseURI, nsIProtocolHandler::URI_IS_UI_RESOURCE, &isResource); NS_ENSURE_SUCCESS(rv, false);
--- a/js/xpconnect/loader/mozJSLoaderUtils.cpp +++ b/js/xpconnect/loader/mozJSLoaderUtils.cpp @@ -4,17 +4,17 @@ * 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/scache/StartupCache.h" #include "jsapi.h" #include "jsfriendapi.h" -#include "nsJSPrincipals.h" +#include "mozilla/BasePrincipal.h" using namespace JS; using namespace mozilla::scache; using mozilla::UniquePtr; // We only serialize scripts with system principals. So we don't serialize the // principals when writing a script. Instead, when reading it back, we set the // principals to the system principals. @@ -40,18 +40,18 @@ nsresult ReadCachedScript(StartupCache* MOZ_ASSERT((code & JS::TranscodeResult_Throw) != 0); JS_ClearPendingException(cx); return NS_ERROR_OUT_OF_MEMORY; } nsresult WriteCachedScript(StartupCache* cache, nsACString& uri, JSContext* cx, HandleScript script) { - MOZ_ASSERT(nsJSPrincipals::get(JS_GetScriptPrincipals(script)) - ->GetIsSystemPrincipal()); + MOZ_ASSERT( + nsJSPrincipals::get(JS_GetScriptPrincipals(script))->IsSystemPrincipal()); JS::TranscodeBuffer buffer; JS::TranscodeResult code = JS::EncodeScript(cx, buffer, script); if (code != JS::TranscodeResult_Ok) { if ((code & JS::TranscodeResult_Failure) != 0) { return NS_ERROR_FAILURE; } MOZ_ASSERT((code & JS::TranscodeResult_Throw) != 0);
--- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -259,17 +259,17 @@ void AssertLoadingPrincipalAndClientInfo // 2. Null principals currently require exact object identity for // nsIPrincipal::Equals() to return true. This doesn't work here because // ClientInfo::GetPrincipal() uses PrincipalInfoToPrincipal() to allocate // a new object. To work around this we compare the principal origin // string itself. If bug 1431771 is fixed then we could switch to // Equals(). // Allow worker debugger to load with a system principal. - if (aLoadingPrincipal->GetIsSystemPrincipal() && + if (aLoadingPrincipal->IsSystemPrincipal() && (aType == nsIContentPolicy::TYPE_INTERNAL_WORKER || aType == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER || aType == nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER || aType == nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS)) { return; } // Perform a fast comparison for most principal checks.
--- a/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp +++ b/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp @@ -1,16 +1,17 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * 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 "AddonManagerWebAPI.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/dom/Navigator.h" #include "mozilla/dom/NavigatorBinding.h" #include "mozilla/Preferences.h" #include "nsGlobalWindow.h" #include "xpcpublic.h" #include "nsIDocShell.h" @@ -115,17 +116,17 @@ bool AddonManagerWebAPI::IsAPIEnabled(JS nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal(); if (!principal) { return false; } // Reaching a window with a system principal means we have reached // privileged UI of some kind so stop at this point and allow access. - if (principal->GetIsSystemPrincipal()) { + if (principal->IsSystemPrincipal()) { return true; } nsCOMPtr<nsIDocShell> docShell = win->GetDocShell(); if (!docShell) { // This window has been torn down so don't allow access to the API. return false; }