Bug 1435871 - Open prefs from Payment Request in a tab. r=jaws
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Sat, 20 Oct 2018 03:40:05 +0000
changeset 490569 d0f1450799b56b9960ad6df2da432a5fd5849417
parent 490568 a1db0baedde03d00e96ddd577b8d3672f115a726
child 490571 f88ebf2720c875520d2de1cf4104a3b550c73ad8
child 490581 37df3d44e6882b69f9b8eda9ca67b5d322272fa7
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjaws
bugs1435871
milestone64.0a1
Bug 1435871 - Open prefs from Payment Request in a tab. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D8497
browser/components/payments/content/paymentDialogWrapper.js
browser/components/payments/res/containers/payment-dialog.js
browser/components/payments/res/containers/rich-picker.css
browser/components/payments/test/browser/browser_openPreferences.js
--- a/browser/components/payments/content/paymentDialogWrapper.js
+++ b/browser/components/payments/content/paymentDialogWrapper.js
@@ -14,16 +14,18 @@ const paymentSrv = Cc["@mozilla.org/dom/
 
 const paymentUISrv = Cc["@mozilla.org/dom/payments/payment-ui-service;1"]
                      .getService(Ci.nsIPaymentUIService);
 
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
+ChromeUtils.defineModuleGetter(this, "BrowserWindowTracker",
+                               "resource:///modules/BrowserWindowTracker.jsm");
 ChromeUtils.defineModuleGetter(this, "MasterPassword",
                                "resource://formautofill/MasterPassword.jsm");
 ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils",
                                "resource://gre/modules/PrivateBrowsingUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "formAutofillStorage", () => {
   let storage;
   try {
@@ -482,20 +484,17 @@ var paymentDialogWrapper = {
       gDevToolsBrowser,
     } = ChromeUtils.import("resource://devtools/client/framework/gDevTools.jsm", {});
     gDevToolsBrowser.openContentProcessToolbox({
       selectedBrowser: document.getElementById("paymentRequestFrame").frameLoader,
     });
   },
 
   onOpenPreferences() {
-    let prefsURL = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
-    prefsURL.data = "about:preferences#privacy-form-autofill";
-    Services.ww.openWindow(null, AppConstants.BROWSER_CHROME_URL, "_blank", "chrome,all,dialog=no",
-                           prefsURL);
+    BrowserWindowTracker.getTopWindow().openPreferences("privacy-form-autofill");
   },
 
   onPaymentCancel() {
     const showResponse = this.createShowResponse({
       acceptStatus: Ci.nsIPaymentActionResponse.PAYMENT_REJECTED,
     });
 
     paymentSrv.respondPayment(showResponse);
--- a/browser/components/payments/res/containers/payment-dialog.js
+++ b/browser/components/payments/res/containers/payment-dialog.js
@@ -393,17 +393,17 @@ export default class PaymentDialog exten
     this._renderPayerFields(state);
 
     let isMac = /mac/i.test(navigator.platform);
     for (let manageTextEl of this._manageText.children) {
       manageTextEl.hidden = manageTextEl.dataset.os == "mac" ? !isMac : isMac;
       let link = manageTextEl.querySelector("a");
       // The href is only set to be exposed to accessibility tools so users know what will open.
       // The actual opening happens from the click event listener.
-      link.href = "about:preferences#privacy-address-autofill";
+      link.href = "about:preferences#privacy-form-autofill";
     }
 
     this._renderPayButton(state);
 
     for (let page of this._mainContainer.querySelectorAll(":scope > .page")) {
       page.hidden = state.page.id != page.id;
     }
 
--- a/browser/components/payments/res/containers/rich-picker.css
+++ b/browser/components/payments/res/containers/rich-picker.css
@@ -59,19 +59,25 @@ payment-method-picker.rich-picker {
     "invalid  invalid invalid invalid";
 }
 
 .security-code-container {
   display: flex;
   flex-grow: 1;
   grid-area: csc;
   margin: 10px 0; /* Has to be same as rich-select */
-  /* So the error outline appears above the adjacent dropdown */
-  z-index: 1;
 }
 
 .rich-picker .security-code {
   border: 1px solid #0C0C0D33;
-  /* Override the border from common.css */
-  border-inline-start: none !important;
+  /* Underlap the 1px border from common.css */
+  margin-inline-start: -1px;
   flex-grow: 1;
   padding: 8px;
 }
+
+.rich-picker .security-code:-moz-ui-invalid,
+.rich-picker .security-code:focus {
+  /* So the error outline and focus ring appear above the adjacent dropdown when appropriate. */
+  /* We don't want to always be on top or we will cover the error outline or focus outline from the
+     dropdown. */
+  z-index: 1;
+}
--- a/browser/components/payments/test/browser/browser_openPreferences.js
+++ b/browser/components/payments/test/browser/browser_openPreferences.js
@@ -15,19 +15,18 @@ add_task(async function test_openPrefere
     url: BLANK_PAGE_URL,
   }, async browser => {
     let {win, frame} = await setupPaymentDialog(browser, {
       methodData,
       details,
       merchantTaskFn: PTU.ContentTasks.createAndShowRequest,
     });
 
-    let prefsWindowPromise = BrowserTestUtils.waitForNewWindow({
-      url: "about:preferences#privacy",
-    });
+    let prefsTabPromise = BrowserTestUtils.waitForNewTab(gBrowser,
+                                                         "about:preferences#privacy-form-autofill");
 
     let prefsLoadedPromise = TestUtils.topicObserved("sync-pane-loaded");
 
     await spawnPaymentDialogTask(frame, function verifyPrefsLink({isMac}) {
       let manageTextEl = content.document.querySelector(".manage-text");
 
       let expectedVisibleEl;
       if (isMac) {
@@ -44,18 +43,18 @@ add_task(async function test_openPrefere
       let prefsLink = expectedVisibleEl.querySelector("a");
       ok(prefsLink, "Preferences link should exist");
       prefsLink.scrollIntoView();
       EventUtils.synthesizeMouseAtCenter(prefsLink, {}, content);
     }, {
       isMac: AppConstants.platform == "macosx",
     });
 
-    let browserWin = await prefsWindowPromise;
-    ok(browserWin, "Ensure a window was opened");
+    let prefsTab = await prefsTabPromise;
+    ok(prefsTab, "Ensure a tab was opened");
     await prefsLoadedPromise;
 
-    await BrowserTestUtils.closeWindow(browserWin);
+    await BrowserTestUtils.removeTab(prefsTab);
 
     spawnPaymentDialogTask(frame, PTU.DialogContentTasks.manuallyClickCancel);
     await BrowserTestUtils.waitForCondition(() => win.closed, "dialog should be closed");
   });
 });