Bug 1780429 - Display Pin Private Browsing Promo based off Pref r=emcminn,flod

Differential Revision: https://phabricator.services.mozilla.com/D152663
This commit is contained in:
negin 2022-08-09 01:38:28 +00:00
Родитель 6a37a2ab93
Коммит 98bc944a7f
7 изменённых файлов: 144 добавлений и 3 удалений

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

@ -1948,7 +1948,7 @@ pref("browser.promo.focus.disallowed_regions", "cn");
pref("browser.promo.focus.enabled", true);
// Default to enabling pin promos to be shown where allowed.
pref("browser.promo.pin.enabled", true);
pref("browser.promo.pin.enabled", false);
// Comma separated string of mozilla vpn supported platforms.
pref("browser.contentblocking.report.vpn_platforms", "win,mac,linux");

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

@ -450,6 +450,76 @@ const ONBOARDING_MESSAGES = () => [
},
targeting: "true",
},
{
id: "PB_NEWTAB_PIN_PROMO",
template: "pb_newtab",
type: "default",
groups: ["pbNewtab"],
content: {
infoBody: "fluent:about-private-browsing-info-description-simplified",
infoEnabled: true,
infoIcon: "chrome://global/skin/icons/indicator-private-browsing.svg",
infoLinkText: "fluent:about-private-browsing-learn-more-link",
infoTitle: "",
infoTitleEnabled: false,
promoEnabled: true,
promoType: "PIN",
promoHeader: "fluent:about-private-browsing-pin-promo-header",
promoImageLarge:
"chrome://browser/content/assets/private-promo-asset.svg",
promoLinkText: "fluent:about-private-browsing-pin-promo-link-text",
promoLinkType: "button",
promoSectionStyle: "below-search",
promoTitle: "fluent:about-private-browsing-pin-promo-title",
promoTitleEnabled: true,
promoButton: {
action: {
type: "MULTI_ACTION",
data: {
actions: [
{
type: "SET_PREF",
data: {
pref: {
name:
"browser.privacySegmentation.windowSeparation.enabled",
value: true,
},
},
},
{
type: "PIN_FIREFOX_TO_TASKBAR",
data: {
privatePin: true,
},
},
{
type: "BLOCK_MESSAGE",
data: {
id: "PB_NEWTAB_PIN_PROMO",
},
},
{
type: "OPEN_ABOUT_PAGE",
data: { args: "privatebrowsing", where: "current" },
},
],
},
},
},
},
priority: 3,
frequency: {
custom: [
{
cap: 3,
period: 604800000, // Max 3 per week
},
],
lifetime: 12,
},
targeting: "doesAppNeedPrivatePin",
},
];
const OnboardingMessageProvider = {

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

@ -662,7 +662,7 @@ const MESSAGES = () => [
frequency: { lifetime: 3 },
},
{
id: "PB_NEWTAB_PIN_PROMO",
id: "PB_PIN_PROMO",
template: "pb_newtab",
groups: ["pbNewtab"],
content: {
@ -704,7 +704,7 @@ const MESSAGES = () => [
{
type: "BLOCK_MESSAGE",
data: {
id: "PB_NEWTAB_PIN_PROMO",
id: "PB_PIN_PROMO",
},
},
{

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

@ -21,6 +21,7 @@ support-files =
[browser_privatebrowsing_DownloadLastDirWithCPS.js]
[browser_privatebrowsing_about_default_promo.js]
[browser_privatebrowsing_about_default_pin_promo.js]
[browser_privatebrowsing_about_focus_promo.js]
[browser_privatebrowsing_about_nimbus.js]
[browser_privatebrowsing_about_nimbus_messaging.js]

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

@ -0,0 +1,60 @@
/* 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/. */
/* import-globals-from head.js */
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
add_setup(async function() {
ASRouter.resetMessageState();
await SpecialPowers.pushPrefEnv({
set: [["browser.promo.pin.enabled", true]],
});
await ASRouter.onPrefChange();
});
add_task(async function test_pin_promo() {
const sandbox = sinon.createSandbox();
// Stub out the doesAppNeedPin to true so that Pin Promo targeting evaluates true
const { ShellService } = ChromeUtils.import(
"resource:///modules/ShellService.jsm"
);
sandbox
.stub(ShellService, "doesAppNeedPin")
.withArgs(true)
.returns(true);
registerCleanupFunction(async () => {
ASRouter.resetMessageState();
sandbox.restore();
});
let { win: win1, tab: tab1 } = await openTabAndWaitForRender();
await SpecialPowers.spawn(tab1, [], async function() {
const promoContainer = content.document.querySelector(".promo");
const promoHeader = content.document.getElementById("promo-header");
ok(promoContainer, "Pin promo is shown");
is(
promoHeader.textContent,
"Private browsing freedom in one click",
"Correct default values are shown"
);
});
let { win: win2 } = await openTabAndWaitForRender();
let { win: win3 } = await openTabAndWaitForRender();
let { win: win4, tab: tab4 } = await openTabAndWaitForRender();
await SpecialPowers.spawn(tab4, [], async function() {
is(
content.document.getElementById(".private-browsing-promo-link"),
null,
"should no longer render the promo after 3 impressions"
);
});
await BrowserTestUtils.closeWindow(win1);
await BrowserTestUtils.closeWindow(win2);
await BrowserTestUtils.closeWindow(win3);
await BrowserTestUtils.closeWindow(win4);
});

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

@ -54,3 +54,12 @@ about-private-browsing-search-banner-close-button =
about-private-browsing-promo-close-button =
.title = Close
## Strings used in a “pin promotion” message, which prompts users to pin a private window
about-private-browsing-pin-promo-header = Private browsing freedom in one click
about-private-browsing-pin-promo-link-text = { PLATFORM() ->
[macos] Keep in Dock
*[other] Pin to taskbar
}
about-private-browsing-pin-promo-title = No saved cookies or history, right from your desktop. Browse like no ones watching.

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

@ -188,6 +188,7 @@ add_task(async function test_shouldShowFocusPromo() {
});
add_task(async function test_shouldShowPinPromo() {
Preferences.set("browser.promo.pin.enabled", true);
// Show pin promo type by default when promo is enabled
Assert.ok(BrowserUtils.shouldShowPromo(BrowserUtils.PromoType.PIN));