Index: third_party/WebKit/LayoutTests/external/wpt/payment-request/payment-request-constructor.https.html |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/payment-request/payment-request-constructor.https.html b/third_party/WebKit/LayoutTests/external/wpt/payment-request/payment-request-constructor.https.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..91842b6ab02227e8a56c2c8fb7f6829a9d67f538 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/external/wpt/payment-request/payment-request-constructor.https.html |
@@ -0,0 +1,95 @@ |
+<!DOCTYPE html> |
+<!-- Copyright © 2017 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> |
+<meta charset="utf-8"> |
+<title>Test for PaymentRequest Constructor</title> |
+<script src="../resources/testharness.js"></script> |
Marijn Kruisselbrink
2017/05/03 18:26:51
This should just be /resources/testharness.js
please use gerrit instead
2017/05/03 19:30:23
Done.
|
+<script src="../../../resources/testharnessreport.js"></script> |
Marijn Kruisselbrink
2017/05/03 18:26:51
same here, /resources/testharnessreport.js
please use gerrit instead
2017/05/03 19:30:23
Done.
|
+<!-- https://w3c.github.io/browser-payment-api/#constructor --> |
+<script> |
+test(() => { |
+ assert_equals((new PaymentRequest([{supportedMethods: ['basic-card']}], {id: 'foo', total: {label: '', amount: {currency: 'USD', value: '1.00'}}})).id, 'foo'); |
+}); |
Marijn Kruisselbrink
2017/05/03 18:26:51
Could you give every test() a name? The auto-gener
please use gerrit instead
2017/05/03 19:30:23
Done.
|
+ |
+test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([], {total: {label: '', amount: {currency: 'USD', value: '1.00'}}}); |
+ }, 'If the length of the methodData sequence is zero, then throw a TypeError'); |
+}); |
+ |
+test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: []}], {total: {label: '', amount: {currency: 'USD', value: '1.00'}}}); |
+ }, 'If the length of the paymentMethod.supportedMethods sequence is zero, then throw a TypeError'); |
+}); |
+ |
+const invalid_monetary_amounts = ['-', 'notdigits', 'ALSONOTDIGITS', '10.', '.99', '-10.', '-.99', '10-', '1-0', '1.0.0', '1/3', '', null]; |
+for (var i in invalid_monetary_amounts) { |
Marijn Kruisselbrink
2017/05/03 18:26:51
for...in should generally never be used for arrays
please use gerrit instead
2017/05/03 19:30:23
Done.
|
+ test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: ['basic-card']}], {total: {label: '', amount: {currency: 'USD', value: invalid_monetary_amounts[i]}}}); |
+ }, 'If details.total.amount.value is not a valid decimal monetary value (in this case "' + invalid_monetary_amounts[i] + '"), then throw a TypeError'); |
+ }); |
+} |
+ |
+test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: ['basic-card']}], {total: {label: |
+ '', amount: {currency: 'USD', value: '-1.00'}}}); |
+ }, 'If the first character of details.total.amount.value is U+002D HYPHEN-MINUS, then throw a TypeError'); |
+}); |
+ |
+for (var i in invalid_monetary_amounts) { |
+ test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: ['basic-card']}], {total: {label: '', amount: {currency: 'USD', value: '1.00'}}, displayItems: [{label: '', amount: {currency: 'USD', value: invalid_monetary_amounts[i]}}]}); |
+ }, 'For each item in details.displayItems: if item.amount.value is not a valid decimal monetary value (in this case "' + invalid_monetary_amounts[i] + '"), then throw a TypeError'); |
+ }); |
+} |
+ |
+test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: ['basic-card']}], {}); |
+ }, 'Total is required'); |
+}); |
+ |
+test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: ['basic-card']}], {total: {amount: {currency: 'USD', value: '1.00'}}}); |
+ }, 'Label is required'); |
+}); |
+ |
+test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: ['basic-card']}], {total: {label: ''}}); |
+ }, 'Amount is required'); |
+}); |
+ |
+test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: ['basic-card']}], {total: {label: '', amount: {currency: 'USD'}}}); |
+ }, 'Amount value is required'); |
+}); |
+ |
+test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: ['basic-card']}], {total: {label: '', amount: {value: '1.00'}}}); |
+ }, 'Amount currency is required'); |
+}); |
+ |
+test(() => { |
+ assert_throws({name: 'TypeError'}, |
+ () => { |
+ new PaymentRequest([{supportedMethods: ['basic-card']}], {total: {label: '', amount: {currency: 'USD', value: '1.00'}}}, {shippingType: 'invalid'}); |
+ }, 'Shipping type should be valid'); |
+}); |
+</script> |