Backed out 2 changesets (bug 1934109) for causing reftest failures.

Backed out changeset e59f23ac171e (bug 1934109)
Backed out changeset 92adfd182864 (bug 1934109)
This commit is contained in:
Sandor Molnar
2024-12-06 00:12:23 +02:00
parent 168a1083e4
commit 0355016f87
10 changed files with 15 additions and 189 deletions

View File

@@ -1707,14 +1707,6 @@ var SidebarController = {
return;
}
const willHideEvent = new CustomEvent("SidebarWillHide", {
cancelable: true,
});
this.browser.contentWindow?.dispatchEvent(willHideEvent);
if (willHideEvent.defaultPrevented) {
return;
}
this.hideSwitcherPanel();
this._recordPanelToggle(this.currentID, false);
if (this.sidebarRevampEnabled) {

View File

@@ -160,10 +160,6 @@ export class MegalistViewModel {
this.#messageToView("SetNotification", notification);
}
discardChangesConfirmed() {
this.#messageToView("DiscardChangesConfirmed");
}
async receiveCommand({ commandId, snapshotId, value } = {}) {
const dotIndex = commandId?.indexOf(".");
const index = snapshotId;

View File

@@ -93,10 +93,6 @@ export class Aggregator {
setNotification(notification) {
aggregator.forEachViewModel(vm => vm.setNotification(notification));
},
discardChangesConfirmed() {
aggregator.forEachViewModel(vm => vm.discardChangesConfirmed());
},
};
}
}

View File

@@ -72,10 +72,6 @@ export class DataSourceBase {
this.#aggregatorApi.setNotification(notification);
}
discardChangesConfirmed() {
this.#aggregatorApi.discardChangesConfirmed();
}
formatMessages = createFormatMessages("preview/megalist.ftl");
static ftl = new Localization(["branding/brand.ftl", "preview/megalist.ftl"]);

View File

