forked from mirrors/gecko-dev
Backed out 9 changesets (bug 1469993) for causing bustage in build/srcdom/base/nsGlobalWindowInner.cpp on a CLOSED TREE
Backed out changeset e89192032fe2 (bug 1469993) Backed out changeset 4b261595099d (bug 1469993) Backed out changeset 37182cfe869c (bug 1469993) Backed out changeset 5b9870995c73 (bug 1469993) Backed out changeset 55499fcd9738 (bug 1469993) Backed out changeset 8c1c838d54ba (bug 1469993) Backed out changeset 12b9c8bfa41f (bug 1469993) Backed out changeset 04ab7d6c169a (bug 1469993) Backed out changeset 53885d61244e (bug 1469993)
This commit is contained in:
parent
0b89c91c62
commit
c37b51f523
51 changed files with 270 additions and 1273 deletions
|
|
@ -515,6 +515,41 @@ EventListenerManagerHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
|||
lm->~EventListenerManagerMapEntry();
|
||||
}
|
||||
|
||||
static bool
|
||||
IsThirdPartyWindowOrChannel(nsPIDOMWindowInner* aWindow,
|
||||
nsIChannel* aChannel,
|
||||
nsIURI* aURI)
|
||||
{
|
||||
MOZ_ASSERT(!aWindow || !aChannel,
|
||||
"A window and channel should not both be provided.");
|
||||
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
|
||||
if (!thirdPartyUtil) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// In the absence of a window or channel, we assume that we are first-party.
|
||||
bool thirdParty = false;
|
||||
|
||||
if (aWindow) {
|
||||
Unused << thirdPartyUtil->IsThirdPartyWindow(aWindow->GetOuterWindow(),
|
||||
aURI,
|
||||
&thirdParty);
|
||||
}
|
||||
|
||||
if (aChannel) {
|
||||
// Note, we must call IsThirdPartyChannel() here and not just try to
|
||||
// use nsILoadInfo.isThirdPartyContext. That nsILoadInfo property only
|
||||
// indicates if the parent loading window is third party or not. We
|
||||
// want to check the channel URI against the loading principal as well.
|
||||
Unused << thirdPartyUtil->IsThirdPartyChannel(aChannel,
|
||||
nullptr,
|
||||
&thirdParty);
|
||||
}
|
||||
|
||||
return thirdParty;
|
||||
}
|
||||
|
||||
class SameOriginCheckerImpl final : public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
|
|
@ -8802,42 +8837,6 @@ nsContentUtils::GetCookieBehaviorForPrincipal(nsIPrincipal* aPrincipal,
|
|||
}
|
||||
}
|
||||
|
||||
// static public
|
||||
bool
|
||||
nsContentUtils::IsThirdPartyWindowOrChannel(nsPIDOMWindowInner* aWindow,
|
||||
nsIChannel* aChannel,
|
||||
nsIURI* aURI)
|
||||
{
|
||||
MOZ_ASSERT(!aWindow || !aChannel,
|
||||
"A window and channel should not both be provided.");
|
||||
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
|
||||
if (!thirdPartyUtil) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// In the absence of a window or channel, we assume that we are first-party.
|
||||
bool thirdParty = false;
|
||||
|
||||
if (aWindow) {
|
||||
Unused << thirdPartyUtil->IsThirdPartyWindow(aWindow->GetOuterWindow(),
|
||||
aURI,
|
||||
&thirdParty);
|
||||
}
|
||||
|
||||
if (aChannel) {
|
||||
// Note, we must call IsThirdPartyChannel() here and not just try to
|
||||
// use nsILoadInfo.isThirdPartyContext. That nsILoadInfo property only
|
||||
// indicates if the parent loading window is third party or not. We
|
||||
// want to check the channel URI against the loading principal as well.
|
||||
Unused << thirdPartyUtil->IsThirdPartyChannel(aChannel,
|
||||
nullptr,
|
||||
&thirdParty);
|
||||
}
|
||||
|
||||
return thirdParty;
|
||||
}
|
||||
|
||||
// static public
|
||||
bool
|
||||
nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
|
||||
|
|
@ -8853,54 +8852,19 @@ nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (aWindow) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel;
|
||||
nsIDocument* document = aWindow->GetExtantDoc();
|
||||
if (document) {
|
||||
httpChannel = do_QueryInterface(document->GetChannel());
|
||||
}
|
||||
|
||||
// If this is not a tracking resource, nothing is disabled.
|
||||
if (!httpChannel || !httpChannel->GetIsTrackingResource()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Maybe we want to grant this origin.
|
||||
nsIURI* documentURI = aURI ? aURI : aWindow->GetDocumentURI();
|
||||
if (documentURI &&
|
||||
nsGlobalWindowInner::Cast(aWindow)->IsFirstPartyStorageAccessGrantedFor(documentURI)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
|
||||
// aChannel and aWindow are mutually exclusive.
|
||||
MOZ_ASSERT(aChannel);
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (!httpChannel) {
|
||||
return false;
|
||||
channel = aChannel;
|
||||
if (aWindow) {
|
||||
nsIDocument* document = aWindow->GetExtantDoc();
|
||||
if (document) {
|
||||
channel = document->GetChannel();
|
||||
}
|
||||
}
|
||||
|
||||
// If this is not a tracking resource, nothing is disabled.
|
||||
if (!httpChannel->GetIsTrackingResource()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = httpChannel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
rv = aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !loadInfo->IsFirstPartyStorageAccessGrantedFor(uri);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
return httpChannel && httpChannel->GetIsTrackingResource();
|
||||
}
|
||||
|
||||
// static, private
|
||||
|
|
|
|||
|
|
@ -2957,13 +2957,6 @@ public:
|
|||
nsIChannel* aChannel,
|
||||
nsIURI* aURI);
|
||||
|
||||
/*
|
||||
* Returns true if this window/channel is a 3rd party context.
|
||||
*/
|
||||
static bool IsThirdPartyWindowOrChannel(nsPIDOMWindowInner* aWindow,
|
||||
nsIChannel* aChannel,
|
||||
nsIURI* aURI);
|
||||
|
||||
/*
|
||||
* Serializes a HTML nsINode into its markup representation.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
#include "mozilla/URLExtraData.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
|
@ -12416,62 +12415,10 @@ nsIDocument::NotifyUserGestureActivation()
|
|||
LogLevel::Debug,
|
||||
("Document %p has been activated by user.", this));
|
||||
doc->mUserGestureActivated = true;
|
||||
doc->MaybeAllowStorageForOpener();
|
||||
doc = doc->GetSameTypeParentDocument();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsIDocument::MaybeAllowStorageForOpener()
|
||||
{
|
||||
if (!StaticPrefs::privacy_restrict3rdpartystorage_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This will probably change for project fission, but currently this document
|
||||
// and the opener are on the same process. In the future, we should make this
|
||||
// part async.
|
||||
|
||||
nsPIDOMWindowInner* inner = GetInnerWindow();
|
||||
if (NS_WARN_IF(!inner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> outer = inner->GetOuterWindow();
|
||||
if (NS_WARN_IF(!outer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> outerOpener = outer->GetOpener();
|
||||
if (NS_WARN_IF(!outerOpener)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* openerInner = outerOpener->GetCurrentInnerWindow();
|
||||
if (NS_WARN_IF(!openerInner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// No 3rd party.
|
||||
if (!nsContentUtils::IsThirdPartyWindowOrChannel(openerInner, nullptr,
|
||||
nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri = GetDocumentURI();
|
||||
if (NS_WARN_IF(!uri)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString origin;
|
||||
nsresult rv = nsContentUtils::GetUTFOrigin(uri, origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsGlobalWindowInner::Cast(openerInner)->AddFirstPartyStorageAccessGrantedFor(origin);
|
||||
}
|
||||
|
||||
bool
|
||||
nsIDocument::HasBeenUserGestureActivated()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
#include "mozilla/dom/WindowOrientationObserver.h"
|
||||
#endif
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
#include "nsDOMOfflineResourceList.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIIdleService.h"
|
||||
|
|
@ -49,7 +48,6 @@
|
|||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIPermission.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptTimeoutHandler.h"
|
||||
|
|
@ -334,10 +332,6 @@ using mozilla::dom::cache::CacheStorage;
|
|||
// Min idle notification time in seconds.
|
||||
#define MIN_IDLE_NOTIFICATION_TIME_S 1
|
||||
|
||||
// Anti-tracking permission expiration
|
||||
#define ANTITRACKING_EXPIRATION 2592000000 // 30 days.
|
||||
#define ANTITRACKING_PERM_KEY "3rdPartyStorage"
|
||||
|
||||
static LazyLogModule gDOMLeakPRLogInner("DOMLeakInner");
|
||||
|
||||
static bool gIdleObserversAPIFuzzTimeDisabled = false;
|
||||
|
|
@ -922,8 +916,7 @@ nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter *aOuterWindow)
|
|||
mObservingDidRefresh(false),
|
||||
mIteratingDocumentFlushedResolvers(false),
|
||||
mCanSkipCCGeneration(0),
|
||||
mBeforeUnloadListenerCount(0),
|
||||
mStorageGrantedOriginPopulated(false)
|
||||
mBeforeUnloadListenerCount(0)
|
||||
{
|
||||
mIsInnerWindow = true;
|
||||
|
||||
|
|
@ -1241,7 +1234,6 @@ nsGlobalWindowInner::FreeInnerObjects()
|
|||
}
|
||||
|
||||
UnlinkHostObjectURIs();
|
||||
ReleaseFirstPartyStorageAccessGrantedOrigins();
|
||||
|
||||
NotifyWindowIDDestroyed("inner-window-destroyed");
|
||||
|
||||
|
|
@ -1565,7 +1557,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner)
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mIntlUtils)
|
||||
|
||||
tmp->UnlinkHostObjectURIs();
|
||||
tmp->ReleaseFirstPartyStorageAccessGrantedOrigins();
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleRequestExecutor)
|
||||
|
||||
|
|
@ -5203,8 +5194,17 @@ nsGlobalWindowInner::GetCaches(ErrorResult& aRv)
|
|||
if (!mCacheStorage) {
|
||||
bool forceTrustedOrigin =
|
||||
GetOuterWindow()->GetServiceWorkersTestingEnabled();
|
||||
|
||||
nsContentUtils::StorageAccess access =
|
||||
nsContentUtils::StorageAllowedForWindow(this);
|
||||
|
||||
// We don't block the cache API when being told to only allow storage for the
|
||||
// current session.
|
||||
bool storageBlocked = access <= nsContentUtils::StorageAccess::ePrivateBrowsing;
|
||||
|
||||
mCacheStorage = CacheStorage::CreateOnMainThread(cache::DEFAULT_NAMESPACE,
|
||||
this, GetPrincipal(),
|
||||
storageBlocked,
|
||||
forceTrustedOrigin, aRv);
|
||||
}
|
||||
|
||||
|
|
@ -6515,34 +6515,6 @@ nsGlobalWindowInner::GetParentInternal()
|
|||
return outer->GetParentInternal();
|
||||
}
|
||||
|
||||
nsIPrincipal*
|
||||
nsGlobalWindowInner::GetTopLevelStorageAreaPrincipal()
|
||||
{
|
||||
nsPIDOMWindowOuter* outerWindow = GetParentInternal();
|
||||
if (!outerWindow) {
|
||||
// No outer window available!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!outerWindow->IsTopLevelWindow()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* innerWindow = outerWindow->GetCurrentInnerWindow();
|
||||
if (NS_WARN_IF(!innerWindow)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIPrincipal* parentPrincipal =
|
||||
nsGlobalWindowInner::Cast(innerWindow)->GetPrincipal();
|
||||
if (NS_WARN_IF(!parentPrincipal)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return parentPrincipal;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// nsGlobalWindowInner: Timeout Functions
|
||||
//*****************************************************************************
|
||||
|
|
@ -8062,274 +8034,6 @@ nsGlobalWindowInner::GetRegionalPrefsLocales(nsTArray<nsString>& aLocales)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowInner::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigin,
|
||||
bool aOverwritten)
|
||||
{
|
||||
MOZ_ASSERT(StaticPrefs::privacy_restrict3rdpartystorage_enabled());
|
||||
|
||||
if (aOverwritten) {
|
||||
SaveFirstPartyStorageAccessGrantedFor(aOrigin);
|
||||
}
|
||||
|
||||
for (StorageGrantedOrigin& data : mStorageGrantedOrigins) {
|
||||
if (data.mOrigin == aOrigin) {
|
||||
data.mOverwritten = aOverwritten;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool wasAllowed =
|
||||
nsContentUtils::StorageDisabledByAntiTracking(this, nullptr, nullptr);
|
||||
|
||||
StorageGrantedOrigin* data = mStorageGrantedOrigins.AppendElement();
|
||||
data->mOrigin = aOrigin;
|
||||
data->mOverwritten = aOverwritten;
|
||||
|
||||
if (!wasAllowed &&
|
||||
nsContentUtils::StorageDisabledByAntiTracking(this, nullptr, nullptr)) {
|
||||
PropagateFirstPartyStorageAccessGrantedToWorkers(this);
|
||||
}
|
||||
|
||||
// Let's store the origin in the loadInfo as well.
|
||||
if (mDoc) {
|
||||
nsCOMPtr<nsIChannel> channel = mDoc->GetChannel();
|
||||
if (channel) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
if (loadInfo) {
|
||||
loadInfo->AddFirstPartyStorageAccessGrantedFor(aOrigin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowInner::GetFirstPartyStorageAccessGrantedOrigins(nsTArray<nsString>& aOrigin)
|
||||
{
|
||||
aOrigin.Clear();
|
||||
|
||||
if (!StaticPrefs::privacy_restrict3rdpartystorage_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MaybeRestoreFirstPartyStorageAccessGrantedOrigins();
|
||||
for (const StorageGrantedOrigin& data : mStorageGrantedOrigins) {
|
||||
aOrigin.AppendElement(data.mOrigin);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsGlobalWindowInner::IsFirstPartyStorageAccessGrantedFor(nsIURI* aURI)
|
||||
{
|
||||
MOZ_ASSERT(aURI);
|
||||
|
||||
if (!StaticPrefs::privacy_restrict3rdpartystorage_enabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MaybeRestoreFirstPartyStorageAccessGrantedOrigins();
|
||||
|
||||
if (mStorageGrantedOrigins.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoString origin;
|
||||
nsresult rv = nsContentUtils::GetUTFOrigin(aURI, origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const StorageGrantedOrigin& data : mStorageGrantedOrigins) {
|
||||
if (data.mOrigin.Equals(origin)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowInner::ReleaseFirstPartyStorageAccessGrantedOrigins()
|
||||
{
|
||||
mStorageGrantedOriginPopulated = false;
|
||||
mStorageGrantedOrigins.Clear();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowInner::SaveFirstPartyStorageAccessGrantedFor(const nsAString& aOrigin)
|
||||
{
|
||||
MOZ_ASSERT(StaticPrefs::privacy_restrict3rdpartystorage_enabled());
|
||||
|
||||
// Now we need the principal and the origin of the parent window.
|
||||
nsIPrincipal* parentPrincipal = GetTopLevelStorageAreaPrincipal();
|
||||
if (NS_WARN_IF(!parentPrincipal)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString parentOrigin;
|
||||
nsresult rv = parentPrincipal->GetOriginNoSuffix(parentOrigin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's take the principal and the origin of the current window.
|
||||
nsIPrincipal* principal = GetPrincipal();
|
||||
if (NS_WARN_IF(!principal)) {
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ConvertUTF16toUTF8 grantedOrigin(aOrigin);
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(principal,
|
||||
parentOrigin,
|
||||
grantedOrigin);
|
||||
return;
|
||||
}
|
||||
|
||||
// We have this external function because ContentChild includes windows.h and
|
||||
// for this reason it cannot be included here.
|
||||
SendFirstPartyStorageAccessGrantedForOriginToParentProcess(principal,
|
||||
parentOrigin,
|
||||
grantedOrigin);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsGlobalWindowInner::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(nsIPrincipal* aPrincipal,
|
||||
const nsCString& aParentOrigin,
|
||||
const nsCString& aGrantedOrigin)
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
|
||||
nsAutoCString origin;
|
||||
nsresult rv = aPrincipal->GetOriginNoSuffix(origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> pm = services::GetPermissionManager();
|
||||
if (NS_WARN_IF(!pm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t when = (PR_Now() / PR_USEC_PER_MSEC) + ANTITRACKING_EXPIRATION;
|
||||
|
||||
// We store a permission for the 3rd party principal, to know that we grant
|
||||
// the storage permission when loaded by the current parent origin.
|
||||
nsAutoCString type;
|
||||
if (origin == aGrantedOrigin) {
|
||||
type = nsPrintfCString(ANTITRACKING_PERM_KEY "^%s", aParentOrigin.get());
|
||||
} else {
|
||||
type = nsPrintfCString(ANTITRACKING_PERM_KEY "^%s^%s", aParentOrigin.get(),
|
||||
aGrantedOrigin.get());
|
||||
}
|
||||
|
||||
rv = pm->AddFromPrincipal(aPrincipal, type.get(),
|
||||
nsIPermissionManager::ALLOW_ACTION,
|
||||
nsIPermissionManager::EXPIRE_TIME, when);
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowInner::MaybeRestoreFirstPartyStorageAccessGrantedOrigins()
|
||||
{
|
||||
if (!StaticPrefs::privacy_restrict3rdpartystorage_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mStorageGrantedOriginPopulated) {
|
||||
return;
|
||||
}
|
||||
|
||||
mStorageGrantedOriginPopulated = true;
|
||||
|
||||
// Now we need the principal and the origin of the parent window.
|
||||
nsIPrincipal* parentPrincipal = GetTopLevelStorageAreaPrincipal();
|
||||
if (!parentPrincipal) {
|
||||
// No parent window.
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString parentOrigin;
|
||||
nsresult rv = parentPrincipal->GetOriginNoSuffix(parentOrigin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's take the principal and the origin of the current window.
|
||||
nsIPrincipal* principal = GetPrincipal();
|
||||
if (NS_WARN_IF(!principal)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString origin;
|
||||
rv = principal->GetOriginNoSuffix(origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> pm = services::GetPermissionManager();
|
||||
if (NS_WARN_IF(!pm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = pm->GetAllForPrincipal(principal, getter_AddRefs(enumerator));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool more = false;
|
||||
nsCOMPtr<nsISupports> iter;
|
||||
nsCOMPtr<nsIPermission> perm;
|
||||
while (NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && more) {
|
||||
rv = enumerator->GetNext(getter_AddRefs(iter));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
perm = do_QueryInterface(iter);
|
||||
if (NS_WARN_IF(!perm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString type;
|
||||
rv = perm->GetType(type);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!StringBeginsWith(type, NS_LITERAL_CSTRING(ANTITRACKING_PERM_KEY "^"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCCharSeparatedTokenizer token(type, '^');
|
||||
MOZ_ASSERT(token.hasMoreTokens());
|
||||
auto value = token.nextToken();
|
||||
MOZ_ASSERT(value.EqualsLiteral(ANTITRACKING_PERM_KEY));
|
||||
|
||||
nsAutoCString originA;
|
||||
if (token.hasMoreTokens()) {
|
||||
originA = token.nextToken();
|
||||
}
|
||||
|
||||
// This permission was granted for another top-level window.
|
||||
if (originA != parentOrigin) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsAutoCString originB;
|
||||
if (token.hasMoreTokens()) {
|
||||
originB = token.nextToken();
|
||||
}
|
||||
|
||||
AddFirstPartyStorageAccessGrantedFor(NS_ConvertUTF8toUTF16(originB.IsEmpty() ? origin : originB),
|
||||
false /* no overwrite */);
|
||||
}
|
||||
}
|
||||
|
||||
IntlUtils*
|
||||
nsGlobalWindowInner::GetIntlUtils(ErrorResult& aError)
|
||||
{
|
||||
|
|
@ -8476,15 +8180,8 @@ nsPIDOMWindowInner::GetAutoplayRequest()
|
|||
// XXX: Can we define this in a header instead of here?
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
extern uint64_t
|
||||
NextWindowID();
|
||||
|
||||
extern void
|
||||
SendFirstPartyStorageAccessGrantedForOriginToParentProcess(nsIPrincipal* aPrincipal,
|
||||
const nsACString& aParentOrigin,
|
||||
const nsACString& aGrantedOrigin);
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
|||
|
|
@ -717,20 +717,6 @@ public:
|
|||
mozilla::dom::IntlUtils*
|
||||
GetIntlUtils(mozilla::ErrorResult& aRv);
|
||||
|
||||
void
|
||||
AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigin, bool aOverwritten = true);
|
||||
|
||||
void
|
||||
GetFirstPartyStorageAccessGrantedOrigins(nsTArray<nsString>& aOrigins);
|
||||
|
||||
bool
|
||||
IsFirstPartyStorageAccessGrantedFor(nsIURI* aURI);
|
||||
|
||||
static void
|
||||
SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(nsIPrincipal* aPrincipal,
|
||||
const nsCString& aParentOrigin,
|
||||
const nsCString& aGrantedOrigin);
|
||||
|
||||
public:
|
||||
void Alert(nsIPrincipal& aSubjectPrincipal,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
|
@ -1073,15 +1059,6 @@ protected:
|
|||
mozilla::dom::CallerType aCallerType,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
void
|
||||
ReleaseFirstPartyStorageAccessGrantedOrigins();
|
||||
|
||||
void
|
||||
SaveFirstPartyStorageAccessGrantedFor(const nsAString& aOrigin);
|
||||
|
||||
void
|
||||
MaybeRestoreFirstPartyStorageAccessGrantedOrigins();
|
||||
|
||||
// Array of idle observers that are notified of idle events.
|
||||
nsTObserverArray<IdleObserverHolder> mIdleObservers;
|
||||
|
||||
|
|
@ -1129,9 +1106,6 @@ protected:
|
|||
// Get the parent, returns null if this is a toplevel window
|
||||
nsPIDOMWindowOuter* GetParentInternal();
|
||||
|
||||
// Get the parent principal, returns null if this is a toplevel window.
|
||||
nsIPrincipal* GetTopLevelStorageAreaPrincipal();
|
||||
|
||||
public:
|
||||
// popup tracking
|
||||
bool IsPopupSpamWindow();
|
||||
|
|
@ -1502,13 +1476,6 @@ protected:
|
|||
|
||||
nsTArray<mozilla::UniquePtr<PromiseDocumentFlushedResolver>> mDocumentFlushedResolvers;
|
||||
|
||||
struct StorageGrantedOrigin {
|
||||
nsString mOrigin;
|
||||
bool mOverwritten;
|
||||
};
|
||||
nsTArray<StorageGrantedOrigin> mStorageGrantedOrigins;
|
||||
bool mStorageGrantedOriginPopulated;
|
||||
|
||||
static InnerWindowByIdTable* sInnerWindowsById;
|
||||
|
||||
// Members in the mChromeFields member should only be used in chrome windows.
|
||||
|
|
|
|||
|
|
@ -3682,8 +3682,6 @@ protected:
|
|||
// Return the same type parent docuement if exists, or return null.
|
||||
nsIDocument* GetSameTypeParentDocument();
|
||||
|
||||
void MaybeAllowStorageForOpener();
|
||||
|
||||
// Helpers for GetElementsByName.
|
||||
static bool MatchNameAttribute(mozilla::dom::Element* aElement,
|
||||
int32_t aNamespaceID,
|
||||
|
|
|
|||
71
dom/cache/CacheStorage.cpp
vendored
71
dom/cache/CacheStorage.cpp
vendored
|
|
@ -139,13 +139,19 @@ IsTrusted(const PrincipalInfo& aPrincipalInfo, bool aTestingPrefEnabled)
|
|||
// static
|
||||
already_AddRefed<CacheStorage>
|
||||
CacheStorage::CreateOnMainThread(Namespace aNamespace, nsIGlobalObject* aGlobal,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsIPrincipal* aPrincipal, bool aStorageDisabled,
|
||||
bool aForceTrustedOrigin, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aGlobal);
|
||||
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aStorageDisabled) {
|
||||
NS_WARNING("CacheStorage has been disabled.");
|
||||
RefPtr<CacheStorage> ref = new CacheStorage(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
PrincipalInfo principalInfo;
|
||||
nsresult rv = PrincipalToPrincipalInfo(aPrincipal, &principalInfo);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
|
@ -164,7 +170,7 @@ CacheStorage::CreateOnMainThread(Namespace aNamespace, nsIGlobalObject* aGlobal,
|
|||
}
|
||||
|
||||
RefPtr<CacheStorage> ref = new CacheStorage(aNamespace, aGlobal,
|
||||
principalInfo, nullptr);
|
||||
principalInfo, nullptr);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
|
|
@ -177,6 +183,12 @@ CacheStorage::CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
|
|||
MOZ_DIAGNOSTIC_ASSERT(aWorkerPrivate);
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
if (!aWorkerPrivate->IsStorageAllowed()) {
|
||||
NS_WARNING("CacheStorage is not allowed.");
|
||||
RefPtr<CacheStorage> ref = new CacheStorage(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
if (aWorkerPrivate->GetOriginAttributes().mPrivateBrowsingId > 0) {
|
||||
NS_WARNING("CacheStorage not supported during private browsing.");
|
||||
RefPtr<CacheStorage> ref = new CacheStorage(NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
|
@ -243,6 +255,7 @@ CacheStorage::DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
|
|||
ErrorResult rv;
|
||||
RefPtr<CacheStorage> storage =
|
||||
CreateOnMainThread(DEFAULT_NAMESPACE, xpc::NativeGlobal(aGlobal), principal,
|
||||
false, /* private browsing */
|
||||
true, /* force trusted */
|
||||
rv);
|
||||
if (NS_WARN_IF(rv.MaybeSetPendingException(aCx))) {
|
||||
|
|
@ -306,11 +319,6 @@ CacheStorage::Match(JSContext* aCx, const RequestOrUSVString& aRequest,
|
|||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStorage);
|
||||
|
||||
if (!HasStorageAccess()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(mStatus))) {
|
||||
aRv.Throw(mStatus);
|
||||
return nullptr;
|
||||
|
|
@ -345,11 +353,6 @@ CacheStorage::Has(const nsAString& aKey, ErrorResult& aRv)
|
|||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStorage);
|
||||
|
||||
if (!HasStorageAccess()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(mStatus))) {
|
||||
aRv.Throw(mStatus);
|
||||
return nullptr;
|
||||
|
|
@ -374,11 +377,6 @@ CacheStorage::Open(const nsAString& aKey, ErrorResult& aRv)
|
|||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStorage);
|
||||
|
||||
if (!HasStorageAccess()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(mStatus))) {
|
||||
aRv.Throw(mStatus);
|
||||
return nullptr;
|
||||
|
|
@ -403,11 +401,6 @@ CacheStorage::Delete(const nsAString& aKey, ErrorResult& aRv)
|
|||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStorage);
|
||||
|
||||
if (!HasStorageAccess()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(mStatus))) {
|
||||
aRv.Throw(mStatus);
|
||||
return nullptr;
|
||||
|
|
@ -432,11 +425,6 @@ CacheStorage::Keys(ErrorResult& aRv)
|
|||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStorage);
|
||||
|
||||
if (!HasStorageAccess()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(mStatus))) {
|
||||
aRv.Throw(mStatus);
|
||||
return nullptr;
|
||||
|
|
@ -487,14 +475,9 @@ CacheStorage::Constructor(const GlobalObject& aGlobal,
|
|||
}
|
||||
}
|
||||
|
||||
if (privateBrowsing) {
|
||||
RefPtr<CacheStorage> ref = new CacheStorage(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
// Create a CacheStorage object bypassing the trusted origin checks
|
||||
// since this is a chrome-only constructor.
|
||||
return CreateOnMainThread(ns, global, aPrincipal,
|
||||
return CreateOnMainThread(ns, global, aPrincipal, privateBrowsing,
|
||||
true /* force trusted origin */, aRv);
|
||||
}
|
||||
|
||||
|
|
@ -586,28 +569,6 @@ CacheStorage::GetOpenMode() const
|
|||
return mNamespace == CHROME_ONLY_NAMESPACE ? OpenMode::Eager : OpenMode::Lazy;
|
||||
}
|
||||
|
||||
bool
|
||||
CacheStorage::HasStorageAccess() const
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStorage);
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mGlobal);
|
||||
if (NS_WARN_IF(!window)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsContentUtils::StorageAccess access =
|
||||
nsContentUtils::StorageAllowedForWindow(window);
|
||||
return access > nsContentUtils::StorageAccess::ePrivateBrowsing;
|
||||
}
|
||||
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
|
||||
return workerPrivate->IsStorageAllowed();
|
||||
}
|
||||
|
||||
} // namespace cache
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
7
dom/cache/CacheStorage.h
vendored
7
dom/cache/CacheStorage.h
vendored
|
|
@ -45,8 +45,8 @@ class CacheStorage final : public nsISupports
|
|||
public:
|
||||
static already_AddRefed<CacheStorage>
|
||||
CreateOnMainThread(Namespace aNamespace, nsIGlobalObject* aGlobal,
|
||||
nsIPrincipal* aPrincipal, bool aForceTrustedOrigin,
|
||||
ErrorResult& aRv);
|
||||
nsIPrincipal* aPrincipal, bool aStorageDisabled,
|
||||
bool aForceTrustedOrigin, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<CacheStorage>
|
||||
CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
|
||||
|
|
@ -98,9 +98,6 @@ private:
|
|||
OpenMode
|
||||
GetOpenMode() const;
|
||||
|
||||
bool
|
||||
HasStorageAccess() const;
|
||||
|
||||
const Namespace mNamespace;
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
UniquePtr<mozilla::ipc::PrincipalInfo> mPrincipalInfo;
|
||||
|
|
|
|||
|
|
@ -3434,9 +3434,3 @@ nsHTMLDocument::GetFormsAndFormControls(nsContentList** aFormList,
|
|||
NS_ADDREF(*aFormList = holder->mFormList);
|
||||
NS_ADDREF(*aFormControlList = holder->mFormControlList);
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::UserInteractionForTesting()
|
||||
{
|
||||
NotifyUserGestureActivation();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,9 +225,6 @@ public:
|
|||
|
||||
void GetFormsAndFormControls(nsContentList** aFormList,
|
||||
nsContentList** aFormControlList);
|
||||
|
||||
void UserInteractionForTesting();
|
||||
|
||||
protected:
|
||||
~nsHTMLDocument();
|
||||
|
||||
|
|
|
|||
|
|
@ -2663,20 +2663,6 @@ ContentChild::RecvAddPermission(const IPC::Permission& permission)
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentChild::RecvRemoveAllPermissions()
|
||||
{
|
||||
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
|
||||
services::GetPermissionManager();
|
||||
nsPermissionManager* permissionManager =
|
||||
static_cast<nsPermissionManager*>(permissionManagerIface.get());
|
||||
MOZ_ASSERT(permissionManager,
|
||||
"We have no permissionManager in the Content process !");
|
||||
|
||||
permissionManager->RemoveAllFromIPC();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentChild::RecvFlushMemory(const nsString& reason)
|
||||
{
|
||||
|
|
@ -3279,25 +3265,6 @@ NextWindowID()
|
|||
return (processBits << kWindowIDWindowBits) | windowBits;
|
||||
}
|
||||
|
||||
// This code goes here rather than nsGlobalWindow.cpp because nsGlobalWindow.cpp
|
||||
// can't include ContentChild.h since it includes windows.h.
|
||||
void
|
||||
SendFirstPartyStorageAccessGrantedForOriginToParentProcess(nsIPrincipal* aPrincipal,
|
||||
const nsACString& aParentOrigin,
|
||||
const nsACString& aGrantedOrigin)
|
||||
{
|
||||
MOZ_ASSERT(!XRE_IsParentProcess());
|
||||
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
MOZ_ASSERT(cc);
|
||||
|
||||
// This is not really secure, because here we have the content process sending
|
||||
// the request of storing a permission.
|
||||
Unused << cc->SendFirstPartyStorageAccessGrantedForOrigin(IPC::Principal(aPrincipal),
|
||||
aParentOrigin,
|
||||
aGrantedOrigin);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentChild::RecvInvokeDragSession(nsTArray<IPCDataTransfer>&& aTransfers,
|
||||
const uint32_t& aAction)
|
||||
|
|
|
|||
|
|
@ -411,8 +411,6 @@ public:
|
|||
|
||||
virtual mozilla::ipc::IPCResult RecvAddPermission(const IPC::Permission& permission) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvRemoveAllPermissions() override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvFlushMemory(const nsString& reason) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvActivateA11y(const uint32_t& aMainChromeTid,
|
||||
|
|
@ -848,11 +846,6 @@ private:
|
|||
uint64_t
|
||||
NextWindowID();
|
||||
|
||||
void
|
||||
SendFirstPartyStorageAccessGrantedForOriginToParentProcess(nsIPrincipal* aPrincipal,
|
||||
const nsACString& aParentOrigin,
|
||||
const nsACString& aGrantedOrigin);
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@
|
|||
#include "nsDebugImpl.h"
|
||||
#include "nsFrameLoader.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
#include "nsHashPropertyBag.h"
|
||||
#include "nsIAlertsService.h"
|
||||
#include "nsIClipboard.h"
|
||||
|
|
@ -5751,14 +5750,3 @@ ContentParent::RecvBHRThreadHang(const HangDetails& aDetails)
|
|||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentParent::RecvFirstPartyStorageAccessGrantedForOrigin(const Principal& aPrincipal,
|
||||
const nsCString& aParentOrigin,
|
||||
const nsCString& aGrantedOrigin)
|
||||
{
|
||||
nsGlobalWindowInner::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(aPrincipal,
|
||||
aParentOrigin,
|
||||
aGrantedOrigin);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1224,11 +1224,6 @@ public:
|
|||
virtual mozilla::ipc::IPCResult RecvBHRThreadHang(
|
||||
const HangDetails& aHangDetails) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvFirstPartyStorageAccessGrantedForOrigin(const Principal& aPrincipal,
|
||||
const nsCString& aParentOrigin,
|
||||
const nsCString& aGrantedOrigin) override;
|
||||
|
||||
// Notify the ContentChild to enable the input event prioritization when
|
||||
// initializing.
|
||||
void MaybeEnableRemoteInputEventQueue();
|
||||
|
|
|
|||
|
|
@ -468,7 +468,6 @@ child:
|
|||
|
||||
// nsIPermissionManager messages
|
||||
async AddPermission(Permission permission);
|
||||
async RemoveAllPermissions();
|
||||
|
||||
async FlushMemory(nsString reason);
|
||||
|
||||
|
|
@ -1152,15 +1151,6 @@ parent:
|
|||
async BHRThreadHang(HangDetails aHangDetails);
|
||||
|
||||
async AddPerformanceMetrics(nsID aID, PerformanceInfo[] aMetrics);
|
||||
|
||||
/*
|
||||
* A 3rd party context (aPrincipal) has received the permission granted to
|
||||
* have access to aGrantedOrigin when loaded by aParentOrigin.
|
||||
*/
|
||||
async FirstPartyStorageAccessGrantedForOrigin(Principal aPrincipal,
|
||||
nsCString aParentOrigin,
|
||||
nsCString aGrantedOrigin);
|
||||
|
||||
both:
|
||||
async AsyncMessage(nsString aMessage, CpowEntry[] aCpows,
|
||||
Principal aPrincipal, ClonedMessageData aData);
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ CreateCacheStorage(JSContext* aCx, nsIPrincipal* aPrincipal, ErrorResult& aRv,
|
|||
// to revalidate is not available now.
|
||||
return CacheStorage::CreateOnMainThread(cache::CHROME_ONLY_NAMESPACE,
|
||||
sandboxGlobalObject, aPrincipal,
|
||||
false /* private browsing */,
|
||||
true /* force trusted origin */,
|
||||
aRv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,4 @@ partial interface HTMLDocument {
|
|||
*/
|
||||
[ChromeOnly, Pure]
|
||||
readonly attribute NodeList blockedTrackingNodes;
|
||||
|
||||
[ChromeOnly]
|
||||
void userInteractionForTesting();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/Navigator.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCycleCollector.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
|
|
@ -2238,21 +2237,6 @@ RuntimeService::ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
RuntimeService::PropagateFirstPartyStorageAccessGranted(nsPIDOMWindowInner* aWindow)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(StaticPrefs::privacy_restrict3rdpartystorage_enabled());
|
||||
|
||||
nsTArray<WorkerPrivate*> workers;
|
||||
GetWorkersForWindow(aWindow, workers);
|
||||
|
||||
for (uint32_t index = 0; index < workers.Length(); index++) {
|
||||
workers[index]->PropagateFirstPartyStorageAccessGranted();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
RuntimeService::CreateSharedWorker(const GlobalObject& aGlobal,
|
||||
const nsAString& aScriptURL,
|
||||
|
|
@ -2849,18 +2833,6 @@ ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
PropagateFirstPartyStorageAccessGrantedToWorkers(nsPIDOMWindowInner* aWindow)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(StaticPrefs::privacy_restrict3rdpartystorage_enabled());
|
||||
|
||||
RuntimeService* runtime = RuntimeService::GetService();
|
||||
if (runtime) {
|
||||
runtime->PropagateFirstPartyStorageAccessGranted(aWindow);
|
||||
}
|
||||
}
|
||||
|
||||
WorkerPrivate*
|
||||
GetWorkerPrivateFromContext(JSContext* aCx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -152,9 +152,6 @@ public:
|
|||
void
|
||||
ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
void
|
||||
PropagateFirstPartyStorageAccessGranted(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
nsresult
|
||||
CreateSharedWorker(const GlobalObject& aGlobal,
|
||||
const nsAString& aScriptURL,
|
||||
|
|
|
|||
|
|
@ -1540,6 +1540,7 @@ CacheCreator::CreateCacheStorage(nsIPrincipal* aPrincipal)
|
|||
CacheStorage::CreateOnMainThread(mozilla::dom::cache::CHROME_ONLY_NAMESPACE,
|
||||
mSandboxGlobalObject,
|
||||
aPrincipal,
|
||||
false, /* privateBrowsing can't be true here */
|
||||
true /* force trusted origin */,
|
||||
error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
|
|
|
|||
|
|
@ -53,9 +53,6 @@ SuspendWorkersForWindow(nsPIDOMWindowInner* aWindow);
|
|||
void
|
||||
ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
void
|
||||
PropagateFirstPartyStorageAccessGrantedToWorkers(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
// All of these are implemented in WorkerScope.cpp
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ WorkerLoadInfo::WorkerLoadInfo()
|
|||
, mXHRParamsAllowed(false)
|
||||
, mPrincipalIsSystem(false)
|
||||
, mStorageAllowed(false)
|
||||
, mFirstPartyStorageAccessGranted(false)
|
||||
, mServiceWorkersTestingInWindow(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(WorkerLoadInfo);
|
||||
|
|
@ -155,7 +154,6 @@ WorkerLoadInfo::StealFrom(WorkerLoadInfo& aOther)
|
|||
mXHRParamsAllowed = aOther.mXHRParamsAllowed;
|
||||
mPrincipalIsSystem = aOther.mPrincipalIsSystem;
|
||||
mStorageAllowed = aOther.mStorageAllowed;
|
||||
mFirstPartyStorageAccessGranted = aOther.mFirstPartyStorageAccessGranted;
|
||||
mServiceWorkersTestingInWindow = aOther.mServiceWorkersTestingInWindow;
|
||||
mOriginAttributes = aOther.mOriginAttributes;
|
||||
mParentController = aOther.mParentController;
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ struct WorkerLoadInfo
|
|||
bool mXHRParamsAllowed;
|
||||
bool mPrincipalIsSystem;
|
||||
bool mStorageAllowed;
|
||||
bool mFirstPartyStorageAccessGranted;
|
||||
bool mServiceWorkersTestingInWindow;
|
||||
OriginAttributes mOriginAttributes;
|
||||
|
||||
|
|
|
|||
|
|
@ -569,22 +569,6 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
class PropagateFirstPartyStorageAccessGrantedRunnable final : public WorkerControlRunnable
|
||||
{
|
||||
public:
|
||||
explicit PropagateFirstPartyStorageAccessGrantedRunnable(WorkerPrivate* aWorkerPrivate)
|
||||
: WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
|
||||
{}
|
||||
|
||||
private:
|
||||
bool
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
{
|
||||
aWorkerPrivate->PropagateFirstPartyStorageAccessGrantedInternal();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class ReportErrorToConsoleRunnable final : public WorkerRunnable
|
||||
{
|
||||
const char* mMessage;
|
||||
|
|
@ -2008,24 +1992,6 @@ WorkerPrivate::ParentWindowResumed()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
WorkerPrivate::PropagateFirstPartyStorageAccessGranted()
|
||||
{
|
||||
AssertIsOnParentThread();
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (mParentStatus >= Terminating) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<PropagateFirstPartyStorageAccessGrantedRunnable> runnable =
|
||||
new PropagateFirstPartyStorageAccessGrantedRunnable(this);
|
||||
Unused << NS_WARN_IF(!runnable->Dispatch());
|
||||
}
|
||||
|
||||
bool
|
||||
WorkerPrivate::Close()
|
||||
{
|
||||
|
|
@ -3977,18 +3943,6 @@ WorkerPrivate::ThawInternal()
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
WorkerPrivate::PropagateFirstPartyStorageAccessGrantedInternal()
|
||||
{
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
mLoadInfo.mFirstPartyStorageAccessGranted = true;
|
||||
|
||||
for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
|
||||
mChildWorkers[index]->PropagateFirstPartyStorageAccessGranted();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WorkerPrivate::TraverseTimeouts(nsCycleCollectionTraversalCallback& cb)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -268,9 +268,6 @@ public:
|
|||
bool
|
||||
ThawInternal();
|
||||
|
||||
void
|
||||
PropagateFirstPartyStorageAccessGrantedInternal();
|
||||
|
||||
void
|
||||
TraverseTimeouts(nsCycleCollectionTraversalCallback& aCallback);
|
||||
|
||||
|
|
@ -1033,8 +1030,7 @@ public:
|
|||
bool
|
||||
IsStorageAllowed() const
|
||||
{
|
||||
AssertIsOnWorkerThread();
|
||||
return mLoadInfo.mStorageAllowed || mLoadInfo.mFirstPartyStorageAccessGranted;
|
||||
return mLoadInfo.mStorageAllowed;
|
||||
}
|
||||
|
||||
const OriginAttributes&
|
||||
|
|
@ -1105,9 +1101,6 @@ public:
|
|||
bool
|
||||
Thaw(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
void
|
||||
PropagateFirstPartyStorageAccessGranted();
|
||||
|
||||
void
|
||||
EnableDebugger();
|
||||
|
||||
|
|
|
|||
|
|
@ -2117,31 +2117,9 @@ nsPermissionManager::CloseDB(bool aRebuildOnSuccess)
|
|||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPermissionManager::RemoveAllFromIPC()
|
||||
{
|
||||
MOZ_ASSERT(IsChildProcess());
|
||||
|
||||
// Remove from memory and notify immediately. Since the in-memory
|
||||
// database is authoritative, we do not need confirmation from the
|
||||
// on-disk database to notify observers.
|
||||
RemoveAllFromMemory();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPermissionManager::RemoveAllInternal(bool aNotifyObservers)
|
||||
{
|
||||
ENSURE_NOT_CHILD_PROCESS;
|
||||
|
||||
// Let's broadcast the removeAll() to any content process.
|
||||
nsTArray<ContentParent*> parents;
|
||||
ContentParent::GetAll(parents);
|
||||
for (ContentParent* parent : parents) {
|
||||
Unused << parent->SendRemoveAllPermissions();
|
||||
}
|
||||
|
||||
// Remove from memory and notify immediately. Since the in-memory
|
||||
// database is authoritative, we do not need confirmation from the
|
||||
// on-disk database to notify observers.
|
||||
|
|
@ -2557,23 +2535,15 @@ NS_IMETHODIMP nsPermissionManager::GetEnumerator(nsISimpleEnumerator **aEnum)
|
|||
|
||||
NS_IMETHODIMP nsPermissionManager::GetAllForURI(nsIURI* aURI, nsISimpleEnumerator **aEnum)
|
||||
{
|
||||
nsCOMArray<nsIPermission> array;
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsresult rv = GetPrincipal(aURI, getter_AddRefs(principal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return GetAllForPrincipal(principal, aEnum);
|
||||
}
|
||||
MOZ_ASSERT(PermissionAvailable(principal, nullptr));
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermissionManager::GetAllForPrincipal(nsIPrincipal* aPrincipal,
|
||||
nsISimpleEnumerator** aEnum)
|
||||
{
|
||||
nsCOMArray<nsIPermission> array;
|
||||
|
||||
MOZ_ASSERT(PermissionAvailable(aPrincipal, nullptr));
|
||||
|
||||
nsresult rv;
|
||||
RefPtr<PermissionKey> key = PermissionKey::CreateFromPrincipal(aPrincipal, rv);
|
||||
RefPtr<PermissionKey> key = PermissionKey::CreateFromPrincipal(principal, rv);
|
||||
if (!key) {
|
||||
MOZ_ASSERT(NS_FAILED(rv));
|
||||
return rv;
|
||||
|
|
@ -2589,7 +2559,7 @@ nsPermissionManager::GetAllForPrincipal(nsIPrincipal* aPrincipal,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIPermission> permission =
|
||||
nsPermission::Create(aPrincipal,
|
||||
nsPermission::Create(principal,
|
||||
mTypeArray.ElementAt(permEntry.mType),
|
||||
permEntry.mPermission,
|
||||
permEntry.mExpireType,
|
||||
|
|
|
|||
|
|
@ -284,9 +284,6 @@ public:
|
|||
*/
|
||||
static nsTArray<nsCString> GetAllKeysForPrincipal(nsIPrincipal* aPrincipal);
|
||||
|
||||
// From ContentChild.
|
||||
nsresult RemoveAllFromIPC();
|
||||
|
||||
private:
|
||||
virtual ~nsPermissionManager();
|
||||
|
||||
|
|
|
|||
|
|
@ -142,8 +142,9 @@ ImageCacheKey::GetSpecialCaseDocumentToken(nsIDocument* aDocument, nsIURI* aURI)
|
|||
// If this document has been marked as tracker, let's use its address to make
|
||||
// a unique cache key.
|
||||
if (!pointer && aDocument &&
|
||||
nsContentUtils::StorageDisabledByAntiTracking(aDocument->GetInnerWindow(),
|
||||
nullptr, aURI)) {
|
||||
nsContentUtils::StorageDisabledByAntiTracking(nullptr,
|
||||
aDocument->GetChannel(),
|
||||
aURI)) {
|
||||
pointer = aDocument;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -403,7 +403,6 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
|
|||
aLoadInfo->GetSecurityFlags(),
|
||||
aLoadInfo->InternalContentPolicyType(),
|
||||
static_cast<uint32_t>(aLoadInfo->GetTainting()),
|
||||
aLoadInfo->GetFirstPartyStorageAccessGrantedOrigins(),
|
||||
aLoadInfo->GetUpgradeInsecureRequests(),
|
||||
aLoadInfo->GetBrowserUpgradeInsecureRequests(),
|
||||
aLoadInfo->GetBrowserWouldUpgradeInsecureRequests(),
|
||||
|
|
@ -552,7 +551,6 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
|
|||
loadInfoArgs.securityFlags(),
|
||||
loadInfoArgs.contentPolicyType(),
|
||||
static_cast<LoadTainting>(loadInfoArgs.tainting()),
|
||||
loadInfoArgs.firstPartyStorageAccessGrantedOrigins(),
|
||||
loadInfoArgs.upgradeInsecureRequests(),
|
||||
loadInfoArgs.browserUpgradeInsecureRequests(),
|
||||
loadInfoArgs.browserWouldUpgradeInsecureRequests(),
|
||||
|
|
|
|||
|
|
@ -150,12 +150,6 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|||
nsCOMPtr<nsPIDOMWindowOuter> parent = contextOuter->GetScriptableParent();
|
||||
mParentOuterWindowID = parent ? parent->WindowID() : mOuterWindowID;
|
||||
mTopOuterWindowID = FindTopOuterWindowID(contextOuter);
|
||||
|
||||
nsGlobalWindowInner* innerWindow =
|
||||
nsGlobalWindowInner::Cast(contextOuter->GetCurrentInnerWindow());
|
||||
if (innerWindow) {
|
||||
innerWindow->GetFirstPartyStorageAccessGrantedOrigins(mFirstPartyStorageAccessGrantedOrigins);
|
||||
}
|
||||
}
|
||||
|
||||
mInnerWindowID = aLoadingContext->OwnerDoc()->InnerWindowID();
|
||||
|
|
@ -340,12 +334,6 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
|
|||
mParentOuterWindowID = parent ? parent->WindowID() : 0;
|
||||
mTopOuterWindowID = FindTopOuterWindowID(aOuterWindow);
|
||||
|
||||
nsGlobalWindowInner* innerWindow =
|
||||
nsGlobalWindowInner::Cast(aOuterWindow->GetCurrentInnerWindow());
|
||||
if (innerWindow) {
|
||||
innerWindow->GetFirstPartyStorageAccessGrantedOrigins(mFirstPartyStorageAccessGrantedOrigins);
|
||||
}
|
||||
|
||||
// get the docshell from the outerwindow, and then get the originattributes
|
||||
nsCOMPtr<nsIDocShell> docShell = aOuterWindow->GetDocShell();
|
||||
MOZ_ASSERT(docShell);
|
||||
|
|
@ -425,7 +413,6 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
LoadTainting aTainting,
|
||||
const nsTArray<nsString>& aFirstPartyStorageAccessGrantedOrigins,
|
||||
bool aUpgradeInsecureRequests,
|
||||
bool aBrowserUpgradeInsecureRequests,
|
||||
bool aBrowserWouldUpgradeInsecureRequests,
|
||||
|
|
@ -465,7 +452,6 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|||
, mSecurityFlags(aSecurityFlags)
|
||||
, mInternalContentPolicyType(aContentPolicyType)
|
||||
, mTainting(aTainting)
|
||||
, mFirstPartyStorageAccessGrantedOrigins(aFirstPartyStorageAccessGrantedOrigins)
|
||||
, mUpgradeInsecureRequests(aUpgradeInsecureRequests)
|
||||
, mBrowserUpgradeInsecureRequests(aBrowserUpgradeInsecureRequests)
|
||||
, mBrowserWouldUpgradeInsecureRequests(aBrowserWouldUpgradeInsecureRequests)
|
||||
|
|
@ -1406,37 +1392,5 @@ LoadInfo::GetPerformanceStorage()
|
|||
return mPerformanceStorage;
|
||||
}
|
||||
|
||||
const nsTArray<nsString>&
|
||||
LoadInfo::GetFirstPartyStorageAccessGrantedOrigins()
|
||||
{
|
||||
return mFirstPartyStorageAccessGrantedOrigins;
|
||||
}
|
||||
|
||||
bool
|
||||
LoadInfo::IsFirstPartyStorageAccessGrantedFor(nsIURI* aURI)
|
||||
{
|
||||
MOZ_ASSERT(aURI);
|
||||
|
||||
if (mFirstPartyStorageAccessGrantedOrigins.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoString origin;
|
||||
nsresult rv = nsContentUtils::GetUTFOrigin(aURI, origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mFirstPartyStorageAccessGrantedOrigins.Contains(origin);
|
||||
}
|
||||
|
||||
void
|
||||
LoadInfo::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigin)
|
||||
{
|
||||
if (!mFirstPartyStorageAccessGrantedOrigins.Contains(aOrigin)) {
|
||||
mFirstPartyStorageAccessGrantedOrigins.AppendElement(aOrigin);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ private:
|
|||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
LoadTainting aTainting,
|
||||
const nsTArray<nsString>& aFirstPartyStorageAccessGrantedOrigins,
|
||||
bool aUpgradeInsecureRequests,
|
||||
bool aBrowserUpgradeInsecureRequests,
|
||||
bool aBrowserWouldUpgradeInsecureRequests,
|
||||
|
|
@ -174,7 +173,6 @@ private:
|
|||
nsSecurityFlags mSecurityFlags;
|
||||
nsContentPolicyType mInternalContentPolicyType;
|
||||
LoadTainting mTainting;
|
||||
nsTArray<nsString> mFirstPartyStorageAccessGrantedOrigins;
|
||||
bool mUpgradeInsecureRequests;
|
||||
bool mBrowserUpgradeInsecureRequests;
|
||||
bool mBrowserWouldUpgradeInsecureRequests;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ class ServiceWorkerDescriptor;
|
|||
[ref] native nsIRedirectHistoryEntryArray(const nsTArray<nsCOMPtr<nsIRedirectHistoryEntry>>);
|
||||
native OriginAttributes(mozilla::OriginAttributes);
|
||||
[ref] native const_OriginAttributesRef(const mozilla::OriginAttributes);
|
||||
[ref] native CStringArrayRef(const nsTArray<nsCString>);
|
||||
[ref] native StringArrayRef(const nsTArray<nsString>);
|
||||
[ref] native StringArrayRef(const nsTArray<nsCString>);
|
||||
[ref] native Uint64ArrayRef(const nsTArray<uint64_t>);
|
||||
[ref] native PrincipalArrayRef(const nsTArray<nsCOMPtr<nsIPrincipal>>);
|
||||
[ref] native const_ClientInfoRef(const mozilla::dom::ClientInfo);
|
||||
|
|
@ -784,7 +783,7 @@ interface nsILoadInfo : nsISupports
|
|||
* Only call this function when using the SEC_REQUIRE_CORS_DATA_INHERITS mode.
|
||||
*/
|
||||
[noscript, notxpcom, nostdcall]
|
||||
void setCorsPreflightInfo(in CStringArrayRef unsafeHeaders,
|
||||
void setCorsPreflightInfo(in StringArrayRef unsafeHeaders,
|
||||
in boolean forcePreflight);
|
||||
|
||||
/**
|
||||
|
|
@ -793,7 +792,7 @@ interface nsILoadInfo : nsISupports
|
|||
* loadInfo object - use with caution!
|
||||
*/
|
||||
[noscript, notxpcom, nostdcall, binaryname(CorsUnsafeHeaders)]
|
||||
CStringArrayRef corsUnsafeHeaders();
|
||||
StringArrayRef corsUnsafeHeaders();
|
||||
|
||||
/**
|
||||
* Returns value set through setCorsPreflightInfo.
|
||||
|
|
@ -1020,15 +1019,4 @@ interface nsILoadInfo : nsISupports
|
|||
*/
|
||||
[noscript, nostdcall, notxpcom]
|
||||
void SynthesizeServiceWorkerTainting(in LoadTainting aTainting);
|
||||
|
||||
/**
|
||||
* This is the origin that has access storage granted also if 3rd party and
|
||||
* in the tracking protection list.
|
||||
*/
|
||||
[noscript, notxpcom, nostdcall]
|
||||
StringArrayRef getFirstPartyStorageAccessGrantedOrigins();
|
||||
[noscript, notxpcom, nostdcall]
|
||||
bool isFirstPartyStorageAccessGrantedFor(in nsIURI aURI);
|
||||
[noscript, notxpcom, nostdcall]
|
||||
void addFirstPartyStorageAccessGrantedFor(in AString aOrigin);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -107,24 +107,14 @@ interface nsIPermissionManager : nsISupports
|
|||
[optional] in int64_t expireTime);
|
||||
|
||||
/**
|
||||
* Deprecated! Use getAllForPrincipal!
|
||||
* Get all custom permissions for a given URI. This will return
|
||||
* an enumerator of all permissions which are not set to default
|
||||
* and which belong to the matching principal of the given URI.
|
||||
* and which belong to the matching prinicpal of the given URI.
|
||||
*
|
||||
* @param uri the URI to get all permissions for
|
||||
*/
|
||||
nsISimpleEnumerator getAllForURI(in nsIURI uri);
|
||||
|
||||
/**
|
||||
* Get all custom permissions for a given nsIPrincipal. This will return an
|
||||
* enumerator of all permissions which are not set to default and which
|
||||
* belong to the matching principal of the given nsIPrincipal.
|
||||
*
|
||||
* @param principal the URI to get all permissions for
|
||||
*/
|
||||
nsISimpleEnumerator getAllForPrincipal(in nsIPrincipal principal);
|
||||
|
||||
/**
|
||||
* Add permission information for a given principal.
|
||||
* It is internally calling the other add() method using the nsIURI from the
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ CookieServiceChild::TrackCookieLoad(nsIChannel *aChannel)
|
|||
|
||||
bool isForeign = false;
|
||||
bool isTrackingResource = false;
|
||||
bool firstPartyStorageAccessGranted = false;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aChannel->GetURI(getter_AddRefs(uri));
|
||||
if (RequireThirdPartyCheck()) {
|
||||
|
|
@ -187,17 +186,13 @@ CookieServiceChild::TrackCookieLoad(nsIChannel *aChannel)
|
|||
mozilla::OriginAttributes attrs;
|
||||
if (loadInfo) {
|
||||
attrs = loadInfo->GetOriginAttributes();
|
||||
if (loadInfo->IsFirstPartyStorageAccessGrantedFor(uri)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
URIParams uriParams;
|
||||
SerializeURI(uri, uriParams);
|
||||
bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel);
|
||||
bool isSameSiteForeign = NS_IsSameSiteForeign(aChannel, uri);
|
||||
SendPrepareCookieList(uriParams, isForeign, isTrackingResource,
|
||||
firstPartyStorageAccessGranted, isSafeTopLevelNav,
|
||||
isSameSiteForeign, attrs);
|
||||
isSafeTopLevelNav, isSameSiteForeign, attrs);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
|
|
@ -339,7 +334,6 @@ void
|
|||
CookieServiceChild::GetCookieStringFromCookieHashTable(nsIURI *aHostURI,
|
||||
bool aIsForeign,
|
||||
bool aIsTrackingResource,
|
||||
bool aFirstPartyStorageAccessGranted,
|
||||
bool aIsSafeTopLevelNav,
|
||||
bool aIsSameSiteForeign,
|
||||
const OriginAttributes &aOriginAttrs,
|
||||
|
|
@ -373,8 +367,7 @@ CookieServiceChild::GetCookieStringFromCookieHashTable(nsIURI *a
|
|||
nsCookieService::CheckPrefs(permissionService, mCookieBehavior,
|
||||
mThirdPartySession,
|
||||
mThirdPartyNonsecureSession, aHostURI,
|
||||
aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted, nullptr,
|
||||
aIsForeign, aIsTrackingResource, nullptr,
|
||||
CountCookiesFromHashTable(baseDomain, aOriginAttrs),
|
||||
aOriginAttrs);
|
||||
|
||||
|
|
@ -436,7 +429,6 @@ void
|
|||
CookieServiceChild::GetCookieStringSyncIPC(nsIURI *aHostURI,
|
||||
bool aIsForeign,
|
||||
bool aIsTrackingResource,
|
||||
bool aFirstPartyStorageAccessGranted,
|
||||
bool aIsSafeTopLevelNav,
|
||||
bool aIsSameSiteForeign,
|
||||
const OriginAttributes &aAttrs,
|
||||
|
|
@ -445,9 +437,7 @@ CookieServiceChild::GetCookieStringSyncIPC(nsIURI *aHostURI,
|
|||
URIParams uriParams;
|
||||
SerializeURI(aHostURI, uriParams);
|
||||
|
||||
SendGetCookieString(uriParams, aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted, aIsSafeTopLevelNav,
|
||||
aIsSameSiteForeign, aAttrs, &aCookieString);
|
||||
SendGetCookieString(uriParams, aIsForeign, aIsTrackingResource, aIsSafeTopLevelNav, aIsSameSiteForeign, aAttrs, &aCookieString);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
|
@ -558,10 +548,9 @@ CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
|
|||
if (scheme.EqualsLiteral("moz-nullprincipal"))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
mozilla::OriginAttributes attrs;
|
||||
if (aChannel) {
|
||||
loadInfo = aChannel->GetLoadInfo();
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
if (loadInfo) {
|
||||
attrs = loadInfo->GetOriginAttributes();
|
||||
}
|
||||
|
|
@ -578,26 +567,20 @@ CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
|
|||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
}
|
||||
|
||||
bool firstPartyStorageAccessGranted = false;
|
||||
if (loadInfo->IsFirstPartyStorageAccessGrantedFor(aHostURI)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
|
||||
bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel);
|
||||
bool isSameSiteForeign = NS_IsSameSiteForeign(aChannel, aHostURI);
|
||||
|
||||
nsAutoCString result;
|
||||
if (!mIPCSync) {
|
||||
GetCookieStringFromCookieHashTable(aHostURI, isForeign, isTrackingResource,
|
||||
firstPartyStorageAccessGranted, isSafeTopLevelNav,
|
||||
isSameSiteForeign, attrs, result);
|
||||
isSafeTopLevelNav, isSameSiteForeign,
|
||||
attrs, result);
|
||||
} else {
|
||||
if (!mIPCOpen) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
GetCookieStringSyncIPC(aHostURI, isForeign, isTrackingResource,
|
||||
firstPartyStorageAccessGranted, isSafeTopLevelNav,
|
||||
isSameSiteForeign, attrs, result);
|
||||
isSafeTopLevelNav, isSameSiteForeign, attrs, result);
|
||||
}
|
||||
|
||||
if (!result.IsEmpty())
|
||||
|
|
@ -647,23 +630,18 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
|
|||
URIParams channelURIParams;
|
||||
SerializeURI(channelURI, channelURIParams);
|
||||
|
||||
bool firstPartyStorageAccessGranted = false;
|
||||
mozilla::OriginAttributes attrs;
|
||||
if (aChannel) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
if (loadInfo) {
|
||||
attrs = loadInfo->GetOriginAttributes();
|
||||
if (loadInfo->IsFirstPartyStorageAccessGrantedFor(aHostURI)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Asynchronously call the parent.
|
||||
if (mIPCOpen) {
|
||||
SendSetCookieString(hostURIParams, channelURIParams,
|
||||
isForeign, isTrackingResource,
|
||||
firstPartyStorageAccessGranted, cookieString,
|
||||
isForeign, isTrackingResource, cookieString,
|
||||
stringServerTime, attrs, aFromHttp);
|
||||
}
|
||||
|
||||
|
|
@ -682,8 +660,7 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
|
|||
nsCookieService::CheckPrefs(permissionService, mCookieBehavior,
|
||||
mThirdPartySession,
|
||||
mThirdPartyNonsecureSession, aHostURI,
|
||||
isForeign, isTrackingResource,
|
||||
firstPartyStorageAccessGranted, aCookieString,
|
||||
isForeign, isTrackingResource, aCookieString,
|
||||
CountCookiesFromHashTable(baseDomain, attrs),
|
||||
attrs);
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ protected:
|
|||
void GetCookieStringFromCookieHashTable(nsIURI *aHostURI,
|
||||
bool aIsForeign,
|
||||
bool aIsTrackingResource,
|
||||
bool aFirstPartyStorageAccessGranted,
|
||||
bool aIsSafeTopLevelNav,
|
||||
bool aIsSameSiteForeign,
|
||||
const OriginAttributes &aAttrs,
|
||||
|
|
@ -76,7 +75,6 @@ protected:
|
|||
GetCookieStringSyncIPC(nsIURI *aHostURI,
|
||||
bool aIsForeign,
|
||||
bool aIsTrackingResource,
|
||||
bool aFirstPartyStorageAccessGranted,
|
||||
bool aIsSafeTopLevelNav,
|
||||
bool aIsSameSiteForeign,
|
||||
const OriginAttributes &aAttrs,
|
||||
|
|
|
|||
|
|
@ -162,16 +162,10 @@ CookieServiceParent::TrackCookieLoad(nsIChannel *aChannel)
|
|||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
}
|
||||
|
||||
bool storageAccessGranted = false;
|
||||
if (loadInfo && loadInfo->IsFirstPartyStorageAccessGrantedFor(uri)) {
|
||||
storageAccessGranted = true;
|
||||
}
|
||||
|
||||
nsTArray<nsCookie*> foundCookieList;
|
||||
mCookieService->GetCookiesForURI(uri, isForeign, isTrackingResource,
|
||||
storageAccessGranted, isSafeTopLevelNav,
|
||||
aIsSameSiteForeign, false, attrs,
|
||||
foundCookieList);
|
||||
isSafeTopLevelNav, aIsSameSiteForeign,
|
||||
false, attrs, foundCookieList);
|
||||
nsTArray<CookieStruct> matchingCookiesList;
|
||||
SerialializeCookieList(foundCookieList, matchingCookiesList, uri);
|
||||
Unused << SendTrackCookiesLoad(matchingCookiesList, attrs);
|
||||
|
|
@ -202,7 +196,6 @@ mozilla::ipc::IPCResult
|
|||
CookieServiceParent::RecvPrepareCookieList(const URIParams &aHost,
|
||||
const bool &aIsForeign,
|
||||
const bool &aIsTrackingResource,
|
||||
const bool &aFirstPartyStorageAccessGranted,
|
||||
const bool &aIsSafeTopLevelNav,
|
||||
const bool &aIsSameSiteForeign,
|
||||
const OriginAttributes &aAttrs)
|
||||
|
|
@ -212,9 +205,8 @@ CookieServiceParent::RecvPrepareCookieList(const URIParams &aHost,
|
|||
// Send matching cookies to Child.
|
||||
nsTArray<nsCookie*> foundCookieList;
|
||||
mCookieService->GetCookiesForURI(hostURI, aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted, aIsSafeTopLevelNav,
|
||||
aIsSameSiteForeign, false, aAttrs,
|
||||
foundCookieList);
|
||||
aIsSafeTopLevelNav, aIsSameSiteForeign,
|
||||
false, aAttrs, foundCookieList);
|
||||
nsTArray<CookieStruct> matchingCookiesList;
|
||||
SerialializeCookieList(foundCookieList, matchingCookiesList, hostURI);
|
||||
Unused << SendTrackCookiesLoad(matchingCookiesList, aAttrs);
|
||||
|
|
@ -232,7 +224,6 @@ mozilla::ipc::IPCResult
|
|||
CookieServiceParent::RecvGetCookieString(const URIParams& aHost,
|
||||
const bool& aIsForeign,
|
||||
const bool& aIsTrackingResource,
|
||||
const bool& aFirstPartyStorageAccessGranted,
|
||||
const bool& aIsSafeTopLevelNav,
|
||||
const bool& aIsSameSiteForeign,
|
||||
const OriginAttributes& aAttrs,
|
||||
|
|
@ -247,8 +238,8 @@ CookieServiceParent::RecvGetCookieString(const URIParams& aHost,
|
|||
if (!hostURI)
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
mCookieService->GetCookieStringInternal(hostURI, aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted, aIsSafeTopLevelNav,
|
||||
aIsSameSiteForeign, false, aAttrs, *aResult);
|
||||
aIsSafeTopLevelNav, aIsSameSiteForeign,
|
||||
false, aAttrs, *aResult);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +248,6 @@ CookieServiceParent::RecvSetCookieString(const URIParams& aHost,
|
|||
const URIParams& aChannelURI,
|
||||
const bool& aIsForeign,
|
||||
const bool& aIsTrackingResource,
|
||||
const bool& aFirstPartyStorageAccessGranted,
|
||||
const nsCString& aCookieString,
|
||||
const nsCString& aServerTime,
|
||||
const OriginAttributes& aAttrs,
|
||||
|
|
@ -295,10 +285,9 @@ CookieServiceParent::RecvSetCookieString(const URIParams& aHost,
|
|||
// we don't send it back to the same content process.
|
||||
mProcessingCookie = true;
|
||||
mCookieService->SetCookieStringInternal(hostURI, aIsForeign,
|
||||
aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted,
|
||||
cookieString, aServerTime, aFromHttp,
|
||||
aAttrs, dummyChannel);
|
||||
aIsTrackingResource, cookieString,
|
||||
aServerTime, aFromHttp, aAttrs,
|
||||
dummyChannel);
|
||||
mProcessingCookie = false;
|
||||
return IPC_OK();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ protected:
|
|||
virtual mozilla::ipc::IPCResult RecvGetCookieString(const URIParams& aHost,
|
||||
const bool& aIsForeign,
|
||||
const bool& aIsTrackingResource,
|
||||
const bool& aFirstPartyStorageAccessGranted,
|
||||
const bool& aIsSafeTopLevelNav,
|
||||
const bool& aIsSameSiteForeign,
|
||||
const OriginAttributes& aAttrs,
|
||||
|
|
@ -53,7 +52,6 @@ protected:
|
|||
const URIParams& aChannelURI,
|
||||
const bool& aIsForeign,
|
||||
const bool& aIsTrackingResource,
|
||||
const bool& aFirstPartyStorageAccessGranted,
|
||||
const nsCString& aCookieString,
|
||||
const nsCString& aServerTime,
|
||||
const OriginAttributes& aAttrs,
|
||||
|
|
@ -62,7 +60,6 @@ protected:
|
|||
mozilla::ipc::IPCResult RecvPrepareCookieList(const URIParams &aHost,
|
||||
const bool &aIsForeign,
|
||||
const bool &aIsTackingResource,
|
||||
const bool& aFirstPartyStorageAccessGranted,
|
||||
const bool &aIsSafeTopLevelNav,
|
||||
const bool &aIsSameSiteForeign,
|
||||
const OriginAttributes &aAttrs) override;
|
||||
|
|
|
|||
|
|
@ -47,11 +47,7 @@ parent:
|
|||
* rejected depending on user preferences; if those checks are
|
||||
* disabled, this parameter is ignored.
|
||||
* @param isTrackingResource
|
||||
* True if the request has been marked as tracking.
|
||||
* @param firstPartyStorageAccessGranted
|
||||
* True if host has storage access granted. Note that the storage
|
||||
* access is automatically granted also if the channel is not marked as
|
||||
* tracking resource, or if it's not a 3rd party context.
|
||||
* True if the the request has been marked as tracking.
|
||||
* @param isSafeTopLevelNav
|
||||
* True for safe methods like e.g. GET.
|
||||
* @param isSameSiteForeign
|
||||
|
|
@ -73,7 +69,6 @@ parent:
|
|||
nested(inside_cpow) sync GetCookieString(URIParams host,
|
||||
bool isForeign,
|
||||
bool isTrackingResource,
|
||||
bool firstPartyStorageAccessGranted,
|
||||
bool isSafeTopLevelNav,
|
||||
bool isSameSiteForeign,
|
||||
OriginAttributes attrs)
|
||||
|
|
@ -93,11 +88,7 @@ parent:
|
|||
* rejected depending on user preferences; if those checks are
|
||||
* disabled, this parameter is ignored.
|
||||
* @param isTrackingResource
|
||||
* True if the request has been marked as tracking.
|
||||
* @param firstPartyStorageAccessGranted
|
||||
* True if host has storage access granted. Note that the storage
|
||||
* access is automatically granted also if the channel is not marked as
|
||||
* tracking resource, or if it's not a 3rd party context.
|
||||
* True if the the request has been marked as tracking.
|
||||
* @param cookieString
|
||||
* Same as the 'aCookie' argument to nsICookieService.setCookieString.
|
||||
* @param serverTime
|
||||
|
|
@ -120,7 +111,6 @@ parent:
|
|||
URIParams channelURI,
|
||||
bool isForeign,
|
||||
bool isTrackingResource,
|
||||
bool firstPartyStorageAccessGranted,
|
||||
nsCString cookieString,
|
||||
nsCString serverTime,
|
||||
OriginAttributes attrs,
|
||||
|
|
@ -129,7 +119,6 @@ parent:
|
|||
async PrepareCookieList(URIParams host,
|
||||
bool isForeign,
|
||||
bool isTrackingResource,
|
||||
bool firstPartyStorageAccessGranted,
|
||||
bool isSafeTopLevelNav,
|
||||
bool isSameSiteForeign,
|
||||
OriginAttributes attrs);
|
||||
|
|
|
|||
|
|
@ -2045,14 +2045,9 @@ nsCookieService::GetCookieStringCommon(nsIURI *aHostURI,
|
|||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
}
|
||||
|
||||
// Get originAttributes.
|
||||
OriginAttributes attrs;
|
||||
bool firstPartyStorageAccessGranted = false;
|
||||
if (aChannel) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
if (loadInfo && loadInfo->IsFirstPartyStorageAccessGrantedFor(aHostURI)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
|
||||
NS_GetOriginAttributes(aChannel, attrs);
|
||||
}
|
||||
|
||||
|
|
@ -2060,8 +2055,8 @@ nsCookieService::GetCookieStringCommon(nsIURI *aHostURI,
|
|||
bool isSameSiteForeign = NS_IsSameSiteForeign(aChannel, aHostURI);
|
||||
nsAutoCString result;
|
||||
GetCookieStringInternal(aHostURI, isForeign, isTrackingResource,
|
||||
firstPartyStorageAccessGranted, isSafeTopLevelNav,
|
||||
isSameSiteForeign, aHttpBound, attrs, result);
|
||||
isSafeTopLevelNav, isSameSiteForeign,
|
||||
aHttpBound, attrs, result);
|
||||
*aCookie = result.IsEmpty() ? nullptr : ToNewCString(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -2151,20 +2146,15 @@ nsCookieService::SetCookieStringCommon(nsIURI *aHostURI,
|
|||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
}
|
||||
|
||||
// Get originAttributes.
|
||||
OriginAttributes attrs;
|
||||
bool firstPartyStorageAccessGranted = false;
|
||||
if (aChannel) {
|
||||
NS_GetOriginAttributes(aChannel, attrs);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
if (loadInfo && loadInfo->IsFirstPartyStorageAccessGrantedFor(aHostURI)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
|
||||
nsDependentCString cookieString(aCookieHeader);
|
||||
nsDependentCString serverTime(aServerTime ? aServerTime : "");
|
||||
SetCookieStringInternal(aHostURI, isForeign, isTrackingResource,
|
||||
firstPartyStorageAccessGranted, cookieString,
|
||||
SetCookieStringInternal(aHostURI, isForeign, isTrackingResource, cookieString,
|
||||
serverTime, aFromHttp, attrs, aChannel);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -2173,7 +2163,6 @@ void
|
|||
nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
bool aIsForeign,
|
||||
bool aIsTrackingResource,
|
||||
bool aFirstPartyStorageAccessGranted,
|
||||
nsDependentCString &aCookieHeader,
|
||||
const nsCString &aServerTime,
|
||||
bool aFromHttp,
|
||||
|
|
@ -2217,7 +2206,6 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
|
|||
mThirdPartySession,
|
||||
mThirdPartyNonsecureSession, aHostURI,
|
||||
aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted,
|
||||
aCookieHeader.get(), priorCookieCount,
|
||||
aOriginAttrs);
|
||||
|
||||
|
|
@ -3151,7 +3139,6 @@ void
|
|||
nsCookieService::GetCookiesForURI(nsIURI *aHostURI,
|
||||
bool aIsForeign,
|
||||
bool aIsTrackingResource,
|
||||
bool aFirstPartyStorageAccessGranted,
|
||||
bool aIsSafeTopLevelNav,
|
||||
bool aIsSameSiteForeign,
|
||||
bool aHttpBound,
|
||||
|
|
@ -3194,7 +3181,6 @@ nsCookieService::GetCookiesForURI(nsIURI *aHostURI,
|
|||
mThirdPartySession,
|
||||
mThirdPartyNonsecureSession, aHostURI,
|
||||
aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted,
|
||||
nullptr, priorCookieCount,
|
||||
aOriginAttrs);
|
||||
|
||||
|
|
@ -3328,7 +3314,6 @@ void
|
|||
nsCookieService::GetCookieStringInternal(nsIURI *aHostURI,
|
||||
bool aIsForeign,
|
||||
bool aIsTrackingResource,
|
||||
bool aFirstPartyStorageAccessGranted,
|
||||
bool aIsSafeTopLevelNav,
|
||||
bool aIsSameSiteForeign,
|
||||
bool aHttpBound,
|
||||
|
|
@ -3337,9 +3322,8 @@ nsCookieService::GetCookieStringInternal(nsIURI *aHostURI,
|
|||
{
|
||||
AutoTArray<nsCookie*, 8> foundCookieList;
|
||||
GetCookiesForURI(aHostURI, aIsForeign, aIsTrackingResource,
|
||||
aFirstPartyStorageAccessGranted, aIsSafeTopLevelNav,
|
||||
aIsSameSiteForeign, aHttpBound, aOriginAttrs,
|
||||
foundCookieList);
|
||||
aIsSafeTopLevelNav, aIsSameSiteForeign, aHttpBound,
|
||||
aOriginAttrs, foundCookieList);
|
||||
|
||||
nsCookie* cookie;
|
||||
for (uint32_t i = 0; i < foundCookieList.Length(); ++i) {
|
||||
|
|
@ -4178,7 +4162,6 @@ nsCookieService::CheckPrefs(nsICookiePermission *aPermissionService,
|
|||
nsIURI *aHostURI,
|
||||
bool aIsForeign,
|
||||
bool aIsTrackingResource,
|
||||
bool aFirstPartyStorageAccessGranted,
|
||||
const char *aCookieHeader,
|
||||
const int aNumOfCookies,
|
||||
const OriginAttributes &aOriginAttrs)
|
||||
|
|
@ -4201,9 +4184,8 @@ nsCookieService::CheckPrefs(nsICookiePermission *aPermissionService,
|
|||
}
|
||||
|
||||
// No cookies allowed if this request comes from a tracker, in a 3rd party
|
||||
// context, when anti-tracking protection is enabled and when we don't have
|
||||
// access to the first-party cookie jar.
|
||||
if (aIsForeign && aIsTrackingResource && !aFirstPartyStorageAccessGranted &&
|
||||
// context, when anti-tracking protection is enabled.
|
||||
if (aIsForeign && aIsTrackingResource &&
|
||||
StaticPrefs::privacy_restrict3rdpartystorage_enabled()) {
|
||||
return STATUS_REJECTED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,9 +270,9 @@ class nsCookieService final : public nsICookieService
|
|||
static bool IsSameSiteEnabled();
|
||||
static bool PathMatches(nsCookie* aCookie, const nsACString& aPath);
|
||||
static bool CanSetCookie(nsIURI *aHostURI, const nsCookieKey& aKey, nsCookieAttributes &aCookieAttributes, bool aRequireHostMatch, CookieStatus aStatus, nsDependentCString &aCookieHeader, int64_t aServerTime, bool aFromHttp, nsIChannel* aChannel, bool aLeaveSercureAlone, bool &aSetCookie, mozIThirdPartyUtil* aThirdPartyUtil);
|
||||
static CookieStatus CheckPrefs(nsICookiePermission *aPermissionServices, uint8_t aCookieBehavior, bool aThirdPartySession, bool aThirdPartyNonsecureSession, nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, bool aIsFirstPartyStorageAccessGranted, const char *aCookieHeader, const int aNumOfCookies, const OriginAttributes& aOriginAttrs);
|
||||
static CookieStatus CheckPrefs(nsICookiePermission *aPermissionServices, uint8_t aCookieBehavior, bool aThirdPartySession, bool aThirdPartyNonsecureSession, nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, const char *aCookieHeader, const int aNumOfCookies, const OriginAttributes& aOriginAttrs);
|
||||
static int64_t ParseServerTime(const nsCString &aServerTime);
|
||||
void GetCookiesForURI(nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, bool aFirstPartyStorageAccessGranted, bool aIsSafeTopLevelNav, bool aIsTopLevelForeign, bool aHttpBound, const OriginAttributes& aOriginAttrs, nsTArray<nsCookie*>& aCookieList);
|
||||
void GetCookiesForURI(nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, bool aIsSafeTopLevelNav, bool aIsTopLevelForeign, bool aHttpBound, const OriginAttributes& aOriginAttrs, nsTArray<nsCookie*>& aCookieList);
|
||||
|
||||
protected:
|
||||
virtual ~nsCookieService();
|
||||
|
|
@ -298,9 +298,9 @@ class nsCookieService final : public nsICookieService
|
|||
void EnsureReadComplete(bool aInitDBConn);
|
||||
nsresult NormalizeHost(nsCString &aHost);
|
||||
nsresult GetCookieStringCommon(nsIURI *aHostURI, nsIChannel *aChannel, bool aHttpBound, char** aCookie);
|
||||
void GetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, bool aFirstPartyStorageAccessGranted, bool aIsSafeTopLevelNav, bool aIsTopLevelForeign, bool aHttpBound, const OriginAttributes& aOriginAttrs, nsCString &aCookie);
|
||||
void GetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, bool aIsSafeTopLevelNav, bool aIsTopLevelForeign, bool aHttpBound, const OriginAttributes& aOriginAttrs, nsCString &aCookie);
|
||||
nsresult SetCookieStringCommon(nsIURI *aHostURI, const char *aCookieHeader, const char *aServerTime, nsIChannel *aChannel, bool aFromHttp);
|
||||
void SetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, bool aFirstPartyStorageAccessGranted, nsDependentCString &aCookieHeader, const nsCString &aServerTime, bool aFromHttp, const OriginAttributes &aOriginAttrs, nsIChannel* aChannel);
|
||||
void SetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource, nsDependentCString &aCookieHeader, const nsCString &aServerTime, bool aFromHttp, const OriginAttributes &aOriginAttrs, nsIChannel* aChannel);
|
||||
bool SetCookieInternal(nsIURI *aHostURI, const nsCookieKey& aKey, bool aRequireHostMatch, CookieStatus aStatus, nsDependentCString &aCookieHeader, int64_t aServerTime, bool aFromHttp, nsIChannel* aChannel);
|
||||
void AddInternal(const nsCookieKey& aKey, nsCookie *aCookie, int64_t aCurrentTimeInUsec, nsIURI *aHostURI, const char *aCookieHeader, bool aFromHttp);
|
||||
void RemoveCookieFromList(const nsListIter &aIter, mozIStorageBindingParamsArray *aParamsArray = nullptr);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ struct LoadInfoArgs
|
|||
uint32_t securityFlags;
|
||||
uint32_t contentPolicyType;
|
||||
uint32_t tainting;
|
||||
nsString[] firstPartyStorageAccessGrantedOrigins;
|
||||
bool upgradeInsecureRequests;
|
||||
bool browserUpgradeInsecureRequests;
|
||||
bool browserWouldUpgradeInsecureRequests;
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>A popup!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>hi!</h1>
|
||||
<script>
|
||||
|
||||
SpecialPowers.wrap(document).userInteractionForTesting();
|
||||
opener.postMessage("hello!", "*");
|
||||
window.close();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Interact with me!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Interact with me!</h1>
|
||||
<script>
|
||||
|
||||
function info(msg) {
|
||||
parent.postMessage({ type: "info", msg }, "*");
|
||||
}
|
||||
|
||||
function ok(what, msg) {
|
||||
parent.postMessage({ type: "ok", what: !!what, msg }, "*");
|
||||
}
|
||||
|
||||
function is(a, b, msg) {
|
||||
ok(a === b, msg);
|
||||
}
|
||||
|
||||
onmessage = function(e) {
|
||||
let runnableStr = `(() => {return (${e.data.blockingCallback});})();`;
|
||||
let runnable = eval(runnableStr); // eslint-disable-line no-eval
|
||||
runnable.call(this).then(_ => {
|
||||
info("Let's do a window.open()");
|
||||
return new Promise(resolve => {
|
||||
onmessage = resolve;
|
||||
window.open("3rdPartyOpen.html");
|
||||
});
|
||||
}).then(_ => {
|
||||
info("The popup has been dismissed!");
|
||||
let runnableStr = `(() => {return (${e.data.nonBlockingCallback});})();`;
|
||||
let runnable = eval(runnableStr); // eslint-disable-line no-eval
|
||||
return runnable.call(this);
|
||||
}).then(_ => {
|
||||
parent.postMessage({ type: "finish" }, "*");
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -3,15 +3,11 @@ support-files =
|
|||
head.js
|
||||
page.html
|
||||
3rdParty.html
|
||||
3rdPartyUI.html
|
||||
3rdPartyOpen.html
|
||||
empty.js
|
||||
|
||||
[browser_blockingResources.js]
|
||||
[browser_blockingCookies.js]
|
||||
support-files = server.sjs
|
||||
[browser_blockingIndexedDb.js]
|
||||
[browser_blockingStorage.js]
|
||||
[browser_blockingWorkers.js]
|
||||
[browser_blockingMessaging.js]
|
||||
[browser_imageCache.js]
|
||||
support-files = image.sjs
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
AntiTracking.runTest("Set/Get Cookies",
|
||||
// Blocking callback
|
||||
async _ => {
|
||||
is(document.cookie, "", "No cookies for me");
|
||||
|
||||
|
|
@ -15,8 +14,6 @@ AntiTracking.runTest("Set/Get Cookies",
|
|||
|
||||
is(document.cookie, "", "Still no cookies for me");
|
||||
},
|
||||
|
||||
// Non blocking callback
|
||||
async _ => {
|
||||
is(document.cookie, "", "No cookies for me");
|
||||
|
||||
|
|
@ -28,11 +25,11 @@ AntiTracking.runTest("Set/Get Cookies",
|
|||
});
|
||||
|
||||
ok(document.cookie.length, "Some Cookies for me");
|
||||
},
|
||||
|
||||
// Cleanup callback
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
registerCleanupFunction(async _ => {
|
||||
// cache removed.
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
AntiTracking.runTest("IndexedDB",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
try {
|
||||
indexedDB.open("test", "1");
|
||||
ok(false, "IDB should be blocked");
|
||||
} catch (e) {
|
||||
ok(true, "IDB should be blocked");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
},
|
||||
// non-blocking callback
|
||||
async _ => {
|
||||
indexedDB.open("test", "1");
|
||||
ok(true, "IDB should be allowed");
|
||||
},
|
||||
// Cleanup callback
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
AntiTracking.runTest("IndexedDB in workers",
|
||||
async _ => {
|
||||
function blockCode() {
|
||||
try {
|
||||
indexedDB.open("test", "1");
|
||||
postMessage(false);
|
||||
} catch (e) {
|
||||
postMessage(e.name == "SecurityError");
|
||||
}
|
||||
}
|
||||
|
||||
let blob = new Blob([blockCode.toString() + "; blockCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
let blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise(resolve => {
|
||||
worker.onmessage = function(e) {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
async _ => {
|
||||
function nonBlockCode() {
|
||||
indexedDB.open("test", "1");
|
||||
postMessage(false);
|
||||
}
|
||||
|
||||
let blob = new Blob([nonBlockCode.toString() + "; nonBlockCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
let blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise(resolve => {
|
||||
worker.onmessage = function(e) {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
|
@ -10,12 +10,7 @@ AntiTracking.runTest("BroadcastChannel",
|
|||
},
|
||||
async _ => {
|
||||
new BroadcastChannel("hello");
|
||||
ok(true, "BroadcastChannel be used");
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
ok(true, "BroadcastChannel can be used");
|
||||
});
|
||||
|
||||
AntiTracking.runTest("BroadcastChannel in workers",
|
||||
|
|
@ -64,9 +59,4 @@ AntiTracking.runTest("BroadcastChannel in workers",
|
|||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,127 @@
|
|||
AntiTracking.runTest("IndexedDB",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
try {
|
||||
indexedDB.open("test", "1");
|
||||
ok(false, "IDB should be blocked");
|
||||
} catch (e) {
|
||||
ok(true, "IDB should be blocked");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
},
|
||||
// non-blocking callback
|
||||
async _ => {
|
||||
indexedDB.open("test", "1");
|
||||
ok(true, "IDB should be allowed");
|
||||
});
|
||||
|
||||
AntiTracking.runTest("IndexedDB in workers",
|
||||
async _ => {
|
||||
function blockCode() {
|
||||
try {
|
||||
indexedDB.open("test", "1");
|
||||
postMessage(false);
|
||||
} catch (e) {
|
||||
postMessage(e.name == "SecurityError");
|
||||
}
|
||||
}
|
||||
|
||||
let blob = new Blob([blockCode.toString() + "; blockCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
let blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise(resolve => {
|
||||
worker.onmessage = function(e) {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
async _ => {
|
||||
function nonBlockCode() {
|
||||
indexedDB.open("test", "1");
|
||||
postMessage(false);
|
||||
}
|
||||
|
||||
let blob = new Blob([nonBlockCode.toString() + "; nonBlockCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
let blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise(resolve => {
|
||||
worker.onmessage = function(e) {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
AntiTracking.runTest("localStorage",
|
||||
async _ => {
|
||||
try {
|
||||
localStorage.foo = 42;
|
||||
ok(false, "LocalStorage cannot be used!");
|
||||
} catch (e) {
|
||||
ok(true, "LocalStorage cannot be used!");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
},
|
||||
async _ => {
|
||||
localStorage.foo = 42;
|
||||
ok(true, "LocalStorage is allowed");
|
||||
});
|
||||
|
||||
AntiTracking.runTest("sessionStorage",
|
||||
async _ => {
|
||||
sessionStorage.foo = 42;
|
||||
ok(true, "SessionStorage is always allowed");
|
||||
},
|
||||
async _ => {
|
||||
sessionStorage.foo = 42;
|
||||
ok(true, "SessionStorage is always allowed");
|
||||
});
|
||||
|
||||
AntiTracking.runTest("SharedWorkers",
|
||||
async _ => {
|
||||
try {
|
||||
new SharedWorker("a.js", "foo");
|
||||
ok(false, "SharedWorker cannot be used!");
|
||||
} catch (e) {
|
||||
ok(true, "SharedWorker cannot be used!");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
},
|
||||
async _ => {
|
||||
new SharedWorker("a.js", "foo");
|
||||
ok(true, "SharedWorker is allowed");
|
||||
});
|
||||
|
||||
AntiTracking.runTest("ServiceWorkers",
|
||||
async _ => {
|
||||
await navigator.serviceWorker.register("empty.js", { scope: "/" }).then(
|
||||
_ => { ok(false, "ServiceWorker cannot be used!"); },
|
||||
_ => { ok(true, "ServiceWorker cannot be used!"); });
|
||||
},
|
||||
null,
|
||||
[["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true]]);
|
||||
|
||||
AntiTracking.runTest("DOM Cache",
|
||||
async _ => {
|
||||
await caches.open("wow").then(
|
||||
_ => { ok(false, "DOM Cache cannot be used!"); },
|
||||
_ => { ok(true, "DOM Cache cannot be used!"); });
|
||||
},
|
||||
async _ => {
|
||||
await caches.open("wow").then(
|
||||
_ => { ok(true, "DOM Cache can be used!"); },
|
||||
_ => { ok(false, "DOM Cache can be used!"); });
|
||||
});
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
AntiTracking.runTest("localStorage",
|
||||
async _ => {
|
||||
try {
|
||||
localStorage.foo = 42;
|
||||
ok(false, "LocalStorage cannot be used!");
|
||||
} catch (e) {
|
||||
ok(true, "LocalStorage cannot be used!");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
},
|
||||
async _ => {
|
||||
localStorage.foo = 42;
|
||||
ok(true, "LocalStorage is allowed");
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
AntiTracking.runTest("sessionStorage",
|
||||
async _ => {
|
||||
sessionStorage.foo = 42;
|
||||
ok(true, "SessionStorage is always allowed");
|
||||
},
|
||||
async _ => {
|
||||
sessionStorage.foo = 42;
|
||||
ok(true, "SessionStorage is always allowed");
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
AntiTracking.runTest("SharedWorkers",
|
||||
async _ => {
|
||||
try {
|
||||
new SharedWorker("a.js", "foo");
|
||||
ok(false, "SharedWorker cannot be used!");
|
||||
} catch (e) {
|
||||
ok(true, "SharedWorker cannot be used!");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
},
|
||||
async _ => {
|
||||
new SharedWorker("a.js", "foo");
|
||||
ok(true, "SharedWorker is allowed");
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
AntiTracking.runTest("ServiceWorkers",
|
||||
async _ => {
|
||||
await navigator.serviceWorker.register("empty.js", { scope: "/" }).then(
|
||||
_ => { ok(false, "ServiceWorker cannot be used!"); },
|
||||
_ => { ok(true, "ServiceWorker cannot be used!"); });
|
||||
},
|
||||
null,
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
[["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true]]);
|
||||
|
||||
AntiTracking.runTest("DOM Cache",
|
||||
async _ => {
|
||||
await caches.open("wow").then(
|
||||
_ => { ok(false, "DOM Cache cannot be used!"); },
|
||||
_ => { ok(true, "DOM Cache cannot be used!"); });
|
||||
},
|
||||
async _ => {
|
||||
await caches.open("wow").then(
|
||||
_ => { ok(true, "DOM Cache can be used!"); },
|
||||
_ => { ok(false, "DOM Cache can be used!"); });
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
|
@ -5,45 +5,34 @@ const TEST_PATH = "browser/toolkit/components/antitracking/test/browser/";
|
|||
|
||||
const TEST_TOP_PAGE = TEST_DOMAIN + TEST_PATH + "page.html";
|
||||
const TEST_3RD_PARTY_PAGE = TEST_3RD_PARTY_DOMAIN + TEST_PATH + "3rdParty.html";
|
||||
const TEST_3RD_PARTY_PAGE_UI = TEST_3RD_PARTY_DOMAIN + TEST_PATH + "3rdPartyUI.html";
|
||||
|
||||
let {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
this.AntiTracking = {
|
||||
runTest(name, callbackTracking, callbackNonTracking, cleanupFunction, extraPrefs) {
|
||||
runTest(name, callbackTracking, callbackNonTracking, extraPrefs) {
|
||||
this._createTask(name, true, callbackTracking, extraPrefs);
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
if (callbackNonTracking) {
|
||||
this._createTask(name, false, callbackNonTracking);
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createUserInteractionTask(name, callbackTracking, callbackNonTracking, extraPrefs);
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
}
|
||||
},
|
||||
|
||||
async _setupTest(blocking, extraPrefs) {
|
||||
await SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["privacy.restrict3rdpartystorage.enabled", blocking],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
["privacy.trackingprotection.annotate_channels", blocking],
|
||||
]});
|
||||
|
||||
if (extraPrefs && Array.isArray(extraPrefs) && extraPrefs.length) {
|
||||
await SpecialPowers.pushPrefEnv({"set": extraPrefs });
|
||||
}
|
||||
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
},
|
||||
|
||||
_createTask(name, blocking, callback, extraPrefs) {
|
||||
add_task(async function() {
|
||||
info("Starting " + (blocking ? "blocking" : "non-blocking") + " test " + name);
|
||||
|
||||
await AntiTracking._setupTest(blocking, extraPrefs);
|
||||
await SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["privacy.restrict3rdpartystorage.enabled", blocking],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
["privacy.trackingprotection.annotate_channels", blocking],
|
||||
]});
|
||||
|
||||
if (extraPrefs && Array.isArray(extraPrefs) && extraPrefs.length) {
|
||||
await SpecialPowers.pushPrefEnv({"set": extraPrefs });
|
||||
}
|
||||
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
|
||||
info("Creating a new tab");
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
|
||||
|
|
@ -92,73 +81,6 @@ this.AntiTracking = {
|
|||
info("Removing the tab");
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
});
|
||||
},
|
||||
|
||||
_createCleanupTask(cleanupFunction) {
|
||||
add_task(async function() {
|
||||
info("Cleaning up.");
|
||||
if (cleanupFunction) {
|
||||
await cleanupFunction();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_createUserInteractionTask(name, blockingCallback, nonBlockingCallback, extraPrefs) {
|
||||
add_task(async function() {
|
||||
info("Starting user-interaction test " + name);
|
||||
await AntiTracking._setupTest(true, extraPrefs);
|
||||
|
||||
info("Creating a new tab");
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
|
||||
gBrowser.selectedTab = tab;
|
||||
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
info("Creating a 3rd party content");
|
||||
await ContentTask.spawn(browser,
|
||||
{ page: TEST_3RD_PARTY_PAGE_UI,
|
||||
blockingCallback: blockingCallback.toString(),
|
||||
nonBlockingCallback: nonBlockingCallback.toString(),
|
||||
},
|
||||
async function(obj) {
|
||||
await new content.Promise(resolve => {
|
||||
let ifr = content.document.createElement("iframe");
|
||||
ifr.onload = function() {
|
||||
info("Sending code to the 3rd party content");
|
||||
ifr.contentWindow.postMessage(obj, "*");
|
||||
};
|
||||
|
||||
content.addEventListener("message", function msg(event) {
|
||||
if (event.data.type == "finish") {
|
||||
content.removeEventListener("message", msg);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "ok") {
|
||||
ok(event.data.what, event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "info") {
|
||||
info(event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Unknown message");
|
||||
});
|
||||
|
||||
content.document.body.appendChild(ifr);
|
||||
ifr.src = obj.page;
|
||||
});
|
||||
});
|
||||
|
||||
info("Removing the tab");
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue