Bug 1504032 - Remove concept of card types, supportedTypes, BasicCardType enum r=MattN,baku
authorMarcos Cáceres <mcaceres@mozilla.com>
Sat, 10 Nov 2018 06:59:26 +0000
changeset 445522 f1e380fe0a835cb90f83606feb8ac8f3933566d7
parent 445521 af173815a3756b93d0830bacc85510ee9b7b9ff5
child 445523 68f4272a536f32a2f594d2eede19bf9ac6d8d79a
push id72764
push usermcaceres@mozilla.com
push dateSat, 10 Nov 2018 07:29:01 +0000
treeherderautoland@f1e380fe0a83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, baku
bugs1504032
milestone65.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 1504032 - Remove concept of card types, supportedTypes, BasicCardType enum r=MattN,baku The concept of card types, supportedTypes, BasicCardType enum, were removed from the Basic Card spec. Differential Revision: https://phabricator.services.mozilla.com/D10646
browser/components/payments/res/debugging.js
browser/components/payments/res/paymentRequest.js
browser/components/payments/test/PaymentTestUtils.jsm
dom/payments/test/ConstructorChromeScript.js
dom/payments/test/DefaultData.js
dom/payments/test/test_basiccard.html
dom/payments/test/test_constructor.html
dom/payments/test/test_requestShipping.html
dom/payments/test/test_showPayment.html
dom/webidl/BasicCardPayment.webidl
--- a/browser/components/payments/res/debugging.js
+++ b/browser/components/payments/res/debugging.js
@@ -173,19 +173,17 @@ let REQUEST_2 = {
           {
             label: "Credit card fee",
             amount: {
               currency: "CAD",
               value: "1.50",
             },
           },
         ],
