Bug 1497699 - Drop support for PaymentItem.type. r=edenchuang,baku
authorMarcos Cáceres <mcaceres@mozilla.com>
Tue, 16 Oct 2018 12:53:01 +0000
changeset 489857 56d027190d7ba66c1097f0d11c221b4a0b8ee4e7
parent 489856 247936437060b0139fffbf827305c1e16c2df2cc
child 489858 a3521c2b925b7ab1847031a027730962179eea9e
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersedenchuang, baku
bugs1497699
milestone64.0a1
Bug 1497699 - Drop support for PaymentItem.type. r=edenchuang,baku Being removed from the spec. Front-end no longer needs this. Differential Revision: https://phabricator.services.mozilla.com/D8160
dom/interfaces/payments/nsIPaymentRequest.idl
dom/payments/PaymentRequestData.cpp
dom/payments/PaymentRequestData.h
dom/payments/PaymentRequestManager.cpp
dom/payments/ipc/PPaymentRequest.ipdl
dom/payments/test/ConstructorChromeScript.js
dom/payments/test/test_constructor.html
dom/webidl/PaymentRequest.webidl
testing/web-platform/meta/payment-request/PaymentItem/type_member.https.html.ini
testing/web-platform/tests/payment-request/PaymentItem/type_member.https.html
--- a/dom/interfaces/payments/nsIPaymentRequest.idl
+++ b/dom/interfaces/payments/nsIPaymentRequest.idl
@@ -25,17 +25,16 @@ interface nsIPaymentCurrencyAmount : nsI
 };
 
 [scriptable, builtinclass, uuid(4f78a59f-b5ff-4fb5-ab48-3b37d0101b02)]
 interface nsIPaymentItem : nsISupports
 {
   readonly attribute AString label;
   readonly attribute nsIPaymentCurrencyAmount amount;
   readonly attribute boolean pending;
-  readonly attribute AString type;
 };
 
 [scriptable, builtinclass, uuid(74259861-c318-40e8-b3d5-518e701bed80)]
 interface nsIPaymentDetailsModifier : nsISupports
 {
   readonly attribute AString supportedMethods;
   readonly attribute nsIPaymentItem total;
   readonly attribute nsIArray additionalDisplayItems;
--- a/dom/payments/PaymentRequestData.cpp
+++ b/dom/payments/PaymentRequestData.cpp
@@ -104,37 +104,35 @@ PaymentCurrencyAmount::GetValue(nsAStrin
 
 /* PaymentItem */
 
 NS_IMPL_ISUPPORTS(PaymentItem,
                   nsIPaymentItem)
 
 PaymentItem::PaymentItem(const nsAString& aLabel,
                          nsIPaymentCurrencyAmount* aAmount,
-                         const bool aPending,
-                         const nsAString& aType)
+                         const bool aPending)
   : mLabel(aLabel)
   , mAmount(aAmount)
   , mPending(aPending)
-  , mType(aType)
 {
 }
 
 nsresult
 PaymentItem::Create(const IPCPaymentItem& aIPCItem, nsIPaymentItem** aItem)
 {
   NS_ENSURE_ARG_POINTER(aItem);
   nsCOMPtr<nsIPaymentCurrencyAmount> amount;
   nsresult rv = PaymentCurrencyAmount::Create(aIPCItem.amount(),
                                               getter_AddRefs(amount));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   nsCOMPtr<nsIPaymentItem> item =
-    new PaymentItem(aIPCItem.label(), amount, aIPCItem.pending(), aIPCItem.type());
+    new PaymentItem(aIPCItem.label(), amount, aIPCItem.pending());
   item.forget(aItem);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PaymentItem::GetLabel(nsAString& aLabel)
 {
   aLabel = mLabel;
@@ -154,23 +152,16 @@ PaymentItem::GetAmount(nsIPaymentCurrenc
 NS_IMETHODIMP
 PaymentItem::GetPending(bool* aPending)
 {
   NS_ENSURE_ARG_POINTER(aPending);
   *aPending = mPending;
   return NS_OK;
 }
 
-NS_IMETHODIMP
-PaymentItem::GetType(nsAString& aType)
-{
-  aType = mType;
-  return NS_OK;
-}
-
 /* PaymentDetailsModifier */
 
 NS_IMPL_ISUPPORTS(PaymentDetailsModifier,
                   nsIPaymentDetailsModifier)
 
 PaymentDetailsModifier::PaymentDetailsModifier(const nsAString& aSupportedMethods,
                                                nsIPaymentItem* aTotal,
                                                nsIArray* aAdditionalDisplayItems,
--- a/dom/payments/PaymentRequestData.h
+++ b/dom/payments/PaymentRequestData.h
@@ -60,25 +60,23 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPAYMENTITEM
 
   static nsresult Create(const IPCPaymentItem& aIPCItem, nsIPaymentItem** aItem);
 
 private:
   PaymentItem(const nsAString& aLabel,
               nsIPaymentCurrencyAmount* aAmount,
-              const bool aPending,
-              const nsAString& aType);
+              const bool aPending);
 
   ~PaymentItem() = default;
 
   nsString mLabel;
   nsCOMPtr<nsIPaymentCurrencyAmount> mAmount;
   bool mPending;
-  nsString mType;
 };
 
 class PaymentDetailsModifier final : public nsIPaymentDetailsModifier
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPAYMENTDETAILSMODIFIER
 
--- a/dom/payments/PaymentRequestManager.cpp
+++ b/dom/payments/PaymentRequestManager.cpp
@@ -46,28 +46,19 @@ ConvertCurrencyAmount(const PaymentCurre
                       IPCPaymentCurrencyAmount& aIPCCurrencyAmount)
 {
   aIPCCurrencyAmount = IPCPaymentCurrencyAmount(aAmount.mCurrency, aAmount.mValue);
 }
 
 void
 ConvertItem(const PaymentItem& aItem, IPCPaymentItem& aIPCItem)
 {
-  uint8_t typeIndex = UINT8_MAX;
-  if (aItem.mType.WasPassed()) {
-    typeIndex = static_cast<uint8_t>(aItem.mType.Value());
-  }
-  nsString type;
-  if (typeIndex < ArrayLength(PaymentItemTypeValues::strings)) {
-    type.AssignASCII(
-      PaymentItemTypeValues::strings[typeIndex].value);
-  }
   IPCPaymentCurrencyAmount amount;
   ConvertCurrencyAmount(aItem.mAmount, amount);
-  aIPCItem = IPCPaymentItem(aItem.mLabel, amount, aItem.mPending, type);
+  aIPCItem = IPCPaymentItem(aItem.mLabel, amount, aItem.mPending);
 }
 
 nsresult
 ConvertModifier(JSContext* aCx,
                 const PaymentDetailsModifier& aModifier,
                 IPCPaymentDetailsModifier& aIPCModifier)
 {
   NS_ENSURE_ARG_POINTER(aCx);
--- a/dom/payments/ipc/PPaymentRequest.ipdl
+++ b/dom/payments/ipc/PPaymentRequest.ipdl
@@ -22,17 +22,16 @@ struct IPCPaymentCurrencyAmount
   nsString value;
 };
 
 struct IPCPaymentItem
 {
   nsString label;
   IPCPaymentCurrencyAmount amount;
   bool pending;
-  nsString type;
 };
 
 struct IPCPaymentDetailsModifier
 {
   nsString supportedMethods;
   IPCPaymentItem total;
   IPCPaymentItem[] additionalDisplayItems;
   nsString data;
--- a/dom/payments/test/ConstructorChromeScript.js
+++ b/dom/payments/test/ConstructorChromeScript.js
@@ -136,58 +136,39 @@ function checkComplexRequest(payRequest)
   if (details.totalItem.amount.value != "100.00") {
     emitTestFail("total item's value should be '100.00'.");
   }
 
   const displayItems = details.displayItems;
   if (!details.displayItems) {
     emitTestFail("details.displayItems should not be undefined.");
   }
-  if (displayItems.length != 3) {
-    emitTestFail("displayItems' length should be 3.")
+  if (displayItems.length != 2) {
+    emitTestFail("displayItems' length should be 2.")
   }
   let item = displayItems.queryElementAt(0, Ci.nsIPaymentItem);
   if (item.label != "First item") {
     emitTestFail("1st display item's label should be 'First item'.");
   }
   if (item.amount.currency != "USD") {
     emitTestFail("1st display item's currency should be 'USD'.");
   }
   if (item.amount.value != "60.00") {
     emitTestFail("1st display item's value should be '60.00'.");
   }
-  if (item.type != "") {
-    emitTestFail("1st display item's type should be ''.");
-  }
   item = displayItems.queryElementAt(1, Ci.nsIPaymentItem);
   if (item.label != "Second item") {
     emitTestFail("2nd display item's label should be 'Second item'.");
   }
   if (item.amount.currency != "USD") {
     emitTestFail("2nd display item's currency should be 'USD'.");
   }
   if (item.amount.value != "40.00") {
     emitTestFail("2nd display item's value should be '40.00'.");
   }
-  if (item.type != "") {
-    emitTestFail("2nd display item's type should be ''.");
-  }
-  item = displayItems.queryElementAt(2, Ci.nsIPaymentItem);
-  if (item.label != "Tax") {
-    emitTestFail("3rd display item's label should be 'Tax'.");
-  }
-  if (item.amount.currency != "USD") {
-    emitTestFail("3rd display item's currency should be 'USD'.");
-  }
-  if (item.amount.value != "5.00") {
-    emitTestFail("3rd display item's value should be '5.00'.");
-  }
-  if (item.type != "tax") {
-    emitTestFail("3rd display item's type should be 'tax'.");
-  }
 
   const modifiers = details.modifiers;
   if (!modifiers) {
     emitTestFail("details.displayItems should not be undefined.");
   }
   if (modifiers.length != 1) {
     emitTestFail("modifiers' length should be 1.");
   }
--- a/dom/payments/test/test_constructor.html
+++ b/dom/payments/test/test_constructor.html
@@ -70,24 +70,16 @@ https://bugzilla.mozilla.org/show_bug.cg
         }
       },
       {
         label: "Second item",
         amount: {
           currency: "USD",
           value: "40.00"
         }
-      },
-      {
-        label: "Tax",
-        amount: {
-          currency: "USD",
-          value: "5.00"
-        },
-        type: "tax"
       }
     ],
     modifiers: [
       {
         supportedMethods: "basic-card",
         total: {
           label: "Discounted Total",
           amount: {
--- a/dom/webidl/PaymentRequest.webidl
+++ b/dom/webidl/PaymentRequest.webidl
@@ -16,25 +16,20 @@ dictionary PaymentMethodData {
 };
 
 dictionary PaymentCurrencyAmount {
   required DOMString currency;
   required DOMString value;
            DOMString currencySystem = "urn:iso:std:iso:4217";
 };
 
-enum PaymentItemType {
-  "tax"
-};
-
 dictionary PaymentItem {
   required DOMString             label;
   required PaymentCurrencyAmount amount;
            boolean               pending = false;
-           PaymentItemType       type;
 };
 
 dictionary PaymentShippingOption {
   required DOMString             id;
   required DOMString             label;
   required PaymentCurrencyAmount amount;
            boolean               selected = false;
 };
deleted file mode 100644
--- a/testing/web-platform/meta/payment-request/PaymentItem/type_member.https.html.ini
+++ /dev/null
@@ -1,17 +0,0 @@
-[type_member.https.html]
-  [Smoke test]
-    expected: 
-      if not e10s: FAIL
-
-  [An invalid enum value for PaymentDetailsInit.total's type throws TypeError]
-    expected: 
-      if not e10s: FAIL
-
-  [Invalid enum value for PaymentItem.type member throws a TypeError]
-    expected: 
-      if not e10s: FAIL
-
-  [Valid enum values for PaymentItem.type member does not throw]
-    expected: 
-      if not e10s: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/tests/payment-request/PaymentItem/type_member.https.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!doctype html>
-<meta charset="utf8">
-<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentitem-type">
-<title>
-  PaymentItem type member
-</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
-const validMethods = [
-  { supportedMethods: "basic-card" },
-  { supportedMethods: "https://apple.com/apple-pay" },
-];
-const validTotal = {
-  label: "Total",
-  amount: {
-    currency: "USD",
-    value: "5.00",
-  },
-};
-const validDisplayItem = {
-  label: "Item",
-  amount: {
-    currency: "USD",
-    value: "1.00",
-  },
-};
-const validDetails = {
-  total: validTotal,
-  displayItems: [validDisplayItem],
-};
-
-test(() => {
-  new PaymentRequest(validMethods, validDetails);
-}, "Smoke test");
-
-test(() => {
-  // Let's make an invalid DisplayItem for the total
-  const invalidTotal = Object.assign({}, validTotal, {
-    type: "this is not valid",
-  });
-  const invalidDetails = Object.assign({}, validDetails, {
-    total: invalidTotal,
-  });
-  assert_throws(new TypeError(), () => {
-    new PaymentRequest(validMethods, invalidDetails);
-  });
-}, "An invalid enum value for PaymentDetailsInit.total's type throws TypeError");
-
-test(() => {
-  // Let's make an invalid DisplayItem to add to displayItems
-  const invalidDisplayItem = Object.assign({}, validDisplayItem, {
-    type: "this is not valid",
-  });
-  const invalidDetails = Object.assign({}, validDetails, {
-    displayItems: [invalidDisplayItem, validDisplayItem],
-  });
-  assert_throws(new TypeError(), () => {
-    new PaymentRequest(validMethods, invalidDetails);
-  });
-}, "Invalid enum value for PaymentItem.type member throws a TypeError");
-
-test(() => {
-  // Let's make an invalid DisplayItem to add to displayItems
-  const taxDisplayItem = Object.assign({}, validDisplayItem, { type: "tax" });
-  const taxTotal = Object.assign({}, validTotal, { type: "tax" });
-  const validDetailsWithType = Object.assign({}, validDetails, {
-    total: taxTotal,
-    displayItems: [taxDisplayItem],
-  });
-  try {
-    new PaymentRequest(validMethods, validDetailsWithType);
-  } catch (err) {
-    assert_unexpected(err.message);
-  }
-}, "Valid enum values for PaymentItem.type member does not throw");
-</script>