Backed out 10 changesets (bug 1599043) for build bustages in nsGlobalWindowOuter.cpp on a CLOSED TREE

Backed out changeset 463b815557e4 (bug 1599043)
Backed out changeset 7c3f0a58cc6c (bug 1599043)
Backed out changeset 1eadd9f5b50e (bug 1599043)
Backed out changeset e4ea0d47136b (bug 1599043)
Backed out changeset 6b97581c33b6 (bug 1599043)
Backed out changeset a68bd2acf5d6 (bug 1599043)
Backed out changeset c8ed9c52508c (bug 1599043)
Backed out changeset aaf83f7806b4 (bug 1599043)
Backed out changeset 0ad30634e416 (bug 1599043)
Backed out changeset 68219c132efc (bug 1599043)
This commit is contained in:
Oana Pop Rus 2019-12-12 17:14:54 +02:00
Родитель 5bbafc894a
Коммит 53f1ba7c69
25 изменённых файлов: 236 добавлений и 684 удалений

Просмотреть файл

@ -65,12 +65,6 @@ async function assertSitesListed(testCase) {
let categoryItem = document.getElementById(
"protections-popup-category-cookies"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
let cookiesView = document.getElementById("protections-popup-cookiesView");
let viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
@ -301,12 +295,6 @@ add_task(async function testCookiesSubViewAllowed() {
let categoryItem = document.getElementById(
"protections-popup-category-cookies"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
let cookiesView = document.getElementById("protections-popup-cookiesView");
let viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
@ -404,12 +392,6 @@ add_task(async function testCookiesSubViewAllowedHeuristic() {
let categoryItem = document.getElementById(
"protections-popup-category-cookies"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
let cookiesView = document.getElementById("protections-popup-cookiesView");
let viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");
@ -474,12 +456,6 @@ add_task(async function testCookiesSubViewBlockedDoublyNested() {
let categoryItem = document.getElementById(
"protections-popup-category-cookies"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
let cookiesView = document.getElementById("protections-popup-cookiesView");
let viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");

Просмотреть файл

@ -128,24 +128,7 @@ async function testSubview(hasException) {
let categoryItem = document.getElementById(
"protections-popup-category-cryptominers"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
/* eslint-disable mozilla/no-arbitrary-setTimeout */
// We have to wait until the ContentBlockingLog gets updated in the content.
// Unfortunately, we need to use the setTimeout here since we don't have an
// easy to know whether the log is updated in the content. This should be
// removed after the log been removed in the content (Bug 1599046).
await new Promise(resolve => {
setTimeout(resolve, 500);
});
/* eslint-enable mozilla/no-arbitrary-setTimeout */
let subview = document.getElementById("protections-popup-cryptominersView");
let viewShown = BrowserTestUtils.waitForEvent(subview, "ViewShown");
categoryItem.click();

Просмотреть файл

@ -199,24 +199,7 @@ async function testSubview(hasException) {
let categoryItem = document.getElementById(
"protections-popup-category-fingerprinters"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
/* eslint-disable mozilla/no-arbitrary-setTimeout */
// We have to wait until the ContentBlockingLog gets updated in the content.
// Unfortunately, we need to use the setTimeout here since we don't have an
// easy to know whether the log is updated in the content. This should be
// removed after the log been removed in the content (Bug 1599046).
await new Promise(resolve => {
setTimeout(resolve, 500);
});
/* eslint-enable mozilla/no-arbitrary-setTimeout */
let subview = document.getElementById("protections-popup-fingerprintersView");
let viewShown = BrowserTestUtils.waitForEvent(subview, "ViewShown");
categoryItem.click();

Просмотреть файл

@ -71,12 +71,6 @@ add_task(async function testOpenPreferencesFromTrackersSubview() {
let categoryItem = document.getElementById(
"protections-popup-category-tracking-protection"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
let trackersView = document.getElementById("protections-popup-trackersView");
let viewShown = BrowserTestUtils.waitForEvent(trackersView, "ViewShown");
@ -123,12 +117,6 @@ add_task(async function testOpenPreferencesFromCookiesSubview() {
let categoryItem = document.getElementById(
"protections-popup-category-cookies"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
let cookiesView = document.getElementById("protections-popup-cookiesView");
let viewShown = BrowserTestUtils.waitForEvent(cookiesView, "ViewShown");

Просмотреть файл

@ -128,28 +128,11 @@ async function testSubview(hasException) {
let categoryItem = document.getElementById(
"protections-popup-category-socialblock"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "STP category item is visible");
ok(
categoryItem.classList.contains("blocked"),
"STP category item is blocked"
);
/* eslint-disable mozilla/no-arbitrary-setTimeout */
// We have to wait until the ContentBlockingLog gets updated in the content.
// Unfortunately, we need to use the setTimeout here since we don't have an
// easy to know whether the log is updated in the content. This should be
// removed after the log been removed in the content (Bug 1599046).
await new Promise(resolve => {
setTimeout(resolve, 500);
});
/* eslint-enable mozilla/no-arbitrary-setTimeout */
let subview = document.getElementById("protections-popup-socialblockView");
let viewShown = BrowserTestUtils.waitForEvent(subview, "ViewShown");
categoryItem.click();

Просмотреть файл

@ -35,12 +35,6 @@ async function assertSitesListed(blocked) {
let categoryItem = document.getElementById(
"protections-popup-category-tracking-protection"
);
// Explicitly waiting for the category item becoming visible.
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(categoryItem);
});
ok(BrowserTestUtils.is_visible(categoryItem), "TP category item is visible");
let trackersView = document.getElementById("protections-popup-trackersView");
let viewShown = BrowserTestUtils.waitForEvent(trackersView, "ViewShown");

Просмотреть файл

@ -117,95 +117,6 @@ static void ReportOriginSingleHash(OriginMetricID aId,
nsCString(aOrigin));
}
Maybe<uint32_t> ContentBlockingLog::RecordLogParent(
const nsACString& aOrigin, uint32_t aType, bool aBlocked,
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason,
const nsTArray<nsCString>& aTrackingFullHashes) {
MOZ_ASSERT(XRE_IsParentProcess());
uint32_t events = GetContentBlockingEventsInLog();
bool blockedValue = aBlocked;
bool unblocked = false;
switch (aType) {
case nsIWebProgressListener::STATE_COOKIES_LOADED:
MOZ_ASSERT(!aBlocked,
"We don't expected to see blocked STATE_COOKIES_LOADED");
MOZ_FALLTHROUGH;
case nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER:
MOZ_ASSERT(
!aBlocked,
"We don't expected to see blocked STATE_COOKIES_LOADED_TRACKER");
MOZ_FALLTHROUGH;
case nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER:
MOZ_ASSERT(!aBlocked,
"We don't expected to see blocked "
"STATE_COOKIES_LOADED_SOCIALTRACKER");
// Note that the logic in these branches are the logical negation of the
// logic in other branches, since the Document API we have is phrased
// in "loaded" terms as opposed to "blocked" terms.
blockedValue = !aBlocked;
MOZ_FALLTHROUGH;
case nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT:
case nsIWebProgressListener::STATE_LOADED_LEVEL_1_TRACKING_CONTENT:
case nsIWebProgressListener::STATE_LOADED_LEVEL_2_TRACKING_CONTENT:
case nsIWebProgressListener::STATE_BLOCKED_FINGERPRINTING_CONTENT:
case nsIWebProgressListener::STATE_LOADED_FINGERPRINTING_CONTENT:
case nsIWebProgressListener::STATE_BLOCKED_CRYPTOMINING_CONTENT:
case nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT:
case nsIWebProgressListener::STATE_BLOCKED_SOCIALTRACKING_CONTENT:
case nsIWebProgressListener::STATE_LOADED_SOCIALTRACKING_CONTENT:
case nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION:
case nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL:
case nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN:
RecordLogInternal(aOrigin, aType, blockedValue);
break;
case nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER:
case nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER:
RecordLogInternal(aOrigin, aType, blockedValue, aReason,
aTrackingFullHashes);
break;
default:
// Ignore nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
break;
}
if (!aBlocked) {
unblocked = (events & aType) != 0;
}
const uint32_t oldEvents = events;
if (blockedValue) {
events |= aType;
} else if (unblocked) {
events &= ~aType;
}
if (events == oldEvents
#ifdef ANDROID
// GeckoView always needs to notify about blocked trackers,
// since the GeckoView API always needs to report the URI and
// type of any blocked tracker. We use a platform-dependent code
// path here because reporting this notification on desktop
// platforms isn't necessary and doing so can have a big
// performance cost.
&& aType != nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT
#endif
) {
// Avoid dispatching repeated notifications when nothing has
// changed
return Nothing();
}
return Some(events);
}
void ContentBlockingLog::ReportLog(nsIPrincipal* aFirstPartyPrincipal) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aFirstPartyPrincipal);

Просмотреть файл

@ -82,19 +82,90 @@ class ContentBlockingLog final {
ContentBlockingLog() = default;
~ContentBlockingLog() = default;
// Record the log in the parent process. This should be called only in the
// parent process and will replace the RecordLog below after we remove the
// ContentBlockingLog from content processes.
Maybe<uint32_t> RecordLogParent(
const nsACString& aOrigin, uint32_t aType, bool aBlocked,
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason,
const nsTArray<nsCString>& aTrackingFullHashes);
void RecordLog(
const nsACString& aOrigin, uint32_t aType, bool aBlocked,
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason,
const nsTArray<nsCString>& aTrackingFullHashes) {
RecordLogInternal(aOrigin, aType, aBlocked, aReason, aTrackingFullHashes);
DebugOnly<bool> isCookiesBlockedTracker =
aType == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
aType == nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER;
MOZ_ASSERT_IF(aBlocked, aReason.isNothing());
MOZ_ASSERT_IF(!isCookiesBlockedTracker, aReason.isNothing());
MOZ_ASSERT_IF(isCookiesBlockedTracker && !aBlocked, aReason.isSome());
if (aOrigin.IsVoid()) {
return;
}
auto index = mLog.IndexOf(aOrigin, 0, Comparator());
if (index != OriginDataTable::NoIndex) {
OriginEntry& entry = mLog[index];
if (!entry.mData) {
return;
}
if (RecordLogEntryInCustomField(aType, entry, aBlocked)) {
return;
}
if (!entry.mData->mLogs.IsEmpty()) {
auto& last = entry.mData->mLogs.LastElement();
if (last.mType == aType && last.mBlocked == aBlocked) {
++last.mRepeatCount;
// Don't record recorded events. This helps compress our log.
// We don't care about if the the reason is the same, just keep the
// first one.
// Note: {aReason, aTrackingFullHashes} are not compared here and we
// simply keep the first for the reason, and merge hashes to make sure
// they can be correctly recorded.
for (const auto& hash : aTrackingFullHashes) {
if (!last.mTrackingFullHashes.Contains(hash)) {
last.mTrackingFullHashes.AppendElement(hash);
}
}
return;
}
}
if (entry.mData->mLogs.Length() ==
std::max(1u,
StaticPrefs::browser_contentblocking_originlog_length())) {
// Cap the size at the maximum length adjustable by the pref
entry.mData->mLogs.RemoveElementAt(0);
}
entry.mData->mLogs.AppendElement(
LogEntry{aType, 1u, aBlocked, aReason,
nsTArray<nsCString>(aTrackingFullHashes)});
return;
}
// The entry has not been found.
OriginEntry* entry = mLog.AppendElement();
if (NS_WARN_IF(!entry || !entry->mData)) {
return;
}
entry->mOrigin = aOrigin;
if (aType ==
nsIWebProgressListener::STATE_LOADED_LEVEL_1_TRACKING_CONTENT) {
entry->mData->mHasLevel1TrackingContentLoaded = aBlocked;
} else if (aType ==
nsIWebProgressListener::STATE_LOADED_LEVEL_2_TRACKING_CONTENT) {
entry->mData->mHasLevel2TrackingContentLoaded = aBlocked;
} else if (aType == nsIWebProgressListener::STATE_COOKIES_LOADED) {
MOZ_ASSERT(entry->mData->mHasCookiesLoaded.isNothing());
entry->mData->mHasCookiesLoaded.emplace(aBlocked);
} else if (aType == nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER) {
MOZ_ASSERT(entry->mData->mHasTrackerCookiesLoaded.isNothing());
entry->mData->mHasTrackerCookiesLoaded.emplace(aBlocked);
} else if (aType ==
nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER) {
MOZ_ASSERT(entry->mData->mHasSocialTrackerCookiesLoaded.isNothing());
entry->mData->mHasSocialTrackerCookiesLoaded.emplace(aBlocked);
} else {
entry->mData->mLogs.AppendElement(
LogEntry{aType, 1u, aBlocked, aReason,
nsTArray<nsCString>(aTrackingFullHashes)});
}
}
void ReportOrigins();
@ -196,136 +267,7 @@ class ContentBlockingLog final {
}
}
uint32_t GetContentBlockingEventsInLog() {
uint32_t events = 0;
// We iterate the whole log to produce the overview of blocked events.
for (const OriginEntry& entry : mLog) {
if (!entry.mData) {
continue;
}
if (entry.mData->mHasLevel1TrackingContentLoaded) {
events |= nsIWebProgressListener::STATE_LOADED_LEVEL_1_TRACKING_CONTENT;
}
if (entry.mData->mHasLevel2TrackingContentLoaded) {
events |= nsIWebProgressListener::STATE_LOADED_LEVEL_2_TRACKING_CONTENT;
}
if (entry.mData->mHasCookiesLoaded.isSome() &&
entry.mData->mHasCookiesLoaded.value()) {
events |= nsIWebProgressListener::STATE_COOKIES_LOADED;
}
if (entry.mData->mHasTrackerCookiesLoaded.isSome() &&
entry.mData->mHasTrackerCookiesLoaded.value()) {
events |= nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER;
}
if (entry.mData->mHasSocialTrackerCookiesLoaded.isSome() &&
entry.mData->mHasSocialTrackerCookiesLoaded.value()) {
events |= nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER;
}
for (const auto& item : entry.mData->mLogs) {
if (item.mBlocked) {
events |= item.mType;
}
}
}
return events;
}
private:
void RecordLogInternal(
const nsACString& aOrigin, uint32_t aType, bool aBlocked,
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason =
Nothing(),
const nsTArray<nsCString>& aTrackingFullHashes = nsTArray<nsCString>()) {
DebugOnly<bool> isCookiesBlockedTracker =
aType == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
aType == nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER;
MOZ_ASSERT_IF(aBlocked, aReason.isNothing());
MOZ_ASSERT_IF(!isCookiesBlockedTracker, aReason.isNothing());
MOZ_ASSERT_IF(isCookiesBlockedTracker && !aBlocked, aReason.isSome());
if (aOrigin.IsVoid()) {
return;
}
auto index = mLog.IndexOf(aOrigin, 0, Comparator());
if (index != OriginDataTable::NoIndex) {
OriginEntry& entry = mLog[index];
if (!entry.mData) {
return;
}
if (RecordLogEntryInCustomField(aType, entry, aBlocked)) {
return;
}
if (!entry.mData->mLogs.IsEmpty()) {
auto& last = entry.mData->mLogs.LastElement();
if (last.mType == aType && last.mBlocked == aBlocked) {
++last.mRepeatCount;
// Don't record recorded events. This helps compress our log.
// We don't care about if the the reason is the same, just keep the
// first one.
// Note: {aReason, aTrackingFullHashes} are not compared here and we
// simply keep the first for the reason, and merge hashes to make sure
// they can be correctly recorded.
for (const auto& hash : aTrackingFullHashes) {
if (!last.mTrackingFullHashes.Contains(hash)) {
last.mTrackingFullHashes.AppendElement(hash);
}
}
return;
}
}
if (entry.mData->mLogs.Length() ==
std::max(1u,
StaticPrefs::browser_contentblocking_originlog_length())) {
// Cap the size at the maximum length adjustable by the pref
entry.mData->mLogs.RemoveElementAt(0);
}
entry.mData->mLogs.AppendElement(
LogEntry{aType, 1u, aBlocked, aReason,
nsTArray<nsCString>(aTrackingFullHashes)});
return;
}
// The entry has not been found.
OriginEntry* entry = mLog.AppendElement();
if (NS_WARN_IF(!entry || !entry->mData)) {
return;
}
entry->mOrigin = aOrigin;
if (aType ==
nsIWebProgressListener::STATE_LOADED_LEVEL_1_TRACKING_CONTENT) {
entry->mData->mHasLevel1TrackingContentLoaded = aBlocked;
} else if (aType ==
nsIWebProgressListener::STATE_LOADED_LEVEL_2_TRACKING_CONTENT) {
entry->mData->mHasLevel2TrackingContentLoaded = aBlocked;
} else if (aType == nsIWebProgressListener::STATE_COOKIES_LOADED) {
MOZ_ASSERT(entry->mData->mHasCookiesLoaded.isNothing());
entry->mData->mHasCookiesLoaded.emplace(aBlocked);
} else if (aType == nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER) {
MOZ_ASSERT(entry->mData->mHasTrackerCookiesLoaded.isNothing());
entry->mData->mHasTrackerCookiesLoaded.emplace(aBlocked);
} else if (aType ==
nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER) {
MOZ_ASSERT(entry->mData->mHasSocialTrackerCookiesLoaded.isNothing());
entry->mData->mHasSocialTrackerCookiesLoaded.emplace(aBlocked);
} else {
entry->mData->mLogs.AppendElement(
LogEntry{aType, 1u, aBlocked, aReason,
nsTArray<nsCString>(aTrackingFullHashes)});
}
}
bool RecordLogEntryInCustomField(uint32_t aType, OriginEntry& aEntry,
bool aBlocked) {
if (aType ==

Просмотреть файл

@ -5529,6 +5529,31 @@ void nsGlobalWindowOuter::NotifyContentBlockingEvent(
} else {
// Ignore nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
}
const uint32_t oldEvent = event;
if (blockedValue) {
event |= aEvent;
} else if (unblocked) {
event &= ~aEvent;
}
if (event == oldEvent
#ifdef ANDROID
// GeckoView always needs to notify about blocked trackers,
// since the GeckoView API always needs to report the URI and
// type of any blocked tracker. We use a platform-dependent code
// path here because reporting this notification on desktop
// platforms isn't necessary and doing so can have a big
// performance cost.
&& aEvent != nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT
#endif
) {
// Avoid dispatching repeated notifications when nothing has
// changed
return;
}
nsDocShell::Cast(docShell)->nsDocLoader::OnContentBlockingEvent(channel,
event);
});
nsresult rv;
if (StaticPrefs::dom_testing_sync_content_blocking_notifications()) {

Просмотреть файл

@ -3833,11 +3833,18 @@ NS_IMETHODIMP BrowserChild::OnSecurityChange(nsIWebProgress* aWebProgress,
NS_IMETHODIMP BrowserChild::OnContentBlockingEvent(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
uint32_t aEvent) {
// The OnContentBlockingEvent only happenes in the parent process. It should
// not be seen in the content process.
MOZ_DIAGNOSTIC_ASSERT(
false, "OnContentBlockingEvent should not be seen in content process.");
return NS_ERROR_NOT_IMPLEMENTED;
if (!IPCOpen() || !mShouldSendWebProgressEventsToParent) {
return NS_OK;
}
Maybe<WebProgressData> webProgressData;
RequestData requestData;
nsresult rv = PrepareProgressListenerData(aWebProgress, aRequest,
webProgressData, requestData);
NS_ENSURE_SUCCESS(rv, rv);
Unused << SendOnContentBlockingEvent(webProgressData, requestData, aEvent);
return NS_OK;
}
NS_IMETHODIMP BrowserChild::OnProgressChange64(nsIWebProgress* aWebProgress,
@ -4001,25 +4008,6 @@ BrowserChild::DoesWindowSupportProtectedMedia() {
}
#endif
void BrowserChild::NotifyContentBlockingEvent(
uint32_t aEvent, nsIChannel* aChannel, bool aBlocked, nsIURI* aHintURI,
const nsTArray<nsCString>& aTrackingFullHashes,
const Maybe<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>&
aReason) {
if (!IPCOpen()) {
return;
}
Maybe<WebProgressData> webProgressData;
RequestData requestData;
nsresult rv = PrepareProgressListenerData(nullptr, aChannel, webProgressData,
requestData);
NS_ENSURE_SUCCESS_VOID(rv);
Unused << SendNotifyContentBlockingEvent(
aEvent, requestData, aBlocked, aHintURI, aTrackingFullHashes, aReason);
}
BrowserChildMessageManager::BrowserChildMessageManager(
BrowserChild* aBrowserChild)
: ContentFrameMessageManager(new nsFrameMessageManager(aBrowserChild)),

Просмотреть файл

@ -685,11 +685,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
DoesWindowSupportProtectedMedia();
#endif
void NotifyContentBlockingEvent(
uint32_t aEvent, nsIChannel* aChannel, bool aBlocked, nsIURI* aHintURI,
const nsTArray<nsCString>& aTrackingFullHashes,
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason);
protected:
virtual ~BrowserChild();

Просмотреть файл

@ -2668,6 +2668,29 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnSecurityChange(
return IPC_OK();
}
mozilla::ipc::IPCResult BrowserParent::RecvOnContentBlockingEvent(
const Maybe<WebProgressData>& aWebProgressData,
const RequestData& aRequestData, const uint32_t& aEvent) {
nsCOMPtr<nsIBrowser> browser;
nsCOMPtr<nsIWebProgress> manager;
nsCOMPtr<nsIWebProgressListener> managerAsListener;
if (!GetWebProgressListener(getter_AddRefs(browser), getter_AddRefs(manager),
getter_AddRefs(managerAsListener))) {
return IPC_OK();
}
nsCOMPtr<nsIWebProgress> webProgress;
nsCOMPtr<nsIRequest> request;
ReconstructWebProgressAndRequest(manager, aWebProgressData, aRequestData,
getter_AddRefs(webProgress),
getter_AddRefs(request));
Unused << managerAsListener->OnContentBlockingEvent(webProgress, request,
aEvent);
return IPC_OK();
}
mozilla::ipc::IPCResult BrowserParent::RecvNavigationFinished() {
nsCOMPtr<nsIBrowser> browser =
mFrameElement ? mFrameElement->AsBrowser() : nullptr;
@ -2679,35 +2702,6 @@ mozilla::ipc::IPCResult BrowserParent::RecvNavigationFinished() {
return IPC_OK();
}
mozilla::ipc::IPCResult BrowserParent::RecvNotifyContentBlockingEvent(
const uint32_t& aEvent, const RequestData& aRequestData,
const bool aBlocked, nsIURI* aHintURI,
nsTArray<nsCString>&& aTrackingFullHashes,
const Maybe<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>&
aReason) {
MOZ_ASSERT(aRequestData.elapsedLoadTimeMS().isNothing());
RefPtr<BrowsingContext> bc = GetBrowsingContext();
if (!bc || bc->IsDiscarded()) {
return IPC_OK();
}
// Get the top-level browsing context.
bc = bc->Top();
RefPtr<dom::WindowGlobalParent> wgp =
bc->Canonical()->GetCurrentWindowGlobal();
nsCOMPtr<nsIRequest> request = MakeAndAddRef<RemoteWebProgressRequest>(
aRequestData.requestURI(), aRequestData.originalRequestURI(),
aRequestData.matchedList(), aRequestData.elapsedLoadTimeMS());
wgp->NotifyContentBlockingEvent(aEvent, request, aBlocked, aHintURI,
aTrackingFullHashes, aReason);
return IPC_OK();
}
bool BrowserParent::GetWebProgressListener(
nsIBrowser** aOutBrowser, nsIWebProgress** aOutManager,
nsIWebProgressListener** aOutListener) {

Просмотреть файл

@ -316,12 +316,9 @@ class BrowserParent final : public PBrowserParent,
const RequestData& aRequestData, const uint32_t aState,
const Maybe<WebProgressSecurityChangeData>& aSecurityChangeData);
mozilla::ipc::IPCResult RecvNotifyContentBlockingEvent(
const uint32_t& aEvent, const RequestData& aRequestData,
const bool aBlocked, nsIURI* aHintURI,
nsTArray<nsCString>&& aTrackingFullHashes,
const Maybe<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>&
aReason);
mozilla::ipc::IPCResult RecvOnContentBlockingEvent(
const Maybe<WebProgressData>& aWebProgressData,
const RequestData& aRequestData, const uint32_t& aEvent);
mozilla::ipc::IPCResult RecvNavigationFinished();

Просмотреть файл

@ -30,7 +30,6 @@ include PPrintingTypes;
include PTabContext;
include PBackgroundSharedTypes;
include "mozilla/AntiTrackingIPCUtils.h";
include "mozilla/GfxMessageUtils.h";
include "mozilla/layers/LayersMessageUtils.h";
include "mozilla/ipc/TransportSecurityInfoUtils.h";
@ -98,7 +97,6 @@ using mozilla::ScrollFlags from "mozilla/PresShellForwards.h";
using struct InputFormData from "mozilla/dom/SessionStoreMessageUtils.h";
using struct CollectedInputDataValue from "mozilla/dom/SessionStoreMessageUtils.h";
using refcounted class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
using mozilla::AntiTrackingCommon::StorageAccessGrantedReason from "mozilla/AntiTrackingCommon.h";
namespace mozilla {
namespace dom {
@ -623,10 +621,8 @@ parent:
RequestData aRequestData, uint32_t aState,
WebProgressSecurityChangeData? aSecurityChangeData);
async NotifyContentBlockingEvent(uint32_t aEvent, RequestData aRequestData,
bool aBlocked, nsIURI aHintURI,
nsCString[] aTrackingFullHashes,
StorageAccessGrantedReason? aReason);
async OnContentBlockingEvent(WebProgressData? aWebProgressData,
RequestData aRequestData, uint32_t aEvent);
async NavigationFinished();

Просмотреть файл

@ -13,7 +13,6 @@
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/BrowserHost.h"
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/dom/RemoteWebProgress.h"
#include "mozilla/dom/WindowGlobalActorsBinding.h"
#include "mozilla/dom/WindowGlobalChild.h"
#include "mozilla/dom/ChromeUtils.h"
@ -31,7 +30,6 @@
#include "nsQueryObject.h"
#include "nsFrameLoaderOwner.h"
#include "nsSerializationHelper.h"
#include "nsIBrowser.h"
#include "nsITransportSecurityInfo.h"
#include "nsISharePicker.h"
@ -293,64 +291,6 @@ const nsAString& WindowGlobalParent::GetRemoteType() {
return VoidString();
}
void WindowGlobalParent::NotifyContentBlockingEvent(
uint32_t aEvent, nsIRequest* aRequest, bool aBlocked, nsIURI* aURIHint,
const nsTArray<nsCString>& aTrackingFullHashes,
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aURIHint);
DebugOnly<bool> isCookiesBlockedTracker =
aEvent == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
aEvent == nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER;
MOZ_ASSERT_IF(aBlocked, aReason.isNothing());
MOZ_ASSERT_IF(!isCookiesBlockedTracker, aReason.isNothing());
MOZ_ASSERT_IF(isCookiesBlockedTracker && !aBlocked, aReason.isSome());
// Return early if this WindowGlobalParent is in process.
if (IsInProcess()) {
return;
}
nsAutoCString origin;
nsContentUtils::GetASCIIOrigin(aURIHint, origin);
Maybe<uint32_t> event = GetContentBlockingLog()->RecordLogParent(
origin, aEvent, aBlocked, aReason, aTrackingFullHashes);
// Notify the OnContentBlockingEvent if necessary.
if (event) {
// Get the browser parent from the manager directly since the content
// blocking event could happen in the early stage of loading, i.e.
// accessing cookies for the http header. At this stage, the actor is
// not ready, so we would get a nullptr from GetBrowserParent(). But,
// we can actually get it from the manager.
RefPtr<BrowserParent> browserParent =
static_cast<BrowserParent*>(Manager());
if (NS_WARN_IF(!browserParent)) {
return;
}
nsCOMPtr<nsIBrowser> browser;
nsCOMPtr<nsIWebProgress> manager;
nsCOMPtr<nsIWebProgressListener> managerAsListener;
if (!browserParent->GetWebProgressListener(
getter_AddRefs(browser), getter_AddRefs(manager),
getter_AddRefs(managerAsListener))) {
return;
}
MOZ_DIAGNOSTIC_ASSERT(!IsInProcess());
nsCOMPtr<nsIWebProgress> webProgress =
new RemoteWebProgress(manager, OuterWindowId(), InnerWindowId(), 0,
false, BrowsingContext()->IsTopContent());
Unused << managerAsListener->OnContentBlockingEvent(webProgress, aRequest,
event.value());
}
}
already_AddRefed<JSWindowActorParent> WindowGlobalParent::GetActor(
const nsAString& aName, ErrorResult& aRv) {
if (!CanSend()) {

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef mozilla_dom_WindowGlobalParent_h
#define mozilla_dom_WindowGlobalParent_h
#include "mozilla/AntiTrackingCommon.h"
#include "mozilla/RefPtr.h"
#include "mozilla/dom/DOMRect.h"
#include "mozilla/dom/PWindowGlobalParent.h"
@ -17,7 +16,6 @@
#include "nsISupports.h"
#include "mozilla/dom/WindowGlobalActor.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ContentBlockingLog.h"
class nsIPrincipal;
class nsIURI;
@ -132,14 +130,6 @@ class WindowGlobalParent final : public WindowGlobalActor,
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
void NotifyContentBlockingEvent(
uint32_t aEvent, nsIRequest* aRequest, bool aBlocked, nsIURI* aURIHint,
const nsTArray<nsCString>& aTrackingFullHashes,
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason =
Nothing());
ContentBlockingLog* GetContentBlockingLog() { return &mContentBlockingLog; }
protected:
const nsAString& GetRemoteType() override;
JSWindowActor::Type GetSide() override { return JSWindowActor::Type::Parent; }
@ -188,8 +178,6 @@ class WindowGlobalParent final : public WindowGlobalActor,
// True if this window has a "beforeunload" event listener.
bool mHasBeforeUnload;
ContentBlockingLog mContentBlockingLog;
};
} // namespace dom

Просмотреть файл

@ -11,6 +11,16 @@ class GeckoViewContentBlockingChild extends GeckoViewChildModule {
onEnable() {
debug`onEnable`;
const flags = Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING;
this.progressFilter = Cc[
"@mozilla.org/appshell/component/browser-status-filter;1"
].createInstance(Ci.nsIWebProgress);
this.progressFilter.addProgressListener(this, flags);
const webProgress = docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress);
webProgress.addProgressListener(this.progressFilter, flags);
this.messageManager.addMessageListener("ContentBlocking:RequestLog", this);
}
@ -36,6 +46,37 @@ class GeckoViewContentBlockingChild extends GeckoViewChildModule {
}
}
}
onContentBlockingEvent(aWebProgress, aRequest, aEvent) {
debug`onContentBlockingEvent ${aEvent.toString(16)}`;
if (!aRequest || !(aRequest instanceof Ci.nsIClassifiedChannel)) {
return;
}
const channel = aRequest.QueryInterface(Ci.nsIChannel);
const uri = channel.URI && channel.URI.spec;
const classChannel = aRequest.QueryInterface(Ci.nsIClassifiedChannel);
if (!uri) {
return;
}
debug`onContentBlockingEvent matchedList: ${classChannel.matchedList}`;
debug`onContentBlockingEvent matchedTrackingLists: ${
classChannel.matchedTrackingLists
}`;
const message = {
type: "GeckoView:ContentBlockingEvent",
uri: uri,
category: aEvent,
blockedList: classChannel.matchedList || null,
loadedLists: classChannel.matchedTrackingLists,
};
this.eventDispatcher.sendRequest(message);
}
}
const { debug, warn } = GeckoViewContentBlockingChild.initLogging(

Просмотреть файл

@ -158,10 +158,6 @@ class ContentBlockingControllerTest : BaseSessionTest() {
@AssertCalled(count = 1)
override fun onContentBlocked(session: GeckoSession,
event: ContentBlocking.BlockEvent) {
// A workaround for waiting until the log is actually recorded
// in the content process.
// TODO: This should be removed after Bug 1599046.
Thread.sleep(500);
}
})

Просмотреть файл

@ -12,25 +12,12 @@ const { GeckoViewModule } = ChromeUtils.import(
class GeckoViewContentBlocking extends GeckoViewModule {
onEnable() {
const flags = Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING;
this.progressFilter = Cc[
"@mozilla.org/appshell/component/browser-status-filter;1"
].createInstance(Ci.nsIWebProgress);
this.progressFilter.addProgressListener(this, flags);
this.browser.addProgressListener(this.progressFilter, flags);
this.registerListener(["ContentBlocking:RequestLog"]);
this.messageManager.addMessageListener("ContentBlocking:ExportLog", this);
}
onDisable() {
if (this.progressFilter) {
this.progressFilter.removeProgressListener(this);
this.browser.removeProgressListener(this.progressFilter);
delete this.progressFilter;
}
this.unregisterListener(["ContentBlocking:RequestLog"]);
this.messageManager.removeMessageListener(
@ -103,37 +90,6 @@ class GeckoViewContentBlocking extends GeckoViewModule {
}
}
}
onContentBlockingEvent(aWebProgress, aRequest, aEvent) {
debug`onContentBlockingEvent ${aEvent.toString(16)}`;
if (aRequest instanceof Ci.nsIClassifiedChannel) {
return;
}
const channel = aRequest.QueryInterface(Ci.nsIChannel);
const uri = channel.URI && channel.URI.spec;
const classChannel = aRequest.QueryInterface(Ci.nsIClassifiedChannel);
if (!uri) {
return;
}
debug`onContentBlockingEvent matchedList: ${classChannel.matchedList}`;
debug`onContentBlockingEvent matchedTrackingLists: ${
classChannel.matchedTrackingLists
}`;
const message = {
type: "GeckoView:ContentBlockingEvent",
uri: uri,
category: aEvent,
blockedList: classChannel.matchedList || null,
loadedLists: classChannel.matchedTrackingLists,
};
this.eventDispatcher.sendRequest(message);
}
}
const { debug, warn } = GeckoViewContentBlocking.initLogging(

Просмотреть файл

@ -9,7 +9,6 @@
#include "ClassifierDummyChannel.h"
#include "mozilla/AntiTrackingCommon.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/net/HttpBaseChannel.h"
#include "mozilla/net/UrlClassifierFeatureFactory.h"
#include "mozilla/StaticPrefs_network.h"
@ -59,8 +58,9 @@ void UrlClassifierCommon::NotifyChannelClassifierProtectionDisabled(
NS_QueryNotificationCallbacks(aChannel, parentChannel);
if (parentChannel) {
// This channel is a parent-process proxy for a child process request.
// Tell the child process channel to do this as well.
// Tell the child process channel to do this instead.
parentChannel->NotifyChannelClassifierProtectionDisabled(aEvent);
return;
}
nsCOMPtr<nsIURI> uriBeingLoaded =
@ -72,42 +72,6 @@ void UrlClassifierCommon::NotifyChannelClassifierProtectionDisabled(
void UrlClassifierCommon::NotifyChannelBlocked(nsIChannel* aChannel,
nsIURI* aURIBeingLoaded,
unsigned aBlockedReason) {
MOZ_ASSERT(aChannel);
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
// We would notify the OnContentBlockingEvent via the top-level
// WindowGlobalParent if it is in the parent process.
if (XRE_IsParentProcess()) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
RefPtr<dom::BrowsingContext> bc;
loadInfo->GetBrowsingContext(getter_AddRefs(bc));
if (!bc || bc->IsDiscarded()) {
return;
}
// Get the top-level browsing context.
bc = bc->Top();
RefPtr<dom::WindowGlobalParent> wgp =
bc->Canonical()->GetCurrentWindowGlobal();
NS_ENSURE_TRUE_VOID(wgp);
nsTArray<nsCString> trackingFullHashes;
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
do_QueryInterface(aChannel);
if (classifiedChannel) {
Unused << classifiedChannel->GetMatchedTrackingFullHashes(
trackingFullHashes);
}
wgp->NotifyContentBlockingEvent(aBlockedReason, aChannel, true, uri,
trackingFullHashes);
return;
}
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
if (NS_WARN_IF(!thirdPartyUtil)) {
return;
@ -125,6 +89,8 @@ void UrlClassifierCommon::NotifyChannelBlocked(nsIChannel* aChannel,
RefPtr<dom::Document> doc = docShell->GetDocument();
NS_ENSURE_TRUE_VOID(doc);
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
pwin->NotifyContentBlockingEvent(aBlockedReason, aChannel, true, uri,
aChannel);
}
@ -183,6 +149,19 @@ nsresult UrlClassifierCommon::SetTrackingInfo(
NS_ENSURE_ARG(!aLists.IsEmpty());
// Can be called in EITHER the parent or child process.
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(aChannel, parentChannel);
if (parentChannel) {
// This channel is a parent-process proxy for a child process request.
// Tell the child process channel to do this instead.
nsAutoCString strLists, strHashes;
TablesToString(aLists, strLists);
TablesToString(aFullHashes, strHashes);
parentChannel->SetClassifierMatchedTrackingInfo(strLists, strHashes);
return NS_OK;
}
nsresult rv;
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
do_QueryInterface(aChannel, &rv);
@ -192,21 +171,6 @@ nsresult UrlClassifierCommon::SetTrackingInfo(
classifiedChannel->SetMatchedTrackingInfo(aLists, aFullHashes);
}
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(aChannel, parentChannel);
if (parentChannel) {
// This channel is a parent-process proxy for a child process request.
// Tell the child process channel to do this as well.
// TODO: We can remove the code sending the IPC to content to update
// tracking info once we move the ContentBlockingLog into the parent.
// This would be done in Bug 1599046.
nsAutoCString strLists, strHashes;
TablesToString(aLists, strLists);
TablesToString(aFullHashes, strHashes);
parentChannel->SetClassifierMatchedTrackingInfo(strLists, strHashes);
}
return NS_OK;
}
@ -262,6 +226,15 @@ nsresult UrlClassifierCommon::SetBlockedContent(nsIChannel* channel,
}
// Can be called in EITHER the parent or child process.
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(channel, parentChannel);
if (parentChannel) {
// This channel is a parent-process proxy for a child process request.
// Tell the child process channel to do this instead.
parentChannel->SetClassifierMatchedInfo(aList, aProvider, aFullHash);
return NS_OK;
}
nsresult rv;
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
do_QueryInterface(channel, &rv);
@ -271,34 +244,13 @@ nsresult UrlClassifierCommon::SetBlockedContent(nsIChannel* channel,
classifiedChannel->SetMatchedInfo(aList, aProvider, aFullHash);
}
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(channel, parentChannel);
nsCOMPtr<nsIURI> uriBeingLoaded =
AntiTrackingCommon::MaybeGetDocumentURIBeingLoaded(channel);
unsigned state =
UrlClassifierFeatureFactory::GetClassifierBlockingEventCode(aErrorCode);
if (!state) {
state = nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
}
if (parentChannel) {
// This channel is a parent-process proxy for a child process request.
// Tell the child process channel to do this as well.
// TODO: We can remove the code sending the IPC to content to update
// matched info once we move the ContentBlockingLog into the parent.
// This would be done in Bug 1601063.
parentChannel->SetClassifierMatchedInfo(aList, aProvider, aFullHash);
UrlClassifierCommon::NotifyChannelBlocked(channel, uriBeingLoaded, state);
return NS_OK;
}
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
if (NS_WARN_IF(!thirdPartyUtil)) {
return NS_OK;
}
nsCOMPtr<nsIURI> uriBeingLoaded =
AntiTrackingCommon::MaybeGetDocumentURIBeingLoaded(channel);
nsCOMPtr<mozIDOMWindowProxy> win;
rv = thirdPartyUtil->GetTopWindowForChannel(channel, uriBeingLoaded,
getter_AddRefs(win));
@ -311,6 +263,12 @@ nsresult UrlClassifierCommon::SetBlockedContent(nsIChannel* channel,
RefPtr<dom::Document> doc = docShell->GetDocument();
NS_ENSURE_TRUE(doc, NS_OK);
unsigned state =
UrlClassifierFeatureFactory::GetClassifierBlockingEventCode(aErrorCode);
if (!state) {
state = nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
}
UrlClassifierCommon::NotifyChannelBlocked(channel, uriBeingLoaded, state);
// Log a warning to the web console.

Просмотреть файл

@ -866,23 +866,18 @@ void NotifyBlockingDecisionInternal(
nsIChannel* aReportingChannel, nsIChannel* aTrackingChannel,
AntiTrackingCommon::BlockingDecision aDecision, uint32_t aRejectedReason,
nsIURI* aURI, nsPIDOMWindowOuter* aWindow) {
MOZ_DIAGNOSTIC_ASSERT_IF(
nsGlobalWindowOuter::Cast(aWindow)->IsChromeWindow(),
aDecision == AntiTrackingCommon::BlockingDecision::eAllow);
if (aDecision == AntiTrackingCommon::BlockingDecision::eBlock) {
AntiTrackingCommon::NotifyContentBlockingEvent(aWindow, aReportingChannel,
aTrackingChannel, true,
aRejectedReason, aURI);
aWindow->NotifyContentBlockingEvent(aRejectedReason, aReportingChannel,
true, aURI, aTrackingChannel);
ReportBlockingToConsole(aWindow, aURI, aRejectedReason);
}
// Now send the generic "cookies loaded" notifications, from the most generic
// to the most specific.
AntiTrackingCommon::NotifyContentBlockingEvent(
aWindow, aReportingChannel, aTrackingChannel, false,
nsIWebProgressListener::STATE_COOKIES_LOADED, aURI);
aWindow->NotifyContentBlockingEvent(
nsIWebProgressListener::STATE_COOKIES_LOADED, aReportingChannel, false,
aURI, aTrackingChannel);
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
do_QueryInterface(aTrackingChannel);
@ -894,16 +889,16 @@ void NotifyBlockingDecisionInternal(
classifiedChannel->GetThirdPartyClassificationFlags();
if (classificationFlags &
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_TRACKING) {
AntiTrackingCommon::NotifyContentBlockingEvent(
aWindow, aReportingChannel, aTrackingChannel, false,
nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER, aURI);
aWindow->NotifyContentBlockingEvent(
nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER, aReportingChannel,
false, aURI, aTrackingChannel);
}
if (classificationFlags &
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_SOCIALTRACKING) {
AntiTrackingCommon::NotifyContentBlockingEvent(
aWindow, aReportingChannel, aTrackingChannel, false,
nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER, aURI);
aWindow->NotifyContentBlockingEvent(
nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER,
aReportingChannel, false, aURI, aTrackingChannel);
}
}
@ -1118,9 +1113,9 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(
nsIChannel* channel =
pwin->GetCurrentInnerWindow()->GetExtantDoc()->GetChannel();
NotifyContentBlockingEvent(pwin, channel,
parentWindow->GetExtantDoc()->GetChannel(),
false, blockReason, trackingURI, Some(aReason));
pwin->NotifyContentBlockingEvent(blockReason, channel, false, trackingURI,
parentWindow->GetExtantDoc()->GetChannel(),
Some(aReason));
ReportUnblockingToConsole(parentWindow,
NS_ConvertUTF8toUTF16(trackingOrigin),
@ -2104,13 +2099,6 @@ void AntiTrackingCommon::NotifyBlockingDecision(nsIChannel* aChannel,
} else {
parentChannel->NotifyCookieAllowed();
}
// TODO: For ETP fission, we don't need to notify the
// OnContentBlockingEvent in the current stage. Because we still
// send a IPC to the content process in order to update the log in
// the content. And the content would send back to parent to notify
// the event. So, we don't need to notify here. But, we will have to
// notify here once the log move to parent entirely (Bug 1599046).
}
return;
}
@ -2308,38 +2296,3 @@ already_AddRefed<nsIURI> AntiTrackingCommon::MaybeGetDocumentURIBeingLoaded(
}
return uriBeingLoaded.forget();
}
/* static */
void AntiTrackingCommon::NotifyContentBlockingEvent(
nsPIDOMWindowOuter* aWindow, nsIChannel* aReportingChannel,
nsIChannel* aTrackingChannel, bool aBlocked, uint32_t aRejectedReason,
nsIURI* aURI, const Maybe<StorageAccessGrantedReason>& aReason) {
MOZ_ASSERT(aWindow);
// Log the content blocking event. This should be removed in Bug 1599046.
aWindow->NotifyContentBlockingEvent(aRejectedReason, aReportingChannel,
aBlocked, aURI, aTrackingChannel,
aReason);
RefPtr<dom::BrowserChild> browserChild = dom::BrowserChild::GetFrom(aWindow);
NS_ENSURE_TRUE_VOID(browserChild);
nsTArray<nsCString> trackingFullHashes;
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
do_QueryInterface(aTrackingChannel);
if (classifiedChannel) {
Unused << classifiedChannel->GetMatchedTrackingFullHashes(
trackingFullHashes);
}
// Send a message to notify OnContentBlockingEvent in the parent, which will
// update the ContentBlockingLog in the parent.
// We also notify the event in the content above since we haven't move the log
// into the parent process entirely. So, we need to notify and update the
// ContentBlockingLog in the content processes. We can remove this once we
// finish the Bug 1599046.
browserChild->NotifyContentBlockingEvent(aRejectedReason, aReportingChannel,
aBlocked, aURI, trackingFullHashes,
aReason);
}

Просмотреть файл

@ -19,7 +19,6 @@ class nsIPermission;
class nsIPrincipal;
class nsIURI;
class nsPIDOMWindowInner;
class nsPIDOMWindowOuter;
namespace mozilla {
@ -178,12 +177,6 @@ class AntiTrackingCommon final {
// Get the current document URI from a document channel as it is being loaded.
static already_AddRefed<nsIURI> MaybeGetDocumentURIBeingLoaded(
nsIChannel* aChannel);
static void NotifyContentBlockingEvent(
nsPIDOMWindowOuter* aWindow, nsIChannel* aReportingChannel,
nsIChannel* aTrackingChannel, bool aBlocked, uint32_t aRejectedReason,
nsIURI* aURI,
const Maybe<StorageAccessGrantedReason>& aReason = Nothing());
};
} // namespace mozilla

Просмотреть файл

@ -1,28 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_antitrackingipcutils_h
#define mozilla_antitrackingipcutils_h
#include "ipc/IPCMessageUtils.h"
#include "mozilla/AntiTrackingCommon.h"
namespace IPC {
// For allowing passing the enum AntiTrackingCommon::StorageAccessGrantedReason
// over IPC.
template <>
struct ParamTraits<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>
: public ContiguousEnumSerializerInclusive<
mozilla::AntiTrackingCommon::StorageAccessGrantedReason,
mozilla::AntiTrackingCommon::StorageAccessGrantedReason::
eStorageAccessAPI,
mozilla::AntiTrackingCommon::StorageAccessGrantedReason::eOpener> {};
} // namespace IPC
#endif // mozilla_antitrackingipcutils_h

Просмотреть файл

@ -32,7 +32,6 @@ XPCOM_MANIFESTS += [
EXPORTS.mozilla = [
'AntiTrackingCommon.h',
'AntiTrackingIPCUtils.h',
'StorageAccess.h',
'StoragePrincipalHelper.h',
'URLDecorationStripper.h',

Просмотреть файл

@ -192,13 +192,14 @@ function testOnWindow(aTestData) {
let expected;
let browser = win.gBrowser.selectedBrowser;
let wp = win.gBrowser.contentWindow.docShell.QueryInterface(Ci.nsIWebProgress);
let progressListener = {
onContentBlockingEvent(aWebProgress, aRequest, aEvent) {
expected = aTestData.reportUrl;
},
QueryInterface: ChromeUtils.generateQI(["nsISupportsWeakReference"]),
};
win.gBrowser.addProgressListener(progressListener, Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING);
wp.addProgressListener(progressListener, wp.NOTIFY_CONTENT_BLOCKING);
await BrowserTestUtils.loadURI(browser, aTestData.url);
await BrowserTestUtils.browserLoaded(