@@ -148,8 +148,6 @@ export class LoginDataSource extends DataSourceBase {
{ id: "AddLogin" },
{ id: "UpdateLogin" },
{ id: "DeleteLogin" },
{ id: "DiscardChanges" },
{ id: "ConfirmDiscardChanges" },
{
id: "ImportFromBrowser",
label: "passwords-command-import-from-browser",
@@ -185,9 +183,6 @@ export class LoginDataSource extends DataSourceBase {
this.#header.executeAddLogin = newLogin => this.#addLogin(newLogin);
this.#header.executeUpdateLogin = login => this.#updateLogin(login);
this.#header.executeDeleteLogin = login => this.#deleteLogin(login);
this.#header.executeDiscardChanges = options => this.#cancelEdit(options);
this.#header.executeConfirmDiscardChanges = options =>
this.#discardChangesConfirmed(options);
this.#exportPasswordsStrings = {
OSReauthMessage: strings.exportPasswordsOSReauthMessage,
@@ -641,25 +636,6 @@ export class LoginDataSource extends DataSourceBase {
}
}
#cancelEdit(options = {}) {
this.setNotification({
id: "discard-changes",
fromSidebar: options.fromSidebar,
});
}
#discardChangesConfirmed(options = {}) {
if (options.fromSidebar) {
const { BrowserWindowTracker } = ChromeUtils.importESModule(
"resource:///modules/BrowserWindowTracker.sys.mjs"
);
const window = BrowserWindowTracker.getTopWindow();
window.SidebarController.hide();
} else {
this.discardChangesConfirmed();
}
}
#handleLoginStorageErrors(origin, error) {
if (error.message.includes("This login already exists")) {
const existingLoginGuid = error.data.toString();

View File

@@ -49,6 +49,10 @@ export class LoginForm extends MozLitElement {
};
}
disconnectedCallback() {
this.onClose();
}
#removeWarning(warning) {
if (warning.classList.contains("invalid-input")) {
warning.classList.remove("invalid-input");
@@ -205,7 +209,7 @@ export class LoginForm extends MozLitElement {
<moz-button-group>
<moz-button
data-l10n-id="login-item-cancel-button"
@click=${this.onClose}
@click=${this.remove}
></moz-button>
<moz-button
data-l10n-id="login-item-save-new-button"

View File

@@ -51,9 +51,6 @@ export class MegalistAlpha extends MozLitElement {
window.addEventListener("MessageFromViewModel", ev =>
this.#onMessageFromViewModel(ev)
);
window.addEventListener("SidebarWillHide", ev =>
this.#onSidebarWillHide(ev)
);
}
static get properties() {
@@ -123,16 +120,6 @@ export class MegalistAlpha extends MozLitElement {
this.#sendCommand(this.displayMode);
}
#onCancelLoginForm() {
switch (this.viewMode) {
case VIEW_MODES.EDIT:
this.#sendCommand("DiscardChanges");
return;
default:
this.viewMode = VIEW_MODES.LIST;
}
}
#openMenu(e) {
const panelList = this.shadowRoot.querySelector("panel-list");
panelList.toggle(e);
@@ -176,12 +163,6 @@ export class MegalistAlpha extends MozLitElement {
this.reauthResolver?.(isAuthorized);
}
receiveDiscardChangesConfirmed() {
this.viewMode = VIEW_MODES.LIST;
this.editingRecord = null;
this.notification = null;
}
reauthCommandHandler(commandFn) {
return new Promise((resolve, _reject) => {
this.reauthResolver = resolve;
@@ -213,20 +194,6 @@ export class MegalistAlpha extends MozLitElement {
};
}
#onSidebarWillHide(e) {
// Prevent hiding the sidebar if a password is being edited and show a
// message asking to confirm if the user wants to discard their changes.
const shouldShowDiscardChangesPrompt =
this.viewMode === VIEW_MODES.EDIT &&
(!this.notification || this.notification?.id === "discard-changes") &&
!this.notification?.fromSidebar;
if (shouldShowDiscardChangesPrompt) {
this.#sendCommand("DiscardChanges", { value: { fromSidebar: true } });
e.preventDefault();
}
}
// TODO: This should be passed to virtualized list with an explicit height.
renderListItem({ origin: displayOrigin, username, password }, index) {
return html` <password-card
@@ -346,7 +313,7 @@ export class MegalistAlpha extends MozLitElement {
return this.renderList();
case VIEW_MODES.ADD:
return html` <login-form
.onClose=${() => this.#onCancelLoginForm()}
.onClose=${() => (this.viewMode = VIEW_MODES.LIST)}
.onSaveClick=${loginForm => {
this.#sendCommand("AddLogin", { value: loginForm });
}}
@@ -364,7 +331,14 @@ export class MegalistAlpha extends MozLitElement {
this.editingRecord.password.concealed,
this.editingRecord.password.lineIndex
)}
.onClose=${() => this.#onCancelLoginForm()}
.onClose=${() => {
this.#messageToViewModel("Command", {
commandId: "Cancel",
snapshotId: this.editingRecord.password.lineIndex,
});
this.viewMode = VIEW_MODES.LIST;
this.editingRecord = null;
}}
.onSaveClick=${loginForm => {
loginForm.guid = this.editingRecord.origin.guid;
this.#sendCommand("UpdateLogin", { value: loginForm });
@@ -533,8 +507,7 @@ export class MegalistAlpha extends MozLitElement {
.onDismiss=${() => {
this.notification = null;
}}
.messageHandler=${(commandId, options) =>
this.#sendCommand(commandId, options)}
.messageHandler=${commandId => this.#sendCommand(commandId)}
@view-login=${e => this.#scrollPasswordCardIntoView(e.detail.guid)}
>
</notification-message-bar>

View File

@@ -197,27 +197,6 @@ class NotificationMessageBar extends MozLitElement {
type: "primary",
slot: "actions",
dataL10nId: "passwords-delete-password-success-button",
},
})}
`;
}
#renderDiscardChanges() {
return html`
${notificationShell({
onDismiss: this.onDismiss,
dataL10nId: "passwords-discard-changes-heading-and-message",
type: "warning",
primaryAction: {
type: "destructive",
dataL10nId: "passwords-discard-changes-confirm-button",
onClick: () =>
this.messageHandler("ConfirmDiscardChanges", {
value: { fromSidebar: this.notification.fromSidebar },
}),
},
secondaryAction: {
dataL10nId: "passwords-discard-changes-go-back-button",
onClick: this.onDismiss,
},
})}
@@ -238,8 +217,6 @@ class NotificationMessageBar extends MozLitElement {
return this.#renderUpdateLoginSuccess();
case "delete-login-success":
return this.#renderDeleteLoginSuccess();
case "discard-changes":
return this.#renderDiscardChanges();
default:
return "";
}

View File

@@ -310,15 +310,6 @@ passwords-no-passwords-get-started-message = Add them here to get started.
# This string is displayed in a button. If the user clicks it, they will be taken to a form to create a new password.
passwords-add-manually = Add manually
## When the user cancels a login that's currently being edited, we display a message to confirm whether
## or not the user wants to discard their current edits to the login.
passwords-discard-changes-heading-and-message =
.heading = Close without saving?
.message = Your changes wont be saved.
passwords-discard-changes-confirm-button = Confirm
passwords-discard-changes-go-back-button = Go back
## Payments
payments-command-create = Add Payment Method

View File

@@ -1,6 +1,3 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_setup(async function () {
@@ -66,7 +63,6 @@ add_task(async function test_update_login_success() {
"Password not updated."
);
LoginTestUtils.clearData();
SidebarController.hide();
});
add_task(async function test_update_login_duplicate() {
@@ -100,75 +96,4 @@ add_task(async function test_update_login_duplicate() {
await waitForNotification(megalist, "login-already-exists-warning");
LoginTestUtils.clearData();
SidebarController.hide();
});
add_task(async function test_update_login_discard_changes() {
if (!OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) {
ok(true, "Cannot test OSAuth.");
return;
}
const login = TEST_LOGIN_1;
await LoginTestUtils.addLogin(login);
const megalist = await openPasswordsSidebar();
await checkAllLoginsRendered(megalist);
await openEditLoginForm(megalist, getMegalistParent(), 0);
info("Cancelling form.");
const loginForm = megalist.querySelector("login-form");
const cancelButton = loginForm.shadowRoot.querySelector(
"moz-button[data-l10n-id=login-item-cancel-button]"
);
cancelButton.buttonEl.click();
await waitForNotification(megalist, "discard-changes");
ok(true, "Got discard changes notification");
info("Pressing Go Back action on notification");
let notificationMsgBar = megalist.querySelector("notification-message-bar");
const goBackActionButton = notificationMsgBar.shadowRoot.querySelector(
"moz-button[type=default]"
);
goBackActionButton.click();
await BrowserTestUtils.waitForCondition(() => {
const notificationMsgBar = megalist.querySelector(
"notification-message-bar"
);
return !notificationMsgBar;
}, "Notification was not dismissed.");
ok(true, "Discard changes notification dismissed.");
info("Cancelling form again.");
cancelButton.buttonEl.click();
await waitForNotification(megalist, "discard-changes");
ok(true, "Got discard changes notification");
info("Pressing Confirm action on notification");
notificationMsgBar = megalist.querySelector("notification-message-bar");
let confirmButton = notificationMsgBar.shadowRoot.querySelector(
"moz-button[type=destructive]"
);
confirmButton.click();
await checkAllLoginsRendered(megalist);
ok(true, "List view of logins is shown again");
info("Try closing sidebar while editing a login");
await openEditLoginForm(megalist, getMegalistParent(), 0);
SidebarController.hide();
await waitForNotification(megalist, "discard-changes");
ok(true, "Got discard changes notification when closing sidebar");
info("Sidebar should close if discard changes is confirmed");
notificationMsgBar = megalist.querySelector("notification-message-bar");
confirmButton = notificationMsgBar.shadowRoot.querySelector(
"moz-button[type=destructive]"
);
confirmButton.click();
await BrowserTestUtils.waitForCondition(() => {
return !SidebarController.isOpen;
}, "Sidebar did not close.");
ok(!SidebarController.isOpen, "Sidebar closed");
LoginTestUtils.clearData();
});