Bug 1641393 - Warn about the exported logins CSV file. r=MattN,fluent-reviewers
authorAndrei Cristian Petcu <petcuandrei@protonmail.com>
Sat, 30 May 2020 01:44:48 +0000
changeset 533114 9ac6f9017b79ba070f7cb5c5dc1e82f0c6734f93
parent 533113 f65636dc2b12ab0480672a418adccc64219d8d7a
child 533115 e4b730f2d8530aec71ae3e3c432d5289693d448a
push id117582
push usermozilla@noorenberghe.ca
push dateSat, 30 May 2020 02:04:34 +0000
treeherderautoland@9ac6f9017b79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, fluent-reviewers
bugs1641393
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1641393 - Warn about the exported logins CSV file. r=MattN,fluent-reviewers Differential Revision: https://phabricator.services.mozilla.com/D77376
browser/components/aboutlogins/content/aboutLogins.html
browser/components/aboutlogins/content/aboutLogins.js
browser/components/aboutlogins/tests/browser/browser_openExport.js
browser/locales/en-US/browser/aboutLogins.ftl
--- a/browser/components/aboutlogins/content/aboutLogins.html
+++ b/browser/components/aboutlogins/content/aboutLogins.html
@@ -266,17 +266,17 @@
 
     <template id="menu-button-template">
       <link rel="stylesheet" href="chrome://global/skin/in-content/common.css">
       <link rel="stylesheet" href="chrome://browser/content/aboutlogins/common.css">
       <link rel="stylesheet" href="chrome://browser/content/aboutlogins/components/menu-button.css">
       <button class="menu-button ghost-button" data-l10n-id="menu"></button>
       <ul class="menu" role="menu" hidden>
         <button role="menuitem" class="menuitem-button menuitem-import ghost-button" hidden data-supported-platforms="Win32,MacIntel" data-event-name="AboutLoginsImport" data-l10n-id="about-logins-menu-menuitem-import-from-another-browser"></button>
-        <button role="menuitem" class="menuitem-button menuitem-export ghost-button" data-event-name="AboutLoginsExportPasswords" data-l10n-id="about-logins-menu-menuitem-export-logins" hidden></button>
+        <button role="menuitem" class="menuitem-button menuitem-export ghost-button" data-event-name="AboutLoginsExportPasswordsDialog" data-l10n-id="about-logins-menu-menuitem-export-logins" hidden></button>
         <hr role="separator" class="menuitem-separator"></hr>
         <button role="menuitem" class="menuitem-button menuitem-preferences ghost-button" data-event-name="AboutLoginsOpenPreferences" data-l10n-id="menu-menuitem-preferences"></button>
         <hr role="separator" class="menuitem-separator"></hr>
         <button role="menuitem" class="menuitem-button menuitem-help ghost-button" data-event-name="AboutLoginsGetHelp" data-l10n-id="about-logins-menu-menuitem-help"></button>
         <hr role="separator" class="menuitem-separator"></hr>
         <button role="menuitem" class="menuitem-button menuitem-mobile menuitem-mobile-android ghost-button" data-event-name="AboutLoginsOpenMobileAndroid" data-l10n-id="menu-menuitem-android-app"></button>
         <button role="menuitem" class="menuitem-button menuitem-mobile menuitem-mobile-ios ghost-button" data-event-name="AboutLoginsOpenMobileIos" data-l10n-id="menu-menuitem-iphone-app"></button>
       </ul>
--- a/browser/components/aboutlogins/content/aboutLogins.js
+++ b/browser/components/aboutlogins/content/aboutLogins.js
@@ -118,16 +118,33 @@ window.addEventListener("AboutLoginsChro
     case "UpdateVulnerableLogins": {
       gElements.loginList.updateVulnerableLogins(event.detail.value);
       gElements.loginItem.updateVulnerableLogins(event.detail.value);
       break;
     }
   }
 });
 
+window.addEventListener("AboutLoginsExportPasswordsDialog", async event => {
+  let dialog = document.querySelector("confirmation-dialog");
+  let options = {
+    title: "about-logins-confirm-export-dialog-title",
+    message: "about-logins-confirm-export-dialog-message",
+    confirmButtonLabel: "about-logins-confirm-export-dialog-confirm-button",
+  };
+  try {
+    await dialog.show(options);
+    document.dispatchEvent(
+      new CustomEvent("AboutLoginsExportPasswords", { bubbles: true })
+    );
+  } catch (ex) {
+    // The user cancelled the dialog.
+  }
+});
+
 // Begin code that executes on page load.
 
 let searchParamsChanged = false;
 let { protocol, pathname, searchParams } = new URL(document.location);
 
 recordTelemetryEvent({
   method: "open_management",
   object: searchParams.get("entryPoint") || "direct",
--- a/browser/components/aboutlogins/tests/browser/browser_openExport.js
+++ b/browser/components/aboutlogins/tests/browser/browser_openExport.js
@@ -55,14 +55,29 @@ add_task(async function test_open_export
       }
 
       let filePicker = waitForFilePicker();
       await BrowserTestUtils.synthesizeMouseAtCenter(
         getExportMenuItem,
         {},
         browser
       );
+
+      info("Clicking confirm button");
+      await BrowserTestUtils.synthesizeMouseAtCenter(
+        () => {
+          let confirmExportDialog = window.document.querySelector(
+            "confirmation-dialog"
+          );
+          return confirmExportDialog.shadowRoot.querySelector(
+            ".confirm-button"
+          );
+        },
+        {},
+        browser
+      );
+
       info("waiting for Export file picker to get opened");
       await filePicker;
       ok(true, "Export file picker opened");
     }
   );
 });
--- a/browser/locales/en-US/browser/aboutLogins.ftl
+++ b/browser/locales/en-US/browser/aboutLogins.ftl
@@ -158,16 +158,20 @@ about-logins-enable-password-sync-dont-a
 confirmation-dialog-cancel-button = Cancel
 confirmation-dialog-dismiss-button =
   .title = Cancel
 
 about-logins-confirm-remove-dialog-title = Remove this login?
 confirm-delete-dialog-message = This action cannot be undone.
 about-logins-confirm-remove-dialog-confirm-button = Remove
 
+about-logins-confirm-export-dialog-title = Export logins and passwords
+about-logins-confirm-export-dialog-message = Your passwords will be saved as readable text (e.g., BadP@ssw0rd) so anyone who can open the exported file can view them.
+about-logins-confirm-export-dialog-confirm-button = Export…
+
 confirm-discard-changes-dialog-title = Discard unsaved changes?
 confirm-discard-changes-dialog-message = All unsaved changes will be lost.
 confirm-discard-changes-dialog-confirm-button = Discard
 
 ## Breach Alert notification
 
 about-logins-breach-alert-title = Website Breach
 breach-alert-text = Passwords were leaked or stolen from this website since you last updated your login details. Change your password to protect your account.