mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1484583 - Update Tracking Protection UI tour for Content Blocking. r=nhnt11
Differential Revision: https://phabricator.services.mozilla.com/D3929 --HG-- rename : browser/components/uitour/test/browser_trackingProtection.js => browser/components/uitour/test/browser_contentBlocking.js extra : moz-landing-system : lando
This commit is contained in:
parent
f99b0cbb91
commit
8997b3ac3e
@ -1502,6 +1502,9 @@ pref("browser.contentblocking.reportBreakage.enabled", true);
|
||||
pref("browser.contentblocking.reportBreakage.enabled", false);
|
||||
#endif
|
||||
pref("browser.contentblocking.reportBreakage.url", "https://tracking-protection-issues.herokuapp.com/new");
|
||||
// Content Blocking has a separate pref for the intro count, since the former TP intro
|
||||
// was updated when we introduced content blocking and we want people to see it again.
|
||||
pref("browser.contentblocking.introCount", 0);
|
||||
|
||||
pref("privacy.trackingprotection.introCount", 0);
|
||||
pref("privacy.trackingprotection.introURL", "https://www.mozilla.org/%LOCALE%/firefox/%VERSION%/tracking-protection/start/");
|
||||
|
@ -134,11 +134,17 @@ var ContentBlocking = {
|
||||
PREF_ANIMATIONS_ENABLED: "toolkit.cosmeticAnimations.enabled",
|
||||
PREF_REPORT_BREAKAGE_ENABLED: "browser.contentblocking.reportBreakage.enabled",
|
||||
PREF_REPORT_BREAKAGE_URL: "browser.contentblocking.reportBreakage.url",
|
||||
PREF_INTRO_COUNT_CB: "browser.contentblocking.introCount",
|
||||
PREF_INTRO_COUNT_TP: "privacy.trackingprotection.introCount",
|
||||
content: null,
|
||||
icon: null,
|
||||
activeTooltipText: null,
|
||||
disabledTooltipText: null,
|
||||
|
||||
get prefIntroCount() {
|
||||
return this.contentBlockingUIEnabled ? this.PREF_INTRO_COUNT_CB : this.PREF_INTRO_COUNT_TP;
|
||||
},
|
||||
|
||||
get appMenuLabel() {
|
||||
delete this.appMenuLabel;
|
||||
return this.appMenuLabel = document.getElementById("appMenu-tp-label");
|
||||
@ -431,14 +437,11 @@ var ContentBlocking = {
|
||||
} else if (active && webProgress.isTopLevel) {
|
||||
this.iconBox.setAttribute("animate", "true");
|
||||
|
||||
// Open the tracking protection introduction panel, if applicable.
|
||||
if (TrackingProtection.enabledGlobally) {
|
||||
let introCount = Services.prefs.getIntPref("privacy.trackingprotection.introCount");
|
||||
if (introCount < this.MAX_INTROS) {
|
||||
Services.prefs.setIntPref("privacy.trackingprotection.introCount", ++introCount);
|
||||
Services.prefs.savePrefFile(null);
|
||||
this.showIntroPanel();
|
||||
}
|
||||
let introCount = Services.prefs.getIntPref(this.prefIntroCount);
|
||||
if (introCount < this.MAX_INTROS) {
|
||||
Services.prefs.setIntPref(this.prefIntroCount, ++introCount);
|
||||
Services.prefs.savePrefFile(null);
|
||||
this.showIntroPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,11 +498,8 @@ var ContentBlocking = {
|
||||
},
|
||||
|
||||
dontShowIntroPanelAgain() {
|
||||
// This function may be called in private windows, but it does not change
|
||||
// any preference unless Tracking Protection is enabled globally.
|
||||
if (TrackingProtection.enabledGlobally) {
|
||||
Services.prefs.setIntPref("privacy.trackingprotection.introCount",
|
||||
this.MAX_INTROS);
|
||||
if (!PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser)) {
|
||||
Services.prefs.setIntPref(this.prefIntroCount, this.MAX_INTROS);
|
||||
Services.prefs.savePrefFile(null);
|
||||
}
|
||||
},
|
||||
@ -508,13 +508,39 @@ var ContentBlocking = {
|
||||
let brandBundle = document.getElementById("bundle_brand");
|
||||
let brandShortName = brandBundle.getString("brandShortName");
|
||||
|
||||
let introTitle;
|
||||
let introDescription;
|
||||
// This will be sent to the onboarding website to let them know which
|
||||
// UI variation we're showing.
|
||||
let variation;
|
||||
|
||||
if (this.contentBlockingUIEnabled) {
|
||||
introTitle = gNavigatorBundle.getFormattedString("contentBlocking.intro.title",
|
||||
[brandShortName]);
|
||||
// We show a different UI tour variation for users that already have TP
|
||||
// enabled globally.
|
||||
if (TrackingProtection.enabledGlobally) {
|
||||
introDescription = gNavigatorBundle.getString("contentBlocking.intro.v2.description");
|
||||
variation = 2;
|
||||
} else {
|
||||
introDescription = gNavigatorBundle.getFormattedString("contentBlocking.intro.v1.description",
|
||||
[brandShortName]);
|
||||
variation = 1;
|
||||
}
|
||||
} else {
|
||||
introTitle = gNavigatorBundle.getString("trackingProtection.intro.title");
|
||||
introDescription = gNavigatorBundle.getFormattedString("trackingProtection.intro.description2",
|
||||
[brandShortName]);
|
||||
variation = 0;
|
||||
}
|
||||
|
||||
let openStep2 = () => {
|
||||
// When the user proceeds in the tour, adjust the counter to indicate that
|
||||
// the user doesn't need to see the intro anymore.
|
||||
this.dontShowIntroPanelAgain();
|
||||
|
||||
let nextURL = Services.urlFormatter.formatURLPref("privacy.trackingprotection.introURL") +
|
||||
"?step=2&newtab=true";
|
||||
`?step=2&newtab=true&variation=${variation}`;
|
||||
switchToTabHavingURI(nextURL, true, {
|
||||
// Ignore the fragment in case the intro is shown on the tour page
|
||||
// (e.g. if the user manually visited the tour or clicked the link from
|
||||
@ -538,11 +564,7 @@ var ContentBlocking = {
|
||||
|
||||
let panelTarget = await UITour.getTarget(window, "trackingProtection");
|
||||
UITour.initForBrowser(gBrowser.selectedBrowser, window);
|
||||
UITour.showInfo(window, panelTarget,
|
||||
gNavigatorBundle.getString("trackingProtection.intro.title"),
|
||||
gNavigatorBundle.getFormattedString("trackingProtection.intro.description2",
|
||||
[brandShortName]),
|
||||
undefined, buttons,
|
||||
UITour.showInfo(window, panelTarget, introTitle, introDescription, undefined, buttons,
|
||||
{ closeButtonCallback: () => this.dontShowIntroPanelAgain() });
|
||||
},
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ support-files =
|
||||
[browser_backgroundTab.js]
|
||||
[browser_closeTab.js]
|
||||
skip-if = (verify && !debug && (os == 'linux'))
|
||||
[browser_contentBlocking.js]
|
||||
[browser_fxa.js]
|
||||
skip-if = debug || asan # updateUI leaks
|
||||
[browser_no_tabs.js]
|
||||
|
136
browser/components/uitour/test/browser_contentBlocking.js
Normal file
136
browser/components/uitour/test/browser_contentBlocking.js
Normal file
@ -0,0 +1,136 @@
|
||||
"use strict";
|
||||
|
||||
const PREF_INTRO_COUNT = "browser.contentblocking.introCount";
|
||||
const PREF_CB_UI_ENABLED = "browser.contentblocking.ui.enabled";
|
||||
const PREF_TP_ENABLED = "privacy.trackingprotection.enabled";
|
||||
const PREF_FB_ENABLED = "browser.fastblock.enabled";
|
||||
const PREF_FB_TIMEOUT = "browser.fastblock.timeout";
|
||||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
|
||||
const TOOLTIP_PANEL = document.getElementById("UITourTooltip");
|
||||
const TOOLTIP_ANCHOR = document.getElementById("tracking-protection-icon-animatable-box");
|
||||
|
||||
var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
Services.prefs.clearUserPref(PREF_CB_UI_ENABLED);
|
||||
Services.prefs.clearUserPref(PREF_TP_ENABLED);
|
||||
Services.prefs.clearUserPref(PREF_FB_ENABLED);
|
||||
Services.prefs.clearUserPref(PREF_FB_TIMEOUT);
|
||||
Services.prefs.clearUserPref(PREF_INTRO_COUNT);
|
||||
});
|
||||
|
||||
function allowOneIntro() {
|
||||
Services.prefs.setIntPref(PREF_INTRO_COUNT, window.ContentBlocking.MAX_INTROS - 1);
|
||||
}
|
||||
|
||||
add_task(async function setup_test() {
|
||||
Services.prefs.setBoolPref(PREF_CB_UI_ENABLED, true);
|
||||
Services.prefs.setBoolPref(PREF_TP_ENABLED, true);
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
});
|
||||
|
||||
add_task(async function test_benignPage() {
|
||||
info("Load a test page not containing tracking elements");
|
||||
allowOneIntro();
|
||||
await BrowserTestUtils.withNewTab(BENIGN_PAGE, async function() {
|
||||
await Assert.rejects(waitForConditionPromise(() => {
|
||||
return BrowserTestUtils.is_visible(TOOLTIP_PANEL);
|
||||
}, "timeout"), /timeout/, "Info panel shouldn't appear on a benign page");
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_tracking() {
|
||||
info("Load a test page containing tracking elements");
|
||||
allowOneIntro();
|
||||
await BrowserTestUtils.withNewTab({gBrowser, url: TRACKING_PAGE}, async function() {
|
||||
await new Promise((resolve, reject) => {
|
||||
waitForPopupAtAnchor(TOOLTIP_PANEL, TOOLTIP_ANCHOR, resolve,
|
||||
"Intro panel should appear");
|
||||
});
|
||||
|
||||
is(Services.prefs.getIntPref(PREF_INTRO_COUNT), window.ContentBlocking.MAX_INTROS, "Check intro count increased");
|
||||
|
||||
let step2URL = Services.urlFormatter.formatURLPref("privacy.trackingprotection.introURL") +
|
||||
"?step=2&newtab=true&variation=2";
|
||||
let buttons = document.getElementById("UITourTooltipButtons");
|
||||
|
||||
info("Click the step text and nothing should happen");
|
||||
let tabCount = gBrowser.tabs.length;
|
||||
await EventUtils.synthesizeMouseAtCenter(buttons.children[0], {});
|
||||
is(gBrowser.tabs.length, tabCount, "Same number of tabs should be open");
|
||||
|
||||
info("Resetting count to test that viewing the tour prevents future panels");
|
||||
allowOneIntro();
|
||||
|
||||
let panelHiddenPromise = promisePanelElementHidden(window, TOOLTIP_PANEL);
|
||||
let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, step2URL);
|
||||
info("Clicking the main button");
|
||||
EventUtils.synthesizeMouseAtCenter(buttons.children[1], {});
|
||||
let tab = await tabPromise;
|
||||
is(Services.prefs.getIntPref(PREF_INTRO_COUNT), window.ContentBlocking.MAX_INTROS,
|
||||
"Check intro count is at the max after opening step 2");
|
||||
is(gBrowser.tabs.length, tabCount + 1, "Tour step 2 tab opened");
|
||||
await panelHiddenPromise;
|
||||
ok(true, "Panel hid when the button was clicked");
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
info("Open another tracking page and make sure we don't show the panel again");
|
||||
await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function() {
|
||||
await Assert.rejects(waitForConditionPromise(() => {
|
||||
return BrowserTestUtils.is_visible(TOOLTIP_PANEL);
|
||||
}, "timeout"), /timeout/, "Info panel shouldn't appear more than MAX_INTROS");
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_fastBlock() {
|
||||
Services.prefs.clearUserPref(PREF_INTRO_COUNT);
|
||||
|
||||
Services.prefs.setBoolPref(PREF_TP_ENABLED, false);
|
||||
Services.prefs.setBoolPref(PREF_FB_ENABLED, true);
|
||||
Services.prefs.setIntPref(PREF_FB_TIMEOUT, 0);
|
||||
|
||||
info("Load a test page containing tracking elements for FastBlock");
|
||||
allowOneIntro();
|
||||
await BrowserTestUtils.withNewTab({gBrowser, url: TRACKING_PAGE}, async function() {
|
||||
await new Promise((resolve, reject) => {
|
||||
waitForPopupAtAnchor(TOOLTIP_PANEL, TOOLTIP_ANCHOR, resolve,
|
||||
"Intro panel should appear");
|
||||
});
|
||||
|
||||
is(Services.prefs.getIntPref(PREF_INTRO_COUNT), window.ContentBlocking.MAX_INTROS, "Check intro count increased");
|
||||
|
||||
let step2URL = Services.urlFormatter.formatURLPref("privacy.trackingprotection.introURL") +
|
||||
"?step=2&newtab=true&variation=1";
|
||||
let buttons = document.getElementById("UITourTooltipButtons");
|
||||
|
||||
info("Click the step text and nothing should happen");
|
||||
let tabCount = gBrowser.tabs.length;
|
||||
await EventUtils.synthesizeMouseAtCenter(buttons.children[0], {});
|
||||
is(gBrowser.tabs.length, tabCount, "Same number of tabs should be open");
|
||||
|
||||
info("Resetting count to test that viewing the tour prevents future panels");
|
||||
allowOneIntro();
|
||||
|
||||
let panelHiddenPromise = promisePanelElementHidden(window, TOOLTIP_PANEL);
|
||||
let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, step2URL);
|
||||
info("Clicking the main button");
|
||||
EventUtils.synthesizeMouseAtCenter(buttons.children[1], {});
|
||||
let tab = await tabPromise;
|
||||
is(Services.prefs.getIntPref(PREF_INTRO_COUNT), window.ContentBlocking.MAX_INTROS,
|
||||
"Check intro count is at the max after opening step 2");
|
||||
is(gBrowser.tabs.length, tabCount + 1, "Tour step 2 tab opened");
|
||||
await panelHiddenPromise;
|
||||
ok(true, "Panel hid when the button was clicked");
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
info("Open another tracking page and make sure we don't show the panel again");
|
||||
await BrowserTestUtils.withNewTab(TRACKING_PAGE, async function() {
|
||||
await Assert.rejects(waitForConditionPromise(() => {
|
||||
return BrowserTestUtils.is_visible(TOOLTIP_PANEL);
|
||||
}, "timeout"), /timeout/, "Info panel shouldn't appear more than MAX_INTROS");
|
||||
});
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const PREF_INTRO_COUNT = "privacy.trackingprotection.introCount";
|
||||
const PREF_CB_ENABLED = "browser.contentblocking.enabled";
|
||||
const PREF_CB_UI_ENABLED = "browser.contentblocking.ui.enabled";
|
||||
const PREF_TP_ENABLED = "privacy.trackingprotection.enabled";
|
||||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
|
||||
@ -12,7 +12,7 @@ var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/Url
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
Services.prefs.clearUserPref(PREF_CB_ENABLED);
|
||||
Services.prefs.clearUserPref(PREF_CB_UI_ENABLED);
|
||||
Services.prefs.clearUserPref(PREF_TP_ENABLED);
|
||||
Services.prefs.clearUserPref(PREF_INTRO_COUNT);
|
||||
});
|
||||
@ -22,7 +22,7 @@ function allowOneIntro() {
|
||||
}
|
||||
|
||||
add_task(async function setup_test() {
|
||||
Services.prefs.setBoolPref(PREF_CB_ENABLED, true);
|
||||
Services.prefs.setBoolPref(PREF_CB_UI_ENABLED, false);
|
||||
Services.prefs.setBoolPref(PREF_TP_ENABLED, true);
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
});
|
||||
@ -54,7 +54,7 @@ add_task(async function test_trackingPages() {
|
||||
is(Services.prefs.getIntPref(PREF_INTRO_COUNT), window.ContentBlocking.MAX_INTROS, "Check intro count increased");
|
||||
|
||||
let step2URL = Services.urlFormatter.formatURLPref("privacy.trackingprotection.introURL") +
|
||||
"?step=2&newtab=true";
|
||||
"?step=2&newtab=true&variation=0";
|
||||
let buttons = document.getElementById("UITourTooltipButtons");
|
||||
|
||||
info("Click the step text and nothing should happen");
|
||||
|
@ -539,6 +539,12 @@ trackingProtection.intro.description2=When you see the shield, %S is blocking so
|
||||
trackingProtection.intro.step1of3=1 of 3
|
||||
trackingProtection.intro.nextButton.label=Next
|
||||
|
||||
# LOCALIZATION NOTE (contentBlocking.intro.title): %S is brandShortName.
|
||||
contentBlocking.intro.title=New in %S: Content Blocking
|
||||
# LOCALIZATION NOTE (contentBlocking.v1.intro.description): %S is brandShortName.
|
||||
contentBlocking.intro.v1.description=When you see the shield, %S is blocking parts of the page that can slow your browsing or track you online.
|
||||
contentBlocking.intro.v2.description=The privacy benefits of Tracking Protection are now just one part of content blocking. When you see the shield, content blocking is on.
|
||||
|
||||
trackingProtection.toggle.enable.tooltip=Enable Tracking Protection
|
||||
trackingProtection.toggle.disable.tooltip=Disable Tracking Protection
|
||||
trackingProtection.toggle.enable.pbmode.tooltip=Enable Tracking Protection in Private Browsing
|
||||
|
Loading…
Reference in New Issue
Block a user