зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1187022 - Add hover tooltip for tracking protection shield icon;r=MattN
--HG-- extra : commitid : KxZ3gqOI83Z
This commit is contained in:
Родитель
3f09481f19
Коммит
a160cc3e58
|
@ -8,6 +8,11 @@ let TrackingProtection = {
|
||||||
PREF_ENABLED_IN_PRIVATE_WINDOWS: "privacy.trackingprotection.pbmode.enabled",
|
PREF_ENABLED_IN_PRIVATE_WINDOWS: "privacy.trackingprotection.pbmode.enabled",
|
||||||
enabledGlobally: false,
|
enabledGlobally: false,
|
||||||
enabledInPrivateWindows: false,
|
enabledInPrivateWindows: false,
|
||||||
|
container: null,
|
||||||
|
content: null,
|
||||||
|
icon: null,
|
||||||
|
activeTooltipText: null,
|
||||||
|
disabledTooltipText: null,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
let $ = selector => document.querySelector(selector);
|
let $ = selector => document.querySelector(selector);
|
||||||
|
@ -19,6 +24,11 @@ let TrackingProtection = {
|
||||||
Services.prefs.addObserver(this.PREF_ENABLED_GLOBALLY, this, false);
|
Services.prefs.addObserver(this.PREF_ENABLED_GLOBALLY, this, false);
|
||||||
Services.prefs.addObserver(this.PREF_ENABLED_IN_PRIVATE_WINDOWS, this, false);
|
Services.prefs.addObserver(this.PREF_ENABLED_IN_PRIVATE_WINDOWS, this, false);
|
||||||
|
|
||||||
|
this.activeTooltipText =
|
||||||
|
gNavigatorBundle.getString("trackingProtection.icon.activeTooltip");
|
||||||
|
this.disabledTooltipText =
|
||||||
|
gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip");
|
||||||
|
|
||||||
this.enabledHistogram.add(this.enabledGlobally);
|
this.enabledHistogram.add(this.enabledGlobally);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -66,21 +76,14 @@ let TrackingProtection = {
|
||||||
this.icon.setAttribute("animate", "true");
|
this.icon.setAttribute("animate", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let isBlocking = state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT;
|
||||||
STATE_BLOCKED_TRACKING_CONTENT, STATE_LOADED_TRACKING_CONTENT
|
let isAllowing = state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT;
|
||||||
} = Ci.nsIWebProgressListener;
|
|
||||||
|
|
||||||
for (let element of [this.icon, this.content]) {
|
if (isBlocking) {
|
||||||
if (state & STATE_BLOCKED_TRACKING_CONTENT) {
|
this.icon.setAttribute("tooltiptext", this.activeTooltipText);
|
||||||
element.setAttribute("state", "blocked-tracking-content");
|
this.icon.setAttribute("state", "blocked-tracking-content");
|
||||||
} else if (state & STATE_LOADED_TRACKING_CONTENT) {
|
this.content.setAttribute("state", "blocked-tracking-content");
|
||||||
element.setAttribute("state", "loaded-tracking-content");
|
|
||||||
} else {
|
|
||||||
element.removeAttribute("state");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state & STATE_BLOCKED_TRACKING_CONTENT) {
|
|
||||||
// Open the tracking protection introduction panel, if applicable.
|
// Open the tracking protection introduction panel, if applicable.
|
||||||
let introCount = gPrefService.getIntPref("privacy.trackingprotection.introCount");
|
let introCount = gPrefService.getIntPref("privacy.trackingprotection.introCount");
|
||||||
if (introCount < TrackingProtection.MAX_INTROS) {
|
if (introCount < TrackingProtection.MAX_INTROS) {
|
||||||
|
@ -88,6 +91,14 @@ let TrackingProtection = {
|
||||||
gPrefService.savePrefFile(null);
|
gPrefService.savePrefFile(null);
|
||||||
this.showIntroPanel();
|
this.showIntroPanel();
|
||||||
}
|
}
|
||||||
|
} else if (isAllowing) {
|
||||||
|
this.icon.setAttribute("tooltiptext", this.disabledTooltipText);
|
||||||
|
this.icon.setAttribute("state", "loaded-tracking-content");
|
||||||
|
this.content.setAttribute("state", "loaded-tracking-content");
|
||||||
|
} else {
|
||||||
|
this.icon.removeAttribute("tooltiptext");
|
||||||
|
this.icon.removeAttribute("state");
|
||||||
|
this.content.removeAttribute("state");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Telemetry for state change.
|
// Telemetry for state change.
|
||||||
|
|
|
@ -46,6 +46,7 @@ function testBenignPage() {
|
||||||
ok(!TrackingProtection.container.hidden, "The container is visible");
|
ok(!TrackingProtection.container.hidden, "The container is visible");
|
||||||
ok(!TrackingProtection.content.hasAttribute("state"), "content: no state");
|
ok(!TrackingProtection.content.hasAttribute("state"), "content: no state");
|
||||||
ok(!TrackingProtection.icon.hasAttribute("state"), "icon: no state");
|
ok(!TrackingProtection.icon.hasAttribute("state"), "icon: no state");
|
||||||
|
ok(!TrackingProtection.icon.hasAttribute("tooltiptext"), "icon: no tooltip");
|
||||||
|
|
||||||
ok(hidden("#tracking-protection-icon"), "icon is hidden");
|
ok(hidden("#tracking-protection-icon"), "icon is hidden");
|
||||||
ok(hidden("#tracking-action-block"), "blockButton is hidden");
|
ok(hidden("#tracking-action-block"), "blockButton is hidden");
|
||||||
|
@ -64,6 +65,8 @@ function testTrackingPage(window) {
|
||||||
'content: state="blocked-tracking-content"');
|
'content: state="blocked-tracking-content"');
|
||||||
is(TrackingProtection.icon.getAttribute("state"), "blocked-tracking-content",
|
is(TrackingProtection.icon.getAttribute("state"), "blocked-tracking-content",
|
||||||
'icon: state="blocked-tracking-content"');
|
'icon: state="blocked-tracking-content"');
|
||||||
|
is(TrackingProtection.icon.getAttribute("tooltiptext"),
|
||||||
|
gNavigatorBundle.getString("trackingProtection.icon.activeTooltip"), "correct tooltip");
|
||||||
|
|
||||||
ok(!hidden("#tracking-protection-icon"), "icon is visible");
|
ok(!hidden("#tracking-protection-icon"), "icon is visible");
|
||||||
ok(hidden("#tracking-action-block"), "blockButton is hidden");
|
ok(hidden("#tracking-action-block"), "blockButton is hidden");
|
||||||
|
@ -90,6 +93,8 @@ function testTrackingPageUnblocked() {
|
||||||
'content: state="loaded-tracking-content"');
|
'content: state="loaded-tracking-content"');
|
||||||
is(TrackingProtection.icon.getAttribute("state"), "loaded-tracking-content",
|
is(TrackingProtection.icon.getAttribute("state"), "loaded-tracking-content",
|
||||||
'icon: state="loaded-tracking-content"');
|
'icon: state="loaded-tracking-content"');
|
||||||
|
is(TrackingProtection.icon.getAttribute("tooltiptext"),
|
||||||
|
gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip"), "correct tooltip");
|
||||||
|
|
||||||
ok(!hidden("#tracking-protection-icon"), "icon is visible");
|
ok(!hidden("#tracking-protection-icon"), "icon is visible");
|
||||||
ok(!hidden("#tracking-action-block"), "blockButton is visible");
|
ok(!hidden("#tracking-action-block"), "blockButton is visible");
|
||||||
|
|
|
@ -343,6 +343,9 @@ trackingProtection.intro.description=When the shield is visible, that means Fire
|
||||||
trackingProtection.intro.step1of3=1 of 3
|
trackingProtection.intro.step1of3=1 of 3
|
||||||
trackingProtection.intro.nextButton.label=Next
|
trackingProtection.intro.nextButton.label=Next
|
||||||
|
|
||||||
|
trackingProtection.icon.activeTooltip=Tracking attempts blocked
|
||||||
|
trackingProtection.icon.disabledTooltip=Tracking content detected
|
||||||
|
|
||||||
# Edit Bookmark UI
|
# Edit Bookmark UI
|
||||||
editBookmarkPanel.pageBookmarkedTitle=Page Bookmarked
|
editBookmarkPanel.pageBookmarkedTitle=Page Bookmarked
|
||||||
editBookmarkPanel.pageBookmarkedDescription=%S will always remember this page for you.
|
editBookmarkPanel.pageBookmarkedDescription=%S will always remember this page for you.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче