зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1835907, part 5 - Refactor the window's mStorageAccessPermissionGranted variable and its Getters to a more accurate name: mUsingStorageAccess - r=anti-tracking-reviewers,pbz
This probably should have been done earlier, but became obvious with uses of Document::HasStorageAccessPermissionGrated in this stack. Differential Revision: https://phabricator.services.mozilla.com/D184825
This commit is contained in:
Родитель
03e2680076
Коммит
d2a4578703
|
@ -4018,8 +4018,7 @@ nsresult nsDocShell::LoadErrorPage(nsIURI* aErrorURI, nsIURI* aFailedURI,
|
|||
mBrowsingContext->GetCurrentInnerWindowId());
|
||||
nsPIDOMWindowInner* innerWin = mScriptGlobal->GetCurrentInnerWindow();
|
||||
if (innerWin) {
|
||||
loadState->SetTriggeringStorageAccess(
|
||||
innerWin->HasStorageAccessPermissionGranted());
|
||||
loadState->SetTriggeringStorageAccess(innerWin->UsingStorageAccess());
|
||||
}
|
||||
}
|
||||
loadState->SetLoadType(LOAD_ERROR_PAGE);
|
||||
|
@ -4208,7 +4207,7 @@ nsresult nsDocShell::ReloadDocument(nsDocShell* aDocShell, Document* aDocument,
|
|||
nsCOMPtr<nsIContentSecurityPolicy> csp = aDocument->GetCsp();
|
||||
uint32_t triggeringSandboxFlags = aDocument->GetSandboxFlags();
|
||||
uint64_t triggeringWindowId = aDocument->InnerWindowID();
|
||||
bool triggeringStorageAccess = aDocument->HasStorageAccessPermissionGranted();
|
||||
bool triggeringStorageAccess = aDocument->UsingStorageAccess();
|
||||
|
||||
nsAutoString contentTypeHint;
|
||||
aDocument->GetContentType(contentTypeHint);
|
||||
|
@ -5245,8 +5244,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
|
|||
doc->HasValidTransientUserGestureActivation());
|
||||
loadState->SetTriggeringSandboxFlags(doc->GetSandboxFlags());
|
||||
loadState->SetTriggeringWindowId(doc->InnerWindowID());
|
||||
loadState->SetTriggeringStorageAccess(
|
||||
doc->HasStorageAccessPermissionGranted());
|
||||
loadState->SetTriggeringStorageAccess(doc->UsingStorageAccess());
|
||||
}
|
||||
|
||||
loadState->SetPrincipalIsExplicit(true);
|
||||
|
@ -10535,7 +10533,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
|
|||
Document* contextDoc = context->GetExtantDoc();
|
||||
if (contextDoc) {
|
||||
aLoadState->SetTriggeringStorageAccess(
|
||||
contextDoc->HasStorageAccessPermissionGranted());
|
||||
contextDoc->UsingStorageAccess());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13072,8 +13070,7 @@ nsresult nsDocShell::OnLinkClickSync(nsIContent* aContent,
|
|||
if (mBrowsingContext) {
|
||||
triggeringSandboxFlags = aContent->OwnerDoc()->GetSandboxFlags();
|
||||
triggeringWindowId = aContent->OwnerDoc()->InnerWindowID();
|
||||
triggeringStorageAccess =
|
||||
aContent->OwnerDoc()->HasStorageAccessPermissionGranted();
|
||||
triggeringStorageAccess = aContent->OwnerDoc()->UsingStorageAccess();
|
||||
}
|
||||
|
||||
uint32_t flags = INTERNAL_LOAD_FLAGS_NONE;
|
||||
|
|
|
@ -18326,12 +18326,12 @@ nsICookieJarSettings* Document::CookieJarSettings() {
|
|||
return mCookieJarSettings;
|
||||
}
|
||||
|
||||
bool Document::HasStorageAccessPermissionGranted() {
|
||||
bool Document::UsingStorageAccess() {
|
||||
// The HasStoragePermission flag in LoadInfo remains fixed when
|
||||
// it is set in the parent process, so we need to check the cache
|
||||
// to see if the permission is granted afterwards.
|
||||
nsPIDOMWindowInner* inner = GetInnerWindow();
|
||||
if (inner && inner->HasStorageAccessPermissionGranted()) {
|
||||
if (inner && inner->UsingStorageAccess()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1424,8 +1424,8 @@ class Document : public nsINode,
|
|||
// Returns the cookie jar settings for this and sub contexts.
|
||||
nsICookieJarSettings* CookieJarSettings();
|
||||
|
||||
// Returns whether this document has the storage access permission.
|
||||
bool HasStorageAccessPermissionGranted();
|
||||
// Returns whether this document is using unpartitioned cookies
|
||||
bool UsingStorageAccess();
|
||||
|
||||
// Returns whether the storage access permission of the document is granted by
|
||||
// the allow list.
|
||||
|
|
|
@ -7659,14 +7659,12 @@ const nsIGlobalObject* nsPIDOMWindowInner::AsGlobal() const {
|
|||
}
|
||||
|
||||
void nsPIDOMWindowInner::SaveStorageAccessPermissionGranted() {
|
||||
mStorageAccessPermissionGranted = true;
|
||||
mUsingStorageAccess = true;
|
||||
|
||||
nsGlobalWindowInner::Cast(this)->StorageAccessPermissionGranted();
|
||||
}
|
||||
|
||||
bool nsPIDOMWindowInner::HasStorageAccessPermissionGranted() {
|
||||
return mStorageAccessPermissionGranted;
|
||||
}
|
||||
bool nsPIDOMWindowInner::UsingStorageAccess() { return mUsingStorageAccess; }
|
||||
|
||||
nsPIDOMWindowInner::nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow,
|
||||
WindowGlobalChild* aActor)
|
||||
|
@ -7690,7 +7688,7 @@ nsPIDOMWindowInner::nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow,
|
|||
mNumOfIndexedDBDatabases(0),
|
||||
mNumOfOpenWebSockets(0),
|
||||
mEvent(nullptr),
|
||||
mStorageAccessPermissionGranted(false),
|
||||
mUsingStorageAccess(false),
|
||||
mWindowGlobalChild(aActor),
|
||||
mWasSuspendedByGroup(false) {
|
||||
MOZ_ASSERT(aOuterWindow);
|
||||
|
|
|
@ -624,7 +624,7 @@ class nsPIDOMWindowInner : public mozIDOMWindow {
|
|||
|
||||
void SaveStorageAccessPermissionGranted();
|
||||
|
||||
bool HasStorageAccessPermissionGranted();
|
||||
bool UsingStorageAccess();
|
||||
|
||||
uint32_t UpdateLockCount(bool aIncrement) {
|
||||
MOZ_ASSERT_IF(!aIncrement, mLockCount > 0);
|
||||
|
@ -744,10 +744,8 @@ class nsPIDOMWindowInner : public mozIDOMWindow {
|
|||
mozilla::dom::Event* mEvent;
|
||||
|
||||
// A boolean flag indicating whether storage access is granted for the
|
||||
// current window. These are also set as permissions, but it could happen
|
||||
// that we need to access them synchronously in this context, and for
|
||||
// this, we need a copy here.
|
||||
bool mStorageAccessPermissionGranted;
|
||||
// current window and that it is currently being used by this window.
|
||||
bool mUsingStorageAccess;
|
||||
|
||||
// The WindowGlobalChild actor for this window.
|
||||
//
|
||||
|
|
|
@ -589,7 +589,7 @@ nsresult ServiceWorkerPrivate::Initialize() {
|
|||
/* useRegularPrincipal */ true,
|
||||
|
||||
// ServiceWorkers run as first-party, no storage-access permission needed.
|
||||
/* hasStorageAccessPermissionGranted */ false,
|
||||
/* usingStorageAccess */ false,
|
||||
|
||||
cjsData, domain,
|
||||
/* isSecureContext */ true,
|
||||
|
|
|
@ -98,7 +98,7 @@ WorkerLoadInfoData::WorkerLoadInfoData()
|
|||
mWatchedByDevTools(false),
|
||||
mStorageAccess(StorageAccess::eDeny),
|
||||
mUseRegularPrincipal(false),
|
||||
mHasStorageAccessPermissionGranted(false),
|
||||
mUsingStorageAccess(false),
|
||||
mServiceWorkersTestingInWindow(false),
|
||||
mShouldResistFingerprinting(false),
|
||||
mIsThirdPartyContextToTopWindow(true),
|
||||
|
|
|
@ -141,7 +141,7 @@ struct WorkerLoadInfoData {
|
|||
bool mWatchedByDevTools;
|
||||
StorageAccess mStorageAccess;
|
||||
bool mUseRegularPrincipal;
|
||||
bool mHasStorageAccessPermissionGranted;
|
||||
bool mUsingStorageAccess;
|
||||
bool mServiceWorkersTestingInWindow;
|
||||
bool mShouldResistFingerprinting;
|
||||
OriginAttributes mOriginAttributes;
|
||||
|
|
|
@ -2812,8 +2812,7 @@ nsresult WorkerPrivate::GetLoadInfo(
|
|||
aParent->AssociatedBrowsingContextID();
|
||||
loadInfo.mStorageAccess = aParent->StorageAccess();
|
||||
loadInfo.mUseRegularPrincipal = aParent->UseRegularPrincipal();
|
||||
loadInfo.mHasStorageAccessPermissionGranted =
|
||||
aParent->HasStorageAccessPermissionGranted();
|
||||
loadInfo.mUsingStorageAccess = aParent->UsingStorageAccess();
|
||||
loadInfo.mCookieJarSettings = aParent->CookieJarSettings();
|
||||
if (loadInfo.mCookieJarSettings) {
|
||||
loadInfo.mCookieJarSettingsArgs = aParent->CookieJarSettingsArgs();
|
||||
|
@ -2963,17 +2962,16 @@ nsresult WorkerPrivate::GetLoadInfo(
|
|||
globalWindow->GetBrowsingContext()->Id();
|
||||
loadInfo.mStorageAccess = StorageAllowedForWindow(globalWindow);
|
||||
loadInfo.mUseRegularPrincipal = document->UseRegularPrincipal();
|
||||
loadInfo.mHasStorageAccessPermissionGranted =
|
||||
document->HasStorageAccessPermissionGranted();
|
||||
loadInfo.mUsingStorageAccess = document->UsingStorageAccess();
|
||||
loadInfo.mShouldResistFingerprinting =
|
||||
document->ShouldResistFingerprinting(
|
||||
RFPTarget::IsAlwaysEnabledForPrecompute);
|
||||
|
||||
// This is an hack to deny the storage-access-permission for workers of
|
||||
// sub-iframes.
|
||||
if (loadInfo.mHasStorageAccessPermissionGranted &&
|
||||
if (loadInfo.mUsingStorageAccess &&
|
||||
StorageAllowedForDocument(document) != StorageAccess::eAllow) {
|
||||
loadInfo.mHasStorageAccessPermissionGranted = false;
|
||||
loadInfo.mUsingStorageAccess = false;
|
||||
}
|
||||
loadInfo.mIsThirdPartyContextToTopWindow =
|
||||
AntiTrackingUtils::IsThirdPartyWindow(globalWindow, nullptr);
|
||||
|
@ -3029,7 +3027,7 @@ nsresult WorkerPrivate::GetLoadInfo(
|
|||
loadInfo.mWindowID = UINT64_MAX;
|
||||
loadInfo.mStorageAccess = StorageAccess::eAllow;
|
||||
loadInfo.mUseRegularPrincipal = true;
|
||||
loadInfo.mHasStorageAccessPermissionGranted = false;
|
||||
loadInfo.mUsingStorageAccess = false;
|
||||
loadInfo.mCookieJarSettings =
|
||||
mozilla::net::CookieJarSettings::Create(loadInfo.mLoadingPrincipal);
|
||||
loadInfo.mShouldResistFingerprinting =
|
||||
|
@ -3083,9 +3081,8 @@ nsresult WorkerPrivate::GetLoadInfo(
|
|||
// well as the hasStoragePermission flag.
|
||||
nsCOMPtr<nsILoadInfo> channelLoadInfo = loadInfo.mChannel->LoadInfo();
|
||||
rv = channelLoadInfo->SetStoragePermission(
|
||||
loadInfo.mHasStorageAccessPermissionGranted
|
||||
? nsILoadInfo::HasStoragePermission
|
||||
: nsILoadInfo::NoStoragePermission);
|
||||
loadInfo.mUsingStorageAccess ? nsILoadInfo::HasStoragePermission
|
||||
: nsILoadInfo::NoStoragePermission);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = loadInfo.SetPrincipalsAndCSPFromChannel(loadInfo.mChannel);
|
||||
|
@ -4117,7 +4114,7 @@ void WorkerPrivate::PropagateStorageAccessPermissionGrantedInternal() {
|
|||
auto data = mWorkerThreadAccessible.Access();
|
||||
|
||||
mLoadInfo.mUseRegularPrincipal = true;
|
||||
mLoadInfo.mHasStorageAccessPermissionGranted = true;
|
||||
mLoadInfo.mUsingStorageAccess = true;
|
||||
|
||||
WorkerGlobalScope* globalScope = GlobalScope();
|
||||
if (globalScope) {
|
||||
|
|
|
@ -934,7 +934,7 @@ class WorkerPrivate final
|
|||
|
||||
mozilla::StorageAccess StorageAccess() const {
|
||||
AssertIsOnWorkerThread();
|
||||
if (mLoadInfo.mHasStorageAccessPermissionGranted) {
|
||||
if (mLoadInfo.mUsingStorageAccess) {
|
||||
return mozilla::StorageAccess::eAllow;
|
||||
}
|
||||
|
||||
|
@ -946,9 +946,9 @@ class WorkerPrivate final
|
|||
return mLoadInfo.mUseRegularPrincipal;
|
||||
}
|
||||
|
||||
bool HasStorageAccessPermissionGranted() const {
|
||||
bool UsingStorageAccess() const {
|
||||
AssertIsOnWorkerThread();
|
||||
return mLoadInfo.mHasStorageAccessPermissionGranted;
|
||||
return mLoadInfo.mUsingStorageAccess;
|
||||
}
|
||||
|
||||
nsICookieJarSettings* CookieJarSettings() const {
|
||||
|
|
|
@ -260,8 +260,7 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(RemoteWorkerData&& aData) {
|
|||
info.mLoadingPrincipal = loadingPrincipalOrErr.unwrap();
|
||||
info.mStorageAccess = aData.storageAccess();
|
||||
info.mUseRegularPrincipal = aData.useRegularPrincipal();
|
||||
info.mHasStorageAccessPermissionGranted =
|
||||
aData.hasStorageAccessPermissionGranted();
|
||||
info.mUsingStorageAccess = aData.usingStorageAccess();
|
||||
info.mIsThirdPartyContextToTopWindow = aData.isThirdPartyContextToTopWindow();
|
||||
info.mOriginAttributes =
|
||||
BasePrincipal::Cast(principal)->OriginAttributesRef();
|
||||
|
|
|
@ -62,7 +62,7 @@ struct RemoteWorkerData
|
|||
PrincipalInfo partitionedPrincipalInfo;
|
||||
|
||||
bool useRegularPrincipal;
|
||||
bool hasStorageAccessPermissionGranted;
|
||||
bool usingStorageAccess;
|
||||
|
||||
CookieJarSettingsArgs cookieJarSettings;
|
||||
|
||||
|
|
|
@ -236,8 +236,8 @@ already_AddRefed<SharedWorker> SharedWorker::Constructor(
|
|||
nsString(aScriptURL), baseURL, resolvedScriptURL, name, workerType,
|
||||
credentials, loadingPrincipalInfo, principalInfo,
|
||||
partitionedPrincipalInfo, loadInfo.mUseRegularPrincipal,
|
||||
loadInfo.mHasStorageAccessPermissionGranted, cjsData, loadInfo.mDomain,
|
||||
isSecureContext, ipcClientInfo, loadInfo.mReferrerInfo, storageAllowed,
|
||||
loadInfo.mUsingStorageAccess, cjsData, loadInfo.mDomain, isSecureContext,
|
||||
ipcClientInfo, loadInfo.mReferrerInfo, storageAllowed,
|
||||
AntiTrackingUtils::IsThirdPartyWindow(window, nullptr),
|
||||
loadInfo.mShouldResistFingerprinting,
|
||||
OriginTrials::FromWindow(nsGlobalWindowInner::Cast(window)),
|
||||
|
|
|
@ -607,16 +607,16 @@ bool ShouldAllowAccessFor(nsPIDOMWindowInner* aWindow, nsIURI* aURI,
|
|||
return false;
|
||||
}
|
||||
|
||||
// Document::HasStoragePermission first checks if storage access granted is
|
||||
// Document::UsingStorageAccess first checks if storage access granted is
|
||||
// cached in the inner window, if no, it then checks the storage permission
|
||||
// flag in the channel's loadinfo
|
||||
bool allowed = document->HasStorageAccessPermissionGranted();
|
||||
bool allowed = document->UsingStorageAccess();
|
||||
|
||||
if (!allowed) {
|
||||
*aRejectedReason = blockedReason;
|
||||
} else {
|
||||
if (MOZ_LOG_TEST(gAntiTrackingLog, mozilla::LogLevel::Debug) &&
|
||||
aWindow->HasStorageAccessPermissionGranted()) {
|
||||
aWindow->UsingStorageAccess()) {
|
||||
LOG(("Permission stored in the window. All good."));
|
||||
}
|
||||
}
|
||||
|
@ -807,7 +807,7 @@ bool ShouldAllowAccessFor(nsIChannel* aChannel, nsIURI* aURI,
|
|||
|
||||
// Let's see if we have to grant the access for this particular channel.
|
||||
|
||||
// HasStorageAccessPermissionGranted only applies to channels that load
|
||||
// UsingStorageAccess only applies to channels that load
|
||||
// documents, for sub-resources loads, just returns the result from loadInfo.
|
||||
bool isDocument = false;
|
||||
aChannel->GetIsDocument(&isDocument);
|
||||
|
@ -815,7 +815,7 @@ bool ShouldAllowAccessFor(nsIChannel* aChannel, nsIURI* aURI,
|
|||
if (isDocument) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> inner =
|
||||
AntiTrackingUtils::GetInnerWindow(targetBC);
|
||||
if (inner && inner->HasStorageAccessPermissionGranted()) {
|
||||
if (inner && inner->UsingStorageAccess()) {
|
||||
LOG(("Permission stored in the window. All good."));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1006,7 +1006,7 @@ StorageAccessAPIHelper::CheckExistingPermissionDecidesStorageAccessAPI(
|
|||
}
|
||||
return Some(false);
|
||||
}
|
||||
if (aDocument->HasStorageAccessPermissionGranted()) {
|
||||
if (aDocument->UsingStorageAccess()) {
|
||||
return Some(true);
|
||||
}
|
||||
return Nothing();
|
||||
|
|
|
@ -1282,7 +1282,7 @@ nsresult nsWindowWatcher::OpenWindowInternal(
|
|||
if (parentInnerWin) {
|
||||
loadState->SetTriggeringWindowId(parentInnerWin->WindowID());
|
||||
loadState->SetTriggeringStorageAccess(
|
||||
parentInnerWin->HasStorageAccessPermissionGranted());
|
||||
parentInnerWin->UsingStorageAccess());
|
||||
}
|
||||
|
||||
if (subjectPrincipal) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче