Backed out 12 changesets (bug 1915419) for causing failures at test_bouncetracking_purge.js. CLOSED TREE
Backed out changeset e5c32a502e0f (bug 1915419) Backed out changeset 8cbcbb25fc99 (bug 1915419) Backed out changeset 947379a2f167 (bug 1915419) Backed out changeset 4cfe3a954ade (bug 1915419) Backed out changeset 94fba1a2786b (bug 1915419) Backed out changeset 477b4f7c2760 (bug 1915419) Backed out changeset ed6c8d9d39d4 (bug 1915419) Backed out changeset e534c390101c (bug 1915419) Backed out changeset bc3fe74a8b03 (bug 1915419) Backed out changeset afefdce605f9 (bug 1915419) Backed out changeset e58887b90d39 (bug 1915419) Backed out changeset 114298b7b855 (bug 1915419)
This commit is contained in:
@@ -391,7 +391,7 @@ async function createDummyDataForHost(host) {
|
|||||||
"dummy.js";
|
"dummy.js";
|
||||||
|
|
||||||
await SiteDataTestUtils.addToIndexedDB(origin);
|
await SiteDataTestUtils.addToIndexedDB(origin);
|
||||||
await SiteDataTestUtils.addServiceWorker({ win: window, path: dummySWURL });
|
await SiteDataTestUtils.addServiceWorker(dummySWURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -532,15 +532,29 @@ export var SiteDataManager = {
|
|||||||
new Promise(function (resolve) {
|
new Promise(function (resolve) {
|
||||||
const { clearData } = Services;
|
const { clearData } = Services;
|
||||||
if (domainOrHost) {
|
if (domainOrHost) {
|
||||||
let schemelessSite =
|
// First try to clear by base domain for aDomainOrHost. If we can't
|
||||||
Services.eTLD.getSchemelessSiteFromHost(domainOrHost);
|
// get a base domain, fall back to clearing by just host.
|
||||||
clearData.deleteDataFromSite(
|
try {
|
||||||
schemelessSite,
|
clearData.deleteDataFromBaseDomain(
|
||||||
{},
|
domainOrHost,
|
||||||
true,
|
true,
|
||||||
Ci.nsIClearDataService.CLEAR_COOKIES_AND_SITE_DATA,
|
Ci.nsIClearDataService.CLEAR_COOKIES_AND_SITE_DATA,
|
||||||
resolve
|
resolve
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (
|
||||||
|
e.result != Cr.NS_ERROR_HOST_IS_IP_ADDRESS &&
|
||||||
|
e.result != Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS
|
||||||
|
) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
clearData.deleteDataFromHost(
|
||||||
|
domainOrHost,
|
||||||
|
true,
|
||||||
|
Ci.nsIClearDataService.CLEAR_COOKIES_AND_SITE_DATA,
|
||||||
|
resolve
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
clearData.deleteDataFromLocalFiles(
|
clearData.deleteDataFromLocalFiles(
|
||||||
true,
|
true,
|
||||||
|
|||||||
@@ -1361,14 +1361,12 @@ void ChromeUtils::ClearRecentJSDevError(GlobalObject&) {
|
|||||||
|
|
||||||
void ChromeUtils::ClearStyleSheetCacheByPrincipal(GlobalObject&,
|
void ChromeUtils::ClearStyleSheetCacheByPrincipal(GlobalObject&,
|
||||||
nsIPrincipal* aForPrincipal) {
|
nsIPrincipal* aForPrincipal) {
|
||||||
SharedStyleSheetCache::Clear(Some(aForPrincipal));
|
SharedStyleSheetCache::Clear(aForPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeUtils::ClearStyleSheetCacheBySite(
|
void ChromeUtils::ClearStyleSheetCacheByBaseDomain(
|
||||||
GlobalObject&, const nsACString& aSchemelessSite,
|
GlobalObject&, const nsACString& aBaseDomain) {
|
||||||
const dom::OriginAttributesPatternDictionary& aPattern) {
|
SharedStyleSheetCache::Clear(nullptr, &aBaseDomain);
|
||||||
SharedStyleSheetCache::Clear(Nothing(), Some(nsCString(aSchemelessSite)),
|
|
||||||
Some(OriginAttributesPattern(aPattern)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeUtils::ClearStyleSheetCache(GlobalObject&) {
|
void ChromeUtils::ClearStyleSheetCache(GlobalObject&) {
|
||||||
@@ -1377,14 +1375,12 @@ void ChromeUtils::ClearStyleSheetCache(GlobalObject&) {
|
|||||||
|
|
||||||
void ChromeUtils::ClearScriptCacheByPrincipal(GlobalObject&,
|
void ChromeUtils::ClearScriptCacheByPrincipal(GlobalObject&,
|
||||||
nsIPrincipal* aForPrincipal) {
|
nsIPrincipal* aForPrincipal) {
|
||||||
SharedScriptCache::Clear(Some(aForPrincipal));
|
SharedScriptCache::Clear(aForPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeUtils::ClearScriptCacheBySite(
|
void ChromeUtils::ClearScriptCacheByBaseDomain(GlobalObject&,
|
||||||
GlobalObject&, const nsACString& aSchemelessSite,
|
const nsACString& aBaseDomain) {
|
||||||
const dom::OriginAttributesPatternDictionary& aPattern) {
|
SharedScriptCache::Clear(nullptr, &aBaseDomain);
|
||||||
SharedScriptCache::Clear(Nothing(), Some(nsCString(aSchemelessSite)),
|
|
||||||
Some(aPattern));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeUtils::ClearScriptCache(GlobalObject&) {
|
void ChromeUtils::ClearScriptCache(GlobalObject&) {
|
||||||
|
|||||||
@@ -185,18 +185,16 @@ class ChromeUtils {
|
|||||||
static void ClearStyleSheetCacheByPrincipal(GlobalObject&,
|
static void ClearStyleSheetCacheByPrincipal(GlobalObject&,
|
||||||
nsIPrincipal* aForPrincipal);
|
nsIPrincipal* aForPrincipal);
|
||||||
|
|
||||||
static void ClearStyleSheetCacheBySite(
|
static void ClearStyleSheetCacheByBaseDomain(GlobalObject& aGlobal,
|
||||||
GlobalObject&, const nsACString& aSchemelessSite,
|
const nsACString& aBaseDomain);
|
||||||
const dom::OriginAttributesPatternDictionary& aPattern);
|
|
||||||
|
|
||||||
static void ClearStyleSheetCache(GlobalObject& aGlobal);
|
static void ClearStyleSheetCache(GlobalObject& aGlobal);
|
||||||
|
|
||||||
static void ClearScriptCacheByPrincipal(GlobalObject&,
|
static void ClearScriptCacheByPrincipal(GlobalObject&,
|
||||||
nsIPrincipal* aForPrincipal);
|
nsIPrincipal* aForPrincipal);
|
||||||
|
|
||||||
static void ClearScriptCacheBySite(
|
static void ClearScriptCacheByBaseDomain(GlobalObject& aGlobal,
|
||||||
GlobalObject& aGlobal, const nsACString& aSchemelessSite,
|
const nsACString& aBaseDomain);
|
||||||
const dom::OriginAttributesPatternDictionary& aPattern);
|
|
||||||
|
|
||||||
static void ClearScriptCache(GlobalObject& aGlobal);
|
static void ClearScriptCache(GlobalObject& aGlobal);
|
||||||
|
|
||||||
|
|||||||
@@ -228,10 +228,10 @@ namespace ChromeUtils {
|
|||||||
#endif // NIGHTLY_BUILD
|
#endif // NIGHTLY_BUILD
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the stylesheet cache by site. This includes associated
|
* Clears the stylesheet cache by baseDomain. This includes associated
|
||||||
* state-partitioned cache.
|
* state-partitioned cache.
|
||||||
*/
|
*/
|
||||||
undefined clearStyleSheetCacheBySite(UTF8String schemelessSite, optional OriginAttributesPatternDictionary pattern = {});
|
undefined clearStyleSheetCacheByBaseDomain(UTF8String baseDomain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the stylesheet cache by principal.
|
* Clears the stylesheet cache by principal.
|
||||||
@@ -244,10 +244,10 @@ namespace ChromeUtils {
|
|||||||
undefined clearStyleSheetCache();
|
undefined clearStyleSheetCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the JavaScript cache by schemeless site. This includes associated
|
* Clears the JavaScript cache by baseDomain. This includes associated
|
||||||
* state-partitioned cache.
|
* state-partitioned cache.
|
||||||
*/
|
*/
|
||||||
undefined clearScriptCacheBySite(UTF8String schemelessSite, optional OriginAttributesPatternDictionary pattern = {});
|
undefined clearScriptCacheByBaseDomain(UTF8String baseDomain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the JavaScript cache by principal.
|
* Clears the JavaScript cache by principal.
|
||||||
|
|||||||
@@ -2090,18 +2090,22 @@ mozilla::ipc::IPCResult ContentChild::RecvRegisterChromeItem(
|
|||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
mozilla::ipc::IPCResult ContentChild::RecvClearStyleSheetCache(
|
mozilla::ipc::IPCResult ContentChild::RecvClearStyleSheetCache(
|
||||||
const Maybe<RefPtr<nsIPrincipal>>& aPrincipal,
|
const Maybe<RefPtr<nsIPrincipal>>& aForPrincipal,
|
||||||
const Maybe<nsCString>& aSchemelessSite,
|
const Maybe<nsCString>& aBaseDomain) {
|
||||||
const Maybe<OriginAttributesPattern>& aPattern) {
|
nsIPrincipal* principal =
|
||||||
SharedStyleSheetCache::Clear(aPrincipal, aSchemelessSite, aPattern);
|
aForPrincipal ? aForPrincipal.value().get() : nullptr;
|
||||||
|
const nsCString* baseDomain = aBaseDomain ? aBaseDomain.ptr() : nullptr;
|
||||||
|
SharedStyleSheetCache::Clear(principal, baseDomain);
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult ContentChild::RecvClearScriptCache(
|
mozilla::ipc::IPCResult ContentChild::RecvClearScriptCache(
|
||||||
const Maybe<RefPtr<nsIPrincipal>>& aPrincipal,
|
const Maybe<RefPtr<nsIPrincipal>>& aForPrincipal,
|
||||||
const Maybe<nsCString>& aSchemelessSite,
|
const Maybe<nsCString>& aBaseDomain) {
|
||||||
const Maybe<OriginAttributesPattern>& aPattern) {
|
nsIPrincipal* principal =
|
||||||
SharedScriptCache::Clear(aPrincipal, aSchemelessSite, aPattern);
|
aForPrincipal ? aForPrincipal.value().get() : nullptr;
|
||||||
|
const nsCString* baseDomain = aBaseDomain ? aBaseDomain.ptr() : nullptr;
|
||||||
|
SharedScriptCache::Clear(principal, baseDomain);
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2114,16 +2118,15 @@ mozilla::ipc::IPCResult ContentChild::RecvClearImageCacheFromPrincipal(
|
|||||||
loader = imgLoader::NormalLoader();
|
loader = imgLoader::NormalLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
loader->RemoveEntriesInternal(Some(aPrincipal), Nothing(), Nothing());
|
loader->RemoveEntriesInternal(aPrincipal, nullptr);
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult ContentChild::RecvClearImageCacheFromSite(
|
mozilla::ipc::IPCResult ContentChild::RecvClearImageCacheFromBaseDomain(
|
||||||
const nsCString& aSchemelessSite, const OriginAttributesPattern& aPattern) {
|
const nsCString& aBaseDomain) {
|
||||||
imgLoader::NormalLoader()->RemoveEntriesInternal(
|
imgLoader::NormalLoader()->RemoveEntriesInternal(nullptr, &aBaseDomain);
|
||||||
Nothing(), Some(aSchemelessSite), Some(aPattern));
|
imgLoader::PrivateBrowsingLoader()->RemoveEntriesInternal(nullptr,
|
||||||
imgLoader::PrivateBrowsingLoader()->RemoveEntriesInternal(
|
&aBaseDomain);
|
||||||
Nothing(), Some(aSchemelessSite), Some(aPattern));
|
|
||||||
|
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,20 +246,17 @@ class ContentChild final : public PContentChild,
|
|||||||
const ChromeRegistryItem& item);
|
const ChromeRegistryItem& item);
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvClearStyleSheetCache(
|
mozilla::ipc::IPCResult RecvClearStyleSheetCache(
|
||||||
const Maybe<RefPtr<nsIPrincipal>>& aPrincipal,
|
const Maybe<RefPtr<nsIPrincipal>>& aForPrincipal,
|
||||||
const Maybe<nsCString>& aSchemelessSite,
|
const Maybe<nsCString>& aBaseDomain);
|
||||||
const Maybe<OriginAttributesPattern>& aPattern);
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvClearScriptCache(
|
mozilla::ipc::IPCResult RecvClearScriptCache(
|
||||||
const Maybe<RefPtr<nsIPrincipal>>& aPrincipal,
|
const Maybe<RefPtr<nsIPrincipal>>& aForPrincipal,
|
||||||
const Maybe<nsCString>& aSchemelessSite,
|
const Maybe<nsCString>& aBaseDomain);
|
||||||
const Maybe<OriginAttributesPattern>& aPattern);
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvClearImageCacheFromPrincipal(
|
mozilla::ipc::IPCResult RecvClearImageCacheFromPrincipal(
|
||||||
nsIPrincipal* aPrincipal);
|
nsIPrincipal* aPrincipal);
|
||||||
mozilla::ipc::IPCResult RecvClearImageCacheFromSite(
|
mozilla::ipc::IPCResult RecvClearImageCacheFromBaseDomain(
|
||||||
const nsCString& aSchemelessSite,
|
const nsCString& aBaseDomain);
|
||||||
const OriginAttributesPattern& aPattern);
|
|
||||||
mozilla::ipc::IPCResult RecvClearImageCache(const bool& privateLoader,
|
mozilla::ipc::IPCResult RecvClearImageCache(const bool& privateLoader,
|
||||||
const bool& chrome);
|
const bool& chrome);
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ using mozilla::widget::ThemeChangeKind from "mozilla/widget/WidgetMessageUtils.h
|
|||||||
using class mozilla::dom::MessagePort from "mozilla/dom/MessagePort.h";
|
using class mozilla::dom::MessagePort from "mozilla/dom/MessagePort.h";
|
||||||
[MoveOnly=data] using class mozilla::dom::ipc::StructuredCloneData from "mozilla/dom/ipc/StructuredCloneData.h";
|
[MoveOnly=data] using class mozilla::dom::ipc::StructuredCloneData from "mozilla/dom/ipc/StructuredCloneData.h";
|
||||||
using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
|
using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
|
||||||
using mozilla::OriginAttributesPattern from "mozilla/dom/quota/SerializationHelpers.h";
|
|
||||||
using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
|
using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
|
||||||
using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h";
|
using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h";
|
||||||
using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h";
|
using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h";
|
||||||
@@ -664,17 +663,15 @@ child:
|
|||||||
|
|
||||||
async ClearImageCacheFromPrincipal(nullable nsIPrincipal aPrincipal);
|
async ClearImageCacheFromPrincipal(nullable nsIPrincipal aPrincipal);
|
||||||
|
|
||||||
async ClearImageCacheFromSite(nsCString aSchemelessSite, OriginAttributesPattern aPattern);
|
async ClearImageCacheFromBaseDomain(nsCString aBaseDomain);
|
||||||
|
|
||||||
async ClearImageCache(bool privateLoader, bool chrome);
|
async ClearImageCache(bool privateLoader, bool chrome);
|
||||||
|
|
||||||
async ClearStyleSheetCache(nullable nsIPrincipal? aPrincipal,
|
async ClearStyleSheetCache(nullable nsIPrincipal? aForPrincipal,
|
||||||
nsCString? aSchemelessSite,
|
nsCString? aBaseDomain);
|
||||||
OriginAttributesPattern? aPattern);
|
|
||||||
|
|
||||||
async ClearScriptCache(nullable nsIPrincipal? aPrincipal,
|
async ClearScriptCache(nullable nsIPrincipal? aForPrincipal,
|
||||||
nsCString? aSchemelessSite,
|
nsCString? aBaseDomain);
|
||||||
OriginAttributesPattern? aPattern);
|
|
||||||
|
|
||||||
async SetOffline(bool offline);
|
async SetOffline(bool offline);
|
||||||
async SetConnectivity(bool connectivity);
|
async SetConnectivity(bool connectivity);
|
||||||
|
|||||||
@@ -84,36 +84,13 @@ struct ParamTraits<mozilla::OriginAttributesPattern> {
|
|||||||
WriteParam(aWriter, aParam.mPrivateBrowsingId);
|
WriteParam(aWriter, aParam.mPrivateBrowsingId);
|
||||||
WriteParam(aWriter, aParam.mUserContextId);
|
WriteParam(aWriter, aParam.mUserContextId);
|
||||||
WriteParam(aWriter, aParam.mGeckoViewSessionContextId);
|
WriteParam(aWriter, aParam.mGeckoViewSessionContextId);
|
||||||
WriteParam(aWriter, aParam.mPartitionKey);
|
|
||||||
WriteParam(aWriter, aParam.mPartitionKeyPattern);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Read(MessageReader* aReader, paramType* aResult) {
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
||||||
return ReadParam(aReader, &aResult->mFirstPartyDomain) &&
|
return ReadParam(aReader, &aResult->mFirstPartyDomain) &&
|
||||||
ReadParam(aReader, &aResult->mPrivateBrowsingId) &&
|
ReadParam(aReader, &aResult->mPrivateBrowsingId) &&
|
||||||
ReadParam(aReader, &aResult->mUserContextId) &&
|
ReadParam(aReader, &aResult->mUserContextId) &&
|
||||||
ReadParam(aReader, &aResult->mGeckoViewSessionContextId) &&
|
ReadParam(aReader, &aResult->mGeckoViewSessionContextId);
|
||||||
ReadParam(aReader, &aResult->mPartitionKey) &&
|
|
||||||
ReadParam(aReader, &aResult->mPartitionKeyPattern);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct ParamTraits<mozilla::dom::PartitionKeyPatternDictionary> {
|
|
||||||
typedef mozilla::dom::PartitionKeyPatternDictionary paramType;
|
|
||||||
|
|
||||||
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
||||||
WriteParam(aWriter, aParam.mScheme);
|
|
||||||
WriteParam(aWriter, aParam.mBaseDomain);
|
|
||||||
WriteParam(aWriter, aParam.mPort);
|
|
||||||
WriteParam(aWriter, aParam.mForeignByAncestorContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool Read(MessageReader* aReader, paramType* aResult) {
|
|
||||||
return ReadParam(aReader, &aResult->mScheme) &&
|
|
||||||
ReadParam(aReader, &aResult->mBaseDomain) &&
|
|
||||||
ReadParam(aReader, &aResult->mPort) &&
|
|
||||||
ReadParam(aReader, &aResult->mForeignByAncestorContext);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -138,19 +138,21 @@ SharedScriptCache::Observe(nsISupports* aSubject, const char* aTopic,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedScriptCache::Clear(const Maybe<nsCOMPtr<nsIPrincipal>>& aPrincipal,
|
void SharedScriptCache::Clear(nsIPrincipal* aForPrincipal,
|
||||||
const Maybe<nsCString>& aSchemelessSite,
|
const nsACString* aBaseDomain) {
|
||||||
const Maybe<OriginAttributesPattern>& aPattern) {
|
|
||||||
using ContentParent = dom::ContentParent;
|
using ContentParent = dom::ContentParent;
|
||||||
|
|
||||||
if (XRE_IsParentProcess()) {
|
if (XRE_IsParentProcess()) {
|
||||||
|
auto forPrincipal = aForPrincipal ? Some(RefPtr(aForPrincipal)) : Nothing();
|
||||||
|
auto baseDomain = aBaseDomain ? Some(nsCString(*aBaseDomain)) : Nothing();
|
||||||
|
|
||||||
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
||||||
Unused << cp->SendClearScriptCache(aPrincipal, aSchemelessSite, aPattern);
|
Unused << cp->SendClearScriptCache(forPrincipal, baseDomain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sSingleton) {
|
if (sSingleton) {
|
||||||
sSingleton->ClearInProcess(aPrincipal, aSchemelessSite, aPattern);
|
sSingleton->ClearInProcess(aForPrincipal, aBaseDomain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -189,9 +189,8 @@ class SharedScriptCache final
|
|||||||
// a sheet cache (loaders that are not owned by a document).
|
// a sheet cache (loaders that are not owned by a document).
|
||||||
static void LoadCompleted(SharedScriptCache*, ScriptLoadData&);
|
static void LoadCompleted(SharedScriptCache*, ScriptLoadData&);
|
||||||
using Base::LoadCompleted;
|
using Base::LoadCompleted;
|
||||||
static void Clear(const Maybe<nsCOMPtr<nsIPrincipal>>& aPrincipal = Nothing(),
|
static void Clear(nsIPrincipal* aForPrincipal = nullptr,
|
||||||
const Maybe<nsCString>& aSchemelessSite = Nothing(),
|
const nsACString* aBaseDomain = nullptr);
|
||||||
const Maybe<OriginAttributesPattern>& aPattern = Nothing());
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~SharedScriptCache();
|
~SharedScriptCache();
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace mozilla::dom {
|
|||||||
* b. Group headroom is satisfied after origin usage mitigation.
|
* b. Group headroom is satisfied after origin usage mitigation.
|
||||||
* This invokes nsIClearDataService::DeleteDataFromPrincipal().
|
* This invokes nsIClearDataService::DeleteDataFromPrincipal().
|
||||||
* c. Group headroom is satisfied after group usage mitigation.
|
* c. Group headroom is satisfied after group usage mitigation.
|
||||||
* This invokes nsIClearDataService::DeleteDataFromSite().
|
* This invokes nsIClearDataService::DeleteDataFromBaseDomain().
|
||||||
* QuotaUsageChecker::CheckQuotaHeadroom() implements this step.
|
* QuotaUsageChecker::CheckQuotaHeadroom() implements this step.
|
||||||
*
|
*
|
||||||
* If the algorithm is done or error out, the QuotaUsageCheck::mCallback will
|
* If the algorithm is done or error out, the QuotaUsageCheck::mCallback will
|
||||||
@@ -54,7 +54,7 @@ class QuotaUsageChecker final : public nsIQuotaCallback,
|
|||||||
NS_DECL_NSIQUOTAUSAGECALLBACK
|
NS_DECL_NSIQUOTAUSAGECALLBACK
|
||||||
|
|
||||||
// For nsIClearDataService::DeleteDataFromPrincipal() and
|
// For nsIClearDataService::DeleteDataFromPrincipal() and
|
||||||
// nsIClearDataService::DeleteDataFromSite()
|
// nsIClearDataService::DeleteDataFromBaseDomain()
|
||||||
NS_DECL_NSICLEARDATACALLBACK
|
NS_DECL_NSICLEARDATACALLBACK
|
||||||
|
|
||||||
QuotaUsageChecker(nsIPrincipal* aPrincipal,
|
QuotaUsageChecker(nsIPrincipal* aPrincipal,
|
||||||
@@ -193,13 +193,14 @@ void QuotaUsageChecker::CheckQuotaHeadroom() {
|
|||||||
// Group usage headroom is not satisfied even removing the origin usage,
|
// Group usage headroom is not satisfied even removing the origin usage,
|
||||||
// clear all group usage.
|
// clear all group usage.
|
||||||
if ((groupAvailable + mOriginUsage) < groupHeadroom) {
|
if ((groupAvailable + mOriginUsage) < groupHeadroom) {
|
||||||
nsAutoCString baseDomain;
|
nsAutoCString host;
|
||||||
nsresult rv = mPrincipal->GetBaseDomain(baseDomain);
|
nsresult rv = mPrincipal->GetHost(host);
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rv = csd->DeleteDataFromSiteAndOriginAttributesPatternString(
|
|
||||||
baseDomain, u""_ns, false, nsIClearDataService::CLEAR_DOM_QUOTA, this);
|
rv = csd->DeleteDataFromBaseDomain(
|
||||||
|
host, false, nsIClearDataService::CLEAR_DOM_QUOTA, this);
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,9 +84,8 @@ async function clear_qm_origin_group_via_clearData(origin) {
|
|||||||
|
|
||||||
// Initiate group clearing and wait for it.
|
// Initiate group clearing and wait for it.
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
baseDomain,
|
baseDomain,
|
||||||
{},
|
|
||||||
false,
|
false,
|
||||||
Services.clearData.CLEAR_DOM_QUOTA,
|
Services.clearData.CLEAR_DOM_QUOTA,
|
||||||
failedFlags => {
|
failedFlags => {
|
||||||
|
|||||||
@@ -62,15 +62,14 @@ interface imgICache : nsISupports
|
|||||||
void removeEntriesFromPrincipalInAllProcesses(in nsIPrincipal aPrincipal);
|
void removeEntriesFromPrincipalInAllProcesses(in nsIPrincipal aPrincipal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evict images from the non-chrome cache which match the the given site
|
* Evict images from the non-chrome cache which match the the given base
|
||||||
* Matching cache entries will be cleared across all origin attributes
|
* domain. Matching cache entries will be cleared across all origin attributes
|
||||||
* and all processes.
|
* and all processes.
|
||||||
*
|
*
|
||||||
* @param aSchemelessSite site (exlcuding scheme) to delete cache entries for.
|
* @param aBaseDomain base domain to delete cache entries for.
|
||||||
* @throws NS_ERROR_NOT_AVAILABLE if not called in the parent process.
|
* @throws NS_ERROR_NOT_AVAILABLE if not called in the parent process.
|
||||||
*/
|
*/
|
||||||
[implicit_jscontext]
|
void removeEntriesFromBaseDomainInAllProcesses(in ACString aBaseDomain);
|
||||||
void removeEntriesFromSiteInAllProcesses(in ACString aBaseDomain, in jsval OriginAttributesPattern);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find Properties
|
* Find Properties
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
#include "mozilla/StaticPrefs_image.h"
|
#include "mozilla/StaticPrefs_image.h"
|
||||||
#include "mozilla/StaticPrefs_network.h"
|
#include "mozilla/StaticPrefs_network.h"
|
||||||
#include "mozilla/StoragePrincipalHelper.h"
|
#include "mozilla/StoragePrincipalHelper.h"
|
||||||
#include "mozilla/Maybe.h"
|
|
||||||
#include "mozilla/dom/CacheExpirationTime.h"
|
#include "mozilla/dom/CacheExpirationTime.h"
|
||||||
#include "mozilla/dom/ContentParent.h"
|
#include "mozilla/dom/ContentParent.h"
|
||||||
#include "mozilla/dom/FetchPriority.h"
|
#include "mozilla/dom/FetchPriority.h"
|
||||||
@@ -1399,74 +1398,49 @@ imgLoader::RemoveEntriesFromPrincipalInAllProcesses(nsIPrincipal* aPrincipal) {
|
|||||||
loader = imgLoader::NormalLoader();
|
loader = imgLoader::NormalLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
return loader->RemoveEntriesInternal(Some(aPrincipal), Nothing(), Nothing());
|
return loader->RemoveEntriesInternal(aPrincipal, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
imgLoader::RemoveEntriesFromSiteInAllProcesses(
|
imgLoader::RemoveEntriesFromBaseDomainInAllProcesses(
|
||||||
const nsACString& aSchemelessSite,
|
const nsACString& aBaseDomain) {
|
||||||
JS::Handle<JS::Value> aOriginAttributesPattern, JSContext* aCx) {
|
|
||||||
if (!XRE_IsParentProcess()) {
|
if (!XRE_IsParentProcess()) {
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
OriginAttributesPattern pattern;
|
|
||||||
if (!aOriginAttributesPattern.isObject() ||
|
|
||||||
!pattern.Init(aCx, aOriginAttributesPattern)) {
|
|
||||||
return NS_ERROR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
||||||
Unused << cp->SendClearImageCacheFromSite(aSchemelessSite, pattern);
|
Unused << cp->SendClearImageCacheFromBaseDomain(aBaseDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RemoveEntriesInternal(Nothing(), Some(nsCString(aSchemelessSite)),
|
return RemoveEntriesInternal(nullptr, &aBaseDomain);
|
||||||
Some(pattern));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult imgLoader::RemoveEntriesInternal(
|
nsresult imgLoader::RemoveEntriesInternal(nsIPrincipal* aPrincipal,
|
||||||
const Maybe<nsCOMPtr<nsIPrincipal>>& aPrincipal,
|
const nsACString* aBaseDomain) {
|
||||||
const Maybe<nsCString>& aSchemelessSite,
|
// Can only clear by either principal or base domain.
|
||||||
const Maybe<OriginAttributesPattern>& aPattern) {
|
if ((!aPrincipal && !aBaseDomain) || (aPrincipal && aBaseDomain)) {
|
||||||
// Can only clear by either principal or site + pattern.
|
|
||||||
if ((!aPrincipal && !aSchemelessSite) || (aPrincipal && aSchemelessSite) ||
|
|
||||||
aSchemelessSite.isSome() != aPattern.isSome()) {
|
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIEffectiveTLDService> tldService;
|
nsCOMPtr<nsIEffectiveTLDService> tldService;
|
||||||
AutoTArray<RefPtr<imgCacheEntry>, 128> entriesToBeRemoved;
|
AutoTArray<RefPtr<imgCacheEntry>, 128> entriesToBeRemoved;
|
||||||
|
|
||||||
Maybe<OriginAttributesPattern> patternWithPartitionKey = Nothing();
|
|
||||||
if (aPattern) {
|
|
||||||
// Used for checking for cache entries partitioned under aSchemelessSite.
|
|
||||||
OriginAttributesPattern pattern(aPattern.ref());
|
|
||||||
pattern.mPartitionKeyPattern.Construct();
|
|
||||||
pattern.mPartitionKeyPattern.Value().mBaseDomain.Construct(
|
|
||||||
NS_ConvertUTF8toUTF16(aSchemelessSite.ref()));
|
|
||||||
|
|
||||||
patternWithPartitionKey.emplace(std::move(pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
// For base domain we only clear the non-chrome cache.
|
// For base domain we only clear the non-chrome cache.
|
||||||
for (const auto& entry : mCache) {
|
for (const auto& entry : mCache) {
|
||||||
const auto& key = entry.GetKey();
|
const auto& key = entry.GetKey();
|
||||||
|
|
||||||
const bool shouldRemove = [&] {
|
const bool shouldRemove = [&] {
|
||||||
// The isolation key is either just the site, or an origin suffix
|
|
||||||
// which contains the partitionKey holding the baseDomain.
|
|
||||||
|
|
||||||
if (aPrincipal) {
|
if (aPrincipal) {
|
||||||
nsCOMPtr<nsIPrincipal> keyPrincipal =
|
nsCOMPtr<nsIPrincipal> keyPrincipal =
|
||||||
BasePrincipal::CreateContentPrincipal(key.URI(),
|
BasePrincipal::CreateContentPrincipal(key.URI(),
|
||||||
key.OriginAttributesRef());
|
key.OriginAttributesRef());
|
||||||
return keyPrincipal->Equals(aPrincipal.ref());
|
return keyPrincipal->Equals(aPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aSchemelessSite) {
|
if (!aBaseDomain) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Clear by site and pattern.
|
// Clear by baseDomain.
|
||||||
nsAutoCString host;
|
nsAutoCString host;
|
||||||
nsresult rv = key.URI()->GetHost(host);
|
nsresult rv = key.URI()->GetHost(host);
|
||||||
if (NS_FAILED(rv) || host.IsEmpty()) {
|
if (NS_FAILED(rv) || host.IsEmpty()) {
|
||||||
@@ -1481,43 +1455,31 @@ nsresult imgLoader::RemoveEntriesInternal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool hasRootDomain = false;
|
bool hasRootDomain = false;
|
||||||
rv = tldService->HasRootDomain(host, aSchemelessSite.ref(),
|
rv = tldService->HasRootDomain(host, *aBaseDomain, &hasRootDomain);
|
||||||
&hasRootDomain);
|
if (NS_SUCCEEDED(rv) && hasRootDomain) {
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasRootDomain && aPattern->Matches(key.OriginAttributesRef())) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to parse isolation key into origin attributes.
|
// If we don't get a direct base domain match, also check for cache of
|
||||||
Maybe<OriginAttributes> originAttributesWithPartitionKey;
|
// third parties partitioned under aBaseDomain.
|
||||||
{
|
|
||||||
OriginAttributes attrs;
|
// The isolation key is either just the base domain, or an origin suffix
|
||||||
if (attrs.PopulateFromSuffix(key.IsolationKeyRef())) {
|
// which contains the partitionKey holding the baseDomain.
|
||||||
OriginAttributes attrsWithPartitionKey(key.OriginAttributesRef());
|
|
||||||
attrsWithPartitionKey.mPartitionKey = attrs.mPartitionKey;
|
if (key.IsolationKeyRef().Equals(*aBaseDomain)) {
|
||||||
originAttributesWithPartitionKey.emplace(
|
return true;
|
||||||
std::move(attrsWithPartitionKey));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match it against the pattern that contains the partition key and any
|
// The isolation key does not match the given base domain. It may be an
|
||||||
// fields set by the caller pattern.
|
// origin suffix. Parse it into origin attributes.
|
||||||
if (originAttributesWithPartitionKey.isSome()) {
|
OriginAttributes attrs;
|
||||||
nsAutoCString oaSuffixForPrinting;
|
if (!attrs.PopulateFromSuffix(key.IsolationKeyRef())) {
|
||||||
originAttributesWithPartitionKey->CreateSuffix(oaSuffixForPrinting);
|
// Key is not an origin suffix.
|
||||||
|
return false;
|
||||||
nsAutoString patternForPrinting;
|
|
||||||
patternWithPartitionKey->ToJSON(patternForPrinting);
|
|
||||||
|
|
||||||
return patternWithPartitionKey.ref().Matches(
|
|
||||||
originAttributesWithPartitionKey.ref());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The isolation key is the site.
|
return StoragePrincipalHelper::PartitionKeyHasBaseDomain(
|
||||||
return aSchemelessSite->Equals(key.IsolationKeyRef());
|
attrs.mPartitionKey, *aBaseDomain);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (shouldRemove) {
|
if (shouldRemove) {
|
||||||
|
|||||||
@@ -336,10 +336,8 @@ class imgLoader final : public imgILoader,
|
|||||||
|
|
||||||
void VerifyCacheSizes();
|
void VerifyCacheSizes();
|
||||||
|
|
||||||
nsresult RemoveEntriesInternal(
|
nsresult RemoveEntriesInternal(nsIPrincipal* aPrincipal,
|
||||||
const mozilla::Maybe<nsCOMPtr<nsIPrincipal>>& aPrincipal,
|
const nsACString* aBaseDomain);
|
||||||
const mozilla::Maybe<nsCString>& aSchemelessSite,
|
|
||||||
const mozilla::Maybe<mozilla::OriginAttributesPattern>& aPattern);
|
|
||||||
|
|
||||||
// The image loader maintains a hash table of all imgCacheEntries. However,
|
// The image loader maintains a hash table of all imgCacheEntries. However,
|
||||||
// only some of them will be evicted from the cache: those who have no
|
// only some of them will be evicted from the cache: those who have no
|
||||||
|
|||||||
@@ -199,21 +199,21 @@ SharedStyleSheetCache::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedStyleSheetCache::Clear(
|
void SharedStyleSheetCache::Clear(nsIPrincipal* aForPrincipal,
|
||||||
const Maybe<nsCOMPtr<nsIPrincipal>>& aPrincipal,
|
const nsACString* aBaseDomain) {
|
||||||
const Maybe<nsCString>& aSchemelessSite,
|
|
||||||
const Maybe<OriginAttributesPattern>& aPattern) {
|
|
||||||
using ContentParent = dom::ContentParent;
|
using ContentParent = dom::ContentParent;
|
||||||
|
|
||||||
if (XRE_IsParentProcess()) {
|
if (XRE_IsParentProcess()) {
|
||||||
|
auto forPrincipal = aForPrincipal ? Some(RefPtr(aForPrincipal)) : Nothing();
|
||||||
|
auto baseDomain = aBaseDomain ? Some(nsCString(*aBaseDomain)) : Nothing();
|
||||||
|
|
||||||
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
||||||
Unused << cp->SendClearStyleSheetCache(aPrincipal, aSchemelessSite,
|
Unused << cp->SendClearStyleSheetCache(forPrincipal, baseDomain);
|
||||||
aPattern);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sSingleton) {
|
if (sSingleton) {
|
||||||
sSingleton->ClearInProcess(aPrincipal, aSchemelessSite, aPattern);
|
sSingleton->ClearInProcess(aForPrincipal, aBaseDomain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,8 @@ class SharedStyleSheetCache final
|
|||||||
using Base::LoadCompleted;
|
using Base::LoadCompleted;
|
||||||
static void LoadCompletedInternal(SharedStyleSheetCache*, css::SheetLoadData&,
|
static void LoadCompletedInternal(SharedStyleSheetCache*, css::SheetLoadData&,
|
||||||
nsTArray<RefPtr<css::SheetLoadData>>&);
|
nsTArray<RefPtr<css::SheetLoadData>>&);
|
||||||
static void Clear(const Maybe<nsCOMPtr<nsIPrincipal>>& aPrincipal = Nothing(),
|
static void Clear(nsIPrincipal* aForPrincipal = nullptr,
|
||||||
const Maybe<nsCString>& aSchemelessSite = Nothing(),
|
const nsACString* aBaseDomain = nullptr);
|
||||||
const Maybe<OriginAttributesPattern>& aPattern = Nothing());
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void InsertIfNeeded(css::SheetLoadData&);
|
void InsertIfNeeded(css::SheetLoadData&);
|
||||||
|
|||||||
@@ -156,9 +156,8 @@ class SharedSubResourceCache {
|
|||||||
// to be called when the document goes away, or when its principal changes.
|
// to be called when the document goes away, or when its principal changes.
|
||||||
void UnregisterLoader(Loader&);
|
void UnregisterLoader(Loader&);
|
||||||
|
|
||||||
void ClearInProcess(const Maybe<nsCOMPtr<nsIPrincipal>>& aPrincipal,
|
void ClearInProcess(nsIPrincipal* aForPrincipal = nullptr,
|
||||||
const Maybe<nsCString>& aSchemelessSite,
|
const nsACString* aBaseDomain = nullptr);
|
||||||
const Maybe<OriginAttributesPattern>& aPattern);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CancelPendingLoadsForLoader(Loader&);
|
void CancelPendingLoadsForLoader(Loader&);
|
||||||
@@ -194,52 +193,36 @@ class SharedSubResourceCache {
|
|||||||
|
|
||||||
template <typename Traits, typename Derived>
|
template <typename Traits, typename Derived>
|
||||||
void SharedSubResourceCache<Traits, Derived>::ClearInProcess(
|
void SharedSubResourceCache<Traits, Derived>::ClearInProcess(
|
||||||
const Maybe<nsCOMPtr<nsIPrincipal>>& aPrincipal,
|
nsIPrincipal* aForPrincipal, const nsACString* aBaseDomain) {
|
||||||
const Maybe<nsCString>& aSchemelessSite,
|
if (!aForPrincipal && !aBaseDomain) {
|
||||||
const Maybe<OriginAttributesPattern>& aPattern) {
|
|
||||||
MOZ_ASSERT(aSchemelessSite.isSome() == aPattern.isSome(),
|
|
||||||
"Must pass both site and OA pattern.");
|
|
||||||
|
|
||||||
if (!aPrincipal && !aSchemelessSite) {
|
|
||||||
mComplete.Clear();
|
mComplete.Clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto iter = mComplete.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mComplete.Iter(); !iter.Done(); iter.Next()) {
|
||||||
const bool shouldRemove = [&] {
|
const bool shouldRemove = [&] {
|
||||||
if (aPrincipal && iter.Key().Principal()->Equals(aPrincipal.ref())) {
|
if (aForPrincipal && iter.Key().Principal()->Equals(aForPrincipal)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!aSchemelessSite) {
|
if (!aBaseDomain) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Clear by site.
|
// Clear by baseDomain.
|
||||||
nsIPrincipal* partitionPrincipal = iter.Key().PartitionPrincipal();
|
nsIPrincipal* partitionPrincipal = iter.Key().PartitionPrincipal();
|
||||||
|
|
||||||
// Clear entries with site. This includes entries which are partitioned
|
// Clear entries with matching base domain. This includes entries
|
||||||
// under other top level sites (= have a partitionKey set).
|
// which are partitioned under other top level sites (= have a
|
||||||
|
// partitionKey set).
|
||||||
nsAutoCString principalBaseDomain;
|
nsAutoCString principalBaseDomain;
|
||||||
nsresult rv = partitionPrincipal->GetBaseDomain(principalBaseDomain);
|
nsresult rv = partitionPrincipal->GetBaseDomain(principalBaseDomain);
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_SUCCEEDED(rv) && principalBaseDomain.Equals(*aBaseDomain)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (principalBaseDomain.Equals(aSchemelessSite.ref()) &&
|
|
||||||
aPattern.ref().Matches(partitionPrincipal->OriginAttributesRef())) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear entries partitioned under aSchemelessSite. We need to add the
|
// Clear entries partitioned under aBaseDomain.
|
||||||
// partition key filter to aPattern so that we include any OA filtering
|
return StoragePrincipalHelper::PartitionKeyHasBaseDomain(
|
||||||
// specified by the caller. For example the caller may pass aPattern = {
|
partitionPrincipal->OriginAttributesRef().mPartitionKey,
|
||||||
// privateBrowsingId: 1 } which means we may only clear partitioned
|
*aBaseDomain);
|
||||||
// private browsing data.
|
|
||||||
OriginAttributesPattern patternWithPartitionKey(aPattern.ref());
|
|
||||||
patternWithPartitionKey.mPartitionKeyPattern.Construct();
|
|
||||||
patternWithPartitionKey.mPartitionKeyPattern.Value()
|
|
||||||
.mBaseDomain.Construct(NS_ConvertUTF8toUTF16(aSchemelessSite.ref()));
|
|
||||||
|
|
||||||
return patternWithPartitionKey.Matches(
|
|
||||||
partitionPrincipal->OriginAttributesRef());
|
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (shouldRemove) {
|
if (shouldRemove) {
|
||||||
|
|||||||
@@ -326,12 +326,9 @@ export const GeckoViewStorageController = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
clearBaseDomainData(aBaseDomain, aFlags, aCallback) {
|
clearBaseDomainData(aBaseDomain, aFlags, aCallback) {
|
||||||
// Ensure we have a site at this point.
|
|
||||||
let schemelessSite = Services.eTLD.getSchemelessSiteFromHost(aBaseDomain);
|
|
||||||
new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
schemelessSite,
|
aBaseDomain,
|
||||||
{},
|
|
||||||
/* isUserRequest */ true,
|
/* isUserRequest */ true,
|
||||||
convertFlags(aFlags),
|
convertFlags(aFlags),
|
||||||
resolve
|
resolve
|
||||||
|
|||||||
@@ -206,23 +206,6 @@ nsEffectiveTLDService::GetSchemelessSite(nsIURI* aURI, nsACString& aSite) {
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variant of GetSchemelessSite which accepts a host string instead of a URI.
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsEffectiveTLDService::GetSchemelessSiteFromHost(const nsACString& aHostname,
|
|
||||||
nsACString& aSite) {
|
|
||||||
NS_ENSURE_TRUE(!aHostname.IsEmpty(), NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
nsresult rv = GetBaseDomainFromHost(aHostname, 0, aSite);
|
|
||||||
if (rv == NS_ERROR_HOST_IS_IP_ADDRESS ||
|
|
||||||
rv == NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS) {
|
|
||||||
aSite.Assign(aHostname);
|
|
||||||
nsContentUtils::MaybeFixIPv6Host(aSite);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// External function for dealing with URIs to get site correctly.
|
// External function for dealing with URIs to get site correctly.
|
||||||
// Calls through to GetSchemelessSite(), and serializes with the scheme and
|
// Calls through to GetSchemelessSite(), and serializes with the scheme and
|
||||||
// "://" prepended.
|
// "://" prepended.
|
||||||
|
|||||||
@@ -119,28 +119,6 @@ interface nsIEffectiveTLDService : nsISupports
|
|||||||
*/
|
*/
|
||||||
ACString getSchemelessSite(in nsIURI aURI);
|
ACString getSchemelessSite(in nsIURI aURI);
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as getSchemelessSite but takes a host string. Prefer the URI variant
|
|
||||||
* if possible.
|
|
||||||
*
|
|
||||||
* @param aHost
|
|
||||||
* The host to analyze.
|
|
||||||
*
|
|
||||||
* @return the Site.
|
|
||||||
*
|
|
||||||
* @throws NS_ERROR_UNEXPECTED
|
|
||||||
* or other error returned by nsIIDNService::normalize when
|
|
||||||
* the hostname contains characters disallowed in URIs
|
|
||||||
*
|
|
||||||
* @see getSchemelessSite()
|
|
||||||
* @see getBaseDomain()
|
|
||||||
* @see getSite()
|
|
||||||
*
|
|
||||||
* @warning This function should not be used without good reason. Please
|
|
||||||
* use getSite() or the Origin if you are not absolutely certain.
|
|
||||||
*/
|
|
||||||
ACString getSchemelessSiteFromHost(in AUTF8String aHost);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Site for the origin of aURI; e.g. for
|
* Get the Site for the origin of aURI; e.g. for
|
||||||
* "https://www.bbc.co.uk/index.html", this would be "https://bbc.co.uk".
|
* "https://www.bbc.co.uk/index.html", this would be "https://bbc.co.uk".
|
||||||
|
|||||||
@@ -64,10 +64,7 @@ add_task(() => {
|
|||||||
["https://test.example.com", "example.com"],
|
["https://test.example.com", "example.com"],
|
||||||
["https://test1.test2.example.com", "example.com"],
|
["https://test1.test2.example.com", "example.com"],
|
||||||
["https://test1.test2.example.co.uk", "example.co.uk"],
|
["https://test1.test2.example.co.uk", "example.co.uk"],
|
||||||
[
|
["https://test1.test2.example.公司.香港", "example.xn--55qx5d.xn--j6w193g"],
|
||||||
"https://test1.test2.example.\u516c\u53f8.\u9999\u6e2f",
|
|
||||||
"example.xn--55qx5d.xn--j6w193g",
|
|
||||||
],
|
|
||||||
]) {
|
]) {
|
||||||
let origin = Services.io.newURI(originString);
|
let origin = Services.io.newURI(originString);
|
||||||
let answer = Services.eTLD.getSchemelessSite(origin);
|
let answer = Services.eTLD.getSchemelessSite(origin);
|
||||||
@@ -78,29 +75,3 @@ add_task(() => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_getSchemelessSiteFromHost() {
|
|
||||||
for (let [host, result] of [
|
|
||||||
["com", "com"],
|
|
||||||
["test", "test"],
|
|
||||||
["test.", "test."],
|
|
||||||
["::1", "[::1]"],
|
|
||||||
["localhost", "localhost"],
|
|
||||||
["127.0.0.1", "127.0.0.1"],
|
|
||||||
["example.com", "example.com"],
|
|
||||||
["test.example.com", "example.com"],
|
|
||||||
["test1.test2.example.com", "example.com"],
|
|
||||||
["test1.test2.example.co.uk", "example.co.uk"],
|
|
||||||
[
|
|
||||||
"test1.test2.example.\u516c\u53f8.\u9999\u6e2f",
|
|
||||||
"example.xn--55qx5d.xn--j6w193g",
|
|
||||||
],
|
|
||||||
]) {
|
|
||||||
let answer = Services.eTLD.getSchemelessSiteFromHost(host);
|
|
||||||
Assert.equal(
|
|
||||||
answer,
|
|
||||||
result,
|
|
||||||
`"${host}" should have schemeless site ${result}, got ${answer}.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ BounceTrackingProtection::ClearAll() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
BounceTrackingProtection::ClearBySiteHostAndOriginAttributes(
|
BounceTrackingProtection::ClearBySiteHostAndOA(
|
||||||
const nsACString& aSiteHost, JS::Handle<JS::Value> aOriginAttributes,
|
const nsACString& aSiteHost, JS::Handle<JS::Value> aOriginAttributes,
|
||||||
JSContext* aCx) {
|
JSContext* aCx) {
|
||||||
NS_ENSURE_ARG_POINTER(aCx);
|
NS_ENSURE_ARG_POINTER(aCx);
|
||||||
@@ -553,23 +553,10 @@ BounceTrackingProtection::ClearBySiteHostAndOriginAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
BounceTrackingProtection::ClearBySiteHostAndOriginAttributesPattern(
|
BounceTrackingProtection::ClearBySiteHost(const nsACString& aSiteHost) {
|
||||||
const nsACString& aSiteHost, JS::Handle<JS::Value> aOriginAttributesPattern,
|
BounceTrackingState::ResetAll();
|
||||||
JSContext* aCx) {
|
|
||||||
NS_ENSURE_ARG_POINTER(aCx);
|
|
||||||
|
|
||||||
OriginAttributesPattern pattern;
|
return mStorage->ClearBySiteHost(aSiteHost, nullptr);
|
||||||
if (!aOriginAttributesPattern.isObject() ||
|
|
||||||
!pattern.Init(aCx, aOriginAttributesPattern)) {
|
|
||||||
return NS_ERROR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear per-tab state.
|
|
||||||
BounceTrackingState::ResetAllForOriginAttributesPattern(pattern);
|
|
||||||
|
|
||||||
// Clear global state including on-disk state.
|
|
||||||
return mStorage->ClearByOriginAttributesPattern(pattern,
|
|
||||||
Some(nsCString(aSiteHost)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -1065,8 +1052,8 @@ nsresult BounceTrackingProtection::PurgeBounceTrackersForStateGlobal(
|
|||||||
cb->OnDataDeleted(0);
|
cb->OnDataDeleted(0);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Bug 1842067: Clear by site + OA.
|
// TODO: Bug 1842067: Clear by site + OA.
|
||||||
rv = clearDataService->DeleteDataFromSiteAndOriginAttributesPatternString(
|
rv = clearDataService->DeleteDataFromBaseDomain(host, false,
|
||||||
host, u""_ns, false, TRACKER_PURGE_FLAGS, cb);
|
TRACKER_PURGE_FLAGS, cb);
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
clearPromise->Reject(0, __func__);
|
clearPromise->Reject(0, __func__);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,27 +120,12 @@ nsresult BounceTrackingProtectionStorage::ClearByTimeRange(PRTime aFrom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult BounceTrackingProtectionStorage::ClearByOriginAttributesPattern(
|
nsresult BounceTrackingProtectionStorage::ClearByOriginAttributesPattern(
|
||||||
const OriginAttributesPattern& aOriginAttributesPattern,
|
const OriginAttributesPattern& aOriginAttributesPattern) {
|
||||||
const Maybe<nsCString>& aSiteHost) {
|
|
||||||
// Clear in memory state.
|
// Clear in memory state.
|
||||||
for (auto iter = mStateGlobal.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mStateGlobal.Iter(); !iter.Done(); iter.Next()) {
|
||||||
BounceTrackingStateGlobal* stateGlobal = iter.Data();
|
if (aOriginAttributesPattern.Matches(iter.Key())) {
|
||||||
MOZ_ASSERT(stateGlobal);
|
|
||||||
|
|
||||||
if (!aOriginAttributesPattern.Matches(stateGlobal->OriginAttributesRef())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there is no site host filtering we can remove the entire state global.
|
|
||||||
if (aSiteHost.isNothing()) {
|
|
||||||
iter.Remove();
|
iter.Remove();
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise we need to clear just the entries that match the site host.
|
|
||||||
// Update in memory state. Skip storage so we can batch the writes later.
|
|
||||||
nsresult rv = stateGlobal->ClearSiteHost(aSiteHost.ref(), true);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the database.
|
// Update the database.
|
||||||
@@ -150,8 +135,7 @@ nsresult BounceTrackingProtectionStorage::ClearByOriginAttributesPattern(
|
|||||||
nsIScriptSecurityManager::DEFAULT_PRIVATE_BROWSING_ID) {
|
nsIScriptSecurityManager::DEFAULT_PRIVATE_BROWSING_ID) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
return DeleteDBEntriesByOriginAttributesPattern(aOriginAttributesPattern,
|
return DeleteDBEntriesByOriginAttributesPattern(aOriginAttributesPattern);
|
||||||
aSiteHost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult BounceTrackingProtectionStorage::UpdateDBEntry(
|
nsresult BounceTrackingProtectionStorage::UpdateDBEntry(
|
||||||
@@ -323,30 +307,25 @@ nsresult BounceTrackingProtectionStorage::DeleteDBEntriesByType(
|
|||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
BounceTrackingProtectionStorage::DeleteDBEntriesByOriginAttributesPattern(
|
BounceTrackingProtectionStorage::DeleteDBEntriesByOriginAttributesPattern(
|
||||||
const OriginAttributesPattern& aOriginAttributesPattern,
|
const OriginAttributesPattern& aOriginAttributesPattern) {
|
||||||
const Maybe<nsCString>& aSiteHost) {
|
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
MOZ_ASSERT(!aOriginAttributesPattern.mPrivateBrowsingId.WasPassed() ||
|
MOZ_ASSERT(!aOriginAttributesPattern.mPrivateBrowsingId.WasPassed() ||
|
||||||
aOriginAttributesPattern.mPrivateBrowsingId.Value() ==
|
aOriginAttributesPattern.mPrivateBrowsingId.Value() ==
|
||||||
nsIScriptSecurityManager::DEFAULT_PRIVATE_BROWSING_ID,
|
nsIScriptSecurityManager::DEFAULT_PRIVATE_BROWSING_ID,
|
||||||
"Must not clear private browsing data from the table.");
|
"Must not clear private browsing data from the table.");
|
||||||
if (aSiteHost.isSome()) {
|
|
||||||
MOZ_ASSERT(!aSiteHost->IsEmpty(), "aSiteHost must not be empty.");
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult rv = WaitForInitialization();
|
nsresult rv = WaitForInitialization();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
IncrementPendingWrites();
|
IncrementPendingWrites();
|
||||||
RefPtr<BounceTrackingProtectionStorage> self = this;
|
RefPtr<BounceTrackingProtectionStorage> self = this;
|
||||||
|
|
||||||
mBackgroundThread->Dispatch(
|
mBackgroundThread->Dispatch(
|
||||||
NS_NewRunnableFunction(
|
NS_NewRunnableFunction(
|
||||||
"BounceTrackingProtectionStorage::"
|
"BounceTrackingProtectionStorage::"
|
||||||
"DeleteEntriesByOriginAttributesPattern",
|
"DeleteEntriesByOriginAttributesPattern",
|
||||||
[self, aOriginAttributesPattern, siteHost = aSiteHost]() {
|
[self, aOriginAttributesPattern]() {
|
||||||
nsresult rv = DeleteDataByOriginAttributesPattern(
|
nsresult rv = DeleteDataByOriginAttributesPattern(
|
||||||
self->mDatabaseConnection, aOriginAttributesPattern, siteHost);
|
self->mDatabaseConnection, aOriginAttributesPattern);
|
||||||
self->DecrementPendingWrites();
|
self->DecrementPendingWrites();
|
||||||
NS_ENSURE_SUCCESS_VOID(rv);
|
NS_ENSURE_SUCCESS_VOID(rv);
|
||||||
}),
|
}),
|
||||||
@@ -893,25 +872,10 @@ nsresult BounceTrackingProtectionStorage::DeleteDataByType(
|
|||||||
|
|
||||||
nsresult BounceTrackingProtectionStorage::DeleteDataByOriginAttributesPattern(
|
nsresult BounceTrackingProtectionStorage::DeleteDataByOriginAttributesPattern(
|
||||||
mozIStorageConnection* aDatabaseConnection,
|
mozIStorageConnection* aDatabaseConnection,
|
||||||
const OriginAttributesPattern& aOriginAttributesPattern,
|
const OriginAttributesPattern& aOriginAttributesPattern) {
|
||||||
const Maybe<nsCString>& aSiteHost) {
|
|
||||||
MOZ_ASSERT(!NS_IsMainThread(),
|
MOZ_ASSERT(!NS_IsMainThread(),
|
||||||
"Must not write to the table from the main thread.");
|
"Must not write to the table from the main thread.");
|
||||||
MOZ_ASSERT(aDatabaseConnection);
|
MOZ_ASSERT(aDatabaseConnection);
|
||||||
if (aSiteHost.isSome()) {
|
|
||||||
MOZ_ASSERT(!aSiteHost->IsEmpty(), "aSiteHost must not be empty.");
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAutoCString deleteQuery(
|
|
||||||
"DELETE FROM sites WHERE "
|
|
||||||
"ORIGIN_ATTRS_PATTERN_MATCH_OA_SUFFIX(originAttributeSuffix)");
|
|
||||||
|
|
||||||
// Filtering by site host is optional.
|
|
||||||
if (aSiteHost.isSome()) {
|
|
||||||
deleteQuery.AppendLiteral(" AND siteHost = :siteHost");
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteQuery.AppendLiteral(";");
|
|
||||||
|
|
||||||
nsCOMPtr<mozIStorageFunction> patternMatchFunction(
|
nsCOMPtr<mozIStorageFunction> patternMatchFunction(
|
||||||
new OriginAttrsPatternMatchOASuffixSQLFunction(aOriginAttributesPattern));
|
new OriginAttrsPatternMatchOASuffixSQLFunction(aOriginAttributesPattern));
|
||||||
@@ -920,17 +884,9 @@ nsresult BounceTrackingProtectionStorage::DeleteDataByOriginAttributesPattern(
|
|||||||
"ORIGIN_ATTRS_PATTERN_MATCH_OA_SUFFIX"_ns, 1, patternMatchFunction);
|
"ORIGIN_ATTRS_PATTERN_MATCH_OA_SUFFIX"_ns, 1, patternMatchFunction);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<mozIStorageStatement> deleteStmt;
|
rv = aDatabaseConnection->ExecuteSimpleSQL(
|
||||||
rv = aDatabaseConnection->CreateStatement(deleteQuery,
|
"DELETE FROM sites WHERE "
|
||||||
getter_AddRefs(deleteStmt));
|
"ORIGIN_ATTRS_PATTERN_MATCH_OA_SUFFIX(originAttributeSuffix);"_ns);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
if (aSiteHost.isSome()) {
|
|
||||||
rv = deleteStmt->BindUTF8StringByName("siteHost"_ns, aSiteHost.ref());
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = deleteStmt->Execute();
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
return aDatabaseConnection->RemoveFunction(
|
return aDatabaseConnection->RemoveFunction(
|
||||||
|
|||||||
@@ -77,10 +77,8 @@ class BounceTrackingProtectionStorage final : public nsIObserver,
|
|||||||
[[nodiscard]] nsresult ClearByTimeRange(PRTime aFrom, PRTime aTo);
|
[[nodiscard]] nsresult ClearByTimeRange(PRTime aFrom, PRTime aTo);
|
||||||
|
|
||||||
// Clear all state for a given OriginAttributesPattern.
|
// Clear all state for a given OriginAttributesPattern.
|
||||||
// Optional filtering for site host via aSiteHost.
|
|
||||||
[[nodiscard]] nsresult ClearByOriginAttributesPattern(
|
[[nodiscard]] nsresult ClearByOriginAttributesPattern(
|
||||||
const OriginAttributesPattern& aOriginAttributesPattern,
|
const OriginAttributesPattern& aOriginAttributesPattern);
|
||||||
const Maybe<nsCString>& aSiteHost = Nothing());
|
|
||||||
|
|
||||||
// Clear all state.
|
// Clear all state.
|
||||||
[[nodiscard]] nsresult Clear();
|
[[nodiscard]] nsresult Clear();
|
||||||
@@ -159,11 +157,10 @@ class BounceTrackingProtectionStorage final : public nsIObserver,
|
|||||||
BounceTrackingProtectionStorage::EntryType aEntryType);
|
BounceTrackingProtectionStorage::EntryType aEntryType);
|
||||||
|
|
||||||
// Delete all entries matching the given OriginAttributesPattern. Worker
|
// Delete all entries matching the given OriginAttributesPattern. Worker
|
||||||
// thread only. May pass aSiteHost for additional filtering.
|
// thread only.
|
||||||
[[nodiscard]] static nsresult DeleteDataByOriginAttributesPattern(
|
[[nodiscard]] static nsresult DeleteDataByOriginAttributesPattern(
|
||||||
mozIStorageConnection* aDatabaseConnection,
|
mozIStorageConnection* aDatabaseConnection,
|
||||||
const OriginAttributesPattern& aOriginAttributesPattern,
|
const OriginAttributesPattern& aOriginAttributesPattern);
|
||||||
const Maybe<nsCString>& aSiteHost = Nothing());
|
|
||||||
|
|
||||||
// Clear all entries from the database.
|
// Clear all entries from the database.
|
||||||
[[nodiscard]] static nsresult ClearData(
|
[[nodiscard]] static nsresult ClearData(
|
||||||
@@ -216,11 +213,8 @@ class BounceTrackingProtectionStorage final : public nsIObserver,
|
|||||||
BounceTrackingProtectionStorage::EntryType aEntryType);
|
BounceTrackingProtectionStorage::EntryType aEntryType);
|
||||||
|
|
||||||
// Deletes all DB entries matching the given OriginAttributesPattern.
|
// Deletes all DB entries matching the given OriginAttributesPattern.
|
||||||
// Pass aSiteHost for additional filtering. By default all site hosts are
|
|
||||||
// targeted.
|
|
||||||
[[nodiscard]] nsresult DeleteDBEntriesByOriginAttributesPattern(
|
[[nodiscard]] nsresult DeleteDBEntriesByOriginAttributesPattern(
|
||||||
const OriginAttributesPattern& aOriginAttributesPattern,
|
const OriginAttributesPattern& aOriginAttributesPattern);
|
||||||
const Maybe<nsCString>& aSiteHost = Nothing());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A SQL function to match DB entries by OriginAttributesPattern.
|
// A SQL function to match DB entries by OriginAttributesPattern.
|
||||||
|
|||||||
@@ -44,13 +44,10 @@ interface nsIBounceTrackingProtection : nsISupports {
|
|||||||
|
|
||||||
// Clear bounce tracking state for a specific site host and OriginAttributes pair.
|
// Clear bounce tracking state for a specific site host and OriginAttributes pair.
|
||||||
[implicit_jscontext]
|
[implicit_jscontext]
|
||||||
void clearBySiteHostAndOriginAttributes(in ACString aSiteHost, in jsval originAttributes);
|
void clearBySiteHostAndOA(in ACString aSiteHost, in jsval originAttributes);
|
||||||
|
|
||||||
// Clear bounce tracking state for a specific site host and
|
// Clear bounce tracking state for a specific site host for all OriginAttributes.
|
||||||
// OriginAttributesPattern.
|
void clearBySiteHost(in ACString aSiteHost);
|
||||||
// aOriginAttributesPattern = {} clears for all OriginAttributes.
|
|
||||||
[implicit_jscontext]
|
|
||||||
void clearBySiteHostAndOriginAttributesPattern(in ACString aSiteHost, in jsval aOriginAttributesPattern);
|
|
||||||
|
|
||||||
// Clear bounce tracking state for a specific time range.
|
// Clear bounce tracking state for a specific time range.
|
||||||
void clearByTimeRange(in PRTime aFrom, in PRTime aTo);
|
void clearByTimeRange(in PRTime aFrom, in PRTime aTo);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -58,28 +58,14 @@ export const ServiceWorkerCleanUp = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeFromSite(aSchemelessSite, aOriginAttributesPattern) {
|
removeFromBaseDomain(aBaseDomain) {
|
||||||
return unregisterServiceWorkersMatching(sw => {
|
// Service workers are disabled in partitioned contexts. This means we don't
|
||||||
let { principal } = sw;
|
// have to check for a partitionKey, but only look at the top level base
|
||||||
let { originAttributes } = principal;
|
// domain. If this ever changes we need to update this method to account for
|
||||||
|
// partitions. See Bug 1495241.
|
||||||
// Check service workers owned by aSchemelessSite.
|
return unregisterServiceWorkersMatching(
|
||||||
if (
|
sw => sw.principal.baseDomain == aBaseDomain
|
||||||
principal.baseDomain == aSchemelessSite &&
|
);
|
||||||
ChromeUtils.originAttributesMatchPattern(
|
|
||||||
originAttributes,
|
|
||||||
aOriginAttributesPattern
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check service workers partitioned under aSchemelessSite.
|
|
||||||
return ChromeUtils.originAttributesMatchPattern(originAttributes, {
|
|
||||||
partitionKeyPattern: { baseDomain: aSchemelessSite },
|
|
||||||
...aOriginAttributesPattern,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
removeFromPrincipal(aPrincipal) {
|
removeFromPrincipal(aPrincipal) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||||
import { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs";
|
import { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs";
|
||||||
import { ContentTaskUtils } from "resource://testing-common/ContentTaskUtils.sys.mjs";
|
|
||||||
|
|
||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
@@ -171,94 +170,38 @@ export var SiteDataTestUtils = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new serviceworker with the specified path. Note that this method
|
* Adds a new serviceworker with the specified path. Note that this
|
||||||
* will open a new tab at the domain of the SW path to that effect.
|
* method will open a new tab at the domain of the SW path to that effect.
|
||||||
*
|
*
|
||||||
* @param {Object} options
|
* @param {String} path - the path to the service worker to add.
|
||||||
* @param {Window} options.win - The window to open the tab in where the SW is
|
|
||||||
* registered.
|
|
||||||
* @param {String} options.path - the path to the service worker to add.
|
|
||||||
* @param {String} [options.topLevelPath] - If specified this path will be
|
|
||||||
* used for the top level and the service worker will be registered in a frame
|
|
||||||
* with 'path'. If omitted the service worker gets registered in the top level
|
|
||||||
* (tab).
|
|
||||||
* @param {Number} [options.userContextId] - User context to register the
|
|
||||||
* service worker in. By default this targets the default user context (no
|
|
||||||
* container).
|
|
||||||
*
|
*
|
||||||
* @returns a Promise that resolves when the service worker has been
|
* @returns a Promise that resolves when the service worker was registered
|
||||||
* registered
|
|
||||||
*/
|
*/
|
||||||
async addServiceWorker({
|
addServiceWorker(path) {
|
||||||
win,
|
let uri = Services.io.newURI(path);
|
||||||
path,
|
// Register a dummy ServiceWorker.
|
||||||
topLevelPath = null,
|
return BrowserTestUtils.withNewTab(uri.prePath, async function (browser) {
|
||||||
userContextId = undefined,
|
return browser.ownerGlobal.SpecialPowers.spawn(
|
||||||
}) {
|
|
||||||
let uriTopLevel = Services.io.newURI(topLevelPath ?? path);
|
|
||||||
|
|
||||||
// Open a new tab to load the page with the service worker.
|
|
||||||
let tab = win.gBrowser.addTab(uriTopLevel.prePath, {
|
|
||||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
|
||||||
userContextId,
|
|
||||||
});
|
|
||||||
win.gBrowser.selectedTab = tab;
|
|
||||||
let browser = tab.linkedBrowser;
|
|
||||||
await BrowserTestUtils.browserLoaded(
|
|
||||||
browser,
|
|
||||||
false,
|
|
||||||
uriTopLevel.prePath + "/"
|
|
||||||
);
|
|
||||||
|
|
||||||
let registrationBrowsingContext = browser.browsingContext;
|
|
||||||
|
|
||||||
let { SpecialPowers } = browser.ownerGlobal;
|
|
||||||
|
|
||||||
// If caller requested a partitioned service worker create an iframe to
|
|
||||||
// register the SW in.
|
|
||||||
if (topLevelPath) {
|
|
||||||
let uriIframe = topLevelPath ? Services.io.newURI(path) : null;
|
|
||||||
registrationBrowsingContext = await SpecialPowers.spawn(
|
|
||||||
browser,
|
browser,
|
||||||
[uriIframe.prePath],
|
[{ path }],
|
||||||
async uriPrePath => {
|
async ({ path: p }) => {
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
let iframe = content.document.createElement("iframe");
|
let r = await content.navigator.serviceWorker.register(p);
|
||||||
iframe.src = uriPrePath;
|
return new Promise(resolve => {
|
||||||
// eslint-disable-next-line no-undef
|
let worker = r.installing || r.waiting || r.active;
|
||||||
content.document.body.appendChild(iframe);
|
if (worker.state == "activated") {
|
||||||
// Wait for it to load.
|
resolve();
|
||||||
await ContentTaskUtils.waitForEvent(iframe, "load");
|
} else {
|
||||||
|
worker.addEventListener("statechange", () => {
|
||||||
return iframe.browsingContext;
|
if (worker.state == "activated") {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
// SW registration call.
|
|
||||||
await SpecialPowers.spawn(
|
|
||||||
registrationBrowsingContext,
|
|
||||||
[{ path }],
|
|
||||||
async ({ path: p }) => {
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
let r = await content.navigator.serviceWorker.register(p);
|
|
||||||
return new Promise(resolve => {
|
|
||||||
let worker = r.installing || r.waiting || r.active;
|
|
||||||
if (worker.state == "activated") {
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
worker.addEventListener("statechange", () => {
|
|
||||||
if (worker.state == "activated") {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Clean up the temporary tab.
|
|
||||||
BrowserTestUtils.removeTab(tab);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
hasCookies(origin, testEntries = null, testPBMCookies = false) {
|
hasCookies(origin, testEntries = null, testPBMCookies = false) {
|
||||||
@@ -362,8 +305,7 @@ export var SiteDataTestUtils = {
|
|||||||
/**
|
/**
|
||||||
* Checks whether the specified origin has registered ServiceWorkers.
|
* Checks whether the specified origin has registered ServiceWorkers.
|
||||||
*
|
*
|
||||||
* @param {String} origin - the origin of the site to check, excluding the
|
* @param {String} origin - the origin of the site to check
|
||||||
* OriginAttributes suffix.
|
|
||||||
*
|
*
|
||||||
* @returns {Boolean} whether or not the site has ServiceWorkers.
|
* @returns {Boolean} whether or not the site has ServiceWorkers.
|
||||||
*/
|
*/
|
||||||
@@ -374,7 +316,7 @@ export var SiteDataTestUtils = {
|
|||||||
i,
|
i,
|
||||||
Ci.nsIServiceWorkerRegistrationInfo
|
Ci.nsIServiceWorkerRegistrationInfo
|
||||||
);
|
);
|
||||||
if (sw.principal.originNoSuffix == origin) {
|
if (sw.principal.origin == origin) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ interface nsIClearDataService : nsISupports
|
|||||||
* @param aFlags List of flags. See below the accepted values.
|
* @param aFlags List of flags. See below the accepted values.
|
||||||
* @param aCallback this callback will be executed when the operation is
|
* @param aCallback this callback will be executed when the operation is
|
||||||
* completed.
|
* completed.
|
||||||
* @deprecated Use deleteDataFromSite instead.
|
* @deprecated Use deleteDataFromBaseDomain instead.
|
||||||
*/
|
*/
|
||||||
void deleteDataFromHost(in AUTF8String aHost,
|
void deleteDataFromHost(in AUTF8String aHost,
|
||||||
in boolean aIsUserRequest,
|
in boolean aIsUserRequest,
|
||||||
@@ -55,20 +55,15 @@ interface nsIClearDataService : nsISupports
|
|||||||
in nsIClearDataCallback aCallback);
|
in nsIClearDataCallback aCallback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete data from cookie jars associated with the given schemeless site
|
* Delete data owned by or partitioned under a baseDomain (eTLD+1). For
|
||||||
* aSchemelessSite.
|
* instance: mozilla.org. Deletes data across all origin attributes. For
|
||||||
* In addition to regular first-party data this includes data of aSchemelessSite in a
|
* partitioned storage we clear both, data of the baseDomain in 1st-party and
|
||||||
* third-party context and data from other sites partitioned under aSchemelessSite.
|
* 3rd-party context.
|
||||||
* You can use Services.eTLD.getSchemelessSite to extract the site portion of a URI.
|
|
||||||
* See https://html.spec.whatwg.org/#obtain-a-site for details.
|
|
||||||
* If you have an nsIPrincipal object you can simply pass in
|
|
||||||
* principal.baseDomain.
|
|
||||||
* When handling user requests for clearing data using this method is
|
* When handling user requests for clearing data using this method is
|
||||||
* preferred over deleteDataFromPrincipal, since origins may share information
|
* preferred over deleteDataFromPrincipal, since origins may share information
|
||||||
* with their site (e.g. cookies) that are not deleted by principal.
|
* with their site (e.g. cookies) that are not deleted by principal.
|
||||||
* @param aSchemelessSite the site to be cleared excluding scheme.
|
* @param aDomainOrHost the domain or host to be used. Will be converted to
|
||||||
* @param aOriginAttributesPatternString optional pattern to filter OriginAttributes
|
* baseDomain if needed.
|
||||||
* by. If not passed all entries matching aSchemelessSite are cleared.
|
|
||||||
* @param aIsUserRequest true if this request comes from a user interaction.
|
* @param aIsUserRequest true if this request comes from a user interaction.
|
||||||
* This information is important because if true, it's probably better
|
* This information is important because if true, it's probably better
|
||||||
* to remove more than less, for privacy reason. If false (e.g.
|
* to remove more than less, for privacy reason. If false (e.g.
|
||||||
@@ -77,24 +72,14 @@ interface nsIClearDataService : nsISupports
|
|||||||
* @param aFlags List of flags. See below the accepted values.
|
* @param aFlags List of flags. See below the accepted values.
|
||||||
* @param aCallback this callback will be executed when the operation is
|
* @param aCallback this callback will be executed when the operation is
|
||||||
* completed.
|
* completed.
|
||||||
|
* @throws Throws if base domain can't be computed from aDomainOrHost. Callers
|
||||||
|
* may fall back to clearing by principal or host.
|
||||||
*/
|
*/
|
||||||
void deleteDataFromSite(in AUTF8String aSchemelessSite,
|
void deleteDataFromBaseDomain(in AUTF8String aDomainOrHost,
|
||||||
in jsval aOriginAttributesPattern,
|
|
||||||
in boolean aIsUserRequest,
|
in boolean aIsUserRequest,
|
||||||
in uint32_t aFlags,
|
in uint32_t aFlags,
|
||||||
in nsIClearDataCallback aCallback);
|
in nsIClearDataCallback aCallback);
|
||||||
|
|
||||||
/**
|
|
||||||
* Variant of deleteDataFromSite that accepts a JSON string for the OriginAttributesPattern.
|
|
||||||
* This is helpful for native callers because they don't have to construct a jsval.
|
|
||||||
* From JS prefer calling deleteDataFromSite directly.
|
|
||||||
*/
|
|
||||||
void deleteDataFromSiteAndOriginAttributesPatternString(in AUTF8String aSchemelessSite,
|
|
||||||
in AString aOriginAttributesPatternString,
|
|
||||||
in boolean aIsUserRequest,
|
|
||||||
in uint32_t aFlags,
|
|
||||||
in nsIClearDataCallback aCallback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete data owned by a principal.
|
* Delete data owned by a principal.
|
||||||
* @param aPrincipal the nsIPrincipal to be used.
|
* @param aPrincipal the nsIPrincipal to be used.
|
||||||
|
|||||||
@@ -44,9 +44,8 @@ function clearData({ deleteBy = "all", hasUserInput = false } = {}) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if (deleteBy == "baseDomain") {
|
} else if (deleteBy == "baseDomain") {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
TEST_PRINCIPAL.baseDomain,
|
TEST_PRINCIPAL.baseDomain,
|
||||||
{},
|
|
||||||
hasUserInput,
|
hasUserInput,
|
||||||
TEST_CLEAR_DATA_FLAGS,
|
TEST_CLEAR_DATA_FLAGS,
|
||||||
value => {
|
value => {
|
||||||
|
|||||||
@@ -8,17 +8,6 @@ const ORIGIN_A = `https://${BASE_DOMAIN_A}`;
|
|||||||
const ORIGIN_A_HTTP = `http://${BASE_DOMAIN_A}`;
|
const ORIGIN_A_HTTP = `http://${BASE_DOMAIN_A}`;
|
||||||
const ORIGIN_A_SUB = `https://test1.${BASE_DOMAIN_A}`;
|
const ORIGIN_A_SUB = `https://test1.${BASE_DOMAIN_A}`;
|
||||||
|
|
||||||
const CONTAINER_PRINCIPAL_A =
|
|
||||||
Services.scriptSecurityManager.createContentPrincipal(
|
|
||||||
Services.io.newURI(ORIGIN_A),
|
|
||||||
{ userContextId: 2 }
|
|
||||||
);
|
|
||||||
const CONTAINER_PRINCIPAL_A_SUB =
|
|
||||||
Services.scriptSecurityManager.createContentPrincipal(
|
|
||||||
Services.io.newURI(ORIGIN_A_SUB),
|
|
||||||
{ userContextId: 2 }
|
|
||||||
);
|
|
||||||
|
|
||||||
const BASE_DOMAIN_B = "example.org";
|
const BASE_DOMAIN_B = "example.org";
|
||||||
const ORIGIN_B = `https://${BASE_DOMAIN_B}`;
|
const ORIGIN_B = `https://${BASE_DOMAIN_B}`;
|
||||||
const ORIGIN_B_HTTP = `http://${BASE_DOMAIN_B}`;
|
const ORIGIN_B_HTTP = `http://${BASE_DOMAIN_B}`;
|
||||||
@@ -38,23 +27,17 @@ function getTestURLForOrigin(origin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function testCached(origin, isCached) {
|
async function testCached(origin, isCached) {
|
||||||
let principal =
|
let url = getTestURLForOrigin(origin);
|
||||||
Services.scriptSecurityManager.createContentPrincipalFromOrigin(origin);
|
|
||||||
let url = getTestURLForOrigin(principal.originNoSuffix);
|
|
||||||
|
|
||||||
let numParsed;
|
let numParsed;
|
||||||
|
|
||||||
let tab = tabs[principal.origin];
|
let tab = tabs[origin];
|
||||||
let loadedPromise;
|
let loadedPromise;
|
||||||
if (!tab) {
|
if (!tab) {
|
||||||
info("Creating new tab for " + url);
|
info("Creating new tab for " + url);
|
||||||
tab = gBrowser.addTab(url, {
|
tab = BrowserTestUtils.addTab(gBrowser, url);
|
||||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
|
||||||
userContextId: principal.originAttributes.userContextId,
|
|
||||||
});
|
|
||||||
gBrowser.selectedTab = tab;
|
|
||||||
loadedPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
|
loadedPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
|
||||||
tabs[principal.origin] = tab;
|
tabs[origin] = tab;
|
||||||
} else {
|
} else {
|
||||||
loadedPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
|
loadedPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
|
||||||
tab.linkedBrowser.reload();
|
tab.linkedBrowser.reload();
|
||||||
@@ -76,11 +59,6 @@ async function addTestTabs() {
|
|||||||
await testCached(ORIGIN_B, false);
|
await testCached(ORIGIN_B, false);
|
||||||
await testCached(ORIGIN_B_SUB, false);
|
await testCached(ORIGIN_B_SUB, false);
|
||||||
await testCached(ORIGIN_B_HTTP, false);
|
await testCached(ORIGIN_B_HTTP, false);
|
||||||
// Add more entries for ORIGIN_A but set a different user context.
|
|
||||||
await testCached(CONTAINER_PRINCIPAL_A.origin, false);
|
|
||||||
// Add another entry for ORIGIN_A but set a different user context.
|
|
||||||
await testCached(CONTAINER_PRINCIPAL_A_SUB.origin, false);
|
|
||||||
|
|
||||||
// Test that the cache has been populated.
|
// Test that the cache has been populated.
|
||||||
await testCached(ORIGIN_A, true);
|
await testCached(ORIGIN_A, true);
|
||||||
await testCached(ORIGIN_A_SUB, true);
|
await testCached(ORIGIN_A_SUB, true);
|
||||||
@@ -88,8 +66,6 @@ async function addTestTabs() {
|
|||||||
await testCached(ORIGIN_B, true);
|
await testCached(ORIGIN_B, true);
|
||||||
await testCached(ORIGIN_B_SUB, true);
|
await testCached(ORIGIN_B_SUB, true);
|
||||||
await testCached(ORIGIN_B_HTTP, true);
|
await testCached(ORIGIN_B_HTTP, true);
|
||||||
await testCached(CONTAINER_PRINCIPAL_A.origin, true);
|
|
||||||
await testCached(CONTAINER_PRINCIPAL_A_SUB.origin, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cleanupTestTabs() {
|
async function cleanupTestTabs() {
|
||||||
@@ -119,24 +95,20 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
await testCached(ORIGIN_B, true);
|
await testCached(ORIGIN_B, true);
|
||||||
await testCached(ORIGIN_B_SUB, true);
|
await testCached(ORIGIN_B_SUB, true);
|
||||||
await testCached(ORIGIN_B_HTTP, true);
|
await testCached(ORIGIN_B_HTTP, true);
|
||||||
// User context 2 not cleared because we clear by exact principal.
|
|
||||||
await testCached(CONTAINER_PRINCIPAL_A.origin, true);
|
|
||||||
await testCached(CONTAINER_PRINCIPAL_A_SUB.origin, true);
|
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
cleanupTestTabs();
|
cleanupTestTabs();
|
||||||
ChromeUtils.clearStyleSheetCache();
|
ChromeUtils.clearStyleSheetCache();
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_deleteBySite() {
|
add_task(async function test_deleteByBaseDomain() {
|
||||||
await addTestTabs();
|
await addTestTabs();
|
||||||
|
|
||||||
// Clear data for base domain of A.
|
// Clear data for base domain of A.
|
||||||
info("Clearing cache for (schemeless) site " + BASE_DOMAIN_A);
|
info("Clearing cache for base domain " + BASE_DOMAIN_A);
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
BASE_DOMAIN_A,
|
BASE_DOMAIN_A,
|
||||||
{},
|
|
||||||
false,
|
false,
|
||||||
Ci.nsIClearDataService.CLEAR_CSS_CACHE,
|
Ci.nsIClearDataService.CLEAR_CSS_CACHE,
|
||||||
resolve
|
resolve
|
||||||
@@ -147,10 +119,6 @@ add_task(async function test_deleteBySite() {
|
|||||||
await testCached(ORIGIN_A, false);
|
await testCached(ORIGIN_A, false);
|
||||||
await testCached(ORIGIN_A_SUB, false);
|
await testCached(ORIGIN_A_SUB, false);
|
||||||
await testCached(ORIGIN_A_HTTP, false);
|
await testCached(ORIGIN_A_HTTP, false);
|
||||||
// User context 2 also cleared because we passed the wildcard
|
|
||||||
// OriginAttributesPattern {} above.
|
|
||||||
await testCached(CONTAINER_PRINCIPAL_A.origin, false);
|
|
||||||
await testCached(CONTAINER_PRINCIPAL_A_SUB.origin, false);
|
|
||||||
// Entries for B should still exist.
|
// Entries for B should still exist.
|
||||||
await testCached(ORIGIN_B, true);
|
await testCached(ORIGIN_B, true);
|
||||||
await testCached(ORIGIN_B_SUB, true);
|
await testCached(ORIGIN_B_SUB, true);
|
||||||
@@ -160,37 +128,3 @@ add_task(async function test_deleteBySite() {
|
|||||||
cleanupTestTabs();
|
cleanupTestTabs();
|
||||||
ChromeUtils.clearStyleSheetCache();
|
ChromeUtils.clearStyleSheetCache();
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_deleteBySite_oa_pattern() {
|
|
||||||
await addTestTabs();
|
|
||||||
|
|
||||||
// Clear data for site A.
|
|
||||||
info("Clearing cache for (schemeless) site+pattern " + BASE_DOMAIN_A);
|
|
||||||
await new Promise(resolve => {
|
|
||||||
Services.clearData.deleteDataFromSite(
|
|
||||||
BASE_DOMAIN_A,
|
|
||||||
{ userContextId: CONTAINER_PRINCIPAL_A.originAttributes.userContextId },
|
|
||||||
false,
|
|
||||||
Ci.nsIClearDataService.CLEAR_CSS_CACHE,
|
|
||||||
resolve
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Normal entries should not have been cleared.
|
|
||||||
await testCached(ORIGIN_A, true);
|
|
||||||
await testCached(ORIGIN_A_SUB, true);
|
|
||||||
await testCached(ORIGIN_A_HTTP, true);
|
|
||||||
|
|
||||||
// Container entries should have been cleared because we have targeted them with the pattern.
|
|
||||||
await testCached(CONTAINER_PRINCIPAL_A.origin, false);
|
|
||||||
await testCached(CONTAINER_PRINCIPAL_A_SUB.origin, false);
|
|
||||||
|
|
||||||
// Entries for unrelated site B should still exist.
|
|
||||||
await testCached(ORIGIN_B, true);
|
|
||||||
await testCached(ORIGIN_B_SUB, true);
|
|
||||||
await testCached(ORIGIN_B_HTTP, true);
|
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
cleanupTestTabs();
|
|
||||||
ChromeUtils.clearStyleSheetCache();
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -23,12 +23,7 @@ function getTestURLForOrigin(origin) {
|
|||||||
return TEST_ROOT_DIR.replace("chrome://mochitests/content", origin);
|
return TEST_ROOT_DIR.replace("chrome://mochitests/content", origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testCached(
|
async function testCached(origin, isCached, testPartitioned = false) {
|
||||||
origin,
|
|
||||||
isCached,
|
|
||||||
testPartitioned = false,
|
|
||||||
isTODO = false
|
|
||||||
) {
|
|
||||||
let tabs = originToTabs[origin];
|
let tabs = originToTabs[origin];
|
||||||
|
|
||||||
for (let tab of tabs) {
|
for (let tab of tabs) {
|
||||||
@@ -53,11 +48,7 @@ async function testCached(
|
|||||||
msg = "Partitioned under " + msg;
|
msg = "Partitioned under " + msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTODO) {
|
is(actualCached, isCached, msg);
|
||||||
todo(actualCached, isCached, msg);
|
|
||||||
} else {
|
|
||||||
is(actualCached, isCached, msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,45 +145,43 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
// partitioned under B, even though the test principal does not set a
|
// partitioned under B, even though the test principal does not set a
|
||||||
// partitionKey.
|
// partitionKey.
|
||||||
// See Bug 1713088.
|
// See Bug 1713088.
|
||||||
await testCached(ORIGIN_B, true, true, true);
|
await testCached(ORIGIN_B, false, true);
|
||||||
await testCached(ORIGIN_B_SUB, true, true);
|
await testCached(ORIGIN_B_SUB, true, true);
|
||||||
await testCached(ORIGIN_B_HTTP, true, true);
|
await testCached(ORIGIN_B_HTTP, true, true);
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_deleteBySite() {
|
add_task(async function test_deleteByBaseDomain() {
|
||||||
await SpecialPowers.setBoolPref("dom.security.https_first", false);
|
await SpecialPowers.setBoolPref("dom.security.https_first", false);
|
||||||
await addTestTabs();
|
await addTestTabs();
|
||||||
|
|
||||||
// Clear data for site A.
|
// Clear data for base domain of A.
|
||||||
info("Clearing cache for site " + BASE_DOMAIN_A);
|
info("Clearing cache for base domain " + BASE_DOMAIN_A);
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
BASE_DOMAIN_A,
|
BASE_DOMAIN_A,
|
||||||
{},
|
|
||||||
false,
|
false,
|
||||||
Ci.nsIClearDataService.CLEAR_IMAGE_CACHE,
|
Ci.nsIClearDataService.CLEAR_IMAGE_CACHE,
|
||||||
resolve
|
resolve
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
info("All entries for A should have been cleared.");
|
// All entries for A should have been cleared.
|
||||||
await testCached(ORIGIN_A, false);
|
await testCached(ORIGIN_A, false);
|
||||||
await testCached(ORIGIN_A_SUB, false);
|
await testCached(ORIGIN_A_SUB, false);
|
||||||
await testCached(ORIGIN_A_HTTP, false);
|
await testCached(ORIGIN_A_HTTP, false);
|
||||||
|
// Entries for B should still exist.
|
||||||
info("Entries for B should still exist");
|
|
||||||
await testCached(ORIGIN_B, true);
|
await testCached(ORIGIN_B, true);
|
||||||
await testCached(ORIGIN_B_SUB, true);
|
await testCached(ORIGIN_B_SUB, true);
|
||||||
await testCached(ORIGIN_B_HTTP, true);
|
await testCached(ORIGIN_B_HTTP, true);
|
||||||
|
|
||||||
info("All partitioned entries for B under A should have been cleared.");
|
// All partitioned entries for B under A should have been cleared.
|
||||||
await testCached(ORIGIN_A, false, true);
|
await testCached(ORIGIN_A, false, true);
|
||||||
await testCached(ORIGIN_A_SUB, false, true);
|
await testCached(ORIGIN_A_SUB, false, true);
|
||||||
await testCached(ORIGIN_A_HTTP, false, true);
|
await testCached(ORIGIN_A_HTTP, false, true);
|
||||||
|
|
||||||
info("All partitioned entries of A under B should have been cleared.");
|
// All partitioned entries of A under B should have been cleared.
|
||||||
await testCached(ORIGIN_B, false, true);
|
await testCached(ORIGIN_B, false, true);
|
||||||
await testCached(ORIGIN_B_SUB, false, true);
|
await testCached(ORIGIN_B_SUB, false, true);
|
||||||
await testCached(ORIGIN_B_HTTP, false, true);
|
await testCached(ORIGIN_B_HTTP, false, true);
|
||||||
|
|||||||
@@ -67,9 +67,8 @@ async function testDeleteAll(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if (deleteBy == "baseDomain") {
|
} else if (deleteBy == "baseDomain") {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
browser.contentPrincipal.baseDomain,
|
browser.contentPrincipal.baseDomain,
|
||||||
{},
|
|
||||||
hasUserInput,
|
hasUserInput,
|
||||||
clearDataFlag,
|
clearDataFlag,
|
||||||
value => {
|
value => {
|
||||||
|
|||||||
@@ -271,11 +271,10 @@ add_task(async function test_deleteBaseDomain() {
|
|||||||
getPrincipal(ORG_ORIGIN, getOAWithPartitionKey(COM_DOMAIN))
|
getPrincipal(ORG_ORIGIN, getOAWithPartitionKey(COM_DOMAIN))
|
||||||
);
|
);
|
||||||
|
|
||||||
info(`Verifying deleteDataFromSite`);
|
info(`Verifying deleteDataFromBaseDomain`);
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
ORG_DOMAIN,
|
ORG_DOMAIN,
|
||||||
{},
|
|
||||||
true,
|
true,
|
||||||
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
||||||
value => {
|
value => {
|
||||||
|
|||||||
@@ -7,22 +7,13 @@ const { SiteDataTestUtils } = ChromeUtils.importESModule(
|
|||||||
"resource://testing-common/SiteDataTestUtils.sys.mjs"
|
"resource://testing-common/SiteDataTestUtils.sys.mjs"
|
||||||
);
|
);
|
||||||
|
|
||||||
async function addServiceWorker(
|
async function addServiceWorker(origin) {
|
||||||
origin,
|
|
||||||
topLevelOrigin = null,
|
|
||||||
userContextId = null
|
|
||||||
) {
|
|
||||||
let swURL =
|
let swURL =
|
||||||
getRootDirectory(gTestPath).replace("chrome://mochitests/content", origin) +
|
getRootDirectory(gTestPath).replace("chrome://mochitests/content", origin) +
|
||||||
"worker.js";
|
"worker.js";
|
||||||
|
|
||||||
let registered = SiteDataTestUtils.promiseServiceWorkerRegistered(swURL);
|
let registered = SiteDataTestUtils.promiseServiceWorkerRegistered(swURL);
|
||||||
await SiteDataTestUtils.addServiceWorker({
|
await SiteDataTestUtils.addServiceWorker(swURL);
|
||||||
win: window,
|
|
||||||
path: swURL,
|
|
||||||
topLevelPath: topLevelOrigin,
|
|
||||||
userContextId,
|
|
||||||
});
|
|
||||||
await registered;
|
await registered;
|
||||||
|
|
||||||
ok(true, `${origin} has a service worker`);
|
ok(true, `${origin} has a service worker`);
|
||||||
@@ -72,7 +63,7 @@ add_task(async function test_deleteFromHost() {
|
|||||||
"test1.example.org has a service worker"
|
"test1.example.org has a service worker"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clearing the subdomain should not clear the entire site.
|
// Clearing the subdomain should not clear the base domain.
|
||||||
unregistered = SiteDataTestUtils.promiseServiceWorkerUnregistered(
|
unregistered = SiteDataTestUtils.promiseServiceWorkerUnregistered(
|
||||||
"https://test1.example.org"
|
"https://test1.example.org"
|
||||||
);
|
);
|
||||||
@@ -124,21 +115,10 @@ add_task(async function test_deleteFromHost() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_deleteFromSite() {
|
add_task(async function test_deleteFromBaseDomain() {
|
||||||
await addServiceWorker("https://example.com");
|
await addServiceWorker("https://example.com");
|
||||||
await addServiceWorker("https://test1.example.com");
|
await addServiceWorker("https://test1.example.com");
|
||||||
await addServiceWorker("https://test2.example.com");
|
await addServiceWorker("https://test2.example.com");
|
||||||
|
|
||||||
// Both of these partitioned service workers should be removed by
|
|
||||||
// deleteDataFromSite targeting 'example.com'. example.org sw partitioned
|
|
||||||
// under example.com
|
|
||||||
await addServiceWorker(
|
|
||||||
"https://sub1.test1.example.org",
|
|
||||||
"https://example.com"
|
|
||||||
);
|
|
||||||
// example.com sw partitioned under example.org
|
|
||||||
await addServiceWorker("https://www.example.com", "https://example.org");
|
|
||||||
|
|
||||||
await addServiceWorker("https://example.org");
|
await addServiceWorker("https://example.org");
|
||||||
|
|
||||||
let unregistered = SiteDataTestUtils.promiseServiceWorkerUnregistered(
|
let unregistered = SiteDataTestUtils.promiseServiceWorkerUnregistered(
|
||||||
@@ -148,39 +128,20 @@ add_task(async function test_deleteFromSite() {
|
|||||||
"https://test1.example.com"
|
"https://test1.example.com"
|
||||||
);
|
);
|
||||||
let unregisteredSub2 = SiteDataTestUtils.promiseServiceWorkerUnregistered(
|
let unregisteredSub2 = SiteDataTestUtils.promiseServiceWorkerUnregistered(
|
||||||
"https://test2.example.com"
|
"https://test1.example.com"
|
||||||
);
|
);
|
||||||
let unregisteredPartitioned1 =
|
|
||||||
SiteDataTestUtils.promiseServiceWorkerUnregistered(
|
|
||||||
"https://sub1.test1.example.org"
|
|
||||||
);
|
|
||||||
let unregisteredPartitioned2 =
|
|
||||||
SiteDataTestUtils.promiseServiceWorkerUnregistered(
|
|
||||||
"https://www.example.com"
|
|
||||||
);
|
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.com",
|
"example.com",
|
||||||
{}, // All OA
|
|
||||||
true,
|
true,
|
||||||
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
||||||
value => {
|
value => {
|
||||||
Assert.equal(
|
Assert.equal(value, 0);
|
||||||
value,
|
|
||||||
0,
|
|
||||||
"Call to nsIClearDataService should not return any errors."
|
|
||||||
);
|
|
||||||
aResolve();
|
aResolve();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
await Promise.all([
|
await Promise.all([unregistered, unregisteredSub1, unregisteredSub2]);
|
||||||
unregistered,
|
|
||||||
unregisteredSub1,
|
|
||||||
unregisteredSub2,
|
|
||||||
unregisteredPartitioned1,
|
|
||||||
unregisteredPartitioned2,
|
|
||||||
]);
|
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
!SiteDataTestUtils.hasServiceWorkers("https://example.com"),
|
!SiteDataTestUtils.hasServiceWorkers("https://example.com"),
|
||||||
@@ -194,15 +155,6 @@ add_task(async function test_deleteFromSite() {
|
|||||||
!SiteDataTestUtils.hasServiceWorkers("https://test2.example.com"),
|
!SiteDataTestUtils.hasServiceWorkers("https://test2.example.com"),
|
||||||
"test2.example.com has no service worker"
|
"test2.example.com has no service worker"
|
||||||
);
|
);
|
||||||
ok(
|
|
||||||
!SiteDataTestUtils.hasServiceWorkers("https://sub1.test1.example.org"),
|
|
||||||
"sub1.test1.example.org has no service worker"
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
!SiteDataTestUtils.hasServiceWorkers("https://www.example.com"),
|
|
||||||
"www.example.com has no service worker"
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
SiteDataTestUtils.hasServiceWorkers("https://example.org"),
|
SiteDataTestUtils.hasServiceWorkers("https://example.org"),
|
||||||
"example.org has a service worker"
|
"example.org has a service worker"
|
||||||
@@ -212,9 +164,8 @@ add_task(async function test_deleteFromSite() {
|
|||||||
"https://example.org"
|
"https://example.org"
|
||||||
);
|
);
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.org",
|
"example.org",
|
||||||
{},
|
|
||||||
true,
|
true,
|
||||||
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
||||||
value => {
|
value => {
|
||||||
@@ -241,84 +192,6 @@ add_task(async function test_deleteFromSite() {
|
|||||||
!SiteDataTestUtils.hasServiceWorkers("https://test2.example.com"),
|
!SiteDataTestUtils.hasServiceWorkers("https://test2.example.com"),
|
||||||
"test2.example.com has no service worker"
|
"test2.example.com has no service worker"
|
||||||
);
|
);
|
||||||
ok(
|
|
||||||
!SiteDataTestUtils.hasServiceWorkers("https://sub1.test1.example.org"),
|
|
||||||
"sub1.test1.example.org has no service worker"
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
!SiteDataTestUtils.hasServiceWorkers("https://www.example.com"),
|
|
||||||
"www.example.com has no service worker"
|
|
||||||
);
|
|
||||||
|
|
||||||
await SiteDataTestUtils.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_deleteFromSiteWithPattern() {
|
|
||||||
await addServiceWorker("https://example.com");
|
|
||||||
await addServiceWorker("https://test1.example.com");
|
|
||||||
await addServiceWorker("https://test2.example.com");
|
|
||||||
|
|
||||||
// Both of these partitioned service workers should be removed by
|
|
||||||
// deleteDataFromSite targeting 'example.com'. example.org sw partitioned
|
|
||||||
// under example.com
|
|
||||||
await addServiceWorker(
|
|
||||||
"https://sub1.test1.example.org",
|
|
||||||
"https://example.com"
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
SiteDataTestUtils.hasServiceWorkers("https://sub1.test1.example.org"),
|
|
||||||
"sub1.test1.example.org initially has a service worker"
|
|
||||||
);
|
|
||||||
// example.com sw partitioned under example.org
|
|
||||||
await addServiceWorker("https://www.example.com", "https://example.org", 3);
|
|
||||||
|
|
||||||
await addServiceWorker("https://example.org");
|
|
||||||
|
|
||||||
let unregisteredSub2 = SiteDataTestUtils.promiseServiceWorkerUnregistered(
|
|
||||||
"https://www.example.com"
|
|
||||||
);
|
|
||||||
|
|
||||||
await new Promise(aResolve => {
|
|
||||||
Services.clearData.deleteDataFromSite(
|
|
||||||
"example.com",
|
|
||||||
{ userContextId: 3 }, // Only OA with userContextId == 3
|
|
||||||
true,
|
|
||||||
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
|
||||||
value => {
|
|
||||||
Assert.equal(value, 0);
|
|
||||||
aResolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
await Promise.all([unregisteredSub2]);
|
|
||||||
|
|
||||||
ok(
|
|
||||||
SiteDataTestUtils.hasServiceWorkers("https://example.com"),
|
|
||||||
"example.com has a service worker"
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
SiteDataTestUtils.hasServiceWorkers("https://test1.example.com"),
|
|
||||||
"test1.example.com has a service worker"
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
SiteDataTestUtils.hasServiceWorkers("https://test2.example.com"),
|
|
||||||
"test2.example.com has a service worker"
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
SiteDataTestUtils.hasServiceWorkers("https://sub1.test1.example.org"),
|
|
||||||
"sub1.test1.example.org has a service worker"
|
|
||||||
);
|
|
||||||
ok(
|
|
||||||
!SiteDataTestUtils.hasServiceWorkers("https://www.example.com"),
|
|
||||||
"www.example.com has no service worker"
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(
|
|
||||||
SiteDataTestUtils.hasServiceWorkers("https://example.org"),
|
|
||||||
"example.org has a service worker"
|
|
||||||
);
|
|
||||||
|
|
||||||
await SiteDataTestUtils.clear();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_deleteFromPrincipal() {
|
add_task(async function test_deleteFromPrincipal() {
|
||||||
|
|||||||
@@ -131,9 +131,8 @@ add_task(async function test_deleteByBaseDomain() {
|
|||||||
|
|
||||||
info("Clearing sessionStorage for base domain A " + BASE_DOMAIN_A);
|
info("Clearing sessionStorage for base domain A " + BASE_DOMAIN_A);
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
BASE_DOMAIN_A,
|
BASE_DOMAIN_A,
|
||||||
{},
|
|
||||||
false,
|
false,
|
||||||
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
||||||
resolve
|
resolve
|
||||||
|
|||||||
@@ -119,6 +119,97 @@ function addTestData() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function runDeleteBySiteHostTest(clearDataServiceFn) {
|
||||||
|
addTestData();
|
||||||
|
|
||||||
|
let baseDomain = "common-bounce-tracker.com";
|
||||||
|
info("Deleting by base domain " + baseDomain);
|
||||||
|
await new Promise(function (resolve) {
|
||||||
|
clearDataServiceFn(
|
||||||
|
baseDomain,
|
||||||
|
true,
|
||||||
|
CLEAR_BOUNCE_TRACKING_PROTECTION_STATE,
|
||||||
|
failedFlags => {
|
||||||
|
Assert.equal(failedFlags, 0, "Clearing should have succeeded");
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.deepEqual(
|
||||||
|
bounceTrackingProtection
|
||||||
|
.testGetBounceTrackerCandidateHosts(OA_DEFAULT)
|
||||||
|
.map(entry => entry.siteHost)
|
||||||
|
.sort(),
|
||||||
|
[
|
||||||
|
"bounce-tracker-normal-browsing.com",
|
||||||
|
"bounce-tracker-normal-browsing2.com",
|
||||||
|
],
|
||||||
|
"Should have deleted only 'common-bounce-tracker.com' for default OA."
|
||||||
|
);
|
||||||
|
Assert.deepEqual(
|
||||||
|
bounceTrackingProtection
|
||||||
|
.testGetUserActivationHosts(OA_DEFAULT)
|
||||||
|
.map(entry => entry.siteHost)
|
||||||
|
.sort(),
|
||||||
|
[
|
||||||
|
"common-user-activation.com",
|
||||||
|
"user-activation-normal-browsing.com",
|
||||||
|
"user-activation-normal-browsing2.com",
|
||||||
|
],
|
||||||
|
"Should not have deleted any user activations for default OA."
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.deepEqual(
|
||||||
|
bounceTrackingProtection
|
||||||
|
.testGetBounceTrackerCandidateHosts(OA_PRIVATE_BROWSING)
|
||||||
|
.map(entry => entry.siteHost)
|
||||||
|
.sort(),
|
||||||
|
[
|
||||||
|
"bounce-tracker-private-browsing.com",
|
||||||
|
"bounce-tracker-private-browsing2.com",
|
||||||
|
],
|
||||||
|
"Should have deleted only 'common-bounce-tracker.com' for private browsing."
|
||||||
|
);
|
||||||
|
Assert.deepEqual(
|
||||||
|
bounceTrackingProtection
|
||||||
|
.testGetUserActivationHosts(OA_PRIVATE_BROWSING)
|
||||||
|
.map(entry => entry.siteHost)
|
||||||
|
.sort(),
|
||||||
|
[
|
||||||
|
"common-user-activation.com",
|
||||||
|
"user-activation-private-browsing.com",
|
||||||
|
"user-activation-private-browsing2.com",
|
||||||
|
],
|
||||||
|
"Should not have deleted any user activations for private browsing."
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.deepEqual(
|
||||||
|
bounceTrackingProtection
|
||||||
|
.testGetBounceTrackerCandidateHosts(OA_CONTAINER)
|
||||||
|
.map(entry => entry.siteHost)
|
||||||
|
.sort(),
|
||||||
|
["bounce-tracker-container.com", "bounce-tracker-container2.com"],
|
||||||
|
"Should have deleted only 'common-bounce-tracker.com' for container."
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.deepEqual(
|
||||||
|
bounceTrackingProtection
|
||||||
|
.testGetUserActivationHosts(OA_CONTAINER)
|
||||||
|
.map(entry => entry.siteHost)
|
||||||
|
.sort(),
|
||||||
|
[
|
||||||
|
"common-user-activation.com",
|
||||||
|
"user-activation-container.com",
|
||||||
|
"user-activation-container2.com",
|
||||||
|
],
|
||||||
|
"Should not have deleted any user activations for container."
|
||||||
|
);
|
||||||
|
|
||||||
|
// Cleanup.
|
||||||
|
bounceTrackingProtection.clearAll();
|
||||||
|
}
|
||||||
|
|
||||||
do_get_profile();
|
do_get_profile();
|
||||||
|
|
||||||
add_task(async function test_deleteAll() {
|
add_task(async function test_deleteAll() {
|
||||||
@@ -181,6 +272,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
Services.io.newURI("https://common-bounce-tracker.com"),
|
Services.io.newURI("https://common-bounce-tracker.com"),
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
console.debug("principal", principal.origin);
|
||||||
|
|
||||||
info("Deleting by principal " + principal.origin);
|
info("Deleting by principal " + principal.origin);
|
||||||
await new Promise(function (resolve) {
|
await new Promise(function (resolve) {
|
||||||
@@ -203,7 +295,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
[
|
[
|
||||||
"bounce-tracker-normal-browsing.com",
|
"bounce-tracker-normal-browsing.com",
|
||||||
"bounce-tracker-normal-browsing2.com",
|
"bounce-tracker-normal-browsing2.com",
|
||||||
].sort(),
|
],
|
||||||
"Should have deleted only 'common-bounce-tracker.com' for default OA."
|
"Should have deleted only 'common-bounce-tracker.com' for default OA."
|
||||||
);
|
);
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(
|
||||||
@@ -215,7 +307,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
"common-user-activation.com",
|
"common-user-activation.com",
|
||||||
"user-activation-normal-browsing.com",
|
"user-activation-normal-browsing.com",
|
||||||
"user-activation-normal-browsing2.com",
|
"user-activation-normal-browsing2.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any user activations for default OA."
|
"Should not have deleted any user activations for default OA."
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -228,7 +320,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
"bounce-tracker-private-browsing.com",
|
"bounce-tracker-private-browsing.com",
|
||||||
"bounce-tracker-private-browsing2.com",
|
"bounce-tracker-private-browsing2.com",
|
||||||
"common-bounce-tracker.com",
|
"common-bounce-tracker.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted 'common-bounce-tracker.com' for private browsing."
|
"Should not have deleted 'common-bounce-tracker.com' for private browsing."
|
||||||
);
|
);
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(
|
||||||
@@ -240,7 +332,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
"common-user-activation.com",
|
"common-user-activation.com",
|
||||||
"user-activation-private-browsing.com",
|
"user-activation-private-browsing.com",
|
||||||
"user-activation-private-browsing2.com",
|
"user-activation-private-browsing2.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any user activations for private browsing."
|
"Should not have deleted any user activations for private browsing."
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -253,7 +345,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
"bounce-tracker-container.com",
|
"bounce-tracker-container.com",
|
||||||
"bounce-tracker-container2.com",
|
"bounce-tracker-container2.com",
|
||||||
"common-bounce-tracker.com",
|
"common-bounce-tracker.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted 'common-bounce-tracker.com' for container."
|
"Should not have deleted 'common-bounce-tracker.com' for container."
|
||||||
);
|
);
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(
|
||||||
@@ -265,7 +357,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
"common-user-activation.com",
|
"common-user-activation.com",
|
||||||
"user-activation-container.com",
|
"user-activation-container.com",
|
||||||
"user-activation-container2.com",
|
"user-activation-container2.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any user activations for container."
|
"Should not have deleted any user activations for container."
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -295,7 +387,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
[
|
[
|
||||||
"bounce-tracker-normal-browsing.com",
|
"bounce-tracker-normal-browsing.com",
|
||||||
"bounce-tracker-normal-browsing2.com",
|
"bounce-tracker-normal-browsing2.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any bounce tracker candidates for default OA."
|
"Should not have deleted any bounce tracker candidates for default OA."
|
||||||
);
|
);
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(
|
||||||
@@ -307,7 +399,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
"common-user-activation.com",
|
"common-user-activation.com",
|
||||||
"user-activation-normal-browsing.com",
|
"user-activation-normal-browsing.com",
|
||||||
"user-activation-normal-browsing2.com",
|
"user-activation-normal-browsing2.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted 'common-user-activation.com' for default OA."
|
"Should not have deleted 'common-user-activation.com' for default OA."
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -320,7 +412,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
"bounce-tracker-private-browsing.com",
|
"bounce-tracker-private-browsing.com",
|
||||||
"bounce-tracker-private-browsing2.com",
|
"bounce-tracker-private-browsing2.com",
|
||||||
"common-bounce-tracker.com",
|
"common-bounce-tracker.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any bounce tracker candidates for private browsing."
|
"Should not have deleted any bounce tracker candidates for private browsing."
|
||||||
);
|
);
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(
|
||||||
@@ -332,7 +424,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
"common-user-activation.com",
|
"common-user-activation.com",
|
||||||
"user-activation-private-browsing.com",
|
"user-activation-private-browsing.com",
|
||||||
"user-activation-private-browsing2.com",
|
"user-activation-private-browsing2.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted 'common-user-activation.com' for private browsing."
|
"Should not have deleted 'common-user-activation.com' for private browsing."
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -345,7 +437,7 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
"bounce-tracker-container.com",
|
"bounce-tracker-container.com",
|
||||||
"bounce-tracker-container2.com",
|
"bounce-tracker-container2.com",
|
||||||
"common-bounce-tracker.com",
|
"common-bounce-tracker.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any bounce tracker candidates for container."
|
"Should not have deleted any bounce tracker candidates for container."
|
||||||
);
|
);
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(
|
||||||
@@ -361,201 +453,8 @@ add_task(async function test_deleteByPrincipal() {
|
|||||||
bounceTrackingProtection.clearAll();
|
bounceTrackingProtection.clearAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Tests clearing BTP data for a site for all OriginAttributes.
|
add_task(async function test_deleteByBaseDomain() {
|
||||||
add_task(async function test_deleteBySite_allOriginAttributes() {
|
await runDeleteBySiteHostTest(Services.clearData.deleteDataFromBaseDomain);
|
||||||
addTestData();
|
|
||||||
|
|
||||||
let schemelessSite = "common-bounce-tracker.com";
|
|
||||||
info("Deleting by site " + schemelessSite);
|
|
||||||
await new Promise(function (resolve) {
|
|
||||||
Services.clearData.deleteDataFromSite(
|
|
||||||
schemelessSite,
|
|
||||||
{}, // Default OriginAttributesPattern which matches all OriginAttributes.
|
|
||||||
true,
|
|
||||||
CLEAR_BOUNCE_TRACKING_PROTECTION_STATE,
|
|
||||||
failedFlags => {
|
|
||||||
Assert.equal(failedFlags, 0, "Clearing should have succeeded");
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
schemelessSite = "common-user-activation.com";
|
|
||||||
info("Deleting by site " + schemelessSite);
|
|
||||||
await new Promise(function (resolve) {
|
|
||||||
Services.clearData.deleteDataFromSite(
|
|
||||||
schemelessSite,
|
|
||||||
{}, // Default OriginAttributesPattern which matches all OriginAttributes.
|
|
||||||
true,
|
|
||||||
CLEAR_BOUNCE_TRACKING_PROTECTION_STATE,
|
|
||||||
failedFlags => {
|
|
||||||
Assert.equal(failedFlags, 0, "Clearing should have succeeded");
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetBounceTrackerCandidateHosts(OA_DEFAULT)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"bounce-tracker-normal-browsing.com",
|
|
||||||
"bounce-tracker-normal-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should have deleted bounce tracker candidate 'common-bounce-tracker.com' for default OA."
|
|
||||||
);
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetUserActivationHosts(OA_DEFAULT)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"user-activation-normal-browsing.com",
|
|
||||||
"user-activation-normal-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should have deleted user activation for 'common-user-activation.com' for default OA."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetBounceTrackerCandidateHosts(OA_PRIVATE_BROWSING)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"bounce-tracker-private-browsing.com",
|
|
||||||
"bounce-tracker-private-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should have deleted 'common-bounce-tracker.com' for private browsing."
|
|
||||||
);
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetUserActivationHosts(OA_PRIVATE_BROWSING)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"user-activation-private-browsing.com",
|
|
||||||
"user-activation-private-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should have deleted user activation for 'common-bounce-tracker.com' for private browsing."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetBounceTrackerCandidateHosts(OA_CONTAINER)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
["bounce-tracker-container.com", "bounce-tracker-container2.com"].sort(),
|
|
||||||
"Should have deleted only 'common-bounce-tracker.com' for container."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetUserActivationHosts(OA_CONTAINER)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
["user-activation-container.com", "user-activation-container2.com"].sort(),
|
|
||||||
"Should have deleted user activation for 'common-bounce-tracker.com' for container."
|
|
||||||
);
|
|
||||||
|
|
||||||
// Cleanup.
|
|
||||||
bounceTrackingProtection.clearAll();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Tests clearing BTP data for a site for specific a specific OriginAttributes pattern.
|
|
||||||
add_task(async function test_deleteBySite_OAPattern() {
|
|
||||||
addTestData();
|
|
||||||
|
|
||||||
let schemelessSite = "common-bounce-tracker.com";
|
|
||||||
info("Deleting by site " + schemelessSite);
|
|
||||||
await new Promise(function (resolve) {
|
|
||||||
Services.clearData.deleteDataFromSite(
|
|
||||||
schemelessSite,
|
|
||||||
// An OriginAttributesPattern that matches normal browsing => any OA that
|
|
||||||
// has mPrivateBrowsingId == 0
|
|
||||||
{ privateBrowsingId: 0 },
|
|
||||||
true,
|
|
||||||
CLEAR_BOUNCE_TRACKING_PROTECTION_STATE,
|
|
||||||
failedFlags => {
|
|
||||||
Assert.equal(failedFlags, 0, "Clearing should have succeeded");
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetBounceTrackerCandidateHosts(OA_DEFAULT)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"bounce-tracker-normal-browsing.com",
|
|
||||||
"bounce-tracker-normal-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should have deleted only 'common-bounce-tracker.com' for default OA."
|
|
||||||
);
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetUserActivationHosts(OA_DEFAULT)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"common-user-activation.com",
|
|
||||||
"user-activation-normal-browsing.com",
|
|
||||||
"user-activation-normal-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should not have deleted any user activations for default OA."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetBounceTrackerCandidateHosts(OA_PRIVATE_BROWSING)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"common-bounce-tracker.com",
|
|
||||||
"bounce-tracker-private-browsing.com",
|
|
||||||
"bounce-tracker-private-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should not have deleted 'common-bounce-tracker.com' for private browsing."
|
|
||||||
);
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetUserActivationHosts(OA_PRIVATE_BROWSING)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"common-user-activation.com",
|
|
||||||
"user-activation-private-browsing.com",
|
|
||||||
"user-activation-private-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should not have deleted any user activations for private browsing."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetBounceTrackerCandidateHosts(OA_CONTAINER)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
["bounce-tracker-container.com", "bounce-tracker-container2.com"].sort(),
|
|
||||||
"Should have deleted 'common-bounce-tracker.com' for container."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetUserActivationHosts(OA_CONTAINER)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"common-user-activation.com",
|
|
||||||
"user-activation-container.com",
|
|
||||||
"user-activation-container2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should not have deleted any user activations for container."
|
|
||||||
);
|
|
||||||
|
|
||||||
// Cleanup.
|
|
||||||
bounceTrackingProtection.clearAll();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_deleteByRange() {
|
add_task(async function test_deleteByRange() {
|
||||||
@@ -638,94 +537,7 @@ add_task(async function test_deleteByRange() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_deleteByHost() {
|
add_task(async function test_deleteByHost() {
|
||||||
addTestData();
|
await runDeleteBySiteHostTest(Services.clearData.deleteDataFromHost);
|
||||||
|
|
||||||
let host = "common-bounce-tracker.com";
|
|
||||||
info("Deleting by host " + host);
|
|
||||||
await new Promise(function (resolve) {
|
|
||||||
Services.clearData.deleteDataFromHost(
|
|
||||||
host,
|
|
||||||
true,
|
|
||||||
CLEAR_BOUNCE_TRACKING_PROTECTION_STATE,
|
|
||||||
failedFlags => {
|
|
||||||
Assert.equal(failedFlags, 0, "Clearing should have succeeded");
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetBounceTrackerCandidateHosts(OA_DEFAULT)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"bounce-tracker-normal-browsing.com",
|
|
||||||
"bounce-tracker-normal-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should have deleted only 'common-bounce-tracker.com' for default OA."
|
|
||||||
);
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetUserActivationHosts(OA_DEFAULT)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"common-user-activation.com",
|
|
||||||
"user-activation-normal-browsing.com",
|
|
||||||
"user-activation-normal-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should not have deleted any user activations for default OA."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetBounceTrackerCandidateHosts(OA_PRIVATE_BROWSING)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"bounce-tracker-private-browsing.com",
|
|
||||||
"bounce-tracker-private-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should have deleted only 'common-bounce-tracker.com' for private browsing."
|
|
||||||
);
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetUserActivationHosts(OA_PRIVATE_BROWSING)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"common-user-activation.com",
|
|
||||||
"user-activation-private-browsing.com",
|
|
||||||
"user-activation-private-browsing2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should not have deleted any user activations for private browsing."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetBounceTrackerCandidateHosts(OA_CONTAINER)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
["bounce-tracker-container.com", "bounce-tracker-container2.com"].sort(),
|
|
||||||
"Should have deleted only 'common-bounce-tracker.com' for container."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
bounceTrackingProtection
|
|
||||||
.testGetUserActivationHosts(OA_CONTAINER)
|
|
||||||
.map(entry => entry.siteHost)
|
|
||||||
.sort(),
|
|
||||||
[
|
|
||||||
"common-user-activation.com",
|
|
||||||
"user-activation-container.com",
|
|
||||||
"user-activation-container2.com",
|
|
||||||
].sort(),
|
|
||||||
"Should not have deleted any user activations for container."
|
|
||||||
);
|
|
||||||
|
|
||||||
// Cleanup.
|
|
||||||
bounceTrackingProtection.clearAll();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_deleteByOriginAttributes() {
|
add_task(async function test_deleteByOriginAttributes() {
|
||||||
@@ -751,7 +563,7 @@ add_task(async function test_deleteByOriginAttributes() {
|
|||||||
"bounce-tracker-normal-browsing.com",
|
"bounce-tracker-normal-browsing.com",
|
||||||
"bounce-tracker-normal-browsing2.com",
|
"bounce-tracker-normal-browsing2.com",
|
||||||
"common-bounce-tracker.com",
|
"common-bounce-tracker.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any bounce tracker candidates for default OA."
|
"Should not have deleted any bounce tracker candidates for default OA."
|
||||||
);
|
);
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(
|
||||||
@@ -763,7 +575,7 @@ add_task(async function test_deleteByOriginAttributes() {
|
|||||||
"common-user-activation.com",
|
"common-user-activation.com",
|
||||||
"user-activation-normal-browsing.com",
|
"user-activation-normal-browsing.com",
|
||||||
"user-activation-normal-browsing2.com",
|
"user-activation-normal-browsing2.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any user activations for default OA."
|
"Should not have deleted any user activations for default OA."
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -776,7 +588,7 @@ add_task(async function test_deleteByOriginAttributes() {
|
|||||||
"bounce-tracker-private-browsing.com",
|
"bounce-tracker-private-browsing.com",
|
||||||
"bounce-tracker-private-browsing2.com",
|
"bounce-tracker-private-browsing2.com",
|
||||||
"common-bounce-tracker.com",
|
"common-bounce-tracker.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any bounce tracker candidates for private browsing."
|
"Should not have deleted any bounce tracker candidates for private browsing."
|
||||||
);
|
);
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(
|
||||||
@@ -788,7 +600,7 @@ add_task(async function test_deleteByOriginAttributes() {
|
|||||||
"common-user-activation.com",
|
"common-user-activation.com",
|
||||||
"user-activation-private-browsing.com",
|
"user-activation-private-browsing.com",
|
||||||
"user-activation-private-browsing2.com",
|
"user-activation-private-browsing2.com",
|
||||||
].sort(),
|
],
|
||||||
"Should not have deleted any user activations for private browsing."
|
"Should not have deleted any user activations for private browsing."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -203,9 +203,8 @@ add_task(async function test_deleteByBaseDomain() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.com",
|
"example.com",
|
||||||
{},
|
|
||||||
true /* user request */,
|
true /* user request */,
|
||||||
Ci.nsIClearDataService.CLEAR_CERT_EXCEPTIONS,
|
Ci.nsIClearDataService.CLEAR_CERT_EXCEPTIONS,
|
||||||
value => {
|
value => {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ add_task(async function test_delete_exception() {
|
|||||||
"The exception is properly cleared."
|
"The exception is properly cleared."
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test nsIClearDataService.deleteDataFromSite
|
// Test nsIClearDataService.deleteDataFromBaseDomain
|
||||||
info("Adding an exception for example.com");
|
info("Adding an exception for example.com");
|
||||||
Services.cookieBanners.setDomainPref(
|
Services.cookieBanners.setDomainPref(
|
||||||
uri,
|
uri,
|
||||||
@@ -71,11 +71,10 @@ add_task(async function test_delete_exception() {
|
|||||||
"The exception is properly set."
|
"The exception is properly set."
|
||||||
);
|
);
|
||||||
|
|
||||||
info("Trigger the deleteDataFromSite");
|
info("Trigger the deleteDataFromBaseDomain");
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.com",
|
"example.com",
|
||||||
{},
|
|
||||||
true /* user request */,
|
true /* user request */,
|
||||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||||
_ => {
|
_ => {
|
||||||
@@ -211,7 +210,7 @@ add_task(async function test_delete_executed_record() {
|
|||||||
"The record is properly cleared."
|
"The record is properly cleared."
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test nsIClearDataService.deleteDataFromSite
|
// Test nsIClearDataService.deleteDataFromBaseDomain
|
||||||
info("Adding a record for example.com");
|
info("Adding a record for example.com");
|
||||||
Services.cookieBanners.markSiteExecuted("example.com", true, false);
|
Services.cookieBanners.markSiteExecuted("example.com", true, false);
|
||||||
|
|
||||||
@@ -225,11 +224,10 @@ add_task(async function test_delete_executed_record() {
|
|||||||
"The record is properly set."
|
"The record is properly set."
|
||||||
);
|
);
|
||||||
|
|
||||||
info("Trigger the deleteDataFromSite");
|
info("Trigger the deleteDataFromBaseDomain");
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.com",
|
"example.com",
|
||||||
{},
|
|
||||||
true /* user request */,
|
true /* user request */,
|
||||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||||
_ => {
|
_ => {
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ add_task(async function test_localfile_cookies() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// The following tests ensure we properly clear (partitioned/unpartitioned)
|
// The following tests ensure we properly clear (partitioned/unpartitioned)
|
||||||
// cookies when using deleteDataFromSite and deleteDataFromHost.
|
// cookies when using deleteDataFromBaseDomain and deleteDataFromHost.
|
||||||
|
|
||||||
function getTestCookieName(host, topLevelBaseDomain) {
|
function getTestCookieName(host, topLevelBaseDomain) {
|
||||||
if (!topLevelBaseDomain) {
|
if (!topLevelBaseDomain) {
|
||||||
@@ -263,9 +263,8 @@ add_task(async function test_baseDomain_cookies() {
|
|||||||
|
|
||||||
// Clear cookies of example.net including partitions.
|
// Clear cookies of example.net including partitions.
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.net",
|
"example.net",
|
||||||
{},
|
|
||||||
false,
|
false,
|
||||||
Ci.nsIClearDataService.CLEAR_COOKIES,
|
Ci.nsIClearDataService.CLEAR_COOKIES,
|
||||||
aResolve
|
aResolve
|
||||||
@@ -353,11 +352,10 @@ add_task(async function test_baseDomain_cookies_subdomain() {
|
|||||||
Services.cookies.removeAll();
|
Services.cookies.removeAll();
|
||||||
setTestCookies();
|
setTestCookies();
|
||||||
|
|
||||||
// Clear cookies of example.net including partitions.
|
// Clear cookies of test.example.net including partitions.
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.net",
|
"test.example.net",
|
||||||
{},
|
|
||||||
false,
|
false,
|
||||||
Ci.nsIClearDataService.CLEAR_COOKIES,
|
Ci.nsIClearDataService.CLEAR_COOKIES,
|
||||||
aResolve
|
aResolve
|
||||||
|
|||||||
@@ -265,9 +265,8 @@ add_task(async function test_basedomain_downloads() {
|
|||||||
await list.addView(view);
|
await list.addView(view);
|
||||||
|
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.net",
|
"example.net",
|
||||||
{},
|
|
||||||
true /* user request */,
|
true /* user request */,
|
||||||
Ci.nsIClearDataService.CLEAR_DOWNLOADS,
|
Ci.nsIClearDataService.CLEAR_DOWNLOADS,
|
||||||
value => {
|
value => {
|
||||||
|
|||||||
@@ -62,14 +62,13 @@ add_task(async function test_clear_fingerprinting_protection_state() {
|
|||||||
"The fingerprinting randomization key is reset properly."
|
"The fingerprinting randomization key is reset properly."
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test nsIClearDataService.deleteDataFromSite
|
// Test nsIClearDataService.deleteDataFromBaseDomain
|
||||||
keyStr = newKeyStr;
|
keyStr = newKeyStr;
|
||||||
|
|
||||||
info("Trigger the deleteDataFromSite");
|
info("Trigger the deleteDataFromBaseDomain");
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.com",
|
"example.com",
|
||||||
{},
|
|
||||||
true /* user request */,
|
true /* user request */,
|
||||||
Ci.nsIClearDataService.CLEAR_FINGERPRINTING_PROTECTION_STATE,
|
Ci.nsIClearDataService.CLEAR_FINGERPRINTING_PROTECTION_STATE,
|
||||||
_ => {
|
_ => {
|
||||||
@@ -160,90 +159,3 @@ add_task(async function test_clear_fingerprinting_protection_state() {
|
|||||||
|
|
||||||
Services.prefs.clearUserPref("privacy.resistFingerprinting");
|
Services.prefs.clearUserPref("privacy.resistFingerprinting");
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(
|
|
||||||
async function test_clear_fingerprinting_protection_state_by_site_and_pattern() {
|
|
||||||
info("Enabling fingerprinting randomization");
|
|
||||||
Services.prefs.setBoolPref("privacy.resistFingerprinting", true);
|
|
||||||
|
|
||||||
let uri = Services.io.newURI("https://example.com");
|
|
||||||
let principal = Services.scriptSecurityManager.createContentPrincipal(
|
|
||||||
uri,
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
let privateBrowsingPrincipal =
|
|
||||||
Services.scriptSecurityManager.createContentPrincipal(uri, {
|
|
||||||
privateBrowsingId: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
let channel = Services.io.newChannelFromURI(
|
|
||||||
uri,
|
|
||||||
null, // aLoadingNode
|
|
||||||
principal,
|
|
||||||
null, // aTriggeringPrincipal
|
|
||||||
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
|
|
||||||
Ci.nsIContentPolicy.TYPE_DOCUMENT
|
|
||||||
);
|
|
||||||
let pbmChannel = Services.io.newChannelFromURI(
|
|
||||||
uri,
|
|
||||||
null, // aLoadingNode
|
|
||||||
privateBrowsingPrincipal,
|
|
||||||
null, // aTriggeringPrincipal
|
|
||||||
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
|
|
||||||
Ci.nsIContentPolicy.TYPE_DOCUMENT
|
|
||||||
);
|
|
||||||
|
|
||||||
let [key, pbmKey] = [channel, pbmChannel].map(c => {
|
|
||||||
let k = Services.rfp.testGenerateRandomKey(c);
|
|
||||||
let keyStr = k.map(bytes => bytes.toString(16).padStart(2, "0")).join("");
|
|
||||||
|
|
||||||
// Verify that the key remains the same without clearing.
|
|
||||||
k = Services.rfp.testGenerateRandomKey(c);
|
|
||||||
let keyStrAgain = k
|
|
||||||
.map(bytes => bytes.toString(16).padStart(2, "0"))
|
|
||||||
.join("");
|
|
||||||
|
|
||||||
Assert.equal(
|
|
||||||
keyStr,
|
|
||||||
keyStrAgain,
|
|
||||||
"The fingerprinting randomization key remain the same without clearing."
|
|
||||||
);
|
|
||||||
|
|
||||||
return keyStr;
|
|
||||||
});
|
|
||||||
|
|
||||||
info("Trigger the deleteDataFromSite clearing only PBM data.");
|
|
||||||
await new Promise(resolve => {
|
|
||||||
Services.clearData.deleteDataFromSite(
|
|
||||||
"example.com",
|
|
||||||
{ privateBrowsingId: 1 },
|
|
||||||
true /* user request */,
|
|
||||||
Ci.nsIClearDataService.CLEAR_FINGERPRINTING_PROTECTION_STATE,
|
|
||||||
_ => {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
let [newKey, newPBMKey] = [channel, pbmChannel].map(c => {
|
|
||||||
return Services.rfp
|
|
||||||
.testGenerateRandomKey(c)
|
|
||||||
.map(bytes => bytes.toString(16).padStart(2, "0"))
|
|
||||||
.join("");
|
|
||||||
});
|
|
||||||
|
|
||||||
Assert.equal(
|
|
||||||
key,
|
|
||||||
newKey,
|
|
||||||
"The fingerprinting randomization key remains the same for normal browsing."
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.notEqual(
|
|
||||||
pbmKey,
|
|
||||||
newPBMKey,
|
|
||||||
"The fingerprinting randomization key is reset properly for private browsing."
|
|
||||||
);
|
|
||||||
|
|
||||||
Services.prefs.clearUserPref("privacy.resistFingerprinting");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -180,9 +180,8 @@ add_task(async function test_deleteFromBaseDomain() {
|
|||||||
|
|
||||||
// Clear an unrelated base domain.
|
// Clear an unrelated base domain.
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"foo.com",
|
"foo.com",
|
||||||
{},
|
|
||||||
true,
|
true,
|
||||||
Ci.nsIClearDataService.CLEAR_NETWORK_CACHE,
|
Ci.nsIClearDataService.CLEAR_NETWORK_CACHE,
|
||||||
value => {
|
value => {
|
||||||
@@ -220,9 +219,8 @@ add_task(async function test_deleteFromBaseDomain() {
|
|||||||
|
|
||||||
// Clear data for example.com
|
// Clear data for example.com
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.com",
|
"example.com",
|
||||||
{},
|
|
||||||
true,
|
true,
|
||||||
Ci.nsIClearDataService.CLEAR_NETWORK_CACHE,
|
Ci.nsIClearDataService.CLEAR_NETWORK_CACHE,
|
||||||
value => {
|
value => {
|
||||||
|
|||||||
@@ -199,163 +199,90 @@ function addTestPermissions() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_task(async function test_removeBySite() {
|
add_task(async function test_basedomain_permissions() {
|
||||||
addTestPermissions();
|
for (let domain of [
|
||||||
|
"example.net",
|
||||||
|
"test.example.net",
|
||||||
|
"foo.bar.example.net",
|
||||||
|
]) {
|
||||||
|
addTestPermissions();
|
||||||
|
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.net",
|
domain,
|
||||||
{}, // All OriginAttributes
|
true /* user request */,
|
||||||
true /* user request */,
|
Ci.nsIClearDataService.CLEAR_PERMISSIONS,
|
||||||
Ci.nsIClearDataService.CLEAR_PERMISSIONS,
|
value => {
|
||||||
value => {
|
Assert.equal(value, 0);
|
||||||
Assert.equal(value, 0);
|
aResolve();
|
||||||
aResolve();
|
}
|
||||||
}
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Should have cleared all entries associated with the base domain.
|
||||||
|
Assert.ok(
|
||||||
|
!PermissionTestUtils.getPermissionObject(
|
||||||
|
"https://example.net",
|
||||||
|
"geo",
|
||||||
|
true
|
||||||
|
)
|
||||||
);
|
);
|
||||||
});
|
Assert.ok(
|
||||||
|
!PermissionTestUtils.getPermissionObject(
|
||||||
// Should have cleared all entries associated with the site.
|
"http://example.net",
|
||||||
Assert.ok(
|
"cookie",
|
||||||
!PermissionTestUtils.getPermissionObject("https://example.net", "geo", true)
|
true
|
||||||
);
|
)
|
||||||
Assert.ok(
|
|
||||||
!PermissionTestUtils.getPermissionObject(
|
|
||||||
"http://example.net",
|
|
||||||
"cookie",
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
Assert.ok(
|
|
||||||
!PermissionTestUtils.getPermissionObject(
|
|
||||||
"https://bar.example.net",
|
|
||||||
"geo",
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
Assert.ok(
|
|
||||||
!PermissionTestUtils.getPermissionObject(
|
|
||||||
"https://foo.bar.example.net",
|
|
||||||
"geo",
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
Assert.ok(
|
|
||||||
!PermissionTestUtils.getPermissionObject(
|
|
||||||
"https://example.com",
|
|
||||||
"3rdPartyStorage^https://example.net",
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
Assert.ok(
|
|
||||||
!PermissionTestUtils.getPermissionObject(
|
|
||||||
"https://example.com",
|
|
||||||
"3rdPartyFrameStorage^https://example.net",
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Unrelated entries should still exist.
|
|
||||||
Assert.equal(
|
|
||||||
PermissionTestUtils.getPermissionObject(
|
|
||||||
"https://example.com",
|
|
||||||
"cookie",
|
|
||||||
true
|
|
||||||
).capability,
|
|
||||||
Services.perms.ALLOW_ACTION
|
|
||||||
);
|
|
||||||
Assert.equal(
|
|
||||||
PermissionTestUtils.getPermissionObject("http://example.com", "geo", true)
|
|
||||||
.capability,
|
|
||||||
Services.perms.ALLOW_ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
Services.perms.removeAll();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Test that passing an OriginAttributesPattern into deleteDataFromSite only
|
|
||||||
// clears permissions matching the pattern.
|
|
||||||
add_task(async function test_removeBySiteAndOAPattern() {
|
|
||||||
let principalRegular = Services.scriptSecurityManager.createContentPrincipal(
|
|
||||||
Services.io.newURI("https://example.net"),
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
let principalRegularSub =
|
|
||||||
Services.scriptSecurityManager.createContentPrincipal(
|
|
||||||
Services.io.newURI("https://sub.example.net"),
|
|
||||||
{}
|
|
||||||
);
|
);
|
||||||
let principalPrivateBrowsing =
|
Assert.ok(
|
||||||
Services.scriptSecurityManager.createContentPrincipal(
|
!PermissionTestUtils.getPermissionObject(
|
||||||
Services.io.newURI("https://example.net"),
|
"https://bar.example.net",
|
||||||
{ privateBrowsingId: 1 }
|
"geo",
|
||||||
|
true
|
||||||
|
)
|
||||||
);
|
);
|
||||||
let principalPrivateBrowsingSub =
|
Assert.ok(
|
||||||
Services.scriptSecurityManager.createContentPrincipal(
|
!PermissionTestUtils.getPermissionObject(
|
||||||
Services.io.newURI("https://sub.example.net"),
|
"https://foo.bar.example.net",
|
||||||
{ privateBrowsingId: 1 }
|
"geo",
|
||||||
|
true
|
||||||
|
)
|
||||||
);
|
);
|
||||||
let principalPrivateBrowsingUnrelated =
|
Assert.ok(
|
||||||
Services.scriptSecurityManager.createContentPrincipal(
|
!PermissionTestUtils.getPermissionObject(
|
||||||
Services.io.newURI("https://example.org"),
|
"https://example.com",
|
||||||
{ privateBrowsingId: 1 }
|
"3rdPartyStorage^https://example.net",
|
||||||
|
true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
Assert.ok(
|
||||||
|
!PermissionTestUtils.getPermissionObject(
|
||||||
|
"https://example.com",
|
||||||
|
"3rdPartyFrameStorage^https://example.net",
|
||||||
|
true
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
[
|
// Unrelated entries should still exist.
|
||||||
principalRegular,
|
Assert.equal(
|
||||||
principalRegularSub,
|
PermissionTestUtils.getPermissionObject(
|
||||||
principalPrivateBrowsing,
|
"https://example.com",
|
||||||
principalPrivateBrowsingSub,
|
"cookie",
|
||||||
principalPrivateBrowsingUnrelated,
|
true
|
||||||
].forEach(principal => {
|
).capability,
|
||||||
Services.perms.addFromPrincipal(
|
|
||||||
principal,
|
|
||||||
"geo",
|
|
||||||
Services.perms.ALLOW_ACTION
|
Services.perms.ALLOW_ACTION
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
info("Clear only private browsing mode permissions for example.net");
|
|
||||||
await new Promise(aResolve => {
|
|
||||||
Services.clearData.deleteDataFromSite(
|
|
||||||
"example.net",
|
|
||||||
{ privateBrowsingId: 1 },
|
|
||||||
true,
|
|
||||||
Ci.nsIClearDataService.CLEAR_PERMISSIONS,
|
|
||||||
value => {
|
|
||||||
Assert.equal(value, 0);
|
|
||||||
aResolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
info(
|
|
||||||
"Test that only the private browsing permissions for 'example.net' have been cleared."
|
|
||||||
);
|
|
||||||
[principalPrivateBrowsing, principalPrivateBrowsingSub].forEach(principal => {
|
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
Services.perms.testExactPermissionFromPrincipal(principal, "geo"),
|
PermissionTestUtils.getPermissionObject("http://example.com", "geo", true)
|
||||||
Services.perms.UNKNOWN_ACTION,
|
.capability,
|
||||||
"Permission has been removed for " + principal.origin
|
Services.perms.ALLOW_ACTION
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
[
|
|
||||||
principalRegular,
|
|
||||||
principalRegularSub,
|
|
||||||
principalPrivateBrowsingUnrelated,
|
|
||||||
].forEach(principal => {
|
|
||||||
Assert.equal(
|
|
||||||
Services.perms.testExactPermissionFromPrincipal(principal, "geo"),
|
|
||||||
Services.perms.ALLOW_ACTION,
|
|
||||||
"Permission still exists for " + principal.origin
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
Services.perms.removeAll();
|
Services.perms.removeAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function removeByHost() {
|
add_task(async function test_host_permissions() {
|
||||||
addTestPermissions();
|
addTestPermissions();
|
||||||
|
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// The following tests ensure we properly clear (partitioned/unpartitioned)
|
// The following tests ensure we properly clear (partitioned/unpartitioned)
|
||||||
// localStorage and indexedDB when using deleteDataFromSite,
|
// localStorage and indexedDB when using deleteDataFromBaseDomain,
|
||||||
// deleteDataFromHost and deleteDataFromPrincipal.
|
// deleteDataFromHost and deleteDataFromPrincipal.
|
||||||
|
|
||||||
// Skip localStorage tests when using legacy localStorage. The legacy
|
// Skip localStorage tests when using legacy localStorage. The legacy
|
||||||
@@ -137,9 +137,8 @@ async function runTestBaseDomain(storageType) {
|
|||||||
|
|
||||||
// Clear entries of example.net including partitions.
|
// Clear entries of example.net including partitions.
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.net",
|
"example.net",
|
||||||
{},
|
|
||||||
false,
|
false,
|
||||||
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
||||||
aResolve
|
aResolve
|
||||||
|
|||||||
@@ -100,9 +100,8 @@ add_task(async function test_baseDomain() {
|
|||||||
|
|
||||||
// Clear hsts data of example.net including partitions.
|
// Clear hsts data of example.net including partitions.
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.net",
|
"example.net",
|
||||||
{},
|
|
||||||
false,
|
false,
|
||||||
Ci.nsIClearDataService.CLEAR_HSTS,
|
Ci.nsIClearDataService.CLEAR_HSTS,
|
||||||
aResolve
|
aResolve
|
||||||
@@ -146,9 +145,8 @@ add_task(async function test_baseDomain() {
|
|||||||
|
|
||||||
// Clear security settings of example.net including partitions.
|
// Clear security settings of example.net including partitions.
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.net",
|
"example.net",
|
||||||
{},
|
|
||||||
false,
|
false,
|
||||||
Ci.nsIClearDataService.CLEAR_CLIENT_AUTH_REMEMBER_SERVICE,
|
Ci.nsIClearDataService.CLEAR_CLIENT_AUTH_REMEMBER_SERVICE,
|
||||||
aResolve
|
aResolve
|
||||||
|
|||||||
@@ -8,116 +8,112 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test that only the cookie permission gets removed.
|
// Test that only the cookie permission gets removed.
|
||||||
add_task(
|
add_task(async function test_removing_shutdown_exception_permission() {
|
||||||
async function test_removing_shutdown_exception_permission_only_clears_cookie_permissions() {
|
let uri = Services.io.newURI("https://example.net");
|
||||||
let uri = Services.io.newURI("https://example.net");
|
let principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||||
let principal = Services.scriptSecurityManager.createContentPrincipal(
|
uri,
|
||||||
uri,
|
{}
|
||||||
{}
|
);
|
||||||
|
|
||||||
|
// add "cookie" (== clear on shutdown exception) permission
|
||||||
|
Services.perms.addFromPrincipal(
|
||||||
|
principal,
|
||||||
|
"cookie",
|
||||||
|
Services.perms.ALLOW_ACTION
|
||||||
|
);
|
||||||
|
|
||||||
|
// add a different permission
|
||||||
|
Services.perms.addFromPrincipal(
|
||||||
|
principal,
|
||||||
|
"notcookie",
|
||||||
|
Services.perms.ALLOW_ACTION
|
||||||
|
);
|
||||||
|
|
||||||
|
await new Promise(aResolve => {
|
||||||
|
Services.clearData.deleteData(
|
||||||
|
Ci.nsIClearDataService.CLEAR_SHUTDOWN_EXCEPTIONS,
|
||||||
|
value => {
|
||||||
|
Assert.equal(value, 0);
|
||||||
|
aResolve();
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// add "cookie" (== clear on shutdown exception) permission
|
// ensure "cookie" permission was cleared and other stays
|
||||||
Services.perms.addFromPrincipal(
|
Assert.equal(
|
||||||
principal,
|
Services.perms.testExactPermissionFromPrincipal(principal, "cookie"),
|
||||||
"cookie",
|
Services.perms.UNKNOWN_ACTION,
|
||||||
Services.perms.ALLOW_ACTION
|
"the cookie permission has been removed"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.perms.testExactPermissionFromPrincipal(principal, "notcookie"),
|
||||||
|
Services.perms.ALLOW_ACTION,
|
||||||
|
"the other permission has not been removed"
|
||||||
|
);
|
||||||
|
|
||||||
|
// reset permission manager
|
||||||
|
await new Promise(aResolve => {
|
||||||
|
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
|
||||||
|
aResolve()
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// add a different permission
|
Assert.equal(Services.perms.all.length, 0, "check all removed");
|
||||||
Services.perms.addFromPrincipal(
|
});
|
||||||
principal,
|
|
||||||
"notcookie",
|
|
||||||
Services.perms.ALLOW_ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
await new Promise(aResolve => {
|
|
||||||
Services.clearData.deleteData(
|
|
||||||
Ci.nsIClearDataService.CLEAR_SHUTDOWN_EXCEPTIONS,
|
|
||||||
value => {
|
|
||||||
Assert.equal(value, 0);
|
|
||||||
aResolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// ensure "cookie" permission was cleared and other stays
|
|
||||||
Assert.equal(
|
|
||||||
Services.perms.testExactPermissionFromPrincipal(principal, "cookie"),
|
|
||||||
Services.perms.UNKNOWN_ACTION,
|
|
||||||
"the cookie permission has been removed"
|
|
||||||
);
|
|
||||||
Assert.equal(
|
|
||||||
Services.perms.testExactPermissionFromPrincipal(principal, "notcookie"),
|
|
||||||
Services.perms.ALLOW_ACTION,
|
|
||||||
"the other permission has not been removed"
|
|
||||||
);
|
|
||||||
|
|
||||||
// reset permission manager
|
|
||||||
await new Promise(aResolve => {
|
|
||||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
|
|
||||||
aResolve()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
Assert.equal(Services.perms.all.length, 0, "check all removed");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// test that the CLEAR_SITE_PERMISSIONS flag does not remove the "cookie" permission
|
// test that the CLEAR_SITE_PERMISSIONS flag does not remove the "cookie" permission
|
||||||
add_task(
|
add_task(async function test_removing_shutdown_exception_permission() {
|
||||||
async function test_removing_site_permissions_skips_cookie_permissions() {
|
let uri = Services.io.newURI("https://example.net");
|
||||||
let uri = Services.io.newURI("https://example.net");
|
let principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||||
let principal = Services.scriptSecurityManager.createContentPrincipal(
|
uri,
|
||||||
uri,
|
{}
|
||||||
{}
|
);
|
||||||
|
|
||||||
|
// add "cookie" (== clear on shutdown exception) permission
|
||||||
|
Services.perms.addFromPrincipal(
|
||||||
|
principal,
|
||||||
|
"cookie",
|
||||||
|
Services.perms.ALLOW_ACTION
|
||||||
|
);
|
||||||
|
|
||||||
|
// add a different permission
|
||||||
|
Services.perms.addFromPrincipal(
|
||||||
|
principal,
|
||||||
|
"notcookie",
|
||||||
|
Services.perms.ALLOW_ACTION
|
||||||
|
);
|
||||||
|
|
||||||
|
await new Promise(aResolve => {
|
||||||
|
Services.clearData.deleteData(
|
||||||
|
Ci.nsIClearDataService.CLEAR_SITE_PERMISSIONS,
|
||||||
|
value => {
|
||||||
|
Assert.equal(value, 0);
|
||||||
|
aResolve();
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// add "cookie" (== clear on shutdown exception) permission
|
// ensure "notcookie" permission was cleared and "cookie" stays
|
||||||
Services.perms.addFromPrincipal(
|
Assert.equal(
|
||||||
principal,
|
Services.perms.testExactPermissionFromPrincipal(principal, "cookie"),
|
||||||
"cookie",
|
Services.perms.ALLOW_ACTION,
|
||||||
Services.perms.ALLOW_ACTION
|
"the cookie permission has not been removed"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.perms.testExactPermissionFromPrincipal(principal, "notcookie"),
|
||||||
|
Services.perms.UNKNOWN_ACTION,
|
||||||
|
"the other permission has been removed"
|
||||||
|
);
|
||||||
|
|
||||||
|
// reset permission manager
|
||||||
|
await new Promise(aResolve => {
|
||||||
|
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
|
||||||
|
aResolve()
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// add a different permission
|
Assert.equal(Services.perms.all.length, 0, "check all removed");
|
||||||
Services.perms.addFromPrincipal(
|
});
|
||||||
principal,
|
|
||||||
"notcookie",
|
|
||||||
Services.perms.ALLOW_ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
await new Promise(aResolve => {
|
|
||||||
Services.clearData.deleteData(
|
|
||||||
Ci.nsIClearDataService.CLEAR_SITE_PERMISSIONS,
|
|
||||||
value => {
|
|
||||||
Assert.equal(value, 0);
|
|
||||||
aResolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// ensure "notcookie" permission was cleared and "cookie" stays
|
|
||||||
Assert.equal(
|
|
||||||
Services.perms.testExactPermissionFromPrincipal(principal, "cookie"),
|
|
||||||
Services.perms.ALLOW_ACTION,
|
|
||||||
"the cookie permission has not been removed"
|
|
||||||
);
|
|
||||||
Assert.equal(
|
|
||||||
Services.perms.testExactPermissionFromPrincipal(principal, "notcookie"),
|
|
||||||
Services.perms.UNKNOWN_ACTION,
|
|
||||||
"the other permission has been removed"
|
|
||||||
);
|
|
||||||
|
|
||||||
// reset permission manager
|
|
||||||
await new Promise(aResolve => {
|
|
||||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
|
|
||||||
aResolve()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
Assert.equal(Services.perms.all.length, 0, "check all removed");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// test that the CLEAR_PERMISSIONS flag still removes both
|
// test that the CLEAR_PERMISSIONS flag still removes both
|
||||||
add_task(async function test_removing_all_permissions() {
|
add_task(async function test_removing_all_permissions() {
|
||||||
@@ -172,73 +168,3 @@ add_task(async function test_removing_all_permissions() {
|
|||||||
|
|
||||||
Assert.equal(Services.perms.all.length, 0, "check all removed");
|
Assert.equal(Services.perms.all.length, 0, "check all removed");
|
||||||
});
|
});
|
||||||
|
|
||||||
// We can't test the pattern clearing here here since "cookie" permissions are
|
|
||||||
// not isolated by OA in the permission manager. See `kStripOAPermissions` in
|
|
||||||
// `PermissionManager.cpp`.
|
|
||||||
add_task(async function test_removeBySiteAndOAPattern() {
|
|
||||||
let principalRegular = Services.scriptSecurityManager.createContentPrincipal(
|
|
||||||
Services.io.newURI("https://example.net"),
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
let principalRegularSub =
|
|
||||||
Services.scriptSecurityManager.createContentPrincipal(
|
|
||||||
Services.io.newURI("https://sub.example.net"),
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
let principalUnrelated =
|
|
||||||
Services.scriptSecurityManager.createContentPrincipal(
|
|
||||||
Services.io.newURI("https://example.org"),
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
|
|
||||||
info("add 'cookie' (== clear on shutdown exception) permissions");
|
|
||||||
[principalRegular, principalRegularSub, principalUnrelated].forEach(
|
|
||||||
principal => {
|
|
||||||
Services.perms.addFromPrincipal(
|
|
||||||
principal,
|
|
||||||
"cookie",
|
|
||||||
Services.perms.ALLOW_ACTION
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
info("Clear all permissions for schemeless site example.net");
|
|
||||||
await new Promise(aResolve => {
|
|
||||||
Services.clearData.deleteDataFromSite(
|
|
||||||
"example.net",
|
|
||||||
{},
|
|
||||||
true,
|
|
||||||
Ci.nsIClearDataService.CLEAR_SHUTDOWN_EXCEPTIONS,
|
|
||||||
value => {
|
|
||||||
Assert.equal(value, 0);
|
|
||||||
aResolve();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
[principalRegular, principalRegularSub].forEach(principal => {
|
|
||||||
Assert.equal(
|
|
||||||
Services.perms.testExactPermissionFromPrincipal(principal, "cookie"),
|
|
||||||
Services.perms.UNKNOWN_ACTION,
|
|
||||||
"cookie permission has been removed for " + principal.origin
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
[principalUnrelated].forEach(principal => {
|
|
||||||
Assert.equal(
|
|
||||||
Services.perms.testExactPermissionFromPrincipal(principal, "cookie"),
|
|
||||||
Services.perms.ALLOW_ACTION,
|
|
||||||
"cookie permission still exists for " + principal.origin
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// reset permission manager
|
|
||||||
await new Promise(aResolve => {
|
|
||||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
|
|
||||||
aResolve()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
Assert.equal(Services.perms.all.length, 0, "check all removed");
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -201,9 +201,8 @@ add_task(async function test_removing_storage_permission_from_base_domainl() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
"example.net",
|
"example.net",
|
||||||
{},
|
|
||||||
true /* user request */,
|
true /* user request */,
|
||||||
Ci.nsIClearDataService.CLEAR_STORAGE_ACCESS,
|
Ci.nsIClearDataService.CLEAR_STORAGE_ACCESS,
|
||||||
value => {
|
value => {
|
||||||
|
|||||||
@@ -164,9 +164,8 @@ add_task(async function test_clearing_by_baseDomain() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
baseDomain,
|
baseDomain,
|
||||||
{},
|
|
||||||
true,
|
true,
|
||||||
Ci.nsIClearDataService.CLEAR_STORAGE_PERMISSIONS,
|
Ci.nsIClearDataService.CLEAR_STORAGE_PERMISSIONS,
|
||||||
value => {
|
value => {
|
||||||
|
|||||||
@@ -267,11 +267,10 @@ add_task(async function test_domain_preference_clearDataService() {
|
|||||||
expected: "OptIn",
|
expected: "OptIn",
|
||||||
});
|
});
|
||||||
|
|
||||||
info("Call ClearDataService.deleteDataFromSite for the domain.");
|
info("Call ClearDataService.deleteDataFromBaseDomain for the domain.");
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
TEST_DOMAIN_B,
|
TEST_DOMAIN_B,
|
||||||
{},
|
|
||||||
true /* user request */,
|
true /* user request */,
|
||||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXCEPTION,
|
||||||
aResolve
|
aResolve
|
||||||
|
|||||||
@@ -268,11 +268,10 @@ add_task(async function testClearDataServiceWithStopExecuteAfterOneAttempt() {
|
|||||||
expected: "OptOut",
|
expected: "OptOut",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Invoke deleteDataFromSite.
|
// Invoke deleteDataFromBaseDomain.
|
||||||
await new Promise(aResolve => {
|
await new Promise(aResolve => {
|
||||||
Services.clearData.deleteDataFromSite(
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
TEST_DOMAIN_A,
|
TEST_DOMAIN_A,
|
||||||
{},
|
|
||||||
true /* user request */,
|
true /* user request */,
|
||||||
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
Ci.nsIClearDataService.CLEAR_COOKIE_BANNER_EXECUTED_RECORD,
|
||||||
aResolve
|
aResolve
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
export var ForgetAboutSite = {
|
export var ForgetAboutSite = {
|
||||||
/**
|
/**
|
||||||
* Clear data associated with a base domain. This includes partitioned storage
|
* Clear data associated with a base domain. This includes partitioned storage
|
||||||
* associated with the domain.
|
* associated with the domain. If a base domain can not be computed from
|
||||||
|
* aDomainOrHost, data will be cleared by host instead.
|
||||||
*
|
*
|
||||||
* @param {string} aDomainOrHost - Domain or host to clear data for. Will be
|
* @param {string} aDomainOrHost - Domain or host to clear data for. Will be
|
||||||
* converted to base domain if needed.
|
* converted to base domain if needed.
|
||||||
@@ -17,16 +18,33 @@ export var ForgetAboutSite = {
|
|||||||
throw new Error("aDomainOrHost can not be empty.");
|
throw new Error("aDomainOrHost can not be empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
let schemelessSite = Services.eTLD.getSchemelessSiteFromHost(aDomainOrHost);
|
let baseDomain;
|
||||||
let errorCount = await new Promise(resolve => {
|
try {
|
||||||
Services.clearData.deleteDataFromSite(
|
baseDomain = Services.eTLD.getBaseDomainFromHost(aDomainOrHost);
|
||||||
schemelessSite,
|
} catch (e) {}
|
||||||
{},
|
|
||||||
true /* user request */,
|
let errorCount;
|
||||||
Ci.nsIClearDataService.CLEAR_FORGET_ABOUT_SITE,
|
if (baseDomain) {
|
||||||
errorCode => resolve(bitCounting(errorCode))
|
errorCount = await new Promise(resolve => {
|
||||||
);
|
Services.clearData.deleteDataFromBaseDomain(
|
||||||
});
|
baseDomain,
|
||||||
|
true /* user request */,
|
||||||
|
Ci.nsIClearDataService.CLEAR_FORGET_ABOUT_SITE,
|
||||||
|
errorCode => resolve(bitCounting(errorCode))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// If we can't get a valid base domain for aDomainOrHost, fall back to
|
||||||
|
// delete by host.
|
||||||
|
errorCount = await new Promise(resolve => {
|
||||||
|
Services.clearData.deleteDataFromHost(
|
||||||
|
aDomainOrHost,
|
||||||
|
true /* user request */,
|
||||||
|
Ci.nsIClearDataService.CLEAR_FORGET_ABOUT_SITE,
|
||||||
|
errorCode => resolve(bitCounting(errorCode))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (errorCount !== 0) {
|
if (errorCount !== 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ interface nsIRFPService : nsISupports
|
|||||||
/**
|
/**
|
||||||
* Clean the fingerprinting randomization key by the given domain.
|
* Clean the fingerprinting randomization key by the given domain.
|
||||||
*/
|
*/
|
||||||
[implicit_jscontext]
|
void cleanRandomKeyByDomain(in ACString aDomain);
|
||||||
void cleanRandomKeyBySite(in ACString aSchemelessSite, in jsval originAttributes);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean the fingerprinting randomization key by the given host and
|
* Clean the fingerprinting randomization key by the given host and
|
||||||
|
|||||||
@@ -1436,26 +1436,51 @@ nsRFPService::CleanRandomKeyByPrincipal(nsIPrincipal* aPrincipal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsRFPService::CleanRandomKeyBySite(
|
nsRFPService::CleanRandomKeyByDomain(const nsACString& aDomain) {
|
||||||
const nsACString& aSchemelessSite,
|
|
||||||
JS::Handle<JS::Value> aOriginAttributesPattern, JSContext* aCx) {
|
|
||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
NS_ENSURE_ARG_POINTER(aCx);
|
|
||||||
|
|
||||||
|
// Get http URI from the domain.
|
||||||
|
nsCOMPtr<nsIURI> httpURI;
|
||||||
|
nsresult rv = NS_NewURI(getter_AddRefs(httpURI), "http://"_ns + aDomain);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
// Use the originAttributes to get the partitionKey.
|
||||||
|
OriginAttributes attrs;
|
||||||
|
attrs.SetPartitionKey(httpURI, false);
|
||||||
|
|
||||||
|
// Create a originAttributesPattern and set the http partitionKey to the
|
||||||
|
// pattern.
|
||||||
OriginAttributesPattern pattern;
|
OriginAttributesPattern pattern;
|
||||||
if (!aOriginAttributesPattern.isObject() ||
|
pattern.mPartitionKey.Reset();
|
||||||
!pattern.Init(aCx, aOriginAttributesPattern)) {
|
pattern.mPartitionKey.Construct(attrs.mPartitionKey);
|
||||||
return NS_ERROR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pattern.mPartitionKeyPattern.WasPassed()) {
|
|
||||||
pattern.mPartitionKeyPattern.Construct();
|
|
||||||
}
|
|
||||||
pattern.mPartitionKeyPattern.Value().mBaseDomain.Construct(
|
|
||||||
NS_ConvertUTF8toUTF16(aSchemelessSite));
|
|
||||||
|
|
||||||
ClearBrowsingSessionKey(pattern);
|
ClearBrowsingSessionKey(pattern);
|
||||||
|
|
||||||
|
// We must also include the cross-site embeds of this principal that end up
|
||||||
|
// re-embedded back into the same principal's top level, otherwise state will
|
||||||
|
// persist for this target
|
||||||
|
attrs.SetPartitionKey(httpURI, true);
|
||||||
|
pattern.mPartitionKey.Reset();
|
||||||
|
pattern.mPartitionKey.Construct(attrs.mPartitionKey);
|
||||||
|
ClearBrowsingSessionKey(pattern);
|
||||||
|
|
||||||
|
// Get https URI from the domain.
|
||||||
|
nsCOMPtr<nsIURI> httpsURI;
|
||||||
|
rv = NS_NewURI(getter_AddRefs(httpsURI), "https://"_ns + aDomain);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
// Use the originAttributes to get the partitionKey and set to the pattern.
|
||||||
|
attrs.SetPartitionKey(httpsURI, false);
|
||||||
|
pattern.mPartitionKey.Reset();
|
||||||
|
pattern.mPartitionKey.Construct(attrs.mPartitionKey);
|
||||||
|
ClearBrowsingSessionKey(pattern);
|
||||||
|
|
||||||
|
// We must also include the cross-site embeds of this principal that end up
|
||||||
|
// re-embedded back into the same principal's top level, otherwise state will
|
||||||
|
// persist for this target
|
||||||
|
attrs.SetPartitionKey(httpsURI, true);
|
||||||
|
pattern.mPartitionKey.Reset();
|
||||||
|
pattern.mPartitionKey.Construct(attrs.mPartitionKey);
|
||||||
|
ClearBrowsingSessionKey(pattern);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user