mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Backed out changeset 1a28547631d7 (bug 1584312) for failures on browser_protections_UI_milestones.js.
This commit is contained in:
parent
5b04a9e49a
commit
771f858152
@ -1264,13 +1264,6 @@ var gProtectionsHandler = {
|
||||
));
|
||||
},
|
||||
|
||||
get _protectionsPopupMilestonesText() {
|
||||
delete this._protectionsPopupMilestonesText;
|
||||
return (this._protectionsPopupMilestonesText = document.getElementById(
|
||||
"protections-popup-milestones-text"
|
||||
));
|
||||
},
|
||||
|
||||
get _notBlockingWhyLink() {
|
||||
delete this._notBlockingWhyLink;
|
||||
return (this._notBlockingWhyLink = document.getElementById(
|
||||
@ -1344,42 +1337,6 @@ var gProtectionsHandler = {
|
||||
3000
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"milestoneListPref",
|
||||
"browser.contentblocking.cfr-milestone.milestones",
|
||||
[],
|
||||
() => this.maybeSetMilestoneCounterText(),
|
||||
val => JSON.parse(val)
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"milestonePref",
|
||||
"browser.contentblocking.cfr-milestone.milestone-achieved",
|
||||
0,
|
||||
() => this.maybeSetMilestoneCounterText()
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"milestoneTimestampPref",
|
||||
"browser.contentblocking.cfr-milestone.milestone-shown-time",
|
||||
0,
|
||||
null,
|
||||
val => parseInt(val)
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"milestonesEnabledPref",
|
||||
"browser.contentblocking.cfr-milestone.enabled",
|
||||
false,
|
||||
() => this.maybeSetMilestoneCounterText()
|
||||
);
|
||||
|
||||
this.maybeSetMilestoneCounterText();
|
||||
|
||||
for (let blocker of this.blockers) {
|
||||
if (blocker.init) {
|
||||
blocker.init();
|
||||
@ -1426,11 +1383,6 @@ var gProtectionsHandler = {
|
||||
relatedToCurrent,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
});
|
||||
|
||||
// Don't show the milestones section anymore.
|
||||
Services.prefs.clearUserPref(
|
||||
"browser.contentblocking.cfr-milestone.milestone-shown-time"
|
||||
);
|
||||
},
|
||||
|
||||
async showTrackersSubview(event) {
|
||||
@ -1836,16 +1788,6 @@ var gProtectionsHandler = {
|
||||
|
||||
// Update the tooltip of the blocked tracker counter.
|
||||
this.maybeUpdateEarliestRecordedDateTooltip();
|
||||
|
||||
let today = Date.now();
|
||||
let threeDaysMillis = 72 * 60 * 60 * 1000;
|
||||
let expired = today - this.milestoneTimestampPref > threeDaysMillis;
|
||||
|
||||
if (this._milestoneTextSet && !expired) {
|
||||
this._protectionsPopup.setAttribute("milestone", this.milestonePref);
|
||||
} else {
|
||||
this._protectionsPopup.removeAttribute("milestone");
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
@ -2010,46 +1952,6 @@ var gProtectionsHandler = {
|
||||
);
|
||||
},
|
||||
|
||||
// Whenever one of the milestone prefs are changed, we attempt to update
|
||||
// the milestone section string. This requires us to fetch the earliest
|
||||
// recorded date from the Tracking DB, hence this process is async.
|
||||
// When completed, we set _milestoneSetText to signal that the section
|
||||
// is populated and ready to be shown - which happens next time we call
|
||||
// refreshProtectionsPopup.
|
||||
_milestoneTextSet: false,
|
||||
async maybeSetMilestoneCounterText() {
|
||||
let trackerCount = this.milestonePref;
|
||||
if (
|
||||
!this.milestonesEnabledPref ||
|
||||
!trackerCount ||
|
||||
!this.milestoneListPref.includes(trackerCount)
|
||||
) {
|
||||
this._milestoneTextSet = false;
|
||||
return;
|
||||
}
|
||||
|
||||
let date = await TrackingDBService.getEarliestRecordedDate();
|
||||
let dateLocaleStr = new Date(date).toLocaleDateString("default", {
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
});
|
||||
|
||||
let desc = PluralForm.get(
|
||||
trackerCount,
|
||||
gNavigatorBundle.getString("protections.milestone.description")
|
||||
);
|
||||
|
||||
this._protectionsPopupMilestonesText.textContent = desc
|
||||
.replace("#1", gBrandBundle.GetStringFromName("brandShortName"))
|
||||
.replace(
|
||||
"#2",
|
||||
trackerCount.toLocaleString(Services.locale.appLocalesAsBCP47)
|
||||
)
|
||||
.replace("#3", dateLocaleStr);
|
||||
|
||||
this._milestoneTextSet = true;
|
||||
},
|
||||
|
||||
showDisabledTooltipForTPIcon() {
|
||||
this._trackingProtectionIconTooltipLabel.textContent = this.strings.disabledTooltipText;
|
||||
gIdentityHandler._trackingProtectionIconContainer.setAttribute(
|
||||
|
@ -3,4 +3,3 @@ support-files =
|
||||
head.js
|
||||
|
||||
[browser_protections_UI.js]
|
||||
[browser_protections_UI_milestones.js]
|
||||
|
@ -9,6 +9,50 @@ ChromeUtils.defineModuleGetter(
|
||||
"resource://gre/modules/ContentBlockingAllowList.jsm"
|
||||
);
|
||||
|
||||
function checkClickTelemetry(objectName, value) {
|
||||
let events = Services.telemetry.snapshotEvents(
|
||||
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS
|
||||
).parent;
|
||||
let buttonEvents = events.filter(
|
||||
e =>
|
||||
e[1] == "security.ui.protectionspopup" &&
|
||||
e[2] == "click" &&
|
||||
e[3] == objectName &&
|
||||
(!value || e[4] == value)
|
||||
);
|
||||
is(buttonEvents.length, 1, `recorded ${objectName} telemetry event`);
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"TrackingDBService",
|
||||
"@mozilla.org/tracking-db-service;1",
|
||||
"nsITrackingDBService"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "TRACK_DB_PATH", function() {
|
||||
return OS.Path.join(OS.Constants.Path.profileDir, "protections.sqlite");
|
||||
});
|
||||
|
||||
const { Sqlite } = ChromeUtils.import("resource://gre/modules/Sqlite.jsm");
|
||||
|
||||
async function addTrackerDataIntoDB(count) {
|
||||
const insertSQL =
|
||||
"INSERT INTO events (type, count, timestamp)" +
|
||||
"VALUES (:type, :count, date(:timestamp));";
|
||||
|
||||
let db = await Sqlite.openConnection({ path: TRACK_DB_PATH });
|
||||
let date = new Date().toISOString();
|
||||
|
||||
await db.execute(insertSQL, {
|
||||
type: TrackingDBService.TRACKERS_ID,
|
||||
count,
|
||||
timestamp: date,
|
||||
});
|
||||
|
||||
await db.close();
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
|
@ -1,99 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
// Hide protections cards so as not to trigger more async messaging
|
||||
// when landing on the page.
|
||||
["browser.contentblocking.report.monitor.enabled", false],
|
||||
["browser.contentblocking.report.lockwise.enabled", false],
|
||||
["browser.contentblocking.report.proxy.enabled", false],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function doTest() {
|
||||
// This also ensures that the DB tables have been initialized.
|
||||
await TrackingDBService.clearAll();
|
||||
|
||||
let milestones = JSON.parse(
|
||||
Services.prefs.getStringPref(
|
||||
"browser.contentblocking.cfr-milestone.milestones"
|
||||
)
|
||||
);
|
||||
let totalTrackerCount = 0;
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
"https://example.com"
|
||||
);
|
||||
|
||||
for (let milestone of milestones) {
|
||||
let trackerCount = milestone - totalTrackerCount;
|
||||
await addTrackerDataIntoDB(trackerCount);
|
||||
totalTrackerCount += trackerCount;
|
||||
|
||||
// Trigger the milestone feature.
|
||||
await TrackingDBService.saveEvents("{}");
|
||||
|
||||
await TestUtils.waitForCondition(
|
||||
() => gProtectionsHandler._milestoneTextSet
|
||||
);
|
||||
|
||||
// We set the shown-time pref to pretend that the CFR has been
|
||||
// shown, so that we can test the panel.
|
||||
// TODO: Full integration test for robustness.
|
||||
Services.prefs.setStringPref(
|
||||
"browser.contentblocking.cfr-milestone.milestone-shown-time",
|
||||
Date.now().toString()
|
||||
);
|
||||
|
||||
await openProtectionsPanel();
|
||||
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(
|
||||
gProtectionsHandler._protectionsPopupMilestonesText
|
||||
),
|
||||
"Milestones section should be visible in the panel."
|
||||
);
|
||||
|
||||
await closeProtectionsPanel();
|
||||
await openProtectionsPanel();
|
||||
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(
|
||||
gProtectionsHandler._protectionsPopupMilestonesText
|
||||
),
|
||||
"Milestones section should still be visible in the panel."
|
||||
);
|
||||
|
||||
let newTabPromise = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
"about:protections"
|
||||
);
|
||||
await EventUtils.synthesizeMouseAtCenter(
|
||||
document.getElementById("protections-popup-milestones-content"),
|
||||
{}
|
||||
);
|
||||
let protectionsTab = await newTabPromise;
|
||||
|
||||
ok(true, "about:protections has been opened as expected.");
|
||||
|
||||
BrowserTestUtils.removeTab(protectionsTab);
|
||||
|
||||
await openProtectionsPanel();
|
||||
|
||||
ok(
|
||||
!BrowserTestUtils.is_visible(
|
||||
gProtectionsHandler._protectionsPopupMilestonesText
|
||||
),
|
||||
"Milestones section should no longer be visible in the panel."
|
||||
);
|
||||
|
||||
await closeProtectionsPanel();
|
||||
}
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
await TrackingDBService.clearAll();
|
||||
});
|
@ -1,19 +1,6 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const { Sqlite } = ChromeUtils.import("resource://gre/modules/Sqlite.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"TrackingDBService",
|
||||
"@mozilla.org/tracking-db-service;1",
|
||||
"nsITrackingDBService"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "TRACK_DB_PATH", function() {
|
||||
return OS.Path.join(OS.Constants.Path.profileDir, "protections.sqlite");
|
||||
});
|
||||
|
||||
var protectionsPopup = document.getElementById("protections-popup");
|
||||
var protectionsPopupMainView = document.getElementById(
|
||||
"protections-popup-mainView"
|
||||
@ -74,34 +61,3 @@ async function closeProtectionsPanel() {
|
||||
PanelMultiView.hidePopup(protectionsPopup);
|
||||
await popuphiddenPromise;
|
||||
}
|
||||
|
||||
function checkClickTelemetry(objectName, value) {
|
||||
let events = Services.telemetry.snapshotEvents(
|
||||
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS
|
||||
).parent;
|
||||
let buttonEvents = events.filter(
|
||||
e =>
|
||||
e[1] == "security.ui.protectionspopup" &&
|
||||
e[2] == "click" &&
|
||||
e[3] == objectName &&
|
||||
(!value || e[4] == value)
|
||||
);
|
||||
is(buttonEvents.length, 1, `recorded ${objectName} telemetry event`);
|
||||
}
|
||||
|
||||
async function addTrackerDataIntoDB(count) {
|
||||
const insertSQL =
|
||||
"INSERT INTO events (type, count, timestamp)" +
|
||||
"VALUES (:type, :count, date(:timestamp));";
|
||||
|
||||
let db = await Sqlite.openConnection({ path: TRACK_DB_PATH });
|
||||
let date = new Date().toISOString();
|
||||
|
||||
await db.execute(insertSQL, {
|
||||
type: TrackingDBService.TRACKERS_ID,
|
||||
count,
|
||||
timestamp: date,
|
||||
});
|
||||
|
||||
await db.close();
|
||||
}
|
||||
|
@ -155,18 +155,6 @@
|
||||
</hbox>
|
||||
</stack>
|
||||
</vbox>
|
||||
|
||||
<hbox id="protections-popup-milestones" class="protections-popup-section">
|
||||
<!-- wrap=true is needed for descriptionheightworkaround, see bug 1564077 -->
|
||||
<toolbarbutton id="protections-popup-milestones-content"
|
||||
flex="1"
|
||||
wrap="true"
|
||||
oncommand="gProtectionsHandler.openProtections(true);">
|
||||
<description id="protections-popup-milestones-text" flex="1"
|
||||
role="heading" aria-level="2"/>
|
||||
<image id="protections-popup-milestones-illustration"/>
|
||||
</toolbarbutton>
|
||||
</hbox>
|
||||
</panelview>
|
||||
|
||||
<!-- Site Not Working? SubView -->
|
||||
|
@ -575,16 +575,6 @@ protections.footer.blockedTrackerCounter.description=1 Blocked;#1 Blocked
|
||||
# %S is the date on which we started counting (e.g., July 17, 2019).
|
||||
protections.footer.blockedTrackerCounter.tooltip=Since %S
|
||||
|
||||
# Milestones section in the Protections Panel
|
||||
# LOCALIZATION NOTE (protections.milestone.description):
|
||||
# Semicolon-separated list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #1 is replaced with brandShortName.
|
||||
# #2 is replaced with the (locale-formatted) number of trackers blocked
|
||||
# #3 is replaced by a locale-formatted date with short month and numeric year.
|
||||
# In English this looks like "Firefox blocked over 10,000 trackers since Oct 2019"
|
||||
protections.milestone.description=#1 blocked #2 tracker since #3;#1 blocked over #2 trackers since #3
|
||||
|
||||
# Edit Bookmark UI
|
||||
editBookmarkPanel.newBookmarkTitle=New Bookmark
|
||||
editBookmarkPanel.editBookmarkTitle=Edit This Bookmark
|
||||
|
@ -1,4 +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 http://mozilla.org/MPL/2.0/. -->
|
||||
<svg width="32" height="40" xmlns="http://www.w3.org/2000/svg"><path d="M31.617 10.435V5.009a1.74 1.74 0 00-1.443-1.74L16.296.87a1.687 1.687 0 00-.592 0L1.87 3.288a1.74 1.74 0 00-1.444 1.74v5.425c-.043 2.87-.07 4.948.052 6.244.748 8.295 2.496 12.078 5.47 16.147a16.165 16.165 0 009.704 6.287c.113.013.227.013.34 0 .112.014.226.014.338 0a16.409 16.409 0 009.757-6.313c2.974-4.07 4.722-7.826 5.47-16.156.13-1.287.104-3.365.06-6.226z" fill="context-fill"/><path d="M15.704.87L1.87 3.287a1.74 1.74 0 00-1.444 1.74v5.425c-.043 2.87-.07 4.948.052 6.244.748 8.295 2.496 12.078 5.47 16.147a16.165 16.165 0 009.704 6.287c.113.013.227.013.34 0V.87a1.74 1.74 0 00-.288 0z" opacity=".5" fill="context-stroke"/><path d="M12.878 11.635c-1.4.174-2.295 2.191-2.052 4.122.122.982.713 1.452.87 3.217 0 .174 0 .322.043.47a16.66 16.66 0 003.044-.166 5.009 5.009 0 01-.053-.87c.219-1.13.347-2.275.383-3.425-.226-1.757-.983-3.505-2.235-3.348zm2.052 8.487c-.84.135-1.688.202-2.539.2h-.548c.025.398.083.794.174 1.182.14.566.618 1.557 1.687 1.418a1.452 1.452 0 001.374-1.809c-.035-.348-.095-.67-.148-.991zm4.2-5.879c-1.252-.156-2.008 1.592-2.234 3.34.036 1.15.164 2.296.382 3.426.008.29-.01.581-.052.87 1.002.146 2.015.202 3.026.164v-.47c.174-1.738.765-2.234.87-3.216.295-1.922-.6-3.94-1.992-4.114zm-2.208 9.47a1.452 1.452 0 001.339 1.809c1.07.139 1.548-.87 1.687-1.418a7.07 7.07 0 00.174-1.174H19.6c-.845 0-1.688-.066-2.522-.2-.06.322-.121.644-.156.983z" fill="#FBFBFE"/></svg>
|
Before Width: | Height: | Size: 1.6 KiB |
@ -1107,74 +1107,3 @@ description#identity-popup-content-verifier,
|
||||
.protections-popup-description > description {
|
||||
margin: 10px 24px;
|
||||
}
|
||||
|
||||
#protections-popup:not([milestone]) #protections-popup-milestones {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#protections-popup-milestones {
|
||||
margin: 0 calc(var(--horizontal-padding) * 0.5) var(--vertical-section-padding);
|
||||
/* Override .protections-popup-section */
|
||||
border-top: none;
|
||||
background-color: var(--arrowpanel-dimmed);
|
||||
}
|
||||
|
||||
#protections-popup-milestones-content {
|
||||
padding: var(--vertical-section-padding) calc(var(--horizontal-padding) * 0.5);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#protections-popup-milestones-content:hover {
|
||||
background-color: var(--arrowpanel-dimmed);
|
||||
}
|
||||
|
||||
#protections-popup-milestones-content:hover:active {
|
||||
background-color: var(--arrowpanel-dimmed-further);
|
||||
}
|
||||
|
||||
#protections-popup-milestones-text {
|
||||
font-size: 1.23em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#protections-popup-milestones-illustration {
|
||||
list-style-image: url(chrome://browser/skin/controlcenter/etp-milestone.svg);
|
||||
-moz-context-properties: fill, stroke;
|
||||
margin-inline-start: var(--horizontal-padding);
|
||||
margin-inline-end: 4px;
|
||||
}
|
||||
|
||||
#protections-popup[milestone] #protections-popup-milestones-illustration {
|
||||
fill: #45278d;
|
||||
stroke: #321c64;
|
||||
}
|
||||
|
||||
#protections-popup[milestone="5000"] #protections-popup-milestones-illustration {
|
||||
fill: #5a29cb;
|
||||
stroke: #45278d;
|
||||
}
|
||||
|
||||
#protections-popup[milestone="10000"] #protections-popup-milestones-illustration {
|
||||
fill: #7641e5;
|
||||
stroke: #5a29cb;
|
||||
}
|
||||
|
||||
#protections-popup[milestone="25000"] #protections-popup-milestones-illustration {
|
||||
fill: #e31587;
|
||||
stroke: #c60084;
|
||||
}
|
||||
|
||||
#protections-popup[milestone="50000"] #protections-popup-milestones-illustration {
|
||||
fill: #ff298a;
|
||||
stroke: #e31587;
|
||||
}
|
||||
|
||||
#protections-popup[milestone="100000"] #protections-popup-milestones-illustration {
|
||||
fill: #ffa436;
|
||||
stroke: #e27f2e;
|
||||
}
|
||||
|
||||
#protections-popup[milestone="500000"] #protections-popup-milestones-illustration {
|
||||
fill: #ffd567;
|
||||
stroke: #ffbd4f;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@
|
||||
skin/classic/browser/controlcenter/cryptominers-disabled.svg (../shared/controlcenter/cryptominers-disabled.svg)
|
||||
skin/classic/browser/controlcenter/mcb-disabled.svg (../shared/controlcenter/mcb-disabled.svg)
|
||||
skin/classic/browser/controlcenter/extension.svg (../shared/controlcenter/extension.svg)
|
||||
skin/classic/browser/controlcenter/etp-milestone.svg (../shared/controlcenter/etp-milestone.svg)
|
||||
skin/classic/browser/controlcenter/fingerprinters.svg (../shared/controlcenter/fingerprinters.svg)
|
||||
skin/classic/browser/controlcenter/fingerprinters-disabled.svg (../shared/controlcenter/fingerprinters-disabled.svg)
|
||||
skin/classic/browser/controlcenter/info.svg (../shared/controlcenter/info.svg)
|
||||
|
Loading…
Reference in New Issue
Block a user