Bug 1435871 - Open prefs from Payment Request in a tab. r=jaws
☠☠ backed out by 0623ed3cb752 ☠ ☠
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 17 Oct 2018 18:46:12 +0000
changeset 490145 8eab3320b8c5fdda47ceb1c45e59628c7439f76d
parent 490144 29777ddd9def409cde9edd50570982ea23d07568
child 490146 19b1ad6ceade3ce4ce42e9b4dd793f03e5e81be9
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/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, "OSKeyStore",
                                "resource://formautofill/OSKeyStore.jsm");
 ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils",
                                "resource://gre/modules/PrivateBrowsingUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "formAutofillStorage", () => {
   let storage;
   try {
@@ -481,20 +483,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
@@ -380,17 +380,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/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");
   });
 });