-        data: {
-          supportedTypes: "credit",
-        },
+        data: {},
       },
     ],
     error: "",
   },
   paymentOptions: {
     requestPayerName: false,
     requestPayerEmail: false,
     requestPayerPhone: false,
--- a/browser/components/payments/res/paymentRequest.js
+++ b/browser/components/payments/res/paymentRequest.js
@@ -245,17 +245,17 @@ var paymentRequest = {
       throw new Error(`${method.methodName} (${methodID}) is not a supported payment method`);
     }
     let modifiers = state.request.paymentDetails.modifiers;
     if (!modifiers || !modifiers.length) {
       return null;
     }
     let modifier = modifiers.find(m => {
       // take the first matching modifier
-      // TODO (bug 1429198): match on supportedTypes and supportedNetworks
+      // TODO (bug 1429198): match on supportedNetworks
       return m.supportedMethods == "basic-card";
     });
     return modifier || null;
   },
 
   /**
    * @param {object} state object representing the UI state
    * @returns {object} in the shape of `nsIPaymentItem` representing the total
--- a/browser/components/payments/test/PaymentTestUtils.jsm
+++ b/browser/components/payments/test/PaymentTestUtils.jsm
@@ -416,19 +416,17 @@ var PaymentTestUtils = {
               amount: { currency: "USD", value: "0.50" },
             },
           ],
           supportedMethods: "basic-card",
           total: {
             label: "Total due",
             amount: { currency: "USD", value: "2.50" },
           },
-          data: {
-            supportedTypes: "credit",
-          },
+          data: {},
         },
         {
           additionalDisplayItems: [
             {
               label: "Bob-pay fee",
               amount: { currency: "USD", value: "1.50" },
             },
           ],
--- a/dom/payments/test/ConstructorChromeScript.js
+++ b/dom/payments/test/ConstructorChromeScript.js
@@ -103,30 +103,16 @@ function checkComplexRequest(payRequest)
   }
   for (let idx = 0; idx < supportedNetworks.length; idx++) {
     if (supportedNetworks[idx] != expectedSupportedNetworks[idx]) {
       emitTestFail("supportedNetworks[" + idx + "] should be '" +
                    expectedSupportedNetworks[idx] + "', but got '" +
                    supportedNetworks[idx] + "'.");
     }
   }
-  const supportedTypes = data.supportedTypes;
-  const expectedSupportedTypes = ["prepaid", "debit", "credit"];
-  if (supportedTypes.length != expectedSupportedTypes.length) {
-    emitTestFail("supportedTypes.length should be '" +
-                 expectedSupportedTypes.length + "', but got '" +
-                 supportedTypes.length + "'.");
-  }
-  for (let idx = 0; idx < supportedTypes.length; idx++) {
-    if (supportedTypes[idx] != expectedSupportedTypes[idx]) {
-      emitTestFail("supportedTypes[" + idx + "] should be '" +
-                   expectedSupportedTypes[idx] + "', but got '" +
-                   supportedTypes[idx] + "'.");
-    }
-  }
   // checking the passed PaymentDetails parameter
   const details = payRequest.paymentDetails;
   if (details.id != "payment details" ) {
     emitTestFail("details.id should be 'payment details'.");
   }
   if (details.totalItem.label != "Total") {
     emitTestFail("total item's label should be 'Total'.");
   }
--- a/dom/payments/test/DefaultData.js
+++ b/dom/payments/test/DefaultData.js
@@ -1,16 +1,15 @@
 // testing data declation
 const defaultMethods = [{
   supportedMethods: "basic-card",
   data: {
     supportedNetworks: ['unionpay', 'visa', 'mastercard', 'amex', 'discover',
                         'diners', 'jcb', 'mir',
     ],
-    supportedTypes: ['prepaid', 'debit', 'credit'],
   },
 }, {
   supportedMethods: "testing-payment-method",
 }];
 
 const defaultDetails = {
   total: {
     label: "Total",
--- a/dom/payments/test/test_basiccard.html
+++ b/dom/payments/test/test_basiccard.html
@@ -16,23 +16,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   var gUrl = SimpleTest.getTestFileURL('BasiccardChromeScript.js');
   var gScript = SpecialPowers.loadChromeScript(gUrl);
 
   function testFailHandler(message) {
     ok(false, message);
   }
   gScript.addMessageListener("test-fail", testFailHandler);
 
-  const errorTypesMethods = [{
-    supportedMethods: "basic-card",
-    data: {
-      supportedTypes: ["myType"],
-    },
-  }];
-
   const errorNetworksMethods = [{
     supportedMethods: "basic-card",
     data: {
       supportedNetworks: ["myNetwork"],
     },
   }];
 
   const nullDataMethods = [{
@@ -50,17 +43,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   }];
 
   const defaultMethods = [{
     supportedMethods: "basic-card",
     data: {
       supportedNetworks: ["unionpay", "visa", "mastercard", "amex", "discover",
                           "diners", "jcb", "mir",
       ],
-      supportedTypes: ["prepaid", "debit", "credit"],
     },
   }];
   const defaultDetails = {
     id: "test payment",
     total: {
       label: "Total",
       amount: {
         currency: "USD",
@@ -92,29 +84,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   const defaultOptions = {
     requestPayerName: true,
     requestPayerEmail: false,
     requestPayerPhone: false,
     requestShipping: true,
     shippingType: "shipping"
   };
 
-  function testBasicCardRequestWithErrorTypes() {
-    return new Promise((resolve, reject) => {
-      try {
-        const payRequest = new PaymentRequest(errorTypesMethods, defaultDetails, defaultOptions);
-        ok(false, "Expected 'TypeError', but got success construction.");
-        resolve();
-      } catch (e) {
-        is(e.name, "TypeError", "Expected TypeError, but got " + e.name);
-        resolve();
-      }
-    });
-  }
-
   function testBasicCardRequestWithErrorNetworks() {
     return new Promise((resolve, reject) => {
       try {
         const payRequest = new PaymentRequest(errorNetworksMethods, defaultDetails, defaultOptions);
         ok(false, "Expected 'TypeError', but got success construction.");
         resolve();
       } catch (e) {
         is(e.name, "TypeError", "Expected TypeError, but got " + e.name);
@@ -277,18 +256,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       gScript.removeMessageListener("test-fail", testFailHandler)
       gScript.destroy();
       SimpleTest.finish();
     });
     gScript.sendAsyncMessage("teardown");
   }
 
   function runTests() {
-    testBasicCardRequestWithErrorTypes()
-    .then(testBasicCardRequestWithErrorNetworks)
+    testBasicCardRequestWithErrorNetworks()
     .then(testBasicCardRequestWithUnconvertableData)
     .then(testBasicCardRequestWithNullData)
     .then(testBasicCardRequestWithEmptyData)
     .then(testCanMakePaymentWithBasicCardRequest)
     .then(testBasicCardSimpleResponse)
     .then(testBasicCardDetailedResponse)
     .then(testSpecialAddressResponse)
     .then(testBasicCardErrorResponse)
--- a/dom/payments/test/test_constructor.html
+++ b/dom/payments/test/test_constructor.html
@@ -35,17 +35,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   };
 
   const complexMethods = [{
     supportedMethods: "basic-card",
     data: {
       supportedNetworks: ['unionpay', 'visa', 'mastercard', 'amex', 'discover',
                           'diners', 'jcb', 'mir',
       ],
-      supportedTypes: ['prepaid', 'debit', 'credit'],
     },
   }];
 
   const nonBasicCardMethods = [{
     supportedMethods: "testing-payment-method",
     data: {
       paymentId: "P3892940",
       paymentType: "prepaid",
--- a/dom/payments/test/test_requestShipping.html
+++ b/dom/payments/test/test_requestShipping.html
@@ -22,17 +22,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   gScript.addMessageListener("test-fail", testFailHandler);
 
   const defaultMethods = [{
     supportedMethods: "basic-card",
     data: {
       supportedNetworks: ['unionpay', 'visa', 'mastercard', 'amex', 'discover',
                           'diners', 'jcb', 'mir',
       ],
-      supportedTypes: ['prepaid', 'debit', 'credit'],
     },
   }, {
     supportedMethods: "testing-payment-method",
   }];
   const defaultDetails = {
     id: "test payment",
     total: {
       label: "Total",
--- a/dom/payments/test/test_showPayment.html
+++ b/dom/payments/test/test_showPayment.html
@@ -28,17 +28,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   // testing data declaration
   // default parameters for PaymentRequest construction
   const defaultMethods = [{
     supportedMethods: "basic-card",
     data: {
       supportedNetworks: ['unionpay', 'visa', 'mastercard', 'amex', 'discover',
                           'diners', 'jcb', 'mir',
       ],
-      supportedTypes: ['prepaid', 'debit', 'credit'],
     },
   }, {
     supportedMethods: "testing-payment-method",
   }];
 
   const defaultTotal = {
     label: "Total",
     amount: {
--- a/dom/webidl/BasicCardPayment.webidl
+++ b/dom/webidl/BasicCardPayment.webidl
@@ -1,25 +1,19 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * The origin of this WebIDL file is
  *   https://www.w3.org/TR/payment-request/#paymentrequest-interface
  */
-enum BasicCardType {
-  "credit",
-  "debit",
-  "prepaid"
-};
 
 dictionary BasicCardRequest {
   sequence<DOMString> supportedNetworks;
-  sequence<BasicCardType> supportedTypes;
 };
 
 dictionary BasicCardResponse {
            DOMString cardholderName;
   required DOMString cardNumber;
            DOMString expiryMonth;
            DOMString expiryYear;
            DOMString cardSecurityCode;