Backed out 3 changesets (bug 1889444) for causing xpcshell failures on test_JOG.js CLOSED TREE

Backed out changeset 40bffb571031 (bug 1889444)
Backed out changeset 3b1dc8369d98 (bug 1889444)
Backed out changeset 794e7b951f29 (bug 1889444)
This commit is contained in:
pstanciu
2024-06-18 22:53:49 +03:00
parent 779d3c3fd0
commit 7422c4eea9
10 changed files with 10 additions and 220 deletions

View File

@@ -33,14 +33,12 @@
#include "xpcpublic.h"
#include "mozilla/glean/GleanMetrics.h"
#include "mozilla/ContentBlockingLog.h"
#include "mozilla/glean/GleanPings.h"
#define TEST_OBSERVER_MSG_RECORD_BOUNCES_FINISHED "test-record-bounces-finished"
namespace mozilla {
NS_IMPL_ISUPPORTS(BounceTrackingProtection, nsIObserver,
nsIBounceTrackingProtection);
NS_IMPL_ISUPPORTS(BounceTrackingProtection, nsIBounceTrackingProtection);
LazyLogModule gBounceTrackingProtectionLog("BounceTrackingProtection");
@@ -318,21 +316,6 @@ nsresult BounceTrackingProtection::RecordUserActivation(
aActivationTime.valueOr(PR_Now()));
}
NS_IMETHODIMP
BounceTrackingProtection::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
MOZ_LOG(gBounceTrackingProtectionLog, LogLevel::Debug,
("%s: aTopic: %s", __FUNCTION__, aTopic));
if (!strcmp(aTopic, "idle-daily")) {
#if defined(EARLY_BETA_OR_EARLIER)
// Submit custom telemetry ping.
glean_pings::BounceTrackingProtection.Submit();
#endif // defined(EARLY_BETA_OR_EARLIER)
}
return NS_OK;
}
NS_IMETHODIMP
BounceTrackingProtection::TestGetBounceTrackerCandidateHosts(
JS::Handle<JS::Value> aOriginAttributes, JSContext* aCx,
@@ -715,8 +698,7 @@ nsresult BounceTrackingProtection::PurgeBounceTrackersForStateGlobal(
RefPtr<ClearDataMozPromise::Private> clearPromise =
new ClearDataMozPromise::Private(__func__);
RefPtr<ClearDataCallback> cb =
new ClearDataCallback(clearPromise, host, bounceTime);
RefPtr<ClearDataCallback> cb = new ClearDataCallback(clearPromise, host);
MOZ_LOG(gBounceTrackingProtectionLog, LogLevel::Info,
("%s: Purging bounce tracker. siteHost: %s, bounceTime: %" PRIu64

View File

@@ -24,10 +24,8 @@ class OriginAttributes;
extern LazyLogModule gBounceTrackingProtectionLog;
class BounceTrackingProtection final : public nsIObserver,
public nsIBounceTrackingProtection {
class BounceTrackingProtection final : public nsIBounceTrackingProtection {
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_NSIBOUNCETRACKINGPROTECTION
public:

View File

@@ -36,12 +36,8 @@ nsTArray<RefPtr<nsIUrlClassifierFeature>>
ClearDataCallback::sUrlClassifierFeatures;
ClearDataCallback::ClearDataCallback(ClearDataMozPromise::Private* aPromise,
const nsACString& aHost,
PRTime aBounceTime)
: mHost(aHost),
mBounceTime(aBounceTime),
mPromise(aPromise),
mClearDurationTimer(0) {
const nsACString& aHost)
: mHost(aHost), mPromise(aPromise), mClearDurationTimer(0) {
MOZ_ASSERT(!aHost.IsEmpty(), "Host must not be empty");
if (!StaticPrefs::privacy_bounceTrackingProtection_enableDryRunMode()) {
@@ -82,8 +78,7 @@ NS_IMETHODIMP ClearDataCallback::OnDataDeleted(uint32_t aFailedFlags) {
mPromise->Reject(aFailedFlags, __func__);
} else {
MOZ_LOG(gBounceTrackingProtectionLog, LogLevel::Debug,
("%s: Cleared host: %s, bounceTime: %" PRIu64, __FUNCTION__,
mHost.get(), mBounceTime));
("%s: Cleared %s", __FUNCTION__, mHost.get()));
mPromise->Resolve(mHost, __func__);
// Only record classifications on successful deletion.
@@ -92,8 +87,6 @@ NS_IMETHODIMP ClearDataCallback::OnDataDeleted(uint32_t aFailedFlags) {
// Always collect clear duration and purge count.
RecordClearDurationTelemetry();
RecordPurgeCountTelemetry(aFailedFlags != 0);
RecordPurgeEventTelemetry(aFailedFlags == 0);
return NS_OK;
}
@@ -168,18 +161,3 @@ ClearDataCallback::OnClassifyComplete(
return NS_OK;
}
void ClearDataCallback::RecordPurgeEventTelemetry(bool aSuccess) {
// Record a glean event for the clear action. This is only recorded in
// pre-release channels.
#if defined(EARLY_BETA_OR_EARLIER)
glean::bounce_tracking_protection::PurgeActionExtra extra = {
.bounceTime = Some(mBounceTime / PR_USEC_PER_SEC),
.isDryRun = Some(
StaticPrefs::privacy_bounceTrackingProtection_enableDryRunMode()),
.siteHost = Some(mHost),
.success = Some(aSuccess),
};
glean::bounce_tracking_protection::purge_action.Record(Some(extra));
#endif // defined(EARLY_BETA_OR_EARLIER)
}

View File

@@ -26,15 +26,13 @@ class ClearDataCallback final : public nsIClearDataCallback,
NS_DECL_NSIURLCLASSIFIERFEATURECALLBACK
explicit ClearDataCallback(ClearDataMozPromise::Private* aPromise,
const nsACString& aHost, PRTime aBounceTime);
const nsACString& aHost);
private:
virtual ~ClearDataCallback();
// Site host which was cleared.
nsCString mHost;
// Timestamp of when the bounce occurred that led to the tracker being purged.
PRTime mBounceTime;
// Promise which is resolved or rejected when the clear operation completes.
RefPtr<ClearDataMozPromise::Private> mPromise;
@@ -51,9 +49,6 @@ class ClearDataCallback final : public nsIClearDataCallback,
// List of features for classifying bounce trackers that have been purged.
// See kUrlClassifierFeatures for the list of features.
static nsTArray<RefPtr<nsIUrlClassifierFeature>> sUrlClassifierFeatures;
// Event telemetry for purges.
void RecordPurgeEventTelemetry(bool aSuccess);
};
} // namespace mozilla

View File

@@ -15,8 +15,5 @@ Classes = [
'singleton': True,
'constructor': 'mozilla::BounceTrackingProtection::GetSingleton',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'categories': {
'idle-daily': 'BounceTrackingProtection',
}
},
]

View File

@@ -53,37 +53,6 @@ bounce.tracking.protection:
- success
- failure
- dry
purge_action:
type: event
description: >
Dispatched whenever a bounce tracker site is purged. Only collected in
early Beta and Nightly.
bugs:
- https://bugzilla.mozilla.org/1889444
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1889444#c16
data_sensitivity:
- stored_content
notification_emails:
- pbz@mozilla.com
- bvandersloot@mozilla.com
- manuel@mozilla.com
send_in_pings:
- bounce-tracking-protection
expires: 134
extra_keys:
site_host:
description: The site host of which the data has been purged.
type: string
bounce_time:
description: Timestamp (seconds since epoch) of the last detected bounce.
type: quantity
is_dry_run:
description: Whether we just pretended to purge since the client is in dry-run mode.
type: boolean
success:
description: Whether the purge data call was successful. false indicates an error in ClearDataService.
type: boolean
enabled_at_startup:
type: boolean
description: >

View File

@@ -1,21 +0,0 @@
# 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 https://mozilla.org/MPL/2.0/.
---
$schema: moz://mozilla.org/schemas/glean/pings/2-0-0
bounce-tracking-protection:
description: |
A ping representing Bounce Tracking Protection stats. Note that this
ping does not include client_id. More details are available in Bug 1889444
include_client_id: false
metadata:
include_info_sections: false
use_ohttp: true
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1889444
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1889444#c16
notification_emails:
- pbz@mozilla.com

View File

@@ -33,11 +33,9 @@ support-files = [
["browser_bouncetracking_stateful_web_worker.js"]
["browser_bouncetracking_telemetry_purge_count.js"]
["browser_bouncetracking_telemetry_purge_duration.js"]
["browser_bouncetracking_telemetry_purge_events.js"]
["browser_bouncetracking_webAuthUserActivation.js"]
support-files = ["!/dom/webauthn/tests/browser/head.js"]
support-files = [ "!/dom/webauthn/tests/browser/head.js"]
["browser_bouncetracking_telemetry_purge_count.js"]

View File

@@ -1,105 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
let bounceTrackingProtection;
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.bounceTrackingProtection.requireStatefulBounces", true],
["privacy.bounceTrackingProtection.bounceTrackingGracePeriodSec", 0],
],
});
bounceTrackingProtection = Cc[
"@mozilla.org/bounce-tracking-protection;1"
].getService(Ci.nsIBounceTrackingProtection);
// Clear telemetry before test.
Services.fog.testResetFOG();
});
async function runTest(useDryRunMode) {
await SpecialPowers.pushPrefEnv({
set: [["privacy.bounceTrackingProtection.enableDryRunMode", useDryRunMode]],
});
is(
Glean.bounceTrackingProtection.purgeAction.testGetValue(),
null,
"There should be no purge events initially."
);
info("Run server bounce with cookie.");
await runTestBounce({
bounceType: "server",
setState: "cookie-server",
postBounceCallback: () => {
is(
Glean.bounceTrackingProtection.purgeAction.testGetValue(),
null,
"There should still be no purge events after bounce, because we haven't purged yet."
);
},
});
info("Purge event telemetry is only recorded on early beta or nightly.");
if (AppConstants.EARLY_BETA_OR_EARLIER) {
let events = Glean.bounceTrackingProtection.purgeAction.testGetValue();
is(events.length, 1, "There should be one purge event after bounce.");
let [event] = events;
is(
event.extra.site_host,
"itisatracker.org",
"The site host should be correct."
);
ok(event.extra.success, "Purging should have succeeded");
// Confusingly all extra fields are converted to strings.
is(
event.extra.is_dry_run,
useDryRunMode ? "true" : "false",
"The purge should not be a dry run."
);
let bounceTimeInt = Number.parseInt(event.extra.bounce_time, 10);
Assert.greater(
bounceTimeInt,
0,
"The bounce time should be greater than 0."
);
Assert.less(
bounceTimeInt,
Date.now() / 1000,
"The bounce time should be before the current time."
);
} else {
// Late Beta or Release
is(
Glean.bounceTrackingProtection.purgeAction.testGetValue(),
null,
"There should still be no purge events after bounce on late beta or release."
);
}
// Cleanup
// runTestBounceHelper already cleans up bounce tracking protection state.
Services.fog.testResetFOG();
await SpecialPowers.popPrefEnv();
}
/**
* Tests that purge events are recorded correctly.
*/
add_task(async function test_purge_event() {
await runTest(false);
});
/**
* Tests that purge events are recorded correctly in dry-run mode.
*/
add_task(async function test_purge_event_dry_run() {
await runTest(true);
});

View File

@@ -122,7 +122,6 @@ metrics_yamls = sorted(
# Order is lexicographical, enforced by t/c/glean/tests/pytest/test_yaml_indices.py
gecko_pings = [
"dom/pings.yaml",
"toolkit/components/antitracking/bouncetrackingprotection/pings.yaml",
"toolkit/components/glean/pings.yaml",
"toolkit/components/reportbrokensite/pings.yaml",
]