зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 13 changesets (bug 1469714, bug 1491061) for bustages at src/dom/base/nsDocument.cpp, failures at test_browserGlue_bookmarkshtml.js and browser_startup.js on a CLOSED TREE
Backed out changeset 494e23ba027e (bug 1491061) Backed out changeset 43552fcae4a4 (bug 1491061) Backed out changeset 0fb2ac9ad5ec (bug 1469714) Backed out changeset 4a88ff107478 (bug 1469714) Backed out changeset 158def1e0b8c (bug 1469714) Backed out changeset 61dc8b46e7f6 (bug 1469714) Backed out changeset 453370408672 (bug 1469714) Backed out changeset ff443966e3d9 (bug 1469714) Backed out changeset 88f414c8cecc (bug 1469714) Backed out changeset 36e5c9e69f10 (bug 1469714) Backed out changeset f90b4272f420 (bug 1469714) Backed out changeset 4db771422e75 (bug 1469714) Backed out changeset fe750643da13 (bug 1469714)
This commit is contained in:
Родитель
5f9feb966a
Коммит
78e7d3e5c7
|
@ -1499,6 +1499,13 @@ pref("browser.ping-centre.production.endpoint", "https://tiles.services.mozilla.
|
|||
// Enable GMP support in the addon manager.
|
||||
pref("media.gmp-provider.enabled", true);
|
||||
|
||||
// Enable the new Content Blocking UI only on Nightly.
|
||||
#ifdef NIGHTLY_BUILD
|
||||
pref("browser.contentblocking.ui.enabled", true);
|
||||
#else
|
||||
pref("browser.contentblocking.ui.enabled", false);
|
||||
#endif
|
||||
|
||||
// Define a set of default features for the Content Blocking UI
|
||||
pref("browser.contentblocking.fastblock.ui.enabled", true);
|
||||
pref("browser.contentblocking.fastblock.control-center.ui.enabled", true);
|
||||
|
|
|
@ -25,5 +25,3 @@ SANDBOX_KEYWORD("allow-popups-to-escape-sandbox", allowpopupstoescapesandbox,
|
|||
SANDBOX_PROPAGATES_TO_AUXILIARY_BROWSING_CONTEXTS)
|
||||
SANDBOX_KEYWORD("allow-presentation", allowpresentation,
|
||||
SANDBOXED_PRESENTATION)
|
||||
SANDBOX_KEYWORD("allow-storage-access-by-user-activation",
|
||||
allowstorageaccessbyuseractivatetion, SANDBOXED_STORAGE_ACCESS)
|
||||
|
|
|
@ -117,7 +117,6 @@
|
|||
#include "nsIDOMWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsICookieService.h"
|
||||
|
||||
// for radio group stuff
|
||||
#include "nsIRadioVisitor.h"
|
||||
|
@ -12832,7 +12831,7 @@ nsIDocument::MaybeAllowStorageForOpener()
|
|||
{
|
||||
if (StaticPrefs::network_cookie_cookieBehavior() !=
|
||||
nsICookieService::BEHAVIOR_REJECT_TRACKER ||
|
||||
!AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions()) {
|
||||
!StaticPrefs::browser_contentblocking_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -13530,212 +13529,6 @@ nsIDocument::GetSelection(ErrorResult& aRv)
|
|||
return nsGlobalWindowInner::Cast(window)->GetSelection(aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::dom::Promise>
|
||||
nsIDocument::HasStorageAccess(mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsIGlobalObject* global = GetScopeObject();
|
||||
if (!global) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (NodePrincipal()->GetIsNullPrincipal()) {
|
||||
promise->MaybeResolve(false);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
if (IsTopLevelContentDocument()) {
|
||||
promise->MaybeResolve(true);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> topLevelDoc = GetTopLevelContentDocument();
|
||||
if (!topLevelDoc) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return nullptr;
|
||||
}
|
||||
if (topLevelDoc->NodePrincipal()->Equals(NodePrincipal())) {
|
||||
promise->MaybeResolve(true);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
if (AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions() &&
|
||||
StaticPrefs::network_cookie_cookieBehavior() ==
|
||||
nsICookieService::BEHAVIOR_REJECT_TRACKER) {
|
||||
// If we need to abide by Content Blocking cookie restrictions, ensure to
|
||||
// first do all of our storage access checks. If storage access isn't
|
||||
// disabled in our document, given that we're a third-party, we must either
|
||||
// not be a tracker, or be whitelisted for some reason (e.g. a storage
|
||||
// access permission being granted). In that case, resolve the promise and
|
||||
// say we have obtained storage access.
|
||||
if (!nsContentUtils::StorageDisabledByAntiTracking(this, nullptr)) {
|
||||
// Note, storage might be allowed because the top-level document is on
|
||||
// the content blocking allowlist! In that case, don't provide special
|
||||
// treatment here.
|
||||
bool isOnAllowList = false;
|
||||
if (NS_SUCCEEDED(AntiTrackingCommon::IsOnContentBlockingAllowList(
|
||||
topLevelDoc->GetDocumentURI(), isOnAllowList)) &&
|
||||
!isOnAllowList) {
|
||||
promise->MaybeResolve(true);
|
||||
return promise.forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* inner = GetInnerWindow();
|
||||
nsGlobalWindowOuter* outer = nullptr;
|
||||
if (inner) {
|
||||
outer = nsGlobalWindowOuter::Cast(inner->GetOuterWindow());
|
||||
promise->MaybeResolve(outer->HasStorageAccess());
|
||||
} else {
|
||||
promise->MaybeRejectWithUndefined();
|
||||
}
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::dom::Promise>
|
||||
nsIDocument::RequestStorageAccess(mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsIGlobalObject* global = GetScopeObject();
|
||||
if (!global) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Step 1. If the document already has been granted access, resolve.
|
||||
nsPIDOMWindowInner* inner = GetInnerWindow();
|
||||
nsGlobalWindowOuter* outer = nullptr;
|
||||
if (inner) {
|
||||
outer = nsGlobalWindowOuter::Cast(inner->GetOuterWindow());
|
||||
if (outer->HasStorageAccess()) {
|
||||
promise->MaybeResolveWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2. If the document has a null origin, reject.
|
||||
if (NodePrincipal()->GetIsNullPrincipal()) {
|
||||
promise->MaybeRejectWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
// Only enforce third-party checks when there is a reason to enforce them.
|
||||
if (StaticPrefs::network_cookie_cookieBehavior() !=
|
||||
nsICookieService::BEHAVIOR_ACCEPT) {
|
||||
// Step 3. If the document's frame is the main frame, resolve.
|
||||
if (IsTopLevelContentDocument()) {
|
||||
promise->MaybeResolveWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
// Step 4. If the sub frame's origin is equal to the main frame's, resolve.
|
||||
nsCOMPtr<nsIDocument> topLevelDoc = GetTopLevelContentDocument();
|
||||
if (!topLevelDoc) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return nullptr;
|
||||
}
|
||||
if (topLevelDoc->NodePrincipal()->Equals(NodePrincipal())) {
|
||||
promise->MaybeResolveWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
}
|
||||
|
||||
// Step 5. If the sub frame is not sandboxed, skip to step 7.
|
||||
// Step 6. If the sub frame doesn't have the token
|
||||
// "allow-storage-access-by-user-activation", reject.
|
||||
if (mSandboxFlags & SANDBOXED_STORAGE_ACCESS) {
|
||||
promise->MaybeRejectWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
// Step 7. If the sub frame's parent frame is not the top frame, reject.
|
||||
nsIDocument* parent = GetParentDocument();
|
||||
if (parent && !parent->IsTopLevelContentDocument()) {
|
||||
promise->MaybeRejectWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
// Step 8. If the browser is not processing a user gesture, reject.
|
||||
if (!EventStateManager::IsHandlingUserInput()) {
|
||||
promise->MaybeRejectWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
// Step 9. Check any additional rules that the browser has.
|
||||
// Examples: Whitelists, blacklists, on-device classification,
|
||||
// user settings, anti-clickjacking heuristics, or prompting the
|
||||
// user for explicit permission. Reject if some rule is not fulfilled.
|
||||
|
||||
if (nsContentUtils::IsInPrivateBrowsing(this)) {
|
||||
// If the document is in PB mode, it doesn't have access to its persistent
|
||||
// cookie jar, so reject the promise here.
|
||||
promise->MaybeRejectWithUndefined();
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
bool granted = true;
|
||||
bool isTrackingWindow = false;
|
||||
if (AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions() &&
|
||||
StaticPrefs::network_cookie_cookieBehavior() ==
|
||||
nsICookieService::BEHAVIOR_REJECT_TRACKER) {
|
||||
// Only do something special for third-party tracking content.
|
||||
if (nsContentUtils::StorageDisabledByAntiTracking(this, nullptr)) {
|
||||
// Note: If this has returned true, the top-level document is guaranteed
|
||||
// to not be on the Content Blocking allow list.
|
||||
DebugOnly<bool> isOnAllowList = false;
|
||||
MOZ_ASSERT_IF(NS_SUCCEEDED(AntiTrackingCommon::IsOnContentBlockingAllowList(
|
||||
parent->GetDocumentURI(), isOnAllowList)),
|
||||
!isOnAllowList);
|
||||
|
||||
isTrackingWindow = true;
|
||||
// TODO: prompt for permission
|
||||
}
|
||||
}
|
||||
|
||||
// Step 10. Grant the document access to cookies and store that fact for
|
||||
// the purposes of future calls to hasStorageAccess() and
|
||||
// requestStorageAccess().
|
||||
if (granted && inner) {
|
||||
outer->SetHasStorageAccess(true);
|
||||
if (isTrackingWindow) {
|
||||
nsCOMPtr<nsIURI> uri = GetDocumentURI();
|
||||
if (NS_WARN_IF(!uri)) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return nullptr;
|
||||
}
|
||||
nsAutoString origin;
|
||||
nsresult rv = nsContentUtils::GetUTFOrigin(uri, origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(origin,
|
||||
inner,
|
||||
AntiTrackingCommon::eStorageAccessAPI)
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[promise] (bool) {
|
||||
promise->MaybeResolveWithUndefined();
|
||||
},
|
||||
[promise] (bool) {
|
||||
promise->MaybeRejectWithUndefined();
|
||||
});
|
||||
} else {
|
||||
promise->MaybeResolveWithUndefined();
|
||||
}
|
||||
}
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
void
|
||||
nsIDocument::RecordNavigationTiming(ReadyState aReadyState)
|
||||
{
|
||||
|
|
|
@ -6268,12 +6268,6 @@ nsGlobalWindowInner::GetTopLevelPrincipal()
|
|||
nsIPrincipal*
|
||||
nsGlobalWindowInner::GetTopLevelStorageAreaPrincipal()
|
||||
{
|
||||
if (mDoc && ((mDoc->GetSandboxFlags() & SANDBOXED_STORAGE_ACCESS) != 0 ||
|
||||
nsContentUtils::IsInPrivateBrowsing(mDoc))) {
|
||||
// Storage access is disabled
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsPIDOMWindowOuter* outerWindow = GetParentInternal();
|
||||
if (!outerWindow) {
|
||||
// No outer window available!
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "nsScreen.h"
|
||||
#include "nsHistory.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsIDOMStorageManager.h"
|
||||
#include "nsISecureBrowserUI.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
|
@ -92,7 +91,6 @@
|
|||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/ProcessHangMonitor.h"
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
#include "mozilla/ThrottledEventQueue.h"
|
||||
#include "AudioChannelService.h"
|
||||
#include "nsAboutProtocolUtils.h"
|
||||
|
@ -831,7 +829,6 @@ nsGlobalWindowOuter::nsGlobalWindowOuter()
|
|||
mIsChrome(false),
|
||||
mAllowScriptsToClose(false),
|
||||
mTopLevelOuterContentWindow(false),
|
||||
mHasStorageAccess(false),
|
||||
mSerial(0),
|
||||
#ifdef DEBUG
|
||||
mSetOpenerWindowCalled(false),
|
||||
|
@ -2018,25 +2015,6 @@ nsGlobalWindowOuter::SetNewDocument(nsIDocument* aDocument,
|
|||
ReportLargeAllocStatus();
|
||||
mLargeAllocStatus = LargeAllocStatus::NONE;
|
||||
|
||||
mHasStorageAccess = false;
|
||||
nsIURI* uri = aDocument->GetDocumentURI();
|
||||
if (newInnerWindow) {
|
||||
if (AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions() &&
|
||||
StaticPrefs::network_cookie_cookieBehavior() ==
|
||||
nsICookieService::BEHAVIOR_REJECT_TRACKER &&
|
||||
nsContentUtils::IsThirdPartyWindowOrChannel(newInnerWindow, nullptr,
|
||||
uri) &&
|
||||
nsContentUtils::IsTrackingResourceWindow(newInnerWindow)) {
|
||||
// Grant storage access by default if the first-party storage access
|
||||
// permission has been granted already.
|
||||
// Don't notify in this case, since we would be notifying the user needlessly.
|
||||
mHasStorageAccess =
|
||||
AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(newInnerWindow,
|
||||
uri,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -964,15 +964,6 @@ public:
|
|||
|
||||
bool IsInModalState();
|
||||
|
||||
bool HasStorageAccess() const
|
||||
{
|
||||
return mHasStorageAccess;
|
||||
}
|
||||
void SetHasStorageAccess(bool aHasStorageAccess)
|
||||
{
|
||||
mHasStorageAccess = aHasStorageAccess;
|
||||
}
|
||||
|
||||
// Convenience functions for the many methods that need to scale
|
||||
// from device to CSS pixels or vice versa. Note: if a presentation
|
||||
// context is not available, they will assume a 1:1 ratio.
|
||||
|
@ -1097,9 +1088,6 @@ protected:
|
|||
|
||||
bool mTopLevelOuterContentWindow : 1;
|
||||
|
||||
// whether storage access has been granted to this frame.
|
||||
bool mHasStorageAccess : 1;
|
||||
|
||||
nsCOMPtr<nsIScriptContext> mContext;
|
||||
nsWeakPtr mOpener;
|
||||
nsCOMPtr<nsIControllers> mControllers;
|
||||
|
|
|
@ -1234,11 +1234,6 @@ public:
|
|||
|
||||
mozilla::dom::Selection* GetSelection(mozilla::ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<mozilla::dom::Promise>
|
||||
HasStorageAccess(mozilla::ErrorResult& aRv);
|
||||
already_AddRefed<mozilla::dom::Promise>
|
||||
RequestStorageAccess(mozilla::ErrorResult& aRv);
|
||||
|
||||
/**
|
||||
* Gets the event target to dispatch key events to if there is no focused
|
||||
* content in the document.
|
||||
|
|
|
@ -112,10 +112,5 @@ const unsigned long SANDBOXED_ORIENTATION_LOCK = 0x2000;
|
|||
*/
|
||||
const unsigned long SANDBOXED_PRESENTATION = 0x4000;
|
||||
|
||||
/**
|
||||
* This flag disables access to the first-party storage area by user activation.
|
||||
*/
|
||||
const unsigned long SANDBOXED_STORAGE_ACCESS = 0x8000;
|
||||
|
||||
const unsigned long SANDBOX_ALL_FLAGS = 0xFFFF;
|
||||
const unsigned long SANDBOX_ALL_FLAGS = 0x7FFF;
|
||||
#endif
|
||||
|
|
|
@ -483,14 +483,6 @@ partial interface Document {
|
|||
Selection? getSelection();
|
||||
};
|
||||
|
||||
// https://github.com/whatwg/html/issues/3338
|
||||
partial interface Document {
|
||||
[Pref="dom.storage_access.enabled", Throws]
|
||||
Promise<boolean> hasStorageAccess();
|
||||
[Pref="dom.storage_access.enabled", Throws]
|
||||
Promise<void> requestStorageAccess();
|
||||
};
|
||||
|
||||
// Extension to give chrome JS the ability to determine whether
|
||||
// the user has interacted with the document or not.
|
||||
partial interface Document {
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "jsfriendapi.h"
|
||||
#include "js/LocaleSensitive.h"
|
||||
#include "mozilla/AbstractThread.h"
|
||||
#include "mozilla/AntiTrackingCommon.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
|
@ -2273,7 +2272,7 @@ RuntimeService::PropagateFirstPartyStorageAccessGranted(nsPIDOMWindowInner* aWin
|
|||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(StaticPrefs::network_cookie_cookieBehavior() ==
|
||||
nsICookieService::BEHAVIOR_REJECT_TRACKER &&
|
||||
AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions());
|
||||
StaticPrefs::browser_contentblocking_enabled());
|
||||
|
||||
nsTArray<WorkerPrivate*> workers;
|
||||
GetWorkersForWindow(aWindow, workers);
|
||||
|
@ -2885,7 +2884,7 @@ PropagateFirstPartyStorageAccessGrantedToWorkers(nsPIDOMWindowInner* aWindow)
|
|||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(StaticPrefs::network_cookie_cookieBehavior() ==
|
||||
nsICookieService::BEHAVIOR_REJECT_TRACKER &&
|
||||
AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions());
|
||||
StaticPrefs::browser_contentblocking_enabled());
|
||||
|
||||
RuntimeService* runtime = RuntimeService::GetService();
|
||||
if (runtime) {
|
||||
|
|
|
@ -1478,27 +1478,6 @@ VARCACHE_PREF(
|
|||
bool, true
|
||||
)
|
||||
|
||||
// Whether Content Blocking UI has been enabled.
|
||||
// Enable the new Content Blocking UI only on Nightly.
|
||||
#ifdef NIGHTLY_BUILD
|
||||
# define PREF_VALUE true
|
||||
#else
|
||||
# define PREF_VALUE false
|
||||
#endif
|
||||
VARCACHE_PREF(
|
||||
"browser.contentblocking.ui.enabled",
|
||||
browser_contentblocking_ui_enabled,
|
||||
bool, PREF_VALUE
|
||||
)
|
||||
#undef PREF_VALUE
|
||||
|
||||
// Whether Content Blocking Third-Party Cookies UI has been enabled.
|
||||
VARCACHE_PREF(
|
||||
"browser.contentblocking.rejecttrackers.ui.enabled",
|
||||
browser_contentblocking_rejecttrackers_ui_enabled,
|
||||
bool, false
|
||||
)
|
||||
|
||||
// Whether FastBlock has been enabled.
|
||||
VARCACHE_PREF(
|
||||
"browser.fastblock.enabled",
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "prtime.h"
|
||||
|
||||
#define ANTITRACKING_PERM_KEY "3rdPartyStorage"
|
||||
|
@ -65,13 +64,6 @@ GetParentPrincipalAndTrackingOrigin(nsGlobalWindowInner* a3rdPartyTrackingWindow
|
|||
{
|
||||
MOZ_ASSERT(nsContentUtils::IsTrackingResourceWindow(a3rdPartyTrackingWindow));
|
||||
|
||||
nsIDocument* doc = a3rdPartyTrackingWindow->GetDocument();
|
||||
// Make sure storage access isn't disabled
|
||||
if (doc && ((doc->GetSandboxFlags() & SANDBOXED_STORAGE_ACCESS) != 0 ||
|
||||
nsContentUtils::IsInPrivateBrowsing(doc))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now we need the principal and the origin of the parent window.
|
||||
nsCOMPtr<nsIPrincipal> topLevelStoragePrincipal =
|
||||
a3rdPartyTrackingWindow->GetTopLevelStorageAreaPrincipal();
|
||||
|
@ -203,7 +195,7 @@ ReportBlockingToConsole(nsPIDOMWindowOuter* aWindow, nsIHttpChannel* aChannel,
|
|||
aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN ||
|
||||
aRejectedReason == nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT);
|
||||
|
||||
if (!AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions()) {
|
||||
if (!StaticPrefs::browser_contentblocking_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -323,14 +315,6 @@ ReportUnblockingConsole(nsPIDOMWindowInner* aWindow,
|
|||
|
||||
} // anonymous
|
||||
|
||||
/* static */ bool
|
||||
AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions()
|
||||
{
|
||||
return StaticPrefs::browser_contentblocking_enabled() &&
|
||||
StaticPrefs::browser_contentblocking_ui_enabled() &&
|
||||
StaticPrefs::browser_contentblocking_rejecttrackers_ui_enabled();
|
||||
}
|
||||
|
||||
/* static */ RefPtr<AntiTrackingCommon::StorageAccessGrantPromise>
|
||||
AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigin,
|
||||
nsPIDOMWindowInner* aParentWindow,
|
||||
|
@ -348,7 +332,7 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigi
|
|||
return StorageAccessGrantPromise::CreateAndResolve(true, __func__);
|
||||
}
|
||||
|
||||
if (!ShouldHonorContentBlockingCookieRestrictions()) {
|
||||
if (!StaticPrefs::browser_contentblocking_enabled()) {
|
||||
LOG(("The content blocking pref has been disabled, bail out early"));
|
||||
return StorageAccessGrantPromise::CreateAndResolve(true, __func__);
|
||||
}
|
||||
|
@ -548,7 +532,7 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* aWin
|
|||
|
||||
if (behavior == nsICookieService::BEHAVIOR_REJECT_FOREIGN) {
|
||||
// Now, we have to also honour the Content Blocking pref.
|
||||
if (!ShouldHonorContentBlockingCookieRestrictions()) {
|
||||
if (!StaticPrefs::browser_contentblocking_enabled()) {
|
||||
LOG(("The content blocking pref has been disabled, bail out early by "
|
||||
"by pretending our window isn't a third-party window"));
|
||||
return true;
|
||||
|
@ -574,7 +558,7 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* aWin
|
|||
MOZ_ASSERT(behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER);
|
||||
|
||||
// Now, we have to also honour the Content Blocking pref.
|
||||
if (!ShouldHonorContentBlockingCookieRestrictions()) {
|
||||
if (!StaticPrefs::browser_contentblocking_enabled()) {
|
||||
LOG(("The content blocking pref has been disabled, bail out early by "
|
||||
"by pretending our window isn't a tracking window"));
|
||||
return true;
|
||||
|
@ -755,7 +739,7 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel
|
|||
|
||||
if (behavior == nsICookieService::BEHAVIOR_REJECT_FOREIGN) {
|
||||
// Now, we have to also honour the Content Blocking pref.
|
||||
if (!ShouldHonorContentBlockingCookieRestrictions()) {
|
||||
if (!StaticPrefs::browser_contentblocking_enabled()) {
|
||||
LOG(("The content blocking pref has been disabled, bail out early by "
|
||||
"by pretending our window isn't a third-party window"));
|
||||
return true;
|
||||
|
@ -781,7 +765,7 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel
|
|||
MOZ_ASSERT(behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER);
|
||||
|
||||
// Now, we have to also honour the Content Blocking pref.
|
||||
if (!ShouldHonorContentBlockingCookieRestrictions()) {
|
||||
if (!StaticPrefs::browser_contentblocking_enabled()) {
|
||||
LOG(("The content blocking pref has been disabled, bail out early by "
|
||||
"pretending our channel isn't a tracking channel"));
|
||||
return true;
|
||||
|
@ -903,7 +887,7 @@ AntiTrackingCommon::MaybeIsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner*
|
|||
}
|
||||
|
||||
// Now, we have to also honour the Content Blocking pref.
|
||||
if (!ShouldHonorContentBlockingCookieRestrictions()) {
|
||||
if (!StaticPrefs::browser_contentblocking_enabled()) {
|
||||
LOG(("The content blocking pref has been disabled, bail out early"));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,19 +29,6 @@ public:
|
|||
typedef std::function<void(const bool&)>
|
||||
FirstPartyStorageAccessGrantedForOriginResolver;
|
||||
|
||||
// This function should be called to determine whether we need to honour the
|
||||
// content blocking cookie restrictions. It takes into account whether
|
||||
// content blocking itself is active, and also whether the UI for it is being
|
||||
// shown to the user. The reason we make this depend on whether the UI is being
|
||||
// shown is to avoid confusing scenarios where the user's privacy choices will
|
||||
// be overridden by the invisible prefs that cannot be controlled in the UI.
|
||||
//
|
||||
// Please note that this function doesn't perform any special checks on _what_
|
||||
// kind of restrictions the consumer is expected to follow. The consumer is
|
||||
// still responsible to perform further checks to determine that.
|
||||
static bool
|
||||
ShouldHonorContentBlockingCookieRestrictions();
|
||||
|
||||
// This method returns true if the URI has first party storage access when
|
||||
// loaded inside the passed 3rd party context tracking resource window.
|
||||
// If the window is first party context, please use
|
||||
|
|
|
@ -30,14 +30,6 @@ support-files = server.sjs
|
|||
[browser_imageCache5.js]
|
||||
[browser_imageCache6.js]
|
||||
[browser_imageCache7.js]
|
||||
[browser_imageCache8.js]
|
||||
[browser_imageCache9.js]
|
||||
[browser_imageCache10.js]
|
||||
[browser_imageCache11.js]
|
||||
[browser_imageCache12.js]
|
||||
[browser_imageCache13.js]
|
||||
[browser_imageCache14.js]
|
||||
[browser_imageCache15.js]
|
||||
[browser_onBeforeRequestNotificationForTrackingResources.js]
|
||||
[browser_onModifyRequestNotificationForTrackingResources.js]
|
||||
[browser_permissionInNormalWindows.js]
|
||||
|
@ -46,6 +38,3 @@ support-files = server.sjs
|
|||
support-files = subResources.sjs
|
||||
[browser_script.js]
|
||||
support-files = tracker.js
|
||||
[browser_storageAccessPrivateWindow.js]
|
||||
[browser_storageAccessSandboxed.js]
|
||||
[browser_storageAccessWithHeuristics.js]
|
||||
|
|
|
@ -6,8 +6,6 @@ add_task(async function() {
|
|||
await SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["browser.contentblocking.enabled", true],
|
||||
["browser.contentblocking.ui.enabled", true],
|
||||
["browser.contentblocking.rejecttrackers.ui.enabled", true],
|
||||
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
|
|
|
@ -43,91 +43,3 @@ AntiTracking.runTest("Set/Get Cookies",
|
|||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
AntiTracking.runTest("Cookies and Storage Access API",
|
||||
// Blocking callback
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
is(document.cookie, "", "No cookies for me");
|
||||
document.cookie = "name=value";
|
||||
is(document.cookie, "", "No cookies for me");
|
||||
|
||||
await fetch("server.sjs").then(r => r.text()).then(text => {
|
||||
is(text, "cookie-not-present", "We should not have cookies");
|
||||
});
|
||||
// Let's do it twice.
|
||||
await fetch("server.sjs").then(r => r.text()).then(text => {
|
||||
is(text, "cookie-not-present", "We should not have cookies");
|
||||
});
|
||||
|
||||
is(document.cookie, "", "Still no cookies for me");
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
is(document.cookie, "", "No cookies for me");
|
||||
document.cookie = "name=value";
|
||||
is(document.cookie, "name=value", "I have the cookies!");
|
||||
},
|
||||
|
||||
// Non blocking callback
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
is(document.cookie, "", "No cookies for me");
|
||||
|
||||
await fetch("server.sjs").then(r => r.text()).then(text => {
|
||||
is(text, "cookie-not-present", "We should not have cookies");
|
||||
});
|
||||
|
||||
document.cookie = "name=value";
|
||||
ok(document.cookie.includes("name=value"), "Some cookies for me");
|
||||
ok(document.cookie.includes("foopy=1"), "Some cookies for me");
|
||||
|
||||
await fetch("server.sjs").then(r => r.text()).then(text => {
|
||||
is(text, "cookie-present", "We should have cookies");
|
||||
});
|
||||
|
||||
ok(document.cookie.length, "Some Cookies for me");
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
ok(document.cookie.length, "Still some Cookies for me");
|
||||
ok(document.cookie.includes("name=value"), "Some cookies for me");
|
||||
ok(document.cookie.includes("foopy=1"), "Some cookies for me");
|
||||
},
|
||||
|
||||
// Cleanup callback
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
null, false, false);
|
||||
|
|
|
@ -41,20 +41,16 @@ AntiTracking.runTest("IndexedDB in workers",
|
|||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
await new Promise(resolve => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
async _ => {
|
||||
function nonBlockCode() {
|
||||
indexedDB.open("test", "1");
|
||||
postMessage(true);
|
||||
postMessage(false);
|
||||
}
|
||||
|
||||
let blob = new Blob([nonBlockCode.toString() + "; nonBlockCode();"]);
|
||||
|
@ -66,13 +62,9 @@ AntiTracking.runTest("IndexedDB in workers",
|
|||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
await new Promise(resolve => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
|
@ -81,200 +73,3 @@ AntiTracking.runTest("IndexedDB in workers",
|
|||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
AntiTracking.runTest("IndexedDB and Storage Access API",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
try {
|
||||
indexedDB.open("test", "1");
|
||||
ok(false, "IDB should be blocked");
|
||||
} catch (e) {
|
||||
ok(true, "IDB should be blocked");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
indexedDB.open("test", "1");
|
||||
ok(true, "IDB should be allowed");
|
||||
},
|
||||
// non-blocking callback
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
indexedDB.open("test", "1");
|
||||
ok(true, "IDB should be allowed");
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
indexedDB.open("test", "1");
|
||||
ok(true, "IDB should be allowed");
|
||||
},
|
||||
// Cleanup callback
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
null, false, false);
|
||||
|
||||
AntiTracking.runTest("IndexedDB in workers and Storage Access API",
|
||||
async _ => {
|
||||
function blockCode() {
|
||||
try {
|
||||
indexedDB.open("test", "1");
|
||||
postMessage(false);
|
||||
} catch (e) {
|
||||
postMessage(e.name == "SecurityError");
|
||||
}
|
||||
}
|
||||
function nonBlockCode() {
|
||||
indexedDB.open("test", "1");
|
||||
postMessage(true);
|
||||
}
|
||||
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
let blob = new Blob([blockCode.toString() + "; blockCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
let blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
blob = new Blob([nonBlockCode.toString() + "; nonBlockCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
async _ => {
|
||||
function nonBlockCode() {
|
||||
indexedDB.open("test", "1");
|
||||
postMessage(true);
|
||||
}
|
||||
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
let blob = new Blob([nonBlockCode.toString() + "; nonBlockCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
let blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
|
||||
worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
null, false, false);
|
||||
|
|
|
@ -38,13 +38,9 @@ AntiTracking.runTest("BroadcastChannel in workers",
|
|||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
await new Promise(resolve => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
|
@ -63,13 +59,9 @@ AntiTracking.runTest("BroadcastChannel in workers",
|
|||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
await new Promise(resolve => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
|
@ -78,194 +70,3 @@ AntiTracking.runTest("BroadcastChannel in workers",
|
|||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
AntiTracking.runTest("BroadcastChannel and Storage Access API",
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
try {
|
||||
new BroadcastChannel("hello");
|
||||
ok(false, "BroadcastChannel cannot be used!");
|
||||
} catch (e) {
|
||||
ok(true, "BroadcastChannel cannot be used!");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
new BroadcastChannel("hello");
|
||||
ok(true, "BroadcastChannel can be used");
|
||||
},
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
new BroadcastChannel("hello");
|
||||
ok(true, "BroadcastChanneli can be used");
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
new BroadcastChannel("hello");
|
||||
ok(true, "BroadcastChannel can be used");
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
null, false, false);
|
||||
|
||||
AntiTracking.runTest("BroadcastChannel in workers and Storage Access API",
|
||||
async _ => {
|
||||
function blockingCode() {
|
||||
try {
|
||||
new BroadcastChannel("hello");
|
||||
postMessage(false);
|
||||
} catch (e) {
|
||||
postMessage(e.name == "SecurityError");
|
||||
}
|
||||
}
|
||||
function nonBlockingCode() {
|
||||
new BroadcastChannel("hello");
|
||||
postMessage(true);
|
||||
}
|
||||
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
let blob = new Blob([blockingCode.toString() + "; blockingCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
let blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
blob = new Blob([nonBlockingCode.toString() + "; nonBlockingCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
async _ => {
|
||||
function nonBlockingCode() {
|
||||
new BroadcastChannel("hello");
|
||||
postMessage(true);
|
||||
}
|
||||
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
let blob = new Blob([nonBlockingCode.toString() + "; nonBlockingCode();"]);
|
||||
ok(blob, "Blob has been created");
|
||||
|
||||
let blobURL = URL.createObjectURL(blob);
|
||||
ok(blobURL, "Blob URL has been created");
|
||||
|
||||
let worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
|
||||
worker = new Worker(blobURL);
|
||||
ok(worker, "Worker has been created");
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
worker.onmessage = function(e) {
|
||||
if (e) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
null, false, false);
|
||||
|
|
|
@ -36,122 +36,3 @@ AntiTracking.runTest("sessionStorage",
|
|||
true,
|
||||
true,
|
||||
false);
|
||||
|
||||
AntiTracking.runTest("localStorage and Storage Access API",
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
try {
|
||||
localStorage.foo = 42;
|
||||
ok(false, "LocalStorage cannot be used!");
|
||||
} catch (e) {
|
||||
ok(true, "LocalStorage cannot be used!");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
localStorage.foo = 42;
|
||||
ok(true, "LocalStorage is allowed");
|
||||
},
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
localStorage.foo = 42;
|
||||
ok(true, "LocalStorage is allowed");
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
localStorage.foo = 42;
|
||||
ok(true, "LocalStorage is allowed");
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
null, false, false);
|
||||
|
||||
AntiTracking.runTest("sessionStorage and Storage Access API",
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
sessionStorage.foo = 42;
|
||||
ok(true, "SessionStorage is always allowed");
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
sessionStorage.foo = 42;
|
||||
ok(true, "SessionStorage is allowed after calling the storage access API too");
|
||||
},
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
sessionStorage.foo = 42;
|
||||
ok(true, "SessionStorage is always allowed");
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
sessionStorage.foo = 42;
|
||||
ok(true, "SessionStorage is allowed after calling the storage access API too");
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
null, false, false);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
requestLongerTimeout(2);
|
||||
|
||||
AntiTracking.runTest("SharedWorkers",
|
||||
async _ => {
|
||||
try {
|
||||
|
@ -22,7 +20,7 @@ AntiTracking.runTest("SharedWorkers",
|
|||
|
||||
AntiTracking.runTest("ServiceWorkers",
|
||||
async _ => {
|
||||
await navigator.serviceWorker.register("empty.js").then(
|
||||
await navigator.serviceWorker.register("empty.js", { scope: "/" }).then(
|
||||
_ => { ok(false, "ServiceWorker cannot be used!"); },
|
||||
_ => { ok(true, "ServiceWorker cannot be used!"); });
|
||||
},
|
||||
|
@ -52,208 +50,3 @@ AntiTracking.runTest("DOM Cache",
|
|||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
AntiTracking.runTest("SharedWorkers and Storage Access API",
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
try {
|
||||
new SharedWorker("a.js", "foo");
|
||||
ok(false, "SharedWorker cannot be used!");
|
||||
} catch (e) {
|
||||
ok(true, "SharedWorker cannot be used!");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
new SharedWorker("a.js", "foo");
|
||||
ok(true, "SharedWorker is allowed");
|
||||
},
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
new SharedWorker("a.js", "foo");
|
||||
ok(true, "SharedWorker is allowed");
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
new SharedWorker("a.js", "foo");
|
||||
ok(true, "SharedWorker is allowed");
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
null, false, false);
|
||||
|
||||
AntiTracking.runTest("ServiceWorkers and Storage Access API",
|
||||
async _ => {
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true],
|
||||
]});
|
||||
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
await navigator.serviceWorker.register("empty.js").then(
|
||||
_ => { ok(false, "ServiceWorker cannot be used!"); },
|
||||
_ => { ok(true, "ServiceWorker cannot be used!"); });
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
await navigator.serviceWorker.register("empty.js").then(
|
||||
reg => { ok(true, "ServiceWorker can be used!"); return reg; },
|
||||
_ => { ok(false, "ServiceWorker cannot be used! " + _); }).then(
|
||||
reg => reg.unregister(),
|
||||
_ => { ok(false, "unregister failed"); });
|
||||
},
|
||||
async _ => {
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true],
|
||||
]});
|
||||
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
await navigator.serviceWorker.register("empty.js").then(
|
||||
reg => { ok(true, "ServiceWorker can be used!"); return reg; },
|
||||
_ => { ok(false, "ServiceWorker cannot be used!"); }).then(
|
||||
reg => reg.unregister(),
|
||||
_ => { ok(false, "unregister failed"); });
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
await navigator.serviceWorker.register("empty.js").then(
|
||||
reg => { ok(true, "ServiceWorker can be used!"); return reg; },
|
||||
_ => { ok(false, "ServiceWorker cannot be used!"); }).then(
|
||||
reg => reg.unregister(),
|
||||
_ => { ok(false, "unregister failed"); });
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
[["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true]],
|
||||
false, false);
|
||||
|
||||
AntiTracking.runTest("DOM Cache and Storage Access API",
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => { ok(false, "DOM Cache cannot be used!"); },
|
||||
_ => { ok(true, "DOM Cache cannot be used!"); });
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => { ok(true, "DOM Cache can be used!"); },
|
||||
_ => { ok(false, "DOM Cache can be used!"); });
|
||||
},
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
await caches.open("wow").then(
|
||||
_ => { ok(true, "DOM Cache can be used!"); },
|
||||
_ => { ok(false, "DOM Cache can be used!"); });
|
||||
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
await p;
|
||||
|
||||
hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now has storage access");
|
||||
|
||||
// For non-tracking windows, calling the API is a no-op
|
||||
await caches.open("wow").then(
|
||||
_ => { ok(true, "DOM Cache can be used!"); },
|
||||
_ => { ok(false, "DOM Cache can be used!"); });
|
||||
},
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
null, false, false);
|
||||
|
|
|
@ -74,8 +74,6 @@ add_task(async function() {
|
|||
// Now set up our prefs
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["browser.contentblocking.enabled", true],
|
||||
["browser.contentblocking.ui.enabled", true],
|
||||
["browser.contentblocking.rejecttrackers.ui.enabled", true],
|
||||
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
|
||||
]});
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = false;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_FOREIGN;
|
||||
let blockingByContentBlocking = false;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + "/";
|
||||
}
|
||||
/* import-globals-from imageCacheWorker.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "imageCacheWorker.js", this);
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_FOREIGN;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = false;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + "/";
|
||||
}
|
||||
/* import-globals-from imageCacheWorker.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "imageCacheWorker.js", this);
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_FOREIGN;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = false;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + "/";
|
||||
}
|
||||
/* import-globals-from imageCacheWorker.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "imageCacheWorker.js", this);
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/* Setting a custom permission for this website */
|
||||
let uriObj = Services.io.newURI(TEST_DOMAIN);
|
||||
Services.perms.add(uriObj, "cookie", Services.perms.ALLOW_ACTION);
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = false;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = false;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + "/";
|
||||
}
|
||||
/* import-globals-from imageCacheWorker.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "imageCacheWorker.js", this);
|
|
@ -1,21 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/* Setting a custom permission for this website */
|
||||
let uriObj = Services.io.newURI(TEST_DOMAIN);
|
||||
Services.perms.add(uriObj, "cookie", Services.perms.ALLOW_ACTION);
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = false;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = false;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + "/";
|
||||
}
|
||||
/* import-globals-from imageCacheWorker.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "imageCacheWorker.js", this);
|
|
@ -1,21 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/* Setting a custom permission for this website */
|
||||
let uriObj = Services.io.newURI(TEST_DOMAIN);
|
||||
Services.perms.add(uriObj, "cookie", Services.perms.ALLOW_ACTION);
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = false;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = false;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + "/";
|
||||
}
|
||||
/* import-globals-from imageCacheWorker.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "imageCacheWorker.js", this);
|
|
@ -2,8 +2,6 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = false;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = false;
|
||||
let blockingByContentBlocking = false;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = false;
|
||||
let blockingByAllowList = true;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = false;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = false;
|
||||
let cookieBehavior = BEHAVIOR_REJECT_FOREIGN;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByAllowList = true;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = false;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let cookieBehavior = BEHAVIOR_REJECT_FOREIGN;
|
||||
let blockingByContentBlocking = false;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/* Setting a custom permission for this website */
|
||||
let uriObj = Services.io.newURI(TEST_DOMAIN);
|
||||
Services.perms.add(uriObj, "cookie", Services.perms.ALLOW_ACTION);
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = false;
|
||||
let blockingByContentBlocking = false;
|
||||
let blockingByAllowList = false;
|
||||
let expectedBlockingNotifications = true;
|
||||
let expectedBlockingNotifications = false;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
|
@ -15,4 +17,3 @@ if (jar) {
|
|||
}
|
||||
/* import-globals-from imageCacheWorker.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "imageCacheWorker.js", this);
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_TRACKER;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = true;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + "/";
|
||||
}
|
||||
/* import-globals-from imageCacheWorker.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "imageCacheWorker.js", this);
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let cookieBehavior = BEHAVIOR_REJECT_FOREIGN;
|
||||
let blockingByContentBlocking = true;
|
||||
let blockingByContentBlockingUI = true;
|
||||
let blockingByContentBlockingRTUI = true;
|
||||
let blockingByAllowList = true;
|
||||
let expectedBlockingNotifications = true;
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + "/";
|
||||
}
|
||||
/* import-globals-from imageCacheWorker.js */
|
||||
Services.scriptloader.loadSubScript(rootDir + "imageCacheWorker.js", this);
|
||||
|
|
@ -53,8 +53,6 @@ add_task(async function() {
|
|||
await SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["browser.contentblocking.enabled", true],
|
||||
["browser.contentblocking.ui.enabled", true],
|
||||
["browser.contentblocking.rejecttrackers.ui.enabled", true],
|
||||
["privacy.trackingprotection.enabled", true],
|
||||
// the test doesn't open a private window, so we don't care about this pref's value
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
|
|
|
@ -48,8 +48,6 @@ add_task(async function() {
|
|||
await SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["browser.contentblocking.enabled", true],
|
||||
["browser.contentblocking.ui.enabled", true],
|
||||
["browser.contentblocking.rejecttrackers.ui.enabled", true],
|
||||
["privacy.trackingprotection.enabled", true],
|
||||
// the test doesn't open a private window, so we don't care about this pref's value
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
|
|
|
@ -6,8 +6,6 @@ add_task(async function() {
|
|||
await SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["browser.contentblocking.enabled", true],
|
||||
["browser.contentblocking.ui.enabled", true],
|
||||
["browser.contentblocking.rejecttrackers.ui.enabled", true],
|
||||
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
AntiTracking.runTest("Storage Access API called in a private window",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
let threw = false;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
ok(!threw, "requestStorageAccess should not throw");
|
||||
threw = false;
|
||||
try {
|
||||
await p;
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw, "requestStorageAccess shouldn't be available");
|
||||
},
|
||||
|
||||
null, // non-blocking callback
|
||||
null, // cleanup function
|
||||
[["dom.storage_access.enabled", true]], // extra prefs
|
||||
false, // no window open test
|
||||
false, // no user-interaction test
|
||||
false, // no blocking notifications
|
||||
true, // run in private window
|
||||
null // iframe sandbox
|
||||
);
|
|
@ -1,168 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
AntiTracking.runTest("Storage Access API called in a sandboxed iframe",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
let threw = false;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
ok(!threw, "requestStorageAccess should not throw");
|
||||
threw = false;
|
||||
try {
|
||||
await p;
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw, "requestStorageAccess shouldn't be available");
|
||||
},
|
||||
|
||||
null, // non-blocking callback
|
||||
null, // cleanup function
|
||||
[["dom.storage_access.enabled", true]], // extra prefs
|
||||
false, // no window open test
|
||||
false, // no user-interaction test
|
||||
false, // no blocking notifications
|
||||
false, // run in normal window
|
||||
"allow-scripts allow-same-origin"
|
||||
);
|
||||
|
||||
AntiTracking.runTest("Storage Access API called in a sandboxed iframe with" +
|
||||
" allow-storage-access-by-user-activation",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
let dwu = SpecialPowers.getDOMWindowUtils(window);
|
||||
let helper = dwu.setHandlingUserInput(true);
|
||||
|
||||
let p;
|
||||
let threw = false;
|
||||
try {
|
||||
p = document.requestStorageAccess();
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
} finally {
|
||||
helper.destruct();
|
||||
}
|
||||
ok(!threw, "requestStorageAccess should not throw");
|
||||
threw = false;
|
||||
try {
|
||||
await p;
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(!threw, "requestStorageAccess should be available");
|
||||
},
|
||||
|
||||
null, // non-blocking callback
|
||||
null, // cleanup function
|
||||
[["dom.storage_access.enabled", true]], // extra prefs
|
||||
false, // no window open test
|
||||
false, // no user-interaction test
|
||||
true, // expect blocking notifications
|
||||
false, // run in normal window
|
||||
"allow-scripts allow-same-origin allow-storage-access-by-user-activation"
|
||||
);
|
||||
|
||||
AntiTracking.runTest("Verify that sandboxed contexts don't get the saved permission",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
try {
|
||||
localStorage.foo = 42;
|
||||
ok(false, "LocalStorage cannot be used!");
|
||||
} catch (e) {
|
||||
ok(true, "LocalStorage cannot be used!");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
},
|
||||
|
||||
null, // non-blocking callback
|
||||
null, // cleanup function
|
||||
[["dom.storage_access.enabled", true]], // extra prefs
|
||||
false, // no window open test
|
||||
false, // no user-interaction test
|
||||
false, // no blocking notifications
|
||||
false, // run in normal window
|
||||
"allow-scripts allow-same-origin"
|
||||
);
|
||||
|
||||
AntiTracking.runTest("Verify that sandboxed contexts with" +
|
||||
" allow-storage-access-by-user-activation get the" +
|
||||
" saved permission",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Has storage access");
|
||||
|
||||
localStorage.foo = 42;
|
||||
ok(true, "LocalStorage can be used!");
|
||||
},
|
||||
|
||||
null, // non-blocking callback
|
||||
null, // cleanup function
|
||||
[["dom.storage_access.enabled", true]], // extra prefs
|
||||
false, // no window open test
|
||||
false, // no user-interaction test
|
||||
false, // no blocking notifications
|
||||
false, // run in normal window
|
||||
"allow-scripts allow-same-origin allow-storage-access-by-user-activation"
|
||||
);
|
||||
|
||||
AntiTracking.runTest("Verify that private browsing contexts don't get the saved permission",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
|
||||
try {
|
||||
localStorage.foo = 42;
|
||||
ok(false, "LocalStorage cannot be used!");
|
||||
} catch (e) {
|
||||
ok(true, "LocalStorage cannot be used!");
|
||||
is(e.name, "SecurityError", "We want a security error message.");
|
||||
}
|
||||
},
|
||||
|
||||
null, // non-blocking callback
|
||||
null, // cleanup function
|
||||
[["dom.storage_access.enabled", true]], // extra prefs
|
||||
false, // no window open test
|
||||
false, // no user-interaction test
|
||||
false, // no blocking notifications
|
||||
true, // run in private window
|
||||
null // iframe sandbox
|
||||
);
|
||||
|
||||
AntiTracking.runTest("Verify that non-sandboxed contexts get the" +
|
||||
" saved permission",
|
||||
// blocking callback
|
||||
async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Has storage access");
|
||||
|
||||
localStorage.foo = 42;
|
||||
ok(true, "LocalStorage can be used!");
|
||||
},
|
||||
|
||||
null, // non-blocking callback
|
||||
// cleanup function
|
||||
async _ => {
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
},
|
||||
[["dom.storage_access.enabled", true]], // extra prefs
|
||||
false, // no window open test
|
||||
false, // no user-interaction test
|
||||
false // no blocking notifications
|
||||
);
|
|
@ -1,198 +0,0 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
add_task(async function() {
|
||||
info("Starting subResources test");
|
||||
|
||||
await SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.storage_access.enabled", true],
|
||||
["browser.contentblocking.enabled", true],
|
||||
["browser.contentblocking.ui.enabled", true],
|
||||
["browser.contentblocking.rejecttrackers.ui.enabled", true],
|
||||
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
["privacy.trackingprotection.annotate_channels", true],
|
||||
]});
|
||||
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
});
|
||||
|
||||
add_task(async function testWindowOpenHeuristic() {
|
||||
info("Starting window.open() heuristic test...");
|
||||
|
||||
info("Creating a new tab");
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
|
||||
gBrowser.selectedTab = tab;
|
||||
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
info("Loading tracking scripts");
|
||||
await ContentTask.spawn(browser, {
|
||||
page: TEST_3RD_PARTY_PAGE_WO,
|
||||
}, async obj => {
|
||||
let msg = {};
|
||||
msg.blockingCallback = (async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
}).toString();
|
||||
|
||||
msg.nonBlockingCallback = (async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now obtained storage access");
|
||||
}).toString();
|
||||
|
||||
info("Checking if storage access is denied");
|
||||
await new content.Promise(resolve => {
|
||||
let ifr = content.document.createElement("iframe");
|
||||
ifr.onload = function() {
|
||||
info("Sending code to the 3rd party content");
|
||||
ifr.contentWindow.postMessage(msg, "*");
|
||||
};
|
||||
|
||||
content.addEventListener("message", function msg(event) {
|
||||
if (event.data.type == "finish") {
|
||||
content.removeEventListener("message", msg);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "ok") {
|
||||
ok(event.data.what, event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "info") {
|
||||
info(event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Unknown message");
|
||||
});
|
||||
|
||||
content.document.body.appendChild(ifr);
|
||||
ifr.src = obj.page;
|
||||
});
|
||||
});
|
||||
|
||||
info("Removing the tab");
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
info("Cleaning up.");
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function testUserInteractionHeuristic() {
|
||||
info("Starting user interaction heuristic test...");
|
||||
|
||||
info("Creating a new tab");
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
|
||||
gBrowser.selectedTab = tab;
|
||||
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
info("Loading tracking scripts");
|
||||
await ContentTask.spawn(browser, {
|
||||
page: TEST_3RD_PARTY_PAGE_UI,
|
||||
popup: TEST_POPUP_PAGE,
|
||||
}, async obj => {
|
||||
let msg = {};
|
||||
msg.blockingCallback = (async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(!hasAccess, "Doesn't yet have storage access");
|
||||
}).toString();
|
||||
|
||||
msg.nonBlockingCallback = (async _ => {
|
||||
let hasAccess = await document.hasStorageAccess();
|
||||
ok(hasAccess, "Now obtained storage access");
|
||||
}).toString();
|
||||
|
||||
info("Checking if storage access is denied");
|
||||
|
||||
let ifr = content.document.createElement("iframe");
|
||||
let loading = new content.Promise(resolve => { ifr.onload = resolve; });
|
||||
content.document.body.appendChild(ifr);
|
||||
ifr.src = obj.page;
|
||||
await loading;
|
||||
|
||||
info("The 3rd party content should not have access to first party storage.");
|
||||
await new content.Promise(resolve => {
|
||||
content.addEventListener("message", function msg(event) {
|
||||
if (event.data.type == "finish") {
|
||||
content.removeEventListener("message", msg);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "ok") {
|
||||
ok(event.data.what, event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "info") {
|
||||
info(event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Unknown message");
|
||||
});
|
||||
ifr.contentWindow.postMessage({ callback: msg.blockingCallback }, "*");
|
||||
});
|
||||
|
||||
let windowClosed = new content.Promise(resolve => {
|
||||
Services.ww.registerNotification(function notification(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed") {
|
||||
Services.ww.unregisterNotification(notification);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
info("Opening a window from the iframe.");
|
||||
ifr.contentWindow.open(obj.popup);
|
||||
|
||||
info("Let's wait for the window to be closed");
|
||||
await windowClosed;
|
||||
|
||||
info("The 3rd party content should have access to first party storage.");
|
||||
await new content.Promise(resolve => {
|
||||
content.addEventListener("message", function msg(event) {
|
||||
if (event.data.type == "finish") {
|
||||
content.removeEventListener("message", msg);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "ok") {
|
||||
ok(event.data.what, event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "info") {
|
||||
info(event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Unknown message");
|
||||
});
|
||||
ifr.contentWindow.postMessage({ callback: msg.nonBlockingCallback }, "*");
|
||||
});
|
||||
});
|
||||
|
||||
info("Removing the tab");
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
info("Cleaning up.");
|
||||
await new Promise(resolve => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
|
||||
});
|
||||
});
|
||||
|
|
@ -6,8 +6,6 @@ add_task(async function() {
|
|||
await SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["browser.contentblocking.enabled", true],
|
||||
["browser.contentblocking.ui.enabled", true],
|
||||
["browser.contentblocking.rejecttrackers.ui.enabled", true],
|
||||
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
|
|
|
@ -20,25 +20,22 @@ var gFeatures = undefined;
|
|||
|
||||
let {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
requestLongerTimeout(3);
|
||||
requestLongerTimeout(2);
|
||||
|
||||
this.AntiTracking = {
|
||||
runTest(name, callbackTracking, callbackNonTracking, cleanupFunction, extraPrefs,
|
||||
windowOpenTest = true, userInteractionTest = true, expectedBlockingNotifications = true,
|
||||
runInPrivateWindow = false, iframeSandbox = null) {
|
||||
runInPrivateWindow = false) {
|
||||
// Here we want to test that a 3rd party context is simply blocked.
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: false,
|
||||
callback: callbackTracking,
|
||||
extraPrefs,
|
||||
expectedBlockingNotifications,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
|
@ -59,18 +56,6 @@ this.AntiTracking = {
|
|||
} else {
|
||||
options.blockingByContentBlocking = false;
|
||||
}
|
||||
if ("blockingByContentBlockingUI" in callbackNonTracking) {
|
||||
options.blockingByContentBlockingUI =
|
||||
callbackNonTracking.blockingByContentBlockingUI;
|
||||
} else {
|
||||
options.blockingByContentBlockingUI = false;
|
||||
}
|
||||
if ("blockingByContentBlockingRTUI" in callbackNonTracking) {
|
||||
options.blockingByContentBlockingRTUI =
|
||||
callbackNonTracking.blockingByContentBlockingRTUI;
|
||||
} else {
|
||||
options.blockingByContentBlockingRTUI = false;
|
||||
}
|
||||
if ("blockingByAllowList" in callbackNonTracking) {
|
||||
options.blockingByAllowList =
|
||||
callbackNonTracking.blockingByAllowList;
|
||||
|
@ -81,11 +66,9 @@ this.AntiTracking = {
|
|||
|
||||
// Phase 1: Here we want to test that a 3rd party context is not blocked if pref is off.
|
||||
if (runExtraTests) {
|
||||
// There are six ways in which the third-party context may not be blocked:
|
||||
// There are four ways in which the third-party context may not be blocked:
|
||||
// * If the cookieBehavior pref causes it to not be blocked.
|
||||
// * If the contentBlocking pref causes it to not be blocked.
|
||||
// * If the contentBlocking UI pref causes it to not be blocked.
|
||||
// * If the contentBlocking third-party cookies UI pref causes it to not be blocked.
|
||||
// * If both of these prefs cause it to not be blocked.
|
||||
// * If the top-level page is on the content blocking allow list.
|
||||
// All of these cases are tested here.
|
||||
|
@ -93,14 +76,11 @@ this.AntiTracking = {
|
|||
name,
|
||||
cookieBehavior: BEHAVIOR_ACCEPT,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
|
@ -108,44 +88,11 @@ this.AntiTracking = {
|
|||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_FOREIGN,
|
||||
blockingByContentBlocking: false,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_FOREIGN,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: false,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_FOREIGN,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: false,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
|
@ -153,44 +100,11 @@ this.AntiTracking = {
|
|||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
|
||||
blockingByContentBlocking: false,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: false,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: false,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
|
@ -198,44 +112,11 @@ this.AntiTracking = {
|
|||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_FOREIGN,
|
||||
blockingByContentBlocking: false,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: true,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_FOREIGN,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: false,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: true,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_FOREIGN,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: false,
|
||||
allowList: true,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
|
@ -243,44 +124,11 @@ this.AntiTracking = {
|
|||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
|
||||
blockingByContentBlocking: false,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: true,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: false,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: true,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: false,
|
||||
allowList: true,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
|
@ -288,44 +136,11 @@ this.AntiTracking = {
|
|||
name,
|
||||
cookieBehavior: BEHAVIOR_ACCEPT,
|
||||
blockingByContentBlocking: false,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_ACCEPT,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: false,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
this._createTask({
|
||||
name,
|
||||
cookieBehavior: BEHAVIOR_ACCEPT,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: false,
|
||||
allowList: false,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
|
@ -334,14 +149,11 @@ this.AntiTracking = {
|
|||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_FOREIGN,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: true,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
|
@ -349,14 +161,11 @@ this.AntiTracking = {
|
|||
name,
|
||||
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
|
||||
blockingByContentBlocking: true,
|
||||
blockingByContentBlockingUI: true,
|
||||
blockingByContentBlockingRTUI: true,
|
||||
allowList: true,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
} else {
|
||||
|
@ -364,14 +173,11 @@ this.AntiTracking = {
|
|||
name,
|
||||
cookieBehavior: options.cookieBehavior,
|
||||
blockingByContentBlocking: options.blockingByContentBlocking,
|
||||
blockingByContentBlockingUI: options.blockingByContentBlockingUI,
|
||||
blockingByContentBlockingRTUI: options.blockingByContentBlockingRTUI,
|
||||
allowList: options.blockingByAllowList,
|
||||
callback: callbackNonTracking,
|
||||
extraPrefs: [],
|
||||
expectedBlockingNotifications: false,
|
||||
runInPrivateWindow,
|
||||
iframeSandbox,
|
||||
});
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
}
|
||||
|
@ -379,30 +185,23 @@ this.AntiTracking = {
|
|||
// Phase 2: Here we want to test that a third-party context doesn't
|
||||
// get blocked with when the same origin is opened through window.open().
|
||||
if (windowOpenTest) {
|
||||
this._createWindowOpenTask(name, callbackTracking, callbackNonTracking,
|
||||
runInPrivateWindow, iframeSandbox, extraPrefs);
|
||||
this._createWindowOpenTask(name, callbackTracking, callbackNonTracking, runInPrivateWindow, extraPrefs);
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
}
|
||||
|
||||
// Phase 3: Here we want to test that a third-party context doesn't
|
||||
// get blocked with user interaction present
|
||||
if (userInteractionTest) {
|
||||
this._createUserInteractionTask(name, callbackTracking, callbackNonTracking,
|
||||
runInPrivateWindow, iframeSandbox, extraPrefs);
|
||||
this._createUserInteractionTask(name, callbackTracking, callbackNonTracking, runInPrivateWindow, extraPrefs);
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async _setupTest(win, cookieBehavior, blockingByContentBlocking,
|
||||
blockingByContentBlockingUI, blockingByContentBlockingRTUI,
|
||||
extraPrefs) {
|
||||
async _setupTest(win, cookieBehavior, blockingByContentBlocking, extraPrefs) {
|
||||
await SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.storage_access.enabled", true],
|
||||
["browser.contentblocking.enabled", blockingByContentBlocking],
|
||||
["browser.contentblocking.ui.enabled", blockingByContentBlockingUI],
|
||||
["browser.contentblocking.rejecttrackers.ui.enabled", blockingByContentBlockingRTUI],
|
||||
["network.cookie.cookieBehavior", cookieBehavior],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", false],
|
||||
|
@ -421,12 +220,9 @@ this.AntiTracking = {
|
|||
_createTask(options) {
|
||||
add_task(async function() {
|
||||
info("Starting " + (options.cookieBehavior != BEHAVIOR_ACCEPT ? "blocking" : "non-blocking") + " cookieBehavior (" + options.cookieBehavior + ") and " +
|
||||
(options.blockingByContentBlocking ? "blocking" : "non-blocking") + " contentBlocking and " +
|
||||
(options.blockingByContentBlockingUI ? "" : "no") + " contentBlocking UI and " +
|
||||
(options.blockingByContentBlockingRTUI ? "" : "no") + " contentBlocking third-party cookies UI with" +
|
||||
(options.blockingByContentBlocking ? "blocking" : "non-blocking") + " contentBlocking with" +
|
||||
(options.allowList ? "" : "out") + " allow list test " + options.name +
|
||||
" running in a " + (options.runInPrivateWindow ? "private" : "normal") + " window " +
|
||||
" with iframe sandbox set to " + options.iframeSandbox);
|
||||
" running in a " + (options.runInPrivateWindow ? "private" : "normal") + " window");
|
||||
|
||||
let win = window;
|
||||
if (options.runInPrivateWindow) {
|
||||
|
@ -436,8 +232,6 @@ this.AntiTracking = {
|
|||
|
||||
await AntiTracking._setupTest(win, options.cookieBehavior,
|
||||
options.blockingByContentBlocking,
|
||||
options.blockingByContentBlockingUI,
|
||||
options.blockingByContentBlockingRTUI,
|
||||
options.extraPrefs);
|
||||
|
||||
let cookieBlocked = 0;
|
||||
|
@ -468,8 +262,7 @@ this.AntiTracking = {
|
|||
info("Creating a 3rd party content");
|
||||
await ContentTask.spawn(browser,
|
||||
{ page: TEST_3RD_PARTY_PAGE,
|
||||
callback: options.callback.toString(),
|
||||
iframeSandbox: options.iframeSandbox },
|
||||
callback: options.callback.toString() },
|
||||
async function(obj) {
|
||||
await new content.Promise(resolve => {
|
||||
let ifr = content.document.createElement("iframe");
|
||||
|
@ -477,9 +270,6 @@ this.AntiTracking = {
|
|||
info("Sending code to the 3rd party content");
|
||||
ifr.contentWindow.postMessage(obj.callback, "*");
|
||||
};
|
||||
if (typeof obj.iframeSandbox == "string") {
|
||||
ifr.setAttribute("sandbox", obj.iframeSandbox);
|
||||
}
|
||||
|
||||
content.addEventListener("message", function msg(event) {
|
||||
if (event.data.type == "finish") {
|
||||
|
@ -536,8 +326,7 @@ this.AntiTracking = {
|
|||
});
|
||||
},
|
||||
|
||||
_createWindowOpenTask(name, blockingCallback, nonBlockingCallback, runInPrivateWindow,
|
||||
iframeSandbox, extraPrefs) {
|
||||
_createWindowOpenTask(name, blockingCallback, nonBlockingCallback, runInPrivateWindow, extraPrefs) {
|
||||
add_task(async function() {
|
||||
info("Starting window-open test " + name);
|
||||
|
||||
|
@ -547,7 +336,7 @@ this.AntiTracking = {
|
|||
await TestUtils.topicObserved("browser-delayed-startup-finished");
|
||||
}
|
||||
|
||||
await AntiTracking._setupTest(win, BEHAVIOR_REJECT_TRACKER, true, true, true, extraPrefs);
|
||||
await AntiTracking._setupTest(win, BEHAVIOR_REJECT_TRACKER, true, extraPrefs);
|
||||
|
||||
info("Creating a new tab");
|
||||
let tab = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE);
|
||||
|
@ -566,7 +355,6 @@ this.AntiTracking = {
|
|||
{ page: pageURL,
|
||||
blockingCallback: blockingCallback.toString(),
|
||||
nonBlockingCallback: nonBlockingCallback.toString(),
|
||||
iframeSandbox,
|
||||
},
|
||||
async function(obj) {
|
||||
await new content.Promise(resolve => {
|
||||
|
@ -575,9 +363,6 @@ this.AntiTracking = {
|
|||
info("Sending code to the 3rd party content");
|
||||
ifr.contentWindow.postMessage(obj, "*");
|
||||
};
|
||||
if (typeof obj.iframeSandbox == "string") {
|
||||
ifr.setAttribute("sandbox", obj.iframeSandbox);
|
||||
}
|
||||
|
||||
content.addEventListener("message", function msg(event) {
|
||||
if (event.data.type == "finish") {
|
||||
|
@ -613,8 +398,7 @@ this.AntiTracking = {
|
|||
});
|
||||
},
|
||||
|
||||
_createUserInteractionTask(name, blockingCallback, nonBlockingCallback,
|
||||
runInPrivateWindow, iframeSandbox, extraPrefs) {
|
||||
_createUserInteractionTask(name, blockingCallback, nonBlockingCallback, runInPrivateWindow, extraPrefs) {
|
||||
add_task(async function() {
|
||||
info("Starting user-interaction test " + name);
|
||||
|
||||
|
@ -624,7 +408,7 @@ this.AntiTracking = {
|
|||
await TestUtils.topicObserved("browser-delayed-startup-finished");
|
||||
}
|
||||
|
||||
await AntiTracking._setupTest(win, BEHAVIOR_REJECT_TRACKER, true, true, true, extraPrefs);
|
||||
await AntiTracking._setupTest(win, BEHAVIOR_REJECT_TRACKER, true, extraPrefs);
|
||||
|
||||
info("Creating a new tab");
|
||||
let tab = BrowserTestUtils.addTab(win.gBrowser, TEST_TOP_PAGE);
|
||||
|
@ -639,14 +423,10 @@ this.AntiTracking = {
|
|||
popup: TEST_POPUP_PAGE,
|
||||
blockingCallback: blockingCallback.toString(),
|
||||
nonBlockingCallback: nonBlockingCallback.toString(),
|
||||
iframeSandbox,
|
||||
},
|
||||
async function(obj) {
|
||||
let ifr = content.document.createElement("iframe");
|
||||
let loading = new content.Promise(resolve => { ifr.onload = resolve; });
|
||||
if (typeof obj.iframeSandbox == "string") {
|
||||
ifr.setAttribute("sandbox", obj.iframeSandbox);
|
||||
}
|
||||
content.document.body.appendChild(ifr);
|
||||
ifr.src = obj.page;
|
||||
await loading;
|
||||
|
|
|
@ -24,8 +24,6 @@ AntiTracking.runTest("Image cache - should load the image twice.",
|
|||
runExtraTests: false,
|
||||
cookieBehavior,
|
||||
blockingByContentBlocking,
|
||||
blockingByContentBlockingUI,
|
||||
blockingByContentBlockingRTUI,
|
||||
blockingByAllowList,
|
||||
callback: async _ => {
|
||||
// Let's load the image twice here as well.
|
||||
|
|
|
@ -74,8 +74,6 @@ STATIC_ATOMS = [
|
|||
Atom("allowpopupstoescapesandbox", "allow-popups-to-escape-sandbox"),
|
||||
Atom("allowpopups", "allow-popups"),
|
||||
Atom("allowpresentation", "allow-presentation"),
|
||||
Atom("allowstorageaccessbyuseractivatetion",
|
||||
"allow-storage-access-by-user-activation"),
|
||||
Atom("allowsameorigin", "allow-same-origin"),
|
||||
Atom("allowscripts", "allow-scripts"),
|
||||
Atom("allowscriptstoclose", "allowscriptstoclose"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче