Backed out 4 changesets (bug 1853698, bug 1853763, bug 1846498) for causing mochitest failures on browser_privatebrowsing_resetPBM.js & browser_1089591_still_customizable_after_reset CLOSED TREE

Backed out changeset 15945b5a02c7 (bug 1853698)
Backed out changeset b396820a7a46 (bug 1853763)
Backed out changeset 535f72d66f52 (bug 1846498)
Backed out changeset 439c5b41701a (bug 1846498)
This commit is contained in:
Sandor Molnar
2023-09-26 16:53:51 +03:00
parent 56e89c41d3
commit a389d668fb
21 changed files with 8 additions and 992 deletions

View File

@@ -2879,9 +2879,3 @@ pref("cookiebanners.ui.desktop.cfrVariant", 0);
#ifdef NIGHTLY_BUILD
pref("dom.security.credentialmanagement.identity.enabled", true);
#endif
// Reset Private Browsing Session feature
pref("browser.privatebrowsing.resetPBM.enabled", false);
// Whether the reset private browsing panel should ask for confirmation before
// performing the clear action.
pref("browser.privatebrowsing.resetPBM.showConfirmationDialog", true);

View File

@@ -687,27 +687,4 @@
onclick="ToolbarPanelHub.toggleWhatsNewPref(event)"
data-l10n-id="whatsnew-panel-footer-checkbox"/>
</panelview>
<panelview id="reset-pbm-panel" class="PanelUI-subView">
<hbox id="reset-pbm-panel-container">
<hbox id="reset-pbm-panel-header">
<description data-l10n-id="reset-pbm-panel-heading"/>
</hbox>
<description id="reset-pbm-panel-description" data-l10n-id="reset-pbm-panel-description"/>
<checkbox id="reset-pbm-panel-checkbox" data-l10n-id="reset-pbm-panel-always-ask-checkbox"/>
<html:moz-button-group id="reset-pbm-panel-footer" class="panel-footer">
<button id="reset-pbm-panel-cancel-button"
class="panel-footer-button"
data-l10n-id="reset-pbm-panel-cancel-button"
oncommand="ResetPBMPanel.onCancel(this)"></button>
<button slot="primary"
id="reset-pbm-panel-confirm-button"
class="panel-footer-button"
data-l10n-id="reset-pbm-panel-confirm-button"
oncommand="ResetPBMPanel.onConfirm(this)"></button>
</html:moz-button-group>
</hbox>
</panelview>
</html:template>

View File

@@ -63,7 +63,6 @@ ChromeUtils.defineESModuleGetters(this, {
PromiseUtils: "resource://gre/modules/PromiseUtils.sys.mjs",
PromptUtils: "resource://gre/modules/PromptUtils.sys.mjs",
ReaderMode: "resource://gre/modules/ReaderMode.sys.mjs",
ResetPBMPanel: "resource:///modules/ResetPBMPanel.sys.mjs",
SafeBrowsing: "resource://gre/modules/SafeBrowsing.sys.mjs",
Sanitizer: "resource:///modules/Sanitizer.sys.mjs",
SaveToPocket: "chrome://pocket/content/SaveToPocket.sys.mjs",
@@ -9740,7 +9739,6 @@ var ConfirmationHint = {
* An object with the following optional properties:
* - event (DOM event): The event that triggered the feedback
* - descriptionId (string): message ID of the description text
* - position (string): position of the panel relative to the anchor.
*
*/
show(anchor, messageId, options = {}) {
@@ -9786,7 +9784,7 @@ var ConfirmationHint = {
);
this._panel.openPopup(anchor, {
position: options.position ?? "bottomcenter topleft",
position: "bottomcenter topleft",
triggerEvent: options.event,
});
},

View File

@@ -44,17 +44,17 @@ function AddOldMenuSideButtons() {
CustomizableUI.addWidgetToArea(
"library-button",
"nav-bar",
CustomizableUI.getWidgetIdsInArea("nav-bar").length - 3
CustomizableUI.getWidgetIdsInArea("nav-bar").length - 2
);
CustomizableUI.addWidgetToArea(
"sidebar-button",
"nav-bar",
CustomizableUI.getWidgetIdsInArea("nav-bar").length - 3
CustomizableUI.getWidgetIdsInArea("nav-bar").length - 2
);
CustomizableUI.addWidgetToArea(
"unified-extensions-button",
"nav-bar",
CustomizableUI.getWidgetIdsInArea("nav-bar").length - 3
CustomizableUI.getWidgetIdsInArea("nav-bar").length - 2
);
}

View File

@@ -69,7 +69,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
RemoteSecuritySettings:
"resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs",
RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
ResetPBMPanel: "resource:///modules/ResetPBMPanel.sys.mjs",
SafeBrowsing: "resource://gre/modules/SafeBrowsing.sys.mjs",
Sanitizer: "resource:///modules/Sanitizer.sys.mjs",
SaveToPocket: "chrome://pocket/content/SaveToPocket.sys.mjs",
@@ -1395,8 +1394,6 @@ BrowserGlue.prototype = {
lazy.SaveToPocket.init();
lazy.ResetPBMPanel.init();
AboutHomeStartupCache.init();
Services.obs.notifyObservers(null, "browser-ui-startup-complete");

View File

@@ -57,7 +57,7 @@ const kSubviewEvents = ["ViewShowing", "ViewHiding"];
* The current version. We can use this to auto-add new default widgets as necessary.
* (would be const but isn't because of testing purposes)
*/
var kVersion = 20;
var kVersion = 19;
/**
* Buttons removed from built-ins by version they were removed. kVersion must be
@@ -249,7 +249,6 @@ var CustomizableUIInternal = {
"downloads-button",
AppConstants.MOZ_DEV_EDITION ? "developer-button" : null,
"fxa-toolbar-menu-button",
"reset-pbm-toolbar-button",
].filter(name => name);
this.registerArea(
@@ -659,18 +658,6 @@ var CustomizableUIInternal = {
...addonsPlacements,
];
}
// Add the PBM reset button as the right most button item
if (currentVersion < 20) {
let navbarPlacements = gSavedState.placements[CustomizableUI.AREA_NAVBAR];
// Place the button as the first item to the left of the hamburger menu
if (
navbarPlacements &&
!navbarPlacements.includes("reset-pbm-toolbar-button")
) {
navbarPlacements.push("reset-pbm-toolbar-button");
}
}
},
_updateForNewProtonVersion() {

View File

@@ -151,7 +151,6 @@ function test() {
"urlbar-container",
"downloads-button",
"fxa-toolbar-menu-button",
"reset-pbm-toolbar-button",
],
"Nav-bar placements should be correct."
);
@@ -177,11 +176,7 @@ function test() {
CustomizableUIInternal._updateForNewVersion();
Assert.deepEqual(
getSavedStatePlacements("nav-bar"),
oldNavbarPlacements.concat([
"downloads-button",
"fxa-toolbar-menu-button",
"reset-pbm-toolbar-button",
]),
oldNavbarPlacements.concat(["downloads-button", "fxa-toolbar-menu-button"]),
"Downloads button inserted in navbar"
);
Assert.deepEqual(
@@ -199,11 +194,7 @@ function test() {
CustomizableUIInternal._updateForNewVersion();
Assert.deepEqual(
getSavedStatePlacements("nav-bar"),
oldNavbarPlacements.concat([
"downloads-button",
"fxa-toolbar-menu-button",
"reset-pbm-toolbar-button",
]),
oldNavbarPlacements.concat(["downloads-button", "fxa-toolbar-menu-button"]),
"Downloads button reinserted in navbar"
);
@@ -227,7 +218,6 @@ function test() {
"downloads-button",
"other-widget",
"fxa-toolbar-menu-button",
"reset-pbm-toolbar-button",
];
Assert.deepEqual(
getSavedStatePlacements("nav-bar"),

View File

@@ -98,7 +98,6 @@ add_task(async function test_no_extensions() {
"spring",
"urlbar-container",
"save-to-pocket-button",
"reset-pbm-toolbar-button",
],
"toolbar-menubar": [
"home-button",
@@ -145,7 +144,6 @@ add_task(async function test_existing_browser_actions_no_movement() {
"spring",
"urlbar-container",
"save-to-pocket-button",
"reset-pbm-toolbar-button",
],
"toolbar-menubar": [
"home-button",
@@ -188,7 +186,6 @@ add_task(async function test_migrate_extension_buttons() {
"spring",
"urlbar-container",
"save-to-pocket-button",
"reset-pbm-toolbar-button",
],
"toolbar-menubar": [
"home-button",
@@ -247,7 +244,6 @@ add_task(async function test_migrate_extension_buttons_no_overwrite() {
"spring",
"urlbar-container",
"save-to-pocket-button",
"reset-pbm-toolbar-button",
],
"toolbar-menubar": [
"home-button",
@@ -312,7 +308,6 @@ add_task(async function test_migrate_extension_buttons_elsewhere() {
"urlbar-container",
"ext3-browser-action",
"save-to-pocket-button",
"reset-pbm-toolbar-button",
"ext4-browser-action",
],
"toolbar-menubar": [

View File

@@ -1,235 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
/* eslint-env mozilla/browser-window */
/**
* ResetPBMPanel contains the logic for the restart private browsing action.
* The feature is exposed via a toolbar button in private browsing windows. It
* allows users to restart their private browsing session, clearing all site
* data and closing all PBM tabs / windows.
* The toolbar button for triggering the panel is only shown in private browsing
* windows or if permanent private browsing mode is enabled.
*/
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const ENABLED_PREF = "browser.privatebrowsing.resetPBM.enabled";
const SHOW_CONFIRM_DIALOG_PREF =
"browser.privatebrowsing.resetPBM.showConfirmationDialog";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
CustomizableUI: "resource:///modules/CustomizableUI.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
});
export const ResetPBMPanel = {
// Button and view config for CustomizableUI.
_widgetConfig: null,
/**
* Initialize the widget code depending on pref state.
*/
init() {
// Populate _widgetConfig during init to defer (lazy) CustomizableUI import.
this._widgetConfig ??= {
id: "reset-pbm-toolbar-button",
l10nId: "reset-pbm-toolbar-button",
type: "view",
viewId: "reset-pbm-panel",
defaultArea: lazy.CustomizableUI.AREA_NAVBAR,
onViewShowing(aEvent) {
ResetPBMPanel.onViewShowing(aEvent);
},
};
if (this._enabled) {
lazy.CustomizableUI.createWidget(this._widgetConfig);
} else {
lazy.CustomizableUI.destroyWidget(this._widgetConfig.id);
}
},
/**
* Called when the reset pbm panelview is showing as the result of clicking
* the toolbar button.
*/
async onViewShowing(event) {
let triggeringWindow = event.target.ownerGlobal;
// We may skip the confirmation panel if disabled via pref.
if (!this._shouldConfirmClear) {
// Prevent the panel from showing up.
event.preventDefault();
// If the action is triggered from the overflow menu make sure that the
// panel gets hidden.
lazy.CustomizableUI.hidePanelForNode(event.target);
// Trigger the restart action.
await this._restartPBM(triggeringWindow);
Glean.privateBrowsingResetPbm.resetAction.record({ did_confirm: false });
return;
}
// Before the panel is shown, update checkbox state based on pref.
this._rememberCheck(triggeringWindow).checked = this._shouldConfirmClear;
Glean.privateBrowsingResetPbm.confirmPanel.record({
action: "show",
reason: "toolbar-btn",
});
},
/**
* Handles the confirmation panel cancel button.
* @param {MozButton} button - Cancel button that triggered the action.
*/
onCancel(button) {
if (!this._enabled) {
throw new Error("Not initialized.");
}
lazy.CustomizableUI.hidePanelForNode(button);
Glean.privateBrowsingResetPbm.confirmPanel.record({
action: "hide",
reason: "cancel-btn",
});
},
/**
* Handles the confirmation panel confirm button which triggers the clear
* action.
* @param {MozButton} button - Confirm button that triggered the action.
*/
async onConfirm(button) {
if (!this._enabled) {
throw new Error("Not initialized.");
}
let triggeringWindow = button.ownerGlobal;
// Write the checkbox state to pref. Only do this when the user
// confirms.
// Setting this pref to true means there is no way to see the panel
// again other than flipping the pref back via about:config or resetting
// the profile. This is by design.
Services.prefs.setBoolPref(
SHOW_CONFIRM_DIALOG_PREF,
this._rememberCheck(triggeringWindow).checked
);
lazy.CustomizableUI.hidePanelForNode(button);
Glean.privateBrowsingResetPbm.confirmPanel.record({
action: "hide",
reason: "confirm-btn",
});
// Clear the private browsing session.
await this._restartPBM(triggeringWindow);
Glean.privateBrowsingResetPbm.resetAction.record({ did_confirm: true });
},
/**
* Restart the private browsing session. This is achieved by closing all other
* PBM windows, closing all tabs in the current window but
* about:privatebrowsing and triggering PBM data clearing.
*
* @param {ChromeWindow} triggeringWindow - The (private browsing) chrome window which
* triggered the restart action.
*/
async _restartPBM(triggeringWindow) {
if (
!triggeringWindow ||
!lazy.PrivateBrowsingUtils.isWindowPrivate(triggeringWindow)
) {
throw new Error("Invalid triggering window.");
}
// 1. Close all PBM windows but the current one.
for (let w of Services.ww.getWindowEnumerator()) {
if (
w != triggeringWindow &&
lazy.PrivateBrowsingUtils.isWindowPrivate(w)
) {
// This suppresses confirmation dialogs like the beforeunload
// handler and the tab close warning.
// Skip over windows that don't have the closeWindow method.
w.closeWindow?.(true, null, "restart-pbm");
}
}
// 2. For the current PBM window create a new tab which will be used for
// the initial newtab page.
let newTab = triggeringWindow.gBrowser.addTab(
triggeringWindow.BROWSER_NEW_TAB_URL,
{
triggeringPrincipal:
Services.scriptSecurityManager.getSystemPrincipal(),
}
);
if (!newTab) {
throw new Error("Could not open new tab.");
}
// 3. Close all other tabs.
triggeringWindow.gBrowser.removeAllTabsBut(newTab, {
skipPermitUnload: true,
animate: false,
});
// 4. Clear private browsing data.
// TODO: this doesn't wait for data to be cleared. This is probably
// fine since PBM data is stored in memory and can be cleared quick
// enough. The mechanism is brittle though, some callers still
// perform clearing async. Bug 1846494 will address this.
Services.obs.notifyObservers(null, "last-pb-context-exited");
// Once clearing is complete show a toast message.
let toolbarButton = this._toolbarButton(triggeringWindow);
// Find the anchor used for the confirmation hint panel. If the toolbar
// button is in the overflow menu we can't use it as an anchor. Instead we
// anchor off the overflow button as indicated by cui-anchorid.
let anchor;
let anchorID = toolbarButton.getAttribute("cui-anchorid");
if (anchorID) {
anchor = triggeringWindow.document.getElementById(anchorID);
}
triggeringWindow.ConfirmationHint.show(
anchor ?? toolbarButton,
"reset-pbm-panel-complete",
{ position: "bottomright topright" }
);
},
_toolbarButton(win) {
return lazy.CustomizableUI.getWidget(this._widgetConfig.id).forWindow(win)
.node;
},
_rememberCheck(win) {
return win.document.getElementById("reset-pbm-panel-checkbox");
},
};
XPCOMUtils.defineLazyPreferenceGetter(
ResetPBMPanel,
"_enabled",
ENABLED_PREF,
false,
// On pref change update the init state.
ResetPBMPanel.init.bind(ResetPBMPanel)
);
XPCOMUtils.defineLazyPreferenceGetter(
ResetPBMPanel,
"_shouldConfirmClear",
SHOW_CONFIRM_DIALOG_PREF,
true
);

View File

@@ -1,50 +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/.
# Adding a new metric? We have docs for that!
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html
---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
$tags:
- 'Firefox :: Private Browsing'
private_browsing.reset_pbm:
confirm_panel:
type: event
description: >
Confirm panel show / hide event.
extra_keys:
action:
type: string
description: Whether the panel was hidden or shown.
reason:
type: string
description: Reason for the action.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1853698
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1853698#c3
data_sensitivity:
- interaction
notification_emails:
- pbz@mozilla.com
expires: never
reset_action:
type: event
description: >
Dispatched whenever PBM is restarted / reset via the resetPBM feature.
extra_keys:
did_confirm:
type: boolean
description: Whether the user confirmed the reset action via the confirmation dialog.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1853698
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1853698#c3
data_sensitivity:
- interaction
notification_emails:
- pbz@mozilla.com
expires: never

View File

@@ -10,9 +10,5 @@ BROWSER_CHROME_MANIFESTS += [
JAR_MANIFESTS += ["jar.mn"]
EXTRA_JS_MODULES += [
"ResetPBMPanel.sys.mjs",
]
with Files("**"):
BUG_COMPONENT = ("Firefox", "Private Browsing")

View File

@@ -106,8 +106,6 @@ skip-if = ["verify"]
["browser_privatebrowsing_rememberprompt.js"]
tags = "geolocation xr"
["browser_privatebrowsing_resetPBM.js"]
["browser_privatebrowsing_sidebar.js"]
["browser_privatebrowsing_theming.js"]

View File

@@ -1,561 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const PREF_ID_ALWAYS_ASK =
"browser.privatebrowsing.resetPBM.showConfirmationDialog";
const SELECTOR_TOOLBAR_BUTTON = "#reset-pbm-toolbar-button";
const SELECTOR_PANELVIEW = "panel #reset-pbm-panel";
const SELECTOR_PANEL_HEADING = "#reset-pbm-panel-header > description";
const SELECTOR_PANEL_DESCRIPTION = "#reset-pbm-panel-description";
const SELECTOR_PANEL_CHECKBOX = "#reset-pbm-panel-checkbox";
const SELECTOR_PANEL_CONFIRM_BTN = "#reset-pbm-panel-confirm-button";
const SELECTOR_PANEL_CANCEL_BTN = "#reset-pbm-panel-cancel-button";
const SELECTOR_PANEL_COMPLETION_TOAST = "#confirmation-hint";
/**
* Wait for the reset pbm confirmation panel to open. May also be called if the
* panel is already open.
* @param {ChromeWindow} win - Chrome window in which the panel is embedded.
* @returns {Promise} - Promise which resolves once the panel has been shown.
* Resolves directly if the panel is already visible.
*/
async function waitForConfirmPanelShow(win) {
// Check for the panel, if it's not present yet wait for it to be inserted.
let panelview = win.document.querySelector(SELECTOR_PANELVIEW);
if (!panelview) {
let navToolbox = win.document.getElementById("navigator-toolbox");
await BrowserTestUtils.waitForMutationCondition(
navToolbox,
{ childList: true, subtree: true },
() => {
panelview = win.document.querySelector(SELECTOR_PANELVIEW);
return !!panelview;
}
);
}
// Panel already visible, we can exit early.
if (BrowserTestUtils.is_visible(panelview)) {
return;
}
// Wait for panel shown event.
await BrowserTestUtils.waitForEvent(panelview.closest("panel"), "popupshown");
}
/**
* Hides the completion toast which is shown after the reset action has been
* completed.
* @param {ChromeWindow} win - Chrome window the toast is shown in.
*/
async function hideCompletionToast(win) {
let promiseHidden = BrowserTestUtils.waitForEvent(
win.ConfirmationHint._panel,
"popuphidden"
);
win.ConfirmationHint._panel.hidePopup();
await promiseHidden;
}
/**
* Trigger the reset pbm toolbar button which may open the confirm panel in the
* given window.
* @param {nsIDOMWindow} win - PBM window to trigger the button in.
* @param {boolean} [expectPanelOpen] - After the button action: whether the
* panel is expected to open (true) or remain closed (false).
* @returns {Promise} - Promise which resolves once the button has been
* triggered and, if applicable, the panel has been opened.
*/
async function triggerResetBtn(win, expectPanelOpen = true) {
Assert.ok(
PrivateBrowsingUtils.isWindowPrivate(win),
"Window to open panel is in PBM."
);
let shownPromise;
if (expectPanelOpen) {
shownPromise = waitForConfirmPanelShow(win);
}
await BrowserTestUtils.synthesizeMouseAtCenter(
SELECTOR_TOOLBAR_BUTTON,
{},
win.browsingContext
);
// Promise may not be defined at this point in which case this is a no-op.
await shownPromise;
}
/**
* Provides a promise that resolves once the reset confirmation panel has been hidden.
* @param nsIDOMWindow win - Chrome window that has the panel.
* @returns {Promise}
*/
function waitForConfirmPanelHidden(win) {
return BrowserTestUtils.waitForEvent(
win.document.querySelector(SELECTOR_PANELVIEW).closest("panel"),
"popuphidden"
);
}
/**
* Provides a promise that resolves once the completion toast has been shown.
* @param nsIDOMWindow win - Chrome window that has the panel.
* @returns {Promise}
*/
function waitForCompletionToastShown(win) {
// Init the confirmation hint panel so we can listen for show events.
win.ConfirmationHint._ensurePanel();
return BrowserTestUtils.waitForEvent(
win.document.querySelector(SELECTOR_PANEL_COMPLETION_TOAST),
"popupshown"
);
}
/**
* Wait for private browsing data clearing to be triggered.
* Clearing is not guaranteed to be done at this point. Bug 1846494 will add a
* promise based mechanism and potentially a new triggering method for clearing,
* at which point this helper should be updated.
* @returns {Promise} Promise which resolves when the last-pb-context-exited
* message has been dispatched.
*/
function waitForPBMDataClear() {
return TestUtils.topicObserved("last-pb-context-exited");
}
/**
* Test panel visibility.
* @param {nsIDOMWindow} win - Chrome window which is the parent of the panel.
* @param {string} selector - Query selector for the panel.
* @param {boolean} expectVisible - Whether the panel should be visible (true) or invisible or not present (false).
*/
function assertPanelVisibility(win, selector, expectVisible) {
let panelview = win.document.querySelector(selector);
if (expectVisible) {
Assert.ok(panelview, `Panelview element ${selector} should exist.`);
Assert.ok(
BrowserTestUtils.is_visible(panelview),
`Panelview ${selector} should be visible.`
);
return;
}
Assert.ok(
!panelview || !BrowserTestUtils.is_visible(panelview),
`Panelview ${selector} should be invisible or non-existent.`
);
}
function transformGleanEvents(events) {
if (!events) {
return [];
}
return events.map(e => ({ ...e.extra }));
}
function assertTelemetry(expectedConfirmPanel, expectedResetAction, message) {
info(message);
let confirmPanelEvents = transformGleanEvents(
Glean.privateBrowsingResetPbm.confirmPanel.testGetValue()
);
Assert.deepEqual(
confirmPanelEvents,
expectedConfirmPanel,
"confirmPanel events should match."
);
let resetActionEvents = transformGleanEvents(
Glean.privateBrowsingResetPbm.resetAction.testGetValue()
);
Assert.deepEqual(
resetActionEvents,
expectedResetAction,
"resetAction events should match."
);
}
/**
* Tests that the reset button is only visible in private browsing windows and
* when the feature is enabled.
*/
add_task(async function test_toolbar_button_visibility() {
assertTelemetry([], [], "No glean events initially.");
for (let isEnabled of [false, true]) {
await SpecialPowers.pushPrefEnv({
set: [["browser.privatebrowsing.resetPBM.enabled", isEnabled]],
});
info(
"Test that the toolbar button is never visible in a normal browsing window."
);
let toolbarButtonNormalBrowsing = document.querySelector(
SELECTOR_TOOLBAR_BUTTON
);
Assert.equal(
!!toolbarButtonNormalBrowsing,
isEnabled,
"Normal browsing toolbar button element exists, depending on enabled pref state."
);
if (toolbarButtonNormalBrowsing) {
Assert.ok(
!BrowserTestUtils.is_visible(toolbarButtonNormalBrowsing),
"Toolbar button is not visible in normal browsing"
);
}
info(
"Test that the toolbar button is visible in a private browsing window, depending on enabled pref state."
);
let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
let toolbarButtonPrivateBrowsing = privateWindow.document.querySelector(
SELECTOR_TOOLBAR_BUTTON
);
Assert.equal(
!!toolbarButtonPrivateBrowsing,
isEnabled,
"Private browsing toolbar button element exists, depending on enabled pref state."
);
if (toolbarButtonPrivateBrowsing) {
Assert.equal(
BrowserTestUtils.is_visible(toolbarButtonPrivateBrowsing),
isEnabled,
"Toolbar button is visible in private browsing if enabled."
);
}
await BrowserTestUtils.closeWindow(privateWindow);
await SpecialPowers.popPrefEnv();
}
assertTelemetry([], [], "No glean events after test.");
});
/**
* Tests the panel UI, the 'always ask' checkbox and the confirm and cancel
* actions.
*/
add_task(async function test_panel() {
assertTelemetry([], [], "No glean events initially.");
await SpecialPowers.pushPrefEnv({
set: [["browser.privatebrowsing.resetPBM.enabled", true]],
});
let privateWin = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
// Panel does either not exist (because it's lazy and hasn't been opened yet),
// or it is invisible.
assertPanelVisibility(privateWin, SELECTOR_PANELVIEW, false);
assertPanelVisibility(privateWin, SELECTOR_PANEL_COMPLETION_TOAST, false);
info("Open the panel.");
await triggerResetBtn(privateWin);
assertTelemetry(
[{ action: "show", reason: "toolbar-btn" }],
[],
"There should be a panel show event."
);
info("Check that all expected elements are present and visible.");
[
SELECTOR_PANEL_HEADING,
SELECTOR_PANEL_DESCRIPTION,
SELECTOR_PANEL_CHECKBOX,
SELECTOR_PANEL_CONFIRM_BTN,
SELECTOR_PANEL_CANCEL_BTN,
].forEach(elSelector => {
let el = privateWin.document.querySelector(elSelector);
Assert.ok(el, `Panel element ${elSelector} exists.`);
if (el) {
Assert.ok(
BrowserTestUtils.is_visible(el),
`Panel element ${elSelector} is visible.`
);
}
});
info("Inspect checkbox and pref state.");
let checkbox = privateWin.document.querySelector(SELECTOR_PANEL_CHECKBOX);
Assert.ok(
checkbox.checked,
"The 'always ask' checkbox should be checked initially."
);
Assert.ok(
Services.prefs.getBoolPref(
"browser.privatebrowsing.resetPBM.showConfirmationDialog"
),
"The always ask pref should be true."
);
info("Click the checkbox to uncheck it.");
await BrowserTestUtils.synthesizeMouseAtCenter(
SELECTOR_PANEL_CHECKBOX,
{},
privateWin.browsingContext
);
Assert.ok(
!checkbox.checked,
"The 'always ask' checkbox should no longer be checked."
);
info(
"The pref shouldn't update after clicking the checkbox. It only updates on panel confirm."
);
Assert.ok(
Services.prefs.getBoolPref(
"browser.privatebrowsing.resetPBM.showConfirmationDialog"
),
"The always ask pref should still be true."
);
info("Close the panel via cancel.");
let promisePanelHidden = waitForConfirmPanelHidden(privateWin);
await BrowserTestUtils.synthesizeMouseAtCenter(
SELECTOR_PANEL_CANCEL_BTN,
{},
privateWin.browsingContext
);
await promisePanelHidden;
assertTelemetry(
[
{ action: "show", reason: "toolbar-btn" },
{ action: "hide", reason: "cancel-btn" },
],
[],
"There should be a panel show and a hide event."
);
assertPanelVisibility(privateWin, SELECTOR_PANELVIEW, false);
assertPanelVisibility(privateWin, SELECTOR_PANEL_COMPLETION_TOAST, false);
info("Reopen the panel.");
await triggerResetBtn(privateWin);
assertTelemetry(
[
{ action: "show", reason: "toolbar-btn" },
{ action: "hide", reason: "cancel-btn" },
{ action: "show", reason: "toolbar-btn" },
],
[],
"Should have added a show event."
);
assertPanelVisibility(privateWin, SELECTOR_PANELVIEW, true);
assertPanelVisibility(privateWin, SELECTOR_PANEL_COMPLETION_TOAST, false);
Assert.ok(
checkbox.checked,
"The 'always ask' checkbox should be checked again."
);
Assert.ok(
Services.prefs.getBoolPref(PREF_ID_ALWAYS_ASK),
"The always ask pref should be true."
);
info("Test the checkbox on confirm.");
await BrowserTestUtils.synthesizeMouseAtCenter(
SELECTOR_PANEL_CHECKBOX,
{},
privateWin.browsingContext
);
Assert.ok(
!checkbox.checked,
"The 'always ask' checkbox should no longer be checked."
);
info("Close the panel via confirm.");
let promiseDataCleared = waitForPBMDataClear();
promisePanelHidden = waitForConfirmPanelHidden(privateWin);
let promiseCompletionToastShown = waitForCompletionToastShown(privateWin);
await BrowserTestUtils.synthesizeMouseAtCenter(
SELECTOR_PANEL_CONFIRM_BTN,
{},
privateWin.browsingContext
);
await promisePanelHidden;
assertTelemetry(
[
{ action: "show", reason: "toolbar-btn" },
{ action: "hide", reason: "cancel-btn" },
{ action: "show", reason: "toolbar-btn" },
{ action: "hide", reason: "confirm-btn" },
],
[{ did_confirm: "true" }],
"Should have added a hide and a reset event."
);
await promiseCompletionToastShown;
assertPanelVisibility(privateWin, SELECTOR_PANELVIEW, false);
assertPanelVisibility(privateWin, SELECTOR_PANEL_COMPLETION_TOAST, true);
await promiseDataCleared;
Assert.ok(
!Services.prefs.getBoolPref(PREF_ID_ALWAYS_ASK),
"The always ask pref should now be false."
);
// Need to hide the completion toast, otherwise the next click on the toolbar
// button won't work.
info("Hide the completion toast.");
await hideCompletionToast(privateWin);
info(
"Simulate a click on the toolbar button. This time the panel should not open - we have unchecked 'always ask'."
);
promiseDataCleared = waitForPBMDataClear();
promiseCompletionToastShown = waitForCompletionToastShown(privateWin);
await triggerResetBtn(privateWin, false);
info("Waiting for PBM session to end.");
await promiseDataCleared;
info("Data has been cleared.");
assertPanelVisibility(privateWin, SELECTOR_PANELVIEW, false);
info("Waiting for the completion toast to show.");
await promiseCompletionToastShown;
assertPanelVisibility(privateWin, SELECTOR_PANELVIEW, false);
assertPanelVisibility(privateWin, SELECTOR_PANEL_COMPLETION_TOAST, true);
assertTelemetry(
[
{ action: "show", reason: "toolbar-btn" },
{ action: "hide", reason: "cancel-btn" },
{ action: "show", reason: "toolbar-btn" },
{ action: "hide", reason: "confirm-btn" },
],
[{ did_confirm: "true" }, { did_confirm: "false" }],
"Should have added a reset event."
);
await BrowserTestUtils.closeWindow(privateWin);
Services.prefs.clearUserPref(PREF_ID_ALWAYS_ASK);
// Clean up telemetry
Services.fog.testResetFOG();
});
/**
* Tests that the reset action closes all other private browsing windows and
* tabs and triggers private browsing data clearing.
*/
add_task(async function test_reset_action() {
assertTelemetry([], [], "No glean events initially.");
await SpecialPowers.pushPrefEnv({
set: [["browser.privatebrowsing.resetPBM.enabled", true]],
});
info("Open a few private browsing windows.");
let windowOpenPromises = [];
for (let i = 0; i < 3; i += 1) {
windowOpenPromises.push(
BrowserTestUtils.openNewBrowserWindow({
private: true,
})
);
}
info(
"Open an additional normal browsing window. It should remain open on reset PBM action."
);
let additionalNormalWindow = await BrowserTestUtils.openNewBrowserWindow({
private: false,
});
info(
"Wait for all windows to open and use one to trigger the PBM restart action."
);
let privateBrowsingWindows = await Promise.all(windowOpenPromises);
let [win] = privateBrowsingWindows;
win.focus();
Assert.ok(
PrivateBrowsingUtils.isWindowPrivate(win),
"Window for PBM reset trigger is private window."
);
info("Load a bunch of tabs in the private window.");
let loadPromises = [
"https://example.com",
"https://example.org",
"https://example.net",
].map(async url => {
let tab = BrowserTestUtils.addTab(win.gBrowser, url);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
});
await Promise.all(loadPromises);
info("Switch to the last tab.");
win.gBrowser.selectedTab = win.gBrowser.tabs[win.gBrowser.tabs.length - 1];
Assert.ok(
win.gBrowser.selectedBrowser.currentURI.spec != "about:privatebrowsing",
"The selected tab should not show about:privatebrowsing."
);
let windowClosePromises = [
...privateBrowsingWindows.filter(w => win != w),
].map(w => BrowserTestUtils.windowClosed(w));
// Create promises for tab close for all tabs in the triggering private browsing window.
let promisesTabsClosed = win.gBrowser.tabs.map(tab =>
BrowserTestUtils.waitForTabClosing(tab)
);
info("Trigger the restart PBM action");
let promiseDataClear = waitForPBMDataClear();
await ResetPBMPanel._restartPBM(win);
info(
"Wait for all the windows but the default normal window and the private window which triggered the reset action to be closed."
);
await Promise.all(windowClosePromises);
info("Wait for tabs in the trigger private window to close.");
await Promise.all(promisesTabsClosed);
info("Wait for data to be cleared.");
await promiseDataClear;
Assert.equal(
win.gBrowser.tabs.length,
1,
"Should only have 1 tab remaining."
);
Assert.equal(
win.gBrowser.selectedBrowser.currentURI.spec,
"about:privatebrowsing",
"The remaining tab should point to about:privatebrowsing."
);
// Close the private window that remained open.
await BrowserTestUtils.closeWindow(win);
await BrowserTestUtils.closeWindow(additionalNormalWindow);
// We bypass telemetry by calling ResetPBMPanel._restartPBM directly.
assertTelemetry([], [], "No glean events after the test.");
});

View File

@@ -974,24 +974,6 @@ unified-extensions-button-quarantined =
Extensions
Some extensions are not allowed
## Private browsing reset button
reset-pbm-toolbar-button =
.label = End Private Session
.tooltiptext = End Private Session
reset-pbm-panel-heading = End your private session?
reset-pbm-panel-description = Close all private tabs and delete history, cookies, and all other site data.
reset-pbm-panel-always-ask-checkbox =
.label = Always ask me
.accesskey = A
reset-pbm-panel-cancel-button =
.label = Cancel
.accesskey = C
reset-pbm-panel-confirm-button =
.label = Delete session data
.accesskey = D
reset-pbm-panel-complete = Private session data deleted
## Autorefresh blocker
refresh-blocked-refresh-label = { -brand-short-name } prevented this page from automatically reloading.

View File

@@ -1972,34 +1972,3 @@ panelview:not([mainview]) #PanelUI-whatsNew-title {
.webextension-popup-stack {
position: relative;
}
/* Reset/Restart Private Browsing Panel */
#reset-pbm-panel {
max-width: var(--menu-panel-width-wide);
}
#reset-pbm-panel-container {
padding: 16px 16px 0;
display: flex;
flex-direction: column;
gap: 8px;
}
#reset-pbm-panel-header > description {
margin-bottom: 0;
}
#reset-pbm-panel-header > description,
#reset-pbm-panel-description,
#reset-pbm-panel-footer {
margin-inline: 0;
}
#reset-pbm-panel-header > description {
font-weight: var(--font-weight-bold);
}
#reset-pbm-panel-checkbox {
margin-inline: 0 8px;
}

View File

@@ -1,6 +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="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="context-fill" fill-opacity="context-fill-opacity">
<path d="M12.88 5.07999C12.61 4.63999 11.88 4.63999 11.6 5.07999C11.35 5.48999 11.04 5.86999 10.7 6.20999C10.33 3.39999 8.35 0.989993 5.55 0.0399925C5.28 -0.0500075 4.99 0.0199925 4.79 0.209993C4.59 0.409993 4.51 0.699993 4.6 0.969993C5.21 2.92999 4.76 5.08999 3.42 6.65999C3.4 6.67999 3.37 6.70999 3.35 6.72999C3.33 6.74999 3.31 6.77999 3.29 6.79999L3.24 6.85999C3.24 6.85999 3.21 6.89999 3.2 6.91999C1.46 9.13999 1.66 12.35 3.7 14.35C4.82 15.44 6.29 15.99 7.76 15.99C9.23 15.99 10.71 15.44 11.83 14.34C13.23 12.93 14 11.04 14 8.99999C14 7.60999 13.61 6.24999 12.88 5.06999V5.07999ZM10.77 13.28C10.52 13.53 10.23 13.72 9.94 13.9C9.98 13.69 10 13.48 10 13.26C10 11.84 9.3 10.56 8.21 10.05C8.08 9.98999 7.92 9.98999 7.79 10.05C6.7 10.56 6 11.84 6 13.26C6 13.58 6.04 13.88 6.11 14.18C5.61 13.98 5.15 13.68 4.75 13.29C3.22 11.8 3.08 9.47999 4.4 7.83999C5.85 6.25999 6.54 4.14999 6.35 2.05999C8.15 3.15999 9.29 5.09999 9.29 7.22999C9.29 7.37999 9.29 7.52999 9.27 7.66999C9.25 7.94999 9.39 8.21999 9.63 8.36999C9.87 8.51999 10.17 8.50999 10.42 8.36999C11.06 7.96999 11.64 7.47999 12.13 6.91999C12.38 7.58999 12.51 8.29999 12.51 9.01999C12.51 10.66 11.89 12.18 10.78 13.29L10.77 13.28Z"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -165,7 +165,6 @@
skin/classic/browser/edit-paste.svg (../shared/icons/edit-paste.svg)
skin/classic/browser/fingerprint.svg (../shared/icons/fingerprint.svg)
skin/classic/browser/firefox-view.svg (../shared/icons/firefox-view.svg)
skin/classic/browser/flame.svg (../shared/icons/flame.svg)
skin/classic/browser/forget.svg (../shared/icons/forget.svg)
skin/classic/browser/forward.svg (../shared/icons/forward.svg)
skin/classic/browser/fullscreen.svg (../shared/icons/fullscreen.svg)

View File

@@ -368,14 +368,6 @@
list-style-image: url("chrome://mozapps/skin/extensions/extension.svg");
}
#reset-pbm-toolbar-button {
list-style-image: url("chrome://browser/skin/flame.svg");
:root:not([privatebrowsingmode]) & {
display: none;
}
}
#email-link-button {
list-style-image: url("chrome://browser/skin/mail.svg");
}

View File

@@ -47,7 +47,6 @@ firefox_desktop_metrics = [
"browser/components/shopping/metrics.yaml",
"browser/components/urlbar/metrics.yaml",
"browser/components/preferences/metrics.yaml",
"browser/components/privatebrowsing/metrics.yaml",
"browser/modules/metrics.yaml",
"toolkit/components/crashes/metrics.yaml",
"toolkit/components/nimbus/metrics.yaml",

View File

@@ -1888,8 +1888,3 @@ feltPrivacy:
description: >-
When true, new styles and copy enabled on about:privatebrowsing. When true,
a toggle for showing or hiding quick suggestions appears in about:preferences.
resetPBMAction:
type: boolean
setPref: browser.privatebrowsing.resetPBM.enabled
description: >-
Enables the reset PBM feature button and confirmation panel.