Bug 1435871 - Back out changeset 3f6664786e85 (Bug 1470584) since it's for a windowed dialog. r=jaws
☠☠ backed out by 0623ed3cb752 ☠ ☠
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 17 Oct 2018 18:46:25 +0000
changeset 490143 afdc3066f12cf33cfcf05cd4524b6d72b215acb2
parent 490118 43db36acc04fc464e9f75b79bf635e7cc2ba328b
child 490144 29777ddd9def409cde9edd50570982ea23d07568
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjaws
bugs1435871, 1470584
milestone64.0a1
Bug 1435871 - Back out changeset 3f6664786e85 (Bug 1470584) since it's for a windowed dialog. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D8272
browser/components/payments/paymentUIService.js
browser/components/payments/test/PaymentTestUtils.jsm
browser/components/payments/test/browser/browser_show_dialog.js
--- a/browser/components/payments/paymentUIService.js
+++ b/browser/components/payments/paymentUIService.js
@@ -27,39 +27,25 @@ function PaymentUIService() {
   this.wrappedJSObject = this;
   XPCOMUtils.defineLazyGetter(this, "log", () => {
     let {ConsoleAPI} = ChromeUtils.import("resource://gre/modules/Console.jsm", {});
     return new ConsoleAPI({
       maxLogLevelPref: "dom.payments.loglevel",
       prefix: "Payment UI Service",
     });
   });
-  Services.wm.addListener(this);
   this.log.debug("constructor");
 }
 
 PaymentUIService.prototype = {
   classID: Components.ID("{01f8bd55-9017-438b-85ec-7c15d2b35cdc}"),
   QueryInterface: ChromeUtils.generateQI([Ci.nsIPaymentUIService]),
   DIALOG_URL: "chrome://payments/content/paymentDialogWrapper.xul",
   REQUEST_ID_PREFIX: "paymentRequest-",
 
-  // nsIWindowMediatorListener implementation:
-
-  onOpenWindow(aWindow) {},
-  onCloseWindow(aWindow) {
-    let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
-    let requestId = this.requestIdForWindow(domWindow);
-    if (!requestId || !paymentSrv.getPaymentRequestById(requestId)) {
-      return;
-    }
-    this.log.debug(`onCloseWindow, close of window for active requestId: ${requestId}`);
-    this.rejectPaymentForClosedDialog(requestId);
-  },
-
   // nsIPaymentUIService implementation:
 
   showPayment(requestId) {
     this.log.debug("showPayment:", requestId);
     let chromeWindow = Services.wm.getMostRecentWindow("navigator:browser");
     chromeWindow.openDialog(`${this.DIALOG_URL}?requestId=${requestId}`,
                             `${this.REQUEST_ID_PREFIX}${requestId}`,
                             "modal,dialog,centerscreen,resizable=no");
@@ -76,30 +62,16 @@ PaymentUIService.prototype = {
     let response = found ?
       Ci.nsIPaymentActionResponse.ABORT_SUCCEEDED :
       Ci.nsIPaymentActionResponse.ABORT_FAILED;
 
     abortResponse.init(requestId, response);
     paymentSrv.respondPayment(abortResponse);
   },
 
-  rejectPaymentForClosedDialog(requestId) {
-    this.log.debug("rejectPaymentForClosedDialog:", requestId);
-    const rejectResponse = Cc["@mozilla.org/dom/payments/payment-show-action-response;1"]
-                            .createInstance(Ci.nsIPaymentShowActionResponse);
-    rejectResponse.init(requestId,
-                        Ci.nsIPaymentActionResponse.PAYMENT_REJECTED,
-                        "", // payment method
-                        null, // payment method data
-                        "", // payer name
-                        "", // payer email
-                        "");// payer phone
-    paymentSrv.respondPayment(rejectResponse);
-  },
-
   completePayment(requestId) {
     // completeStatus should be one of "timeout", "success", "fail", ""
     let {completeStatus} = paymentSrv.getPaymentRequestById(requestId);
     this.log.debug(`completePayment: requestId: ${requestId}, completeStatus: ${completeStatus}`);
 
     let closed;
     switch (completeStatus) {
       case "fail":
--- a/browser/components/payments/test/PaymentTestUtils.jsm
+++ b/browser/components/payments/test/PaymentTestUtils.jsm
@@ -117,29 +117,16 @@ var PaymentTestUtils = {
       const rq = new content.PaymentRequest(Cu.cloneInto(methodData, content), details, options);
       content.rq = rq; // assign it so we can retrieve it later
 
       const handle = content.windowUtils.setHandlingUserInput(true);
       content.showPromise = rq.show();
 
       handle.destruct();
     },
-
-    /**
-     * Add a rejection handler for the `showPromise` created by createAndShowRequest
-     * and stash details of any eventual exception or response in `rqResult`
-     */
-    catchShowPromiseRejection: () => {
-      content.rqResult = {};
-      content.showPromise.then(res => content.rqResult.response = res)
-                         .catch(ex => content.rqResult.showException = {
-                           name: ex.name,
-                           message: ex.message,
-                         });
-    },
   },
 
   DialogContentTasks: {
     getShippingOptions: () => {
       let picker = content.document.querySelector("shipping-option-picker");
       let popupBox = Cu.waiveXrays(picker).dropdown.popupBox;
       let selectedOptionIndex = popupBox.selectedIndex;
       let selectedOption = Cu.waiveXrays(picker).dropdown.selectedOption;
--- a/browser/components/payments/test/browser/browser_show_dialog.js
+++ b/browser/components/payments/test/browser/browser_show_dialog.js
@@ -138,41 +138,16 @@ add_task(async function test_show_comple
     let result = await ContentTask.spawn(browser, {}, PTU.ContentTasks.addCompletionHandler);
 
     is(result.response.shippingOption, "1", "Check shipping option");
 
     await BrowserTestUtils.waitForCondition(() => win.closed, "dialog should be closed");
   });
 });
 
-add_task(async function test_show_closeReject_dialog() {
-  await BrowserTestUtils.withNewTab({
-    gBrowser,
-    url: BLANK_PAGE_URL,
-  }, async browser => {
-    let {win} =
-      await setupPaymentDialog(browser, {
-        methodData,
-        details,
-        merchantTaskFn: PTU.ContentTasks.createAndShowRequest,
-      }
-    );
-    await ContentTask.spawn(browser, null, PTU.ContentTasks.catchShowPromiseRejection);
-
-    info("Closing the dialog to reject the payment request");
-    BrowserTestUtils.closeWindow(win);
-    await BrowserTestUtils.waitForCondition(() => win.closed, "dialog should be closed");
-
-    let result = await ContentTask.spawn(browser, null, async () => content.rqResult);
-    ok(result.showException, "Expected promise rejection from the rq.show() promise");
-    ok(!result.response,
-       "rq.show() shouldn't resolve to a response");
-  });
-});
-
 add_task(async function test_localized() {
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: BLANK_PAGE_URL,
   }, async browser => {
     let {win, frame} =
       await setupPaymentDialog(browser, {
         methodData,