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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marcos Cáceres 2018-10-16 12:53:01 +00:00
parent bbf8e689c3
commit 6de37261e9
10 changed files with 6 additions and 154 deletions

View File

@ -30,7 +30,6 @@ 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)]

View File

@ -109,12 +109,10 @@ NS_IMPL_ISUPPORTS(PaymentItem,
PaymentItem::PaymentItem(const nsAString& aLabel,
nsIPaymentCurrencyAmount* aAmount,
const bool aPending,
const nsAString& aType)
const bool aPending)
: mLabel(aLabel)
, mAmount(aAmount)
, mPending(aPending)
, mType(aType)
{
}
@ -129,7 +127,7 @@ PaymentItem::Create(const IPCPaymentItem& aIPCItem, nsIPaymentItem** aItem)
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;
}
@ -159,13 +157,6 @@ PaymentItem::GetPending(bool* aPending)
return NS_OK;
}
NS_IMETHODIMP
PaymentItem::GetType(nsAString& aType)
{
aType = mType;
return NS_OK;
}
/* PaymentDetailsModifier */
NS_IMPL_ISUPPORTS(PaymentDetailsModifier,

View File

@ -65,15 +65,13 @@ public:
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

View File

@ -51,18 +51,9 @@ ConvertCurrencyAmount(const PaymentCurrencyAmount& aAmount,
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

View File

@ -27,7 +27,6 @@ struct IPCPaymentItem
nsString label;
IPCPaymentCurrencyAmount amount;
bool pending;
nsString type;
};
struct IPCPaymentDetailsModifier

View File

@ -141,8 +141,8 @@ function checkComplexRequest(payRequest) {
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") {
@ -154,9 +154,6 @@ function checkComplexRequest(payRequest) {
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'.");
@ -167,22 +164,6 @@ function checkComplexRequest(payRequest) {
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) {

View File

@ -75,14 +75,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345361
currency: "USD",
value: "40.00"
}
},
{
label: "Tax",
amount: {
currency: "USD",
value: "5.00"
},
type: "tax"
}
],
modifiers: [

View File

@ -21,15 +21,10 @@ dictionary PaymentCurrencyAmount {
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 {

View File

@ -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

View File

@ -